From nobody Sat Sep 28 22:36:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548700751248642.6894883014778; Mon, 28 Jan 2019 10:39:11 -0800 (PST) Received: from localhost ([127.0.0.1]:36768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBoH-0008P4-54 for importer@patchew.org; Mon, 28 Jan 2019 13:39:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBN3-0002Zs-PR for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:10:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goBN1-0008Dq-PX for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:10:57 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:36630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goBMz-00086o-RJ for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:10:55 -0500 Received: by mail-wr1-x429.google.com with SMTP id u4so19163091wrp.3 for ; Mon, 28 Jan 2019 10:10:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id b18sm97910681wrw.83.2019.01.28.10.10.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 10:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dzqOBgB1v6gsOex139U1WEoQboBpRHnuWTjE6bnEP1Y=; b=ghfvYoTN/PoXSrCWNXnjyQvmwqR5Rr9miQGLoKLdoipwdI8tkZmFf/14LQIXucaaLZ azsWA504I9azTVdKOjkudAO/3hIL7uwdD3FO+riEP7BKfz9pq9QFnW8kUn7Lzk0ELQa0 fKEZehUIwm7XcvKtnVxwsHhDdqpqnvaqrFPbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dzqOBgB1v6gsOex139U1WEoQboBpRHnuWTjE6bnEP1Y=; b=J2E8M86eGgiSZ7jxUquBn7lMg9Unu5rgUwTi5A+PpMTXiEQvrJ+unw81w3UCTy2XDK nFmNM4zTo7m7gQiR1kMCleo4uNKXjBJJQptz4Cjh0vHdR8u2hW+qGSffU7GR2yB91Sop 1p4+8dZaPRiGSJE1kJYnO3NWM3gDUF+CqvGmqqvEl7ZC5cTlvXa0RUscEn0K9cp94nYn sGlhGySldjdxbHS07YxoLfBusgfyL3SIBCIfxrqA7LGhiuRioe/OW8z/iGpgx7Fu6+Hy 8f8wpJ+7+cq2dkp2pFktav7J/SI3Adltm2LYW7bxMk+9NYeVa5TVW85eyTKlosN/cMFI Xlbw== X-Gm-Message-State: AJcUukf6Saz4LEVSOjBTBxEvpoLcZsSbRRErkrj/lFMWq53FGOqzcwqF ZcYglWVVxraYKa539B256dtgfAcwMPu71w== X-Google-Smtp-Source: ALg8bN5zxHfy128Qy+ZVioAbcY2Tj0KZ2do+Gjm9ahxWBIdqVg3lFk8ttd8/E3WQnMCNFwkjLGlCDg== X-Received: by 2002:a5d:548d:: with SMTP id h13mr21662725wrv.80.1548699051609; Mon, 28 Jan 2019 10:10:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2019 18:10:22 +0000 Message-Id: <20190128181047.20781-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128181047.20781-1-peter.maydell@linaro.org> References: <20190128181047.20781-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 01/26] target/arm: Fix validation of 32-bit address spaces for aa32 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-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Richard Henderson When tsz =3D=3D 0, aarch32 selects the address space via exclusion, and there are no "top_bits" remaining that require validation. Fixes: ba97be9f4a4 Reported-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20190125184913.5970-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 92666e52085..e24689f7677 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10447,7 +10447,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, ta= rget_ulong address, uint64_t ttbr; hwaddr descaddr, indexmask, indexmask_grainsize; uint32_t tableattrs; - target_ulong page_size, top_bits; + target_ulong page_size; uint32_t attrs; int32_t stride; int addrsize, inputsize; @@ -10487,12 +10487,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, = target_ulong address, * We determined the region when collecting the parameters, but we * have not yet validated that the address is valid for the region. * Extract the top bits and verify that they all match select. + * + * For aa32, if inputsize =3D=3D addrsize, then we have selected the + * region by exclusion in aa32_va_parameters and there is no more + * validation to do here. */ - top_bits =3D sextract64(address, inputsize, addrsize - inputsize); - if (-top_bits !=3D param.select || (param.select && !ttbr1_valid)) { - /* In the gap between the two regions, this is a Translation fault= */ - fault_type =3D ARMFault_Translation; - goto do_fault; + if (inputsize < addrsize) { + target_ulong top_bits =3D sextract64(address, inputsize, + addrsize - inputsize); + if (-top_bits !=3D param.select || (param.select && !ttbr1_valid))= { + /* The gap between the two regions is a Translation fault */ + fault_type =3D ARMFault_Translation; + goto do_fault; + } } =20 if (param.using64k) { --=20 2.20.1