From patchwork Fri Jan 25 18:49:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156642 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp692268jaa; Fri, 25 Jan 2019 10:49:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN78vOEl/k7F7N5yvguHBf3ZMmjgMHw4ZBopPzonsusg17JWdr9f/avkLvc87/OYasNxj4d2 X-Received: by 2002:a1c:bdc5:: with SMTP id n188mr8355027wmf.69.1548442177092; Fri, 25 Jan 2019 10:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548442177; cv=none; d=google.com; s=arc-20160816; b=gfxNzAkm2phwmuGnGAibHexB1naVCKr+dW/B1ZDnCUATFKEA63BgaZHNsUZjnpBZIO g7rZBL1SD2gf/sIOMDlmQ4T/EjSg+B5NE+JdtkxO1RRHg8MnuPxgI9oDfoGcSc0G1w1t uKotDtjuBel0+3yyqlxD8FaIhDYK77VS0qdIywHzxQ4/JW7fJI4D8lNyIfAFsagQ/8gm cuVJVBjjDqQtrda+dpjXVx4xuAdJPnz8vkBJD+jXBAuHMb476fEeTlaa9ytEuGwunvL7 tsYgF9gzFfaI86ZSRDpJa6G2oxMpou5lqG1OjpLcMnKnKqg578l2rbU+7m6Gi4d3q2f4 jDyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=qT451ugx4kr/BMT14YDA2irSN0Kgl30bfTPCMg4UxpZJky/QKv3xwPbAKMMvWH0IYS ya6MlHVOxzCqyGSNauM7n/AxoR2KbQ7wZr/kB7+sTGeJUOVyjYsEu2DooLh7X8XJkTs2 YU3LoAHMif73MrT11W5XPlICo92UtzDe5Ifz8J4LJhkkL+Z45BrdN2MMCLcTklEbBSdt nzjZ2bcl/3WVAv4e5QdOz5Xoz8Mpda6uXii/aDJessjmIX30ll88jDKvacKzFq/t0gJN UfknU2lnIGG+mFrS9FWEbmOaDuz5DJ0WQwcTcavBPYFX7fnTvPtkGAGhGpqmIJhX8++v dk2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ATRf6EhT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x20si559237wmh.163.2019.01.25.10.49.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 Jan 2019 10:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ATRf6EhT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:49278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn6Xo-0006bw-40 for patch@linaro.org; Fri, 25 Jan 2019 13:49:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn6XW-0006be-VA for qemu-devel@nongnu.org; Fri, 25 Jan 2019 13:49:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gn6XV-0001m3-SF for qemu-devel@nongnu.org; Fri, 25 Jan 2019 13:49:18 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41069) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gn6XV-0001l0-M0 for qemu-devel@nongnu.org; Fri, 25 Jan 2019 13:49:17 -0500 Received: by mail-pl1-x641.google.com with SMTP id u6so4945651plm.8 for ; Fri, 25 Jan 2019 10:49:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=ATRf6EhT/H7aYgVQ2CRN+ZjaeFHWgSDdNbbqO0Gh9RxcuQ5e4v61IjNu3RQd0jAhQ9 ON/Ss1ylCGlqXWn+e0UykTGzM9onXx8lLxegOgg1KRTFxYL55PW+mlKMA9Mq62aeNLwp ysVUbl2Z2jbQ4gQMmyUHCgjoyf6KfJqlphwcc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=uIwmIupJL2w1/vHO4OHXPPD045SbCrWOycIS3wsDjRENufb7mLM4cMhNzRVQxj//7L bWdx1XsBUXpt9PEWGIGmstRCAe489z6xOJ9GqrQwMqjOkD29l9BshyrNFdY+r2ujTc70 dNp9kccZMPvE4XyC3oaT6I46Ee3Mg/JpV+wS7CSI8zTkKWANSsDbg4J6YACSMirjfDG0 3Cjlf9f8zF2bGOjXwxP+Hnj4yoAJdzTrQveyOv7NvrZOqr1Uyc6lAB4rHedBFQi6g6vk aA+MWSZDhtts+AdMecRDyrDXhmwd4eIR0iehQidqbPanGgfa6aGqnqrINc64uxgQwGst etQQ== X-Gm-Message-State: AJcUukfv+cW/smblS6UZqLCtnC0XD1Dmh7E/yGBwsAF3FtFK3ki9ZfXD uEuY+ssyDBispI/qwi9XaaYP9IqmEWI= X-Received: by 2002:a17:902:7402:: with SMTP id g2mr11811364pll.198.1548442155657; Fri, 25 Jan 2019 10:49:15 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id i2sm41882531pfi.66.2019.01.25.10.49.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jan 2019 10:49:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 10:49:13 -0800 Message-Id: <20190125184913.5970-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH] 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When tsz == 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 --- target/arm/helper.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 92666e5208..e24689f767 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10447,7 +10447,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_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 == addrsize, then we have selected the + * region by exclusion in aa32_va_parameters and there is no more + * validation to do here. */ - top_bits = sextract64(address, inputsize, addrsize - inputsize); - if (-top_bits != param.select || (param.select && !ttbr1_valid)) { - /* In the gap between the two regions, this is a Translation fault */ - fault_type = ARMFault_Translation; - goto do_fault; + if (inputsize < addrsize) { + target_ulong top_bits = sextract64(address, inputsize, + addrsize - inputsize); + if (-top_bits != param.select || (param.select && !ttbr1_valid)) { + /* The gap between the two regions is a Translation fault */ + fault_type = ARMFault_Translation; + goto do_fault; + } } if (param.using64k) {