From patchwork Mon Dec 30 07:26:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Hao X-Patchwork-Id: 13923087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AE13E77188 for ; Mon, 30 Dec 2024 07:27:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSAAg-0003a1-VF; Mon, 30 Dec 2024 02:26:39 -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 1tSAAb-0003Zn-Ra for qemu-devel@nongnu.org; Mon, 30 Dec 2024 02:26:34 -0500 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1tSAAY-0005nU-QB for qemu-devel@nongnu.org; Mon, 30 Dec 2024 02:26:33 -0500 Received: from haooops-ThinkPad-P15v-Gen-1.. (unknown [159.226.43.8]) by APP-03 (Coremail) with SMTP id rQCowAAH7zEXS3Jn9Mq+BA--.25674S2; Mon, 30 Dec 2024 15:26:16 +0800 (CST) From: Miao Hao To: gaosong@loongson.cn Cc: qemu-devel@nongnu.org, Miao Hao Subject: [PATCH] target/loongarch: Fix index calculation for variable length pte Date: Mon, 30 Dec 2024 15:26:13 +0800 Message-Id: <20241230072613.152286-1-haomiao23s@ict.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-C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UUUU== X-Originating-IP: [159.226.43.8] X-CM-SenderInfo: 5kdrzx1drsj2g6lf3hldfou0/ Received-SPF: pass client-ip=159.226.251.81; envelope-from=haomiao23s@ict.ac.cn; helo=cstnet.cn X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Miao Hao --- target/loongarch/tcg/tlb_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index 97f38fc391..a57ddfe8ad 100644 --- a/target/loongarch/tcg/tlb_helper.c +++ b/target/loongarch/tcg/tlb_helper.c @@ -538,9 +538,9 @@ target_ulong helper_lddir(CPULoongArchState *env, target_ulong base, badvaddr = env->CSR_TLBRBADV; base = base & TARGET_PHYS_MASK; - /* 0:64bit, 1:128bit, 2:192bit, 3:256bit */ + /* 0:64bit, 1:128bit, 2:256bit, 3:512bit */ shift = FIELD_EX64(env->CSR_PWCL, CSR_PWCL, PTEWIDTH); - shift = (shift + 1) * 3; + shift = shift + 3; get_dir_base_width(env, &dir_base, &dir_width, level); index = (badvaddr >> dir_base) & ((1 << dir_width) - 1); @@ -595,9 +595,9 @@ void helper_ldpte(CPULoongArchState *env, target_ulong base, target_ulong odd, tmp0 += MAKE_64BIT_MASK(ps, 1); } } else { - /* 0:64bit, 1:128bit, 2:192bit, 3:256bit */ + /* 0:64bit, 1:128bit, 2:256bit, 3:512bit */ shift = FIELD_EX64(env->CSR_PWCL, CSR_PWCL, PTEWIDTH); - shift = (shift + 1) * 3; + shift = shift + 3; badv = env->CSR_TLBRBADV; ptindex = (badv >> ptbase) & ((1 << ptwidth) - 1);