From patchwork Tue Jul 25 14:58:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706151 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232515wrs; Tue, 25 Jul 2023 07:59:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqIN3qNoEMlZLbJtV89v1dbdXwn93apFoXuvS+dqsMFobzzMM1QViwARXogsnhFLkictK1 X-Received: by 2002:a25:9387:0:b0:d0c:15e8:97af with SMTP id a7-20020a259387000000b00d0c15e897afmr5335928ybm.5.1690297187087; Tue, 25 Jul 2023 07:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297187; cv=none; d=google.com; s=arc-20160816; b=JekmVkxZEG8p3lcJOFH4wvFJZTdEufvYSSZ0+tBadXUgvVXJ1OP3dFIU/IT5tkUtfa lKeVXLvBTcKkNKtI4NqE4sp8X5Kq2LbCjLycnnZqAjCZ4hzFBqtMnBwwAvGflhslJqRJ AWv82fNA31lRleUHi3eQo0fgDK2nL28Q8iLpQCkJ0hTM4JVWZNJN1SD0XSbuW4pHz+kQ 7/EWOM7AdtSn39BjXrjER0F9/QvpqAKEkGNxA5YSTY4Rl3S2zMtDiEQJa8ZrIWECdH7F sMSrwQaCw7D6HvamZ29hD1jBF04kJVewlH9uSmA4Ybvqm+fHpCeoVqwgN6LxEHE/Cc// XuKQ== 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; fh=Stq2SV/xhy3nSB1W3Xp07nF/pIUdKhH/vDshjHjvMuw=; b=y/6fQfnEN8UdMETyP1q/hKq2SlVp0bsL+kpIMFO4iqoAIsTTnGdRZepq7T7SYjj6kQ ykWoJlDPMAgTg8n/+kinzDhxUhMfrCfStvKpgs0kFCRgmD8ZDI/ANFY85aGl0lMobFKl N6ILkWrWgtExBQ4fOYbofZosmrj0EDFpjueHjKTfMdpsGJh6KaK78yqdRbV7nELZG9gK muM2zQrbCq1gvDF+UWwYwDh905dZz6AAvyFEUNQVqF2txg+jPnf6oT5suydsAaohN71V 8LgoGc5fQMj4WH0/5on0rJhWfcUQnsC5L9iaDhp0Yk+YJrUWax6Pi4/N4+w2TA40Ak11 o6ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPqhoQd6; 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 i4-20020ac85c04000000b00403c200aae5si6572579qti.638.2023.07.25.07.59.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:47 -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=CPqhoQd6; 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 1qOJVP-0003RD-6Y; Tue, 25 Jul 2023 10:59:19 -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 1qOJVN-0003QK-Lg for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:17 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVJ-0001Dh-3x for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:17 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fd18b1d924so45472415e9.1 for ; Tue, 25 Jul 2023 07:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297151; x=1690901951; 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; b=CPqhoQd6FLmqn1MMGy3g8W4/8T9X+jlPCcQMS0UQOlDgh1o3xo/Qf9WOhkBvDhy0Qh UUrZSmxCKGsaMtHk/Bex/hGum32XTjxJ0q4F1FWGDHMpRP3sKHWSCscNA3eFxtNY5CYi ZzZo/Y5ByxCnyTTeP7KVF68zR3AT44p7W5MMudy1VYhPVjLVW5R2CefskZ/JswCz0Dip E1keItNma0paIsl0W3DFJqqttxC8KPUb9n4CnUpDGRWKQ3hMGaUI75UJe7bsU7FP/WrA 3TDaPlBlE9tLixQN6m3Elhx7cwKCD5/pTefN/mV/A1RWS0L4r74s3GfUbLLbiz9xXQqe wo5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297151; x=1690901951; 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; b=b5zYnnvA+96QYNX2qAEtjBrnjyVLfyxJLWncPeXpIQMDFWGn7oZpir9oXTZDBDFgRA L9CNUmuAINJzsKdovi+ODI+/lA5/YXOji9U0K/A7lnzc4LW4sZncCjm/tCYkoBxkk4b7 4Lp/v+OTV4M2iGGs47od4kmLxZIm6DPtr3HNVSTLRAOR5gWm5tFqJkKAnw22xB1YF97t MLO3HcMo6hLCZUdVxCVscYuIz5dlRhXzc6rX3uoofDnisHHHNJpfMGJqqEmqodnTkQp7 m9WgrrdtdLquHijFIodz3nokKpPNHdpMD0y/EuQaYgB1lqYRoErZiUr6yhZJZYnBHl/3 hJmA== X-Gm-Message-State: ABy/qLaDoZVRxFt3Hh89/oa6Rjzs4ICGmK8z8l9IDQQTDktAbXZTA6et Rb54lE+afK+taD1ZQhml6MczMoWe9E2SYJbkxuM= X-Received: by 2002:a5d:5185:0:b0:314:dea:f1f8 with SMTP id k5-20020a5d5185000000b003140deaf1f8mr8847145wrv.11.1690297151578; Tue, 25 Jul 2023 07:59:11 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id b17-20020a5d40d1000000b00314417f5272sm16586989wrq.64.2023.07.25.07.59.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PULL 07/10] target/mips: Pass directory/leaf shift values to walk_directory() Date: Tue, 25 Jul 2023 16:58:26 +0200 Message-Id: <20230725145829.37782-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 We already evaluated directory_shift and leaf_shift in page_table_walk_refill(), no need to do that again: pass as argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20230717213504.24777-2-philmd@linaro.org> --- target/mips/tcg/sysemu/tlb_helper.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index e5e1e9dd3f..e7be649b02 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -623,18 +623,13 @@ static uint64_t get_tlb_entry_layout(CPUMIPSState *env, uint64_t entry, static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, int directory_index, bool *huge_page, bool *hgpg_directory_hit, - uint64_t *pw_entrylo0, uint64_t *pw_entrylo1) + uint64_t *pw_entrylo0, uint64_t *pw_entrylo1, + int directory_shift, int leaf_shift) { int dph = (env->CP0_PWCtl >> CP0PC_DPH) & 0x1; int psn = (env->CP0_PWCtl >> CP0PC_PSN) & 0x3F; int hugepg = (env->CP0_PWCtl >> CP0PC_HUGEPG) & 0x1; int pf_ptew = (env->CP0_PWField >> CP0PF_PTEW) & 0x3F; - int ptew = (env->CP0_PWSize >> CP0PS_PTEW) & 0x3F; - int native_shift = (((env->CP0_PWSize >> CP0PS_PS) & 1) == 0) ? 2 : 3; - int directory_shift = (ptew > 1) ? -1 : - (hugepg && (ptew == 1)) ? native_shift + 1 : native_shift; - int leaf_shift = (ptew > 1) ? -1 : - (ptew == 1) ? native_shift + 1 : native_shift; uint32_t direntry_size = 1 << (directory_shift + 3); uint32_t leafentry_size = 1 << (leaf_shift + 3); uint64_t entry; @@ -779,7 +774,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (gdw > 0) { vaddr |= goffset; switch (walk_directory(env, &vaddr, pf_gdw, &huge_page, &hgpg_gdhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false; @@ -795,7 +791,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (udw > 0) { vaddr |= uoffset; switch (walk_directory(env, &vaddr, pf_udw, &huge_page, &hgpg_udhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false; @@ -811,7 +808,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (mdw > 0) { vaddr |= moffset; switch (walk_directory(env, &vaddr, pf_mdw, &huge_page, &hgpg_mdhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false;