From nobody Thu Nov 6 19:07:21 2025 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.zoho.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 1488344149306452.50834790015085; Tue, 28 Feb 2017 20:55:49 -0800 (PST) Received: from localhost ([::1]:38388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciwIl-0000gL-R5 for importer@patchew.org; Tue, 28 Feb 2017 23:55:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciw7m-0007zZ-Ba for qemu-devel@nongnu.org; Tue, 28 Feb 2017 23:44:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciw7k-00005R-C3 for qemu-devel@nongnu.org; Tue, 28 Feb 2017 23:44:26 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:56215) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciw7j-0008UM-TL; Tue, 28 Feb 2017 23:44:24 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vY2sS0XNMz9sNF; Wed, 1 Mar 2017 15:44:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1488343452; bh=QSU2yHdywcm26Y/XlGsx89RWxvN8Bi6x+f/3qOp6Nds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fj5iHCvLxqnTTYU44aEvBedaXibcP2lOUpPufR67WbJlb5u1vNkUdKiumEfncA8+T 9zSlpwqyS13C+a6NW+g9+AGAJePOcW4V6ImX15LZ5HFnMHSIntcIw8YzzzPMKuXlhm 26ZlwwYIHokFiNuYaAO60o7sZbxj1y4eFlINZI1I= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 1 Mar 2017 15:43:30 +1100 Message-Id: <20170301044405.1792-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170301044405.1792-1-david@gibson.dropbear.id.au> References: <20170301044405.1792-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 15/50] target/ppc: Correct SDR1 masking 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: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" SDR_64_HTABORG, which indicates the bits of the SDR1 register to use for the base of a 64-bit machine's hashed page table (HPT) isn't correct. It includes the top 46 bits of the register, but in fact the top 4 bits must be zero (according to the ISA v2.07). No actual implementation has supported close to 2^60 bytes of physical address space, so it's kind of irrelevant, but we might as well correct this. In addition, although we checked for bad size values in SDR1, we never reported an error if entirely invalid bits were set there. Add this check to ppc_store_sdr1(). Reported-by: Suraj Jitindar Singh Signed-off-by: David Gibson --- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_helper.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h index 9c74823..54f1e37 100644 --- a/target/ppc/mmu-hash64.h +++ b/target/ppc/mmu-hash64.h @@ -56,7 +56,7 @@ void ppc_hash64_update_rmls(CPUPPCState *env); * Hash page table definitions */ =20 -#define SDR_64_HTABORG 0xFFFFFFFFFFFC0000ULL +#define SDR_64_HTABORG 0x0FFFFFFFFFFC0000ULL #define SDR_64_HTABSIZE 0x000000000000001FULL =20 #define HPTES_PER_GROUP 8 diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 3bc8030..a1af3d6 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -2007,8 +2007,14 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong v= alue) assert(!cpu->vhyp); #if defined(TARGET_PPC64) if (env->mmu_model & POWERPC_MMU_64) { + target_ulong sdr_mask =3D SDR_64_HTABORG | SDR_64_HTABSIZE; target_ulong htabsize =3D value & SDR_64_HTABSIZE; =20 + if (value & ~sdr_mask) { + error_report("Invalid bits 0x"TARGET_FMT_lx" set in SDR1", + value & ~sdr_mask); + value &=3D sdr_mask; + } if (htabsize > 28) { error_report("Invalid HTABSIZE 0x" TARGET_FMT_lx" stored in SD= R1", htabsize); --=20 2.9.3