From patchwork Fri Jan 25 22:57:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156648 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp916821jaa; Fri, 25 Jan 2019 15:16:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN56fKBAfWsEs2DZQg4YJBssAjzhjQreLSgsdoFygXOBDc6JmkZ9BukmJxql/JuVmR1I/4bU X-Received: by 2002:adf:a211:: with SMTP id p17mr13124792wra.179.1548458206837; Fri, 25 Jan 2019 15:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548458206; cv=none; d=google.com; s=arc-20160816; b=Rnt6YMHnrMurFfTxXWxDTzAJj9zzTckUT042t14Ie8POfcAuA2aJlIxkugWkMnYKuB w4+63QqHBn0KfRhJLg0lYNVFuesdUN0OahTKBfSuceyMEaNBtHXcJnaNWFv4sB4tK9Mc +2iFKJ8G+HY+8Z3jMom5Fy5cG+sAQmwggO6CSHE4B9HjbaDp2VCOMFxKPKiNXlNbOzfQ JhcbFHeqUhTPb0s4jIdJ8VMJwjsQJ8CRQcRqoRChS8unbSVoEDYcfaTMHWdiVSz5n9NL owgw1EXNM0jvju0XV+EV5N5rp3PNe799rMNj5NAAQuvwGVbpAHse5yhFp91CEeEQ2OHX uIVg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=Q8SvsvjKjYZg9xnpFJQkxz1OCE0OexR+D/oUNA6V4SJsOfojNg5ZkCZuG4skiarEzr 0pbcPzQShmjRp4UDcRJKpVrNVYZL+mn8X/eylXTE2HzVGBTRSiBWL6CIW0mHK4Bn5LfV 5s4DiEJGtV0FfLGHeV2l4wBpne4xVMbIWnssG6eXgCFaomz18+Wv2RRYsRBoXPo2xSRG OvJs9d3L4VTu+lpjMDDNFdx05gbMLuxdJQfLgIrlwF2+kVgUqIDxgfcxTDXqCzN/c/Jm hKofcPxhsrDmmiMwHL7yLW+6faUyv9Q30yTiZdDtau/IJ2ieuNz42SOO0rqhW7IPx4uw bZ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8rvM1wa; 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 r6si37207097wrg.298.2019.01.25.15.16.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 Jan 2019 15:16:46 -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=d8rvM1wa; 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]:52272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnAiL-0008D3-Qc for patch@linaro.org; Fri, 25 Jan 2019 18:16:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnAe7-0004fe-U5 for qemu-devel@nongnu.org; Fri, 25 Jan 2019 18:12:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnAPZ-0005Is-0b for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:57:21 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:35164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gnAPY-0005Hc-PL for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:57:20 -0500 Received: by mail-pf1-x443.google.com with SMTP id z9so5401640pfi.2 for ; Fri, 25 Jan 2019 14:57:20 -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:in-reply-to:references; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=d8rvM1wa6S6wutcPD09PqP1uYFitV0rOLsOfZetPh6ZBiWCsiicvrcPKVW6JAnGGn+ nc6oJtKZnKQoLgTITZ1VGcQXkiAXB8PGo7SKdepAcYXGV3E8zv+nhrfz9LZbcedRrXoi 42m4rhKJeXI1NiCPYyjzcbIDYU8hXpWppEj6I= 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:in-reply-to :references; bh=8IXyEG4W5+YDCC6g8DrMGZK0JKjR2WU+35EBVQQqr7w=; b=fEZCz1n6Ef7eUWrLPitQHlUz2RYF6Z7EKhgykYASLjDvKWurqvXHUQgK+5CO2X+YJY Wk4LMEX0j3+uMtnHMQDO+wHjy8k9EEHLQHI3Tu5iYbDzkT+R9lBEGGhxsAidDLbSMTUb t3mF02x3Tku/9io1Q/OGQfaPpDqfeLnLL1JVbGQ8mz7OZqgCFIwlyci3dJ6V5lMZSdCh UCMgxSVPXGYLxAwU8YL4VE0ipL6UPf3tmPHQSjIptFHGjkvsMmHcd25ZSINlPhOxRKZF lpxuRG4Mxrt0iJevkQPHRqHY2mX0bVwxMaoMNIAckpH7n/Sn+Kuvoe40VLKfYjKI2mKB sE+g== X-Gm-Message-State: AJcUukdNRMqGKtn6K2njxgaYs4BCX1WhFhoaQVguFk+fkp6g5SGIPaZo Zx4TesU74I7DdaF0BBFBz+8pZRFlaRI= X-Received: by 2002:a62:104a:: with SMTP id y71mr12622147pfi.34.1548457039443; Fri, 25 Jan 2019 14:57:19 -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 c7sm39148321pfh.18.2019.01.25.14.57.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jan 2019 14:57:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 14:57:09 -0800 Message-Id: <20190125225714.10234-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190125225714.10234-1-richard.henderson@linaro.org> References: <20190125225714.10234-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 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) {