From nobody Mon Apr 29 17:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501682432204476.87164493406726; Wed, 2 Aug 2017 07:00:32 -0700 (PDT) Received: from localhost ([::1]:47952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcuCM-0002nW-EA for importer@patchew.org; Wed, 02 Aug 2017 10:00:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcuAn-0001qW-Ij for qemu-devel@nongnu.org; Wed, 02 Aug 2017 09:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcuAk-0005Iy-HA for qemu-devel@nongnu.org; Wed, 02 Aug 2017 09:58:53 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:42971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcuAk-0005Ek-BE for qemu-devel@nongnu.org; Wed, 02 Aug 2017 09:58:50 -0400 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 9E66C66A06861 for ; Wed, 2 Aug 2017 14:58:40 +0100 (IST) Received: from hhmipssw204.hh.imgtec.org (10.100.21.121) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 2 Aug 2017 14:58:43 +0100 From: Yongbok Kim To: Date: Wed, 2 Aug 2017 14:58:31 +0100 Message-ID: <1501682311-16370-1-git-send-email-yongbok.kim@imgtec.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.100.21.121] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.59.15.196 Subject: [Qemu-devel] [PATCH] target-mips: apply CP0.PageMask before writing into TLB entry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Leon Alrae PFN0 and PFN1 have to be masked out with PageMask_Mask. Signed-off-by: Leon Alrae Reviewed-by: Yongbok Kim [Yongbok Kim: Added commit message] Signed-off-by: Yongbok Kim --- target/mips/op_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 526f8e4..320f2b0 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2008,6 +2008,7 @@ static inline uint64_t get_tlb_pfn_from_entrylo(uint6= 4_t entrylo) static void r4k_fill_tlb(CPUMIPSState *env, int idx) { r4k_tlb_t *tlb; + uint64_t mask =3D env->CP0_PageMask >> (TARGET_PAGE_BITS + 1); =20 /* XXX: detect conflicting TLBs and raise a MCHECK exception when need= ed */ tlb =3D &env->tlb->mmu.r4k.tlb[idx]; @@ -2028,13 +2029,13 @@ static void r4k_fill_tlb(CPUMIPSState *env, int idx) tlb->C0 =3D (env->CP0_EntryLo0 >> 3) & 0x7; tlb->XI0 =3D (env->CP0_EntryLo0 >> CP0EnLo_XI) & 1; tlb->RI0 =3D (env->CP0_EntryLo0 >> CP0EnLo_RI) & 1; - tlb->PFN[0] =3D get_tlb_pfn_from_entrylo(env->CP0_EntryLo0) << 12; + tlb->PFN[0] =3D (get_tlb_pfn_from_entrylo(env->CP0_EntryLo0) & ~mask) = << 12; tlb->V1 =3D (env->CP0_EntryLo1 & 2) !=3D 0; tlb->D1 =3D (env->CP0_EntryLo1 & 4) !=3D 0; tlb->C1 =3D (env->CP0_EntryLo1 >> 3) & 0x7; tlb->XI1 =3D (env->CP0_EntryLo1 >> CP0EnLo_XI) & 1; tlb->RI1 =3D (env->CP0_EntryLo1 >> CP0EnLo_RI) & 1; - tlb->PFN[1] =3D get_tlb_pfn_from_entrylo(env->CP0_EntryLo1) << 12; + tlb->PFN[1] =3D (get_tlb_pfn_from_entrylo(env->CP0_EntryLo1) & ~mask) = << 12; } =20 void r4k_helper_tlbinv(CPUMIPSState *env) --=20 2.7.4