From patchwork Tue Oct 10 15:20:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 115415 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3879312qgn; Tue, 10 Oct 2017 08:22:51 -0700 (PDT) X-Received: by 10.36.138.133 with SMTP id v127mr19777683itd.151.1507648971926; Tue, 10 Oct 2017 08:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507648971; cv=none; d=google.com; s=arc-20160816; b=PnhsJYGe0BoknlQEg+KT0h+CBArb11VLbywW7nV5LwH6Sk2C7bH75NTwCUjNFBQu90 +d2lkJaiezuINbys+Ylw9pERyC5tEZZwawZQpfT9MINSD8CLI/nt23OgleuaODV6/HjG G/9Reimv8wI68BI2XBbQ/CgpmINpB7mt6eTuvctsXsuyi57pfyhV8P5sjaxzk+1sK/pC TKkNBCve+cUglRpwzQ4MG2/ttUd0l7uRMXU3sgRRYHn8uUL6ZkTeyw5J5+IM5ijxHPA8 XjvxyeH8G2gF8CL+BC2p0eZds1hsY91d+qpMTmX0962PfbxAgWJFu4NDQXmvl1X8++X7 gk+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=Xxev5wMz4UfjG/wFXqgJB2BGitw4xlL1BZDWhutr69U=; b=HGJIiTNpsXGHdRo/ATSNlbQERviHJbFUhV/yZneDTap5Sg1hp/ssB7IexwkEy1E6Df GuMEyl2pRkT2uUFDDkQjfGsGQo3i+xxvoW7TD60pInnpXFHMYj0lz47LKtKD+YCRSEDH WJKaaXW66KWLk8mSnbzEv6Zy5v73nWWkjGhsrdHhZ/76v1fDPN5FNGeRN3/tHjuUqMth gmUSFQU12N2dqvdWfsWpXnXeDWCiG28vJITgr7qV2FyJ7dKVEXBxFlIlQcy8i/sA6Wuw FZNBbwEQok6NJ8wq3KqrsWwWmehHahK4Yd6iVtOUqIpsqug7G+2n2wfqvGsLoSL8rWIB 4Wag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cgKAUDLi; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k85si9361359ita.89.2017.10.10.08.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 08:22:51 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cgKAUDLi; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1wKr-0000E5-Cr; Tue, 10 Oct 2017 15:20:45 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1wKq-0000Dr-3E for xen-devel@lists.xen.org; Tue, 10 Oct 2017 15:20:44 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 33/5C-23363-B45ECD95; Tue, 10 Oct 2017 15:20:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRWlGSWpSXmKPExsVyMfTGSl33p3c iDT51Wlgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlzLi5iKXjHV3Hv2QLmBsZr3F2MXBxCApMY JQ5N62XsYuTkYBFoZ5aYdcwOJCEh8I5F4tiMWSwgCQmBPImZDx8xQthpEq8/TWWDsCslVq+/w drFyAE0SU1izZsoiKG9TBLfL3xjBomzCehIrJtRC1IuIiAtce3zZUaQGmaBTkaJOW+aweYLC7 hJ/N4/jxniCFWJw0+OgM3nFbCWmPLiCdQueYldbRdZJzDyL2BkWMWoUZxaVJZapGtkoJdUlJm eUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERhA9QwMjDsYm0/4HWKU5GBSEuUtvn0nUogv KT+lMiOxOCO+qDQntfgQowwHh5IEr9kToJxgUWp6akVaZg4wlGHSEhw8SiK8/CBp3uKCxNziz HSI1ClGS44Ldy79YeI4sOcWkOy4efcPkxBLXn5eqpQ4rx1IgwBIQ0ZpHtw4WLxdYpSVEuZlZG BgEOIpSC3KzSxBlX/FKM7BqCTMqwIyhSczrwRu6yugg5iADhJNAzuoJBEhJdXAmMpwrf2gZcK xJduMf6wOmuHhm/m+30Ev0GBq9URLi6OvWqYYXZfilQr5cmTGgQMHdu7YsUTe48KK7Qve83+y M5vBVupSodXb/qDyVHkt+4GXZ039lzAE9Vcfv5W2/u7ytT05DszWrjPurGHcwHqRJSPqy7G8z XUHLmx5HH1P/PK5babbDdljpymxFGckGmoxFxUnAgBYvM0XsgIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1507648839!78760890!1 X-Originating-IP: [209.85.216.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33535 invoked from network); 10 Oct 2017 15:20:39 -0000 Received: from mail-qt0-f169.google.com (HELO mail-qt0-f169.google.com) (209.85.216.169) by server-11.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Oct 2017 15:20:39 -0000 Received: by mail-qt0-f169.google.com with SMTP id f15so52333972qtf.7 for ; Tue, 10 Oct 2017 08:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=sm1fKDmcep0uVhQRGimzeqJVCxDkfrNLmUhbzxP1OFg=; b=cgKAUDLifxOrj/C3hcgPvYXbWjjywTr9slNZC4cC0ot57N6G20xmUioPi+ZlWo87jF Pj3Zk+NO5JkR1+1yIdG3e8Z3EmheYc4029qkyenuQ/W2epzEoFYlhLzLDRCAZ4Zv5iwZ GcKIYJ/vLrJPSTP9YNdNaaKsfRRpsn5L93hNQ= 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=sm1fKDmcep0uVhQRGimzeqJVCxDkfrNLmUhbzxP1OFg=; b=hPe6q2lmAv5Js2b0s48JO3DNCTXkzX8XJnT1uYtsExXvgSooslyst7Izktxk/iX1qm SkRjKH0BA+8o+loxQ45Y/MXGw3t6HaiPtrgMULZrQVUDDGNpBv3+upqrGjvDqJyckgy3 8/pkvfZAgle/K2wMyhv1Nn45pFc/hhYScg9eLhNQjVC1OvoA7eWBw6IBMJAvgUjRoTMD 0uB6t2znM/j0FhCL54FdpAqDPmW2oRrj/vdLfehv0TQR1M+SkBz1eDDjTKXtQecEawMF 5ygndA/ZkYJGnMLvMo+9aVQWBBEMrrUD+xSMkPwOXH9MPMTlTjDA/kzu04+lekqkwuti KYTg== X-Gm-Message-State: AMCzsaWQjC9aDtNGRkMfUcaOeYZhswrIqE1yYLdVCaU2TYaF8Mx7pNGp +C6w7nqAqBLBH1ZCn0r0RYnhI33I/9c= X-Google-Smtp-Source: AOwi7QBBsYp0/mpErzthtQoWD561FL5eNGHPyDiJgstSnrCK2h6i7zWaZlgFYvOctO9q/VfmpyRqjQ== X-Received: by 10.200.39.179 with SMTP id w48mr838149qtw.314.1507648838508; Tue, 10 Oct 2017 08:20:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id q82sm6466143qki.34.2017.10.10.08.20.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 08:20:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 10 Oct 2017 16:20:34 +0100 Message-Id: <20171010152034.6388-1-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 Cc: andre.przywara@arm.com, sstabellini@kernel.org, Julien Grall , Sergej Proskurin Subject: [Xen-devel] [PATCH FOR-4.10] xen/arm: guest_walk: Fix check again the IPS X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The function get_ipa_output_size is check whether the input size configured by the guest is valid and will return it. The check is done with the IPS already shifted against TCR_EL1_IPS_48_BIT. However the constant has been defined with the shift included, resulting the check always been false. Fix it by doing the check on the non-shifted value. This was introduced by commit 7d623b358a "arm/mem_access: Add long-descriptor based gpt" introduced software page-table walk for stage-1. Coverity-ID: 1457707 Signed-off-by: Julien Grall Acked-by: Sergej Proskurin --- Cc: Sergej Proskurin --- xen/arch/arm/guest_walk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c index c38bedcf65..a6de325572 100644 --- a/xen/arch/arm/guest_walk.c +++ b/xen/arch/arm/guest_walk.c @@ -185,7 +185,7 @@ static int guest_walk_sd(const struct vcpu *v, static int get_ipa_output_size(struct domain *d, register_t tcr, unsigned int *output_size) { - unsigned int ips; + register_t ips; static const unsigned int ipa_sizes[7] = { TCR_EL1_IPS_32_BIT_VAL, @@ -200,7 +200,7 @@ static int get_ipa_output_size(struct domain *d, register_t tcr, if ( is_64bit_domain(d) ) { /* Get the intermediate physical address size. */ - ips = (tcr & TCR_EL1_IPS_MASK) >> TCR_EL1_IPS_SHIFT; + ips = tcr & TCR_EL1_IPS_MASK; /* * Return an error on reserved IPA output-sizes and if the IPA @@ -211,7 +211,7 @@ static int get_ipa_output_size(struct domain *d, register_t tcr, if ( ips > TCR_EL1_IPS_48_BIT ) return -EFAULT; - *output_size = ipa_sizes[ips]; + *output_size = ipa_sizes[ips >> TCR_EL1_IPS_SHIFT]; } else *output_size = TCR_EL1_IPS_40_BIT_VAL;