From patchwork Wed Apr 12 11:43:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672629 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp289660wrx; Wed, 12 Apr 2023 04:50:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/TyM/BKd/bDveujSqV9FzgWIzgxwbv7+9Ss80Io0zuajVwhOyK7hiHpXEaYqUu9LTONf4 X-Received: by 2002:a05:6214:29ec:b0:5e8:42d0:d74c with SMTP id jv12-20020a05621429ec00b005e842d0d74cmr21084252qvb.37.1681300236731; Wed, 12 Apr 2023 04:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681300236; cv=none; d=google.com; s=arc-20160816; b=wBtVKQeNO8uEv26RsTjHm6mRNsXKirUDpqBrGM+mjTPFuZLKZgElb3Q/YauMVCGBDm nY9aPkNl+Yld9R4Zngc+xfN9nZZfdx/rljAEzUw9yEhcOc8pq4QcRxdKC6SYVTLz5C6r 432xAIzrvbmFbaBuEadQQM5YCOigcTzCBzkvnQuVPpfFBTcrMjLZ5emXm+o7SWZSU2EQ yd5K5d9/ukQpHTdmwq+ss6wF+Qe/88Wg3LJtQUgiBouPW11H4HARvyhTn0z9rz1Yq2/L KD9k4jvyQvV3tMroyDKlzjw03tDFkB3BPPZYE+EVck8z7QonGQFM0Z9JScvQdr/hVwK4 cJpQ== 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=VRysGopMuvQKVUYQZTztZp4OETaqkIX63XPVMpwePPA=; b=Om4AIC02J3DjyTQiwQTT15k6kHiedh8R29Y1/yZLAgqS/4NaZyBMYzGp7QbrMIovow JJuTkk2rq8a2F2WeO38vMz2yCQbGCrLjSmlRkKkcPLphspGdjafBX8yfNxO+LfVmotQI oOi1CTdaCkisfpUgVqfjn+2+pnxQbF0LmL8Z2TkjcuKwjAi3jxnZw0s4jZ9JoVPPsaZa PcS5cLrMAWEFUKufzAnjvuXrx/B4p2aBJwtuG7CVsQ01mgZG9XsR5UCo3IUzMHGzaOMn 5qHDXP8xyweC8JdszLSs9/m7rykeH2tlX77PskqLLCrk3SKNtJqrw2Psk5JeEEC3ZubD RjZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QJ3F18qO; 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 t12-20020ac8588c000000b003e4ea3f6018si1418985qta.139.2023.04.12.04.50.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Apr 2023 04:50:36 -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=QJ3F18qO; 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 1pmYti-0006Nh-Ae; Wed, 12 Apr 2023 07:44:22 -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 1pmYtI-0004xE-70 for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:57 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmYtF-0002TT-41 for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:55 -0400 Received: by mail-wm1-x330.google.com with SMTP id m8so20047771wmq.5 for ; Wed, 12 Apr 2023 04:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681299831; x=1683891831; 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=VRysGopMuvQKVUYQZTztZp4OETaqkIX63XPVMpwePPA=; b=QJ3F18qOPbwQNDoW+wchI3it8GRc+GussBXF1STfJmsi5SLrFqNbwQaYrs+ylqzIO7 Qjhm3SIpvEuKhxgjP8BMI9HDxx+7veVSXfVAbtotqsMD/cU9dBo59Wkor/6+Fncn2BfY sVJCX5SEHZ6ImZFisg47wFz5z8Cr5cConbTB47l5zbqoVTpXx5a3j20gNs2aIFKxUduP F6AzjFKIvFwNXjuVolFS3LeJCXW8aZJZuGlH4wMJQ+OOIsKb8sTUqinobAGVizt0s6uP uRGn/cIt899oNqIvDLBJFvwt67k63LpZ5nqXhWTx83EXyDc9YshEgI5FR/vM6dqLdkhh qUiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681299831; x=1683891831; 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=VRysGopMuvQKVUYQZTztZp4OETaqkIX63XPVMpwePPA=; b=0LB4TwPDj2ACanb/Awd0QgsCRvaq/CVUYDIw6mMqvpl2NhmKCz+qxdvuJfnV5wgjkf kCgTqNpXj9PQ/sbH07EQE0lsaz8xa5sehB/cUjH6UapMVf4C1bz1Zkrb+X5Ng1bdW0QN ZTG+Ta3ZP8gW8ZDE055qhnYTKdS/kVqwUq+g4VBqxAHozsbUerbjmq/nOm9/U5sjx+6A R0zD10SzqmAQcL9JgotsKJYj3gUvvUbJIz6nBbARrV33lWxt2Ni5PyHOpZiqk14P+J2F +2s9X644Srmoe14YHisQMSQMcHtLsgpkkkZZep27cs0kPFlVZzZrUxzarEFOSUDfX4on d6Sw== X-Gm-Message-State: AAQBX9e9HdQuU1huUnhpcNmyGFUd35hoCpC3Zf+B7GBcOlC2sUaHLfEI hf7accqJqbfSmfhB0E4uhKQI69Jst58TRoxaQ+wBIOTc X-Received: by 2002:a1c:7917:0:b0:3f0:9f28:fb6c with SMTP id l23-20020a1c7917000000b003f09f28fb6cmr1061289wme.12.1681299831380; Wed, 12 Apr 2023 04:43:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 04:43:51 -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 18/25] target/riscv: Hoist second stage mode change to callers Date: Wed, 12 Apr 2023 13:43:26 +0200 Message-Id: <20230412114333.118895-19-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::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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=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 Move the check from the top of get_physical_address to the two callers, where passing mmu_idx makes no sense. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-19-richard.henderson@linaro.org> --- target/riscv/cpu_helper.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 38bd83f66d..5753e4e612 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -777,14 +777,6 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, use_background = true; } - if (first_stage == false) { - /* - * We are in stage 2 translation, this is similar to stage 1. - * Stage 2 is always taken as U-mode - */ - mode = PRV_U; - } - if (mode == PRV_M || !riscv_cpu_cfg(env)->mmu) { *physical = addr; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; @@ -890,7 +882,7 @@ restart: /* Do the second stage translation on the base PTE address. */ int vbase_ret = get_physical_address(env, &vbase, &vbase_prot, base, NULL, MMU_DATA_LOAD, - mmu_idx, false, true, + MMUIdx_U, false, true, is_debug); if (vbase_ret != TRANSLATE_SUCCESS) { @@ -1271,7 +1263,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, im_address = pa; ret = get_physical_address(env, &pa, &prot2, im_address, NULL, - access_type, mmu_idx, false, true, + access_type, MMUIdx_U, false, true, false); qemu_log_mask(CPU_LOG_MMU,