From patchwork Wed Oct 11 14:29:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9999785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5416602BF for ; Wed, 11 Oct 2017 14:31:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3A87289F7 for ; Wed, 11 Oct 2017 14:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A65C728A09; Wed, 11 Oct 2017 14:31:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5774828A04 for ; Wed, 11 Oct 2017 14:31:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2I0V-0006F0-1v; Wed, 11 Oct 2017 14:29:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2I0T-0006Eu-Iw for xen-devel@lists.xen.org; Wed, 11 Oct 2017 14:29:09 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 05/F9-31244-4BA2ED95; Wed, 11 Oct 2017 14:29:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRWlGSWpSXmKPExsVyMfTGZt0tWvc iDWaskrJY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDO+dlxiLNgoWPG5p4mlgfEibxcjF4eQwERG iYd7f7CAOCwC7cwS07a8YANxJATesUgcuXeSvYuRE8jJk/g6cRqQzQFkp0lcexEAEa6UWLzkH xtIWEhATWLNmyiIoT1MEntPvmcGibMJ6Eism1ELUi4iIC1x7fNlRhCbWaBA4tvlE8wgtrCAh8 Sylu1gm1gEVCX+rH/PAmLzClhLrF43hwVilbzErraLrBMY+RcwMqxiVC9OLSpLLdI10Usqykz PKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAweBiDYwdh92f8QoyQHk5Io7/XndyOF+JLy UyozEosz4otKc1KLDzHKcHAoSfAu0LwXKSRYlJqeWpGWmQMMY5i0BAePkgjvEpA0b3FBYm5xZ jpE6hSjJceFO5f+MHEc2HMLSHbcvPuHSYglLz8vVUqc9xRIgwBIQ0ZpHtw4WKxdYpSVEuZlBD pQiKcgtSg3swRV/hWjOAejkjBvM8gUnsy8Eritr4AOYgI6SDTtDshBJYkIKakGxkqPnbKBxYu k+QWlvHMt2TVEYv4bSu5XFuv/My/46MYGAX4rY609sRZdmYv3/Z+w2ZrF0vW55aE9H7ke5Ovv Ob/wUeCD08mWk+dMiDvi++mflhJ/my9b5eF1S5j0LS51L1geuj9W8VFkuq/qwgvMaw5FbTi9s 9DwR/bqmjTWfzOVjl6IMJqircRSnJFoqMVcVJwIAMdoi3+wAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-27.messagelabs.com!1507732147!106600426!1 X-Originating-IP: [209.85.216.179] 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 47730 invoked from network); 11 Oct 2017 14:29:08 -0000 Received: from mail-qt0-f179.google.com (HELO mail-qt0-f179.google.com) (209.85.216.179) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Oct 2017 14:29:08 -0000 Received: by mail-qt0-f179.google.com with SMTP id k31so5691341qta.6 for ; Wed, 11 Oct 2017 07:29:08 -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=MM1NtlrzuRqbq4WL6OLWTq0/nDp96BHSNccFn5dIsZk=; b=D0B5DaY6i9lSxw3/n4ymGqeQ7t2BiwJC2vr3iIdlfQQxm5bQ4SNnPG3X6f6p0yI3GK eISZG7o0CZvyUmIficx7bUkQvvFGsquK9NyG8/NVPsQwExCFjAv0BOK526YFA3plSghA kNemUOiH69TSrWDFOwA+WlHQ4L61qskB8zy6w= 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=MM1NtlrzuRqbq4WL6OLWTq0/nDp96BHSNccFn5dIsZk=; b=LkRijGSG29e6zgOpKvb1i5RC4mL5RzYU9feIB/9vynFCxkXsguvfmSM46CqWzLEznp EgUzLXSkTThYARSvyV80OQOPtewF175ENGhU0GTz78bok9sI1qGe+nvGdgGN9Ist+63i 07yiQSxmAqnk7eRPPjDPUq1pHccrD5Bi6HLxo08q48WYZZZMtLrBepGkjAdbBTK9vae2 O64meaBVqo6jRfybcpUKTJKBaoaF5NQuI9t6Lzg9Ad3G73cjQUM4Xhfq4RoFlGULjJod NHmuB1ChzJ3IVGewpi7fvYvdrUFcc3rJVTwligRAUMvVSq2hZWpZBDcRwj85QTPV4sZg ZJNQ== X-Gm-Message-State: AMCzsaUP4uafCQskKWOntLBpIgnJO8SA07ktydGKv2VJnVO/UujOcqKq O78PJqZiV+ywjEqx7Y6toYZ+1fy3wFk= X-Google-Smtp-Source: AOwi7QD20CeBWTHvUVpX/x03gho9VwLbW4N7tlQwC/qRaboOIGdqpEBUJNHQItFuopOnAr25Cww9Cg== X-Received: by 10.200.4.37 with SMTP id v37mr14774951qtg.313.1507732147249; Wed, 11 Oct 2017 07:29:07 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id g7sm5420460qkf.72.2017.10.11.07.29.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Oct 2017 07:29:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 11 Oct 2017 15:29:02 +0100 Message-Id: <20171011142902.5332-1-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 Cc: Sergej Proskurin , sstabellini@kernel.org, Julien Grall Subject: [Xen-devel] [PATCHv2 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" X-Virus-Scanned: ClamAV using ClamSMTP 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. Note that the IPS code is now surrounded with #ifdef CONFIG_ARM_64 because the Arm32 compiler will complain of shift bigger than the width of the variable. This is fine as the code is executed for 64-bit domain only. Coverity-ID: 1457707 Signed-off-by: Julien Grall Reviewed-by: Sergej Proskurin --- Cc: Sergej Proskurin Changes in v2: - Fix compilation on Arm32 --- xen/arch/arm/guest_walk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c index c38bedcf65..4d1ea0cdc1 100644 --- a/xen/arch/arm/guest_walk.c +++ b/xen/arch/arm/guest_walk.c @@ -185,7 +185,8 @@ 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; +#ifdef CONFIG_ARM_64 + register_t ips; static const unsigned int ipa_sizes[7] = { TCR_EL1_IPS_32_BIT_VAL, @@ -200,7 +201,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,9 +212,10 @@ 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 +#endif *output_size = TCR_EL1_IPS_40_BIT_VAL; return 0;