From patchwork Wed Apr 12 11:43:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672608 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp287239wrx; Wed, 12 Apr 2023 04:44:18 -0700 (PDT) X-Google-Smtp-Source: AKy350brUcWhI/42fFuCSarDYx0aIBndWlvsCHxpCg6lRybdItzBDbR2yDmIo4wMknh4TbH05PFx X-Received: by 2002:ac8:5888:0:b0:3e6:4b7b:253 with SMTP id t8-20020ac85888000000b003e64b7b0253mr31279654qta.7.1681299858555; Wed, 12 Apr 2023 04:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681299858; cv=none; d=google.com; s=arc-20160816; b=bhso8wdeAROw8MUMRgkV3gihtpV8bF6mY6Yc36U+5lLQbUvQ+vHZGLIddzim0EIs4A 3xzIVpZVeiBYfO4/38X3h4YAY6DXCFfEqlqYp0606shyxkxnXV/UgXoJU/UvBm6l4Xq6 3q/5FxLSMfOY7FaJhCehw8kwb1hP5cgpLWqt3/zXKymShciwNPCc6ve67SevZaV8P0FB 6Gq3l7DrrN+h1+Byi+ooCYYQR/4yLxd8oLmUNmGtAI2G2lGAui9Oc7DLhPZEYQcNmBPy cMpwseHcco/y7QsyUUCJHAjefr22QflTKsqcBQpetYazM86I0sO4EG3OhGj0TvTKHXl/ iaWg== 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=3Lv2amYuxnL/rjHsnpYSrIfjZprlyKOd0sUgv/cdui0=; b=cW5YYZaQeR5jqLGggvdgnyFjy74A4z8LAb7F1dn1KeB05Oi5yfAl//dlDMq1a6PFBk P56GKKMxL1QM2O6LIo5yH5Jed5Hkl98ri4xpvmC22kv+BKuL/DZd2drxE0PTCiRk+fH5 wGlPhZOoxiVkN/iA85P32xYiXvx+myNftxlYzZKaf3utRq9p/UR3RJh17pFwoCieF8IZ yIDPTMuOBkU2yVJAQuzP5v8bwQEGYBMhOZSFTtrlrgzMCHLMoCeK5YHjB4jeGdKJzJob EHpDnlTqOkaZBZZZtk4Xcd2h/WubjtX2bTG9YKiNHTfhnxONl/WLMotzcQ77MZiyWpp9 hxzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dxAvSN0Z; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w8-20020ac857c8000000b003ba35fdb9b4si10574581qta.280.2023.04.12.04.44.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Apr 2023 04:44:18 -0700 (PDT) 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=dxAvSN0Z; 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 1pmYtQ-0004z2-JA; Wed, 12 Apr 2023 07:44:08 -0400 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 1pmYtB-0004s0-PI for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:50 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmYt9-0002NQ-72 for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:49 -0400 Received: by mail-wr1-x430.google.com with SMTP id e7so493967wrc.12 for ; Wed, 12 Apr 2023 04:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681299825; x=1683891825; 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=3Lv2amYuxnL/rjHsnpYSrIfjZprlyKOd0sUgv/cdui0=; b=dxAvSN0Za8XtSpewBHotI+liYkI3R0XrGZHy6SfbuCEyIm+MtuFxfbEFSzIPpEJAdS fisDH/mrWbVKN0sPmo21Uj+sNykOQQEIsaJt+/3JqfN2mDEIEuU4OFGaTGnoamkefCxj 6WvLu1enXEJvVTVFvl2YD2p/u3jHl8RZ3xLOpWUJV9cDapiclgm5Kbd2hZZq2H3byg0D NR4ED99Azidh5iIcL8mFWah1sux7Vc6gsJmIA088+/ENagtw3NOl8gVMpmskUuHdAbWo SH7ASFGp4zmfIeGVXUTgOm2eKloNo0G7Qgz2JmRFvO7pmRQvLFgXywDDVRC4bd4iZ39T 7pdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681299825; x=1683891825; 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=3Lv2amYuxnL/rjHsnpYSrIfjZprlyKOd0sUgv/cdui0=; b=RgOIzyYG29A7j0MCo8oS4+tKhGIFau/ufaLKzIgP+1udCrjInxq9yW6QvsuPZJHT2K blq0Af2DkLe9dGYCU0PnRNj2Hcnv1D0MwX4qKVcXj51akNhDEKmg11DpczqqJJXjq1Na n87UUnuB7GLjQml2noGrHW9zu5nWJQgMCSDsgP3jUL4OnE7qmzYLPYuqTnrcNvyJQAnD R1o4xNfDkDyyeeMZvdnZ7CuEA4zKKGK2kOjaW3x63xDSKwYJkM/OiESD4FACKi1YsVgY amDhMA3hMh0SjdTcZV4pDapp++bWKSIX0wjsV+HNqLDEQ+9NsxOb3Vr3Csc2w6EF7wVy S8gw== X-Gm-Message-State: AAQBX9cim2VgDqP24IWEVInasWRTrSh3UVxu7mWsgsnhAZx5IAEllVG6 IwpvJDxvZ/C3hYCUcCUW93WZVOIpEouOIdlDWPylwLnV X-Received: by 2002:adf:f2c5:0:b0:2d1:70cc:66e0 with SMTP id d5-20020adff2c5000000b002d170cc66e0mr1541381wrp.44.1681299825582; Wed, 12 Apr 2023 04:43:45 -0700 (PDT) Received: from stoup.hotel.gast (ip-037-024-010-236.um08.pools.vodafone-ip.de. [37.24.10.236]) by smtp.gmail.com with ESMTPSA id k9-20020a5d4289000000b002d21379bcabsm16980826wrq.110.2023.04.12.04.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 04:43:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, qemu-riscv@nongnu.org, Alistair Francis , Weiwei Li , Daniel Henrique Barboza Subject: [PATCH v7 12/25] target/riscv: Introduce mmuidx_sum Date: Wed, 12 Apr 2023 13:43:20 +0200 Message-Id: <20230412114333.118895-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230412114333.118895-1-richard.henderson@linaro.org> References: <20230412114333.118895-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x430.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 autolearn=unavailable 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 In get_physical_address, we should use the setting passed via mmu_idx rather than checking env->mstatus directly. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-13-richard.henderson@linaro.org> --- target/riscv/internals.h | 5 +++++ target/riscv/cpu_helper.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 7b63c0f1b6..0b61f337dd 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -37,6 +37,11 @@ #define MMUIdx_M 3 #define MMU_2STAGE_BIT (1 << 2) +static inline bool mmuidx_sum(int mmu_idx) +{ + return (mmu_idx & 3) == MMUIdx_S_SUM; +} + /* share data between vector helpers and decode code */ FIELD(VDATA, VM, 0, 1) FIELD(VDATA, LMUL, 1, 3) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 291a1acbf7..29ee9b1b42 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -842,7 +842,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, widened = 2; } /* status.SUM will be ignored if execute on background */ - sum = get_field(env->mstatus, MSTATUS_SUM) || use_background || is_debug; + sum = mmuidx_sum(mmu_idx) || use_background || is_debug; switch (vm) { case VM_1_10_SV32: levels = 2; ptidxbits = 10; ptesize = 4; break;