From patchwork Fri Feb 2 05:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769149 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp754077wrc; Thu, 1 Feb 2024 21:54:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGL1tP21dQ+P9He6FSazQRsoTBSiqLlPO9NKjx7z/I7MLJ9hvT8DTntRP1mnNs3QZgqWeHE X-Received: by 2002:a05:6214:d09:b0:68c:87cf:ada4 with SMTP id 9-20020a0562140d0900b0068c87cfada4mr554083qvh.41.1706853240577; Thu, 01 Feb 2024 21:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706853240; cv=none; d=google.com; s=arc-20160816; b=iPChlMomw3eDH9moMfiBX+EFnw8zalJM5FScYdWU+lWnBCYuKU1hSpIfFlEunrS07F AKh/t6B3cPU+4lX5q8+0H4Yh3MJ+4vOk3EMBV9aXDrB2zyjGfSri2wEWXoElZq8n5lmf RSkWacueZVtdQ4kp+Lxgd5+ZQXgsNR0vntq2a/OjerK+UVKcys26xPEZbRWGgbjMIzcK eFVRLsOrTpOaMossg3HDf4pc338qYMpUad0RUlOqopECF8/jU+Bmh5OmPaNTBa1dlz3C 9WVoKVAKpIUvJVsoJvnInqHuHNrb4CFfJSzM7bPMq4Ghh3TjMM8lTkZgvBh+II3zRKCU M6sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NfNpPvlkxn2D3fI9cYf9hBQTlB/c6mteAgGLiKm11to=; fh=OsWevNCS+nZX2sD408bk6MYXMpYQ58zU/bvirBrE84c=; b=E7Is0uAHXcImPMPgJ/R+48gCWi2WE4WrDbEpnBVVkZ7xwNHAHAEevAbyvnBZhY71Tx F6dJKiWt3AyTnMPmv64YPwMSsYIyirgzAvCmpVoyOH4nNpwgAU+xG2mFGmv/Sf8f1bqu DyQjaQNObZKfHGpwj6DcGjmJKwaJ3ChrtTOT+j2AWxSGw8TyZ9Yo/Cy9/Du4isCOdcBh doMWnwB0VjaRpbpe6PmDKLrHa3qDVzy0zZu/vUCkPK4tqBx0IVxT4cvg6dUSlZIMTknY 7PkOMMGm3TjJuQsvuW65UeA9oOzfKgCJknfoBOOSE5S0WC7pXC9dPT823bHBVtVzPoh4 v7fA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+bi+0js; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVgDqcyfo3JRnYAz4E8PQMS8/+7AH+tSw7DmmufYyt9MNUUNrs3oZDQXnGwPa2F+Oyae7ESQhws+rX9AnTBpgj8 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j8-20020a0cf9c8000000b0068c82361a09si1250406qvo.553.2024.02.01.21.54.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Feb 2024 21:54:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+bi+0js; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVmSZ-0001He-Lg; Fri, 02 Feb 2024 00:51:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVmSS-0001GL-9f for qemu-devel@nongnu.org; Fri, 02 Feb 2024 00:51:25 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVmSP-0001o1-ME for qemu-devel@nongnu.org; Fri, 02 Feb 2024 00:51:22 -0500 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3bea8d764d8so1042639b6e.2 for ; Thu, 01 Feb 2024 21:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706853080; x=1707457880; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NfNpPvlkxn2D3fI9cYf9hBQTlB/c6mteAgGLiKm11to=; b=U+bi+0jsO2Ph593Und3MkaG3KC71v+jFg5gwyHaDbyiom+nTpFaibZkH0qJRuTbSmj Toj0KIp0/x71uzH7iX6xmPwUpag6xIHSl9D70itvKl0jfLsFEbuW/FFNkEWUYIW+gqoH GTxh0wSSvvc4jJBx/kht+srJuG+BlleunkJNSBIpznh/wDkFFPKHSRs5yJOwbQ/J9fIq z/espw1IAm5gyFbOGNqZjJ5qSRei/GI70fdEFXt6qPI+aXUbrr/am9iTxqhrvxnwjHQ8 nJ1YJkVNI5hJ3s0jP2ZghMOqorhNgIWrqex7c1stOxPx8JsRcWtrrbua8VckYU1oAbNS nRkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706853080; x=1707457880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NfNpPvlkxn2D3fI9cYf9hBQTlB/c6mteAgGLiKm11to=; b=BoRuJfqM/aWvlikilOAm7mA6p70AeQSdx9cDYAg7mVbqPjBj8eMv6adWAyW3rbG6oJ NxQnCq0jKPwnDY0xQoh0DDP/2raXQ+7uLFikf1grvg7DFVL9wDRw2PQdIY/xcB4YlR9y oEO4TO7G3E3RAlE1eiIsIG4PM3/tWG2ShI/BMzx+9+CPbfLkKMccbJ5dOrF8JnwsNaBw 8k7FufRfr2NuIALzxswIPE4OVvS49SnGg7UYJxL5h9qFFpc3+hx/JunALr5VSdgy3xsb DE7KQvmxxMAnDLT14KG/USUcz3dsIkhvF/s8PdUrg/2hEnIdyWlxC6vwGO3+9mCNbLvh 7U6w== X-Gm-Message-State: AOJu0YwUBnhSa+iBnxH87fPwZLRJVSO3VHmgAKTCHXSp5CZWLcRIVkJR 9PRWT+VWq8D+LEtshv6rPXUzgJrSrmn6djpVgZYwgz80E7zYIUQomC0eY4AlpAGZe/yxt2hPoyw 25Wo= X-Received: by 2002:aca:1702:0:b0:3be:ba3c:809a with SMTP id j2-20020aca1702000000b003beba3c809amr7136093oii.34.1706853080222; Thu, 01 Feb 2024 21:51:20 -0800 (PST) Received: from stoup.. ([103.210.27.218]) by smtp.gmail.com with ESMTPSA id h2-20020aa79f42000000b006dab0d72cd0sm715111pfr.214.2024.02.01.21.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 21:51:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 18/57] target/nios2: Populate CPUClass.mmu_index Date: Fri, 2 Feb 2024 15:49:57 +1000 Message-Id: <20240202055036.684176-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240202055036.684176-1-richard.henderson@linaro.org> References: <20240202055036.684176-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 12 ++++++------ target/nios2/cpu.c | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 2d79b5b298..9965ff74c1 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -270,12 +270,6 @@ void do_nios2_semihosting(CPUNios2State *env); #define MMU_SUPERVISOR_IDX 0 #define MMU_USER_IDX 1 -static inline int cpu_mmu_index(CPUNios2State *env, bool ifetch) -{ - return (env->ctrl[CR_STATUS] & CR_STATUS_U) ? MMU_USER_IDX : - MMU_SUPERVISOR_IDX; -} - #ifndef CONFIG_USER_ONLY hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, @@ -292,6 +286,12 @@ FIELD(TBFLAGS, CRS0, 0, 1) /* Set if CRS == 0. */ FIELD(TBFLAGS, U, 1, 1) /* Overlaps CR_STATUS_U */ FIELD(TBFLAGS, R0_0, 2, 1) /* Set if R0 == 0. */ +int nios2_cpu_mmu_index(CPUState *cs, bool ifetch); +static inline int cpu_mmu_index(CPUNios2State *env, bool ifetch) +{ + return nios2_cpu_mmu_index(env_cpu(env), ifetch); +} + static inline void cpu_get_tb_cpu_state(CPUNios2State *env, vaddr *pc, uint64_t *cs_base, uint32_t *flags) { diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 596c0c5617..e42885997e 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -57,6 +57,12 @@ static bool nios2_cpu_has_work(CPUState *cs) return cs->interrupt_request & CPU_INTERRUPT_HARD; } +int nios2_cpu_mmu_index(CPUState *cs, bool ifetch) +{ + return (cpu_env(cs)->ctrl[CR_STATUS] & CR_STATUS_U + ? MMU_USER_IDX : MMU_SUPERVISOR_IDX); +} + static void nios2_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); @@ -381,6 +387,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = nios2_cpu_class_by_name; cc->has_work = nios2_cpu_has_work; + cc->mmu_index = nios2_cpu_mmu_index; cc->dump_state = nios2_cpu_dump_state; cc->set_pc = nios2_cpu_set_pc; cc->get_pc = nios2_cpu_get_pc;