From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: Sergej Proskurin <proskurin@sec.in.tum.de>,
sstabellini@kernel.org, Julien Grall <julien.grall@linaro.org>
Subject: [PATCHv2 for-4.10] xen/arm: guest_walk: Fix check again the IPS
Date: Wed, 11 Oct 2017 15:29:02 +0100 [thread overview]
Message-ID: <20171011142902.5332-1-julien.grall@linaro.org> (raw)
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 <julien.grall@linaro.org>
---
Cc: Sergej Proskurin <proskurin@sec.in.tum.de>
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;
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2017-10-11 14:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 14:29 Julien Grall [this message]
2017-10-11 14:51 ` [PATCHv2 for-4.10] xen/arm: guest_walk: Fix check again the IPS Sergej Proskurin
2017-10-11 14:57 ` Julien Grall
2017-10-11 18:02 ` Sergej Proskurin
2017-10-11 18:47 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171011142902.5332-1-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=proskurin@sec.in.tum.de \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).