From nobody Sun May 19 06:05:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1686747714; cv=none; d=zohomail.com; s=zohoarc; b=XmW1gHRZJVgFrX/TAk4V9rV00D2jrl0N1PQIhD0+bETXgJa2GT+1nYQUsHoCWkVvOSLPLtvI0fJGc3rSjUSihM2XUxBQZGj/ED3uG/m6JjCrUdksjKKIF4pe1fNBlreAdAW+z4IfbVq2Mlsovw0SFBMo4vh9OHvb+TJpJZWo6c0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686747714; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9o4m1BpX4P9b7JSMXRvUjNvvXUje8lOxH95OaEmqIiM=; b=gjyvrWn4YbWdai/qpamTuqwLuAHwG1MW7I0+Gapiv77m76Ndjskn0JBanxdsOCGA3e4PBMeG9USgx9z+cVyIGpgLV8yGjW86FRxMvoFM8hw7myPH0AvxtFLeP9ihMtwTtTgV/l76Xv8E8Omh/2HRGUfK8RG7d4zWnGhrqsDr02A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686747714086619.8064393893584; Wed, 14 Jun 2023 06:01:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9Q7i-0002iN-80; Wed, 14 Jun 2023 09:01:18 -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 1q9KQb-0002C1-G3 for qemu-devel@nongnu.org; Wed, 14 Jun 2023 02:56:25 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9KQZ-0004PW-Kg for qemu-devel@nongnu.org; Wed, 14 Jun 2023 02:56:25 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1E5DF40004; Wed, 14 Jun 2023 06:56:16 +0000 (UTC) X-GND-Sasl: c@jia.je DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jia.je; s=gm1; t=1686725779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=9o4m1BpX4P9b7JSMXRvUjNvvXUje8lOxH95OaEmqIiM=; b=MWb9f2ZDjxbkJJPxJHjKLLVyGh46lvNBpV0cNbdqi06W2+5+Ty0mAQpDde1Cs8kZ1bZIQI LSOWePsmUwVe2OSJOqKMSC4jQRN/3Tej5aEBrmQ25jHkhh0cnNTgB4EAYynrqxCdJVH6cL G080QvlV4ee3UJTD90GbD94kCaqIrK2gLby9hsamD71PTTymZl6uVHNyT5AYsBZUI5HsuS v3zVazfg91nVvIkYqqBY8sKChg9tclVAVPYgXyTBP9aJCsCWihKYTZDLkrRxvlHnwgP2gd M+BWr6B5S5mXr5PfcDp/xswFMM7xkW0zLpJF8R11Uc942mfXb3SlLelaUqzasw== X-GND-Sasl: c@jia.je X-GND-Sasl: c@jia.je X-GND-Sasl: c@jia.je From: Jiajie Chen To: qemu-devel@nongnu.org Cc: Jiajie Chen , Song Gao , Xiaojuan Yang Subject: [PATCH] target/loongarch: Fix CSR.DMW0-3.VSEG check Date: Wed, 14 Jun 2023 14:55:56 +0800 Message-Id: <20230614065556.2397513-1-c@jia.je> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=217.70.183.194; envelope-from=c@jia.je; helo=relay2-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Mailman-Approved-At: Wed, 14 Jun 2023 09:01:16 -0400 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @jia.je) X-ZM-MESSAGEID: 1686747736802100003 Content-Type: text/plain; charset="utf-8" The previous code checks whether the highest 16 bits of virtual address equal to that of CSR.DMW0-3. This is incorrect according to the spec, and is corrected to compare only the highest four bits instead. Signed-off-by: Jiajie Chen Reviewed-by: Song Gao --- target/loongarch/tlb_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c index cce1db1e0a..6e00190547 100644 --- a/target/loongarch/tlb_helper.c +++ b/target/loongarch/tlb_helper.c @@ -185,10 +185,10 @@ static int get_physical_address(CPULoongArchState *en= v, hwaddr *physical, } =20 plv =3D kernel_mode | (user_mode << R_CSR_DMW_PLV3_SHIFT); - base_v =3D address >> TARGET_VIRT_ADDR_SPACE_BITS; + base_v =3D address >> R_CSR_DMW_VSEG_SHIFT; /* Check direct map window */ for (int i =3D 0; i < 4; i++) { - base_c =3D env->CSR_DMW[i] >> TARGET_VIRT_ADDR_SPACE_BITS; + base_c =3D FIELD_EX64(env->CSR_DMW[i], CSR_DMW, VSEG); if ((plv & env->CSR_DMW[i]) && (base_c =3D=3D base_v)) { *physical =3D dmw_va2pa(address); *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; --=20 2.30.2