From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, Julien Grall <julien.grall@linaro.org>
Subject: [PATCH for-4.10 1/2] xen/arm: mm: Change the return value of gvirt_to_maddr
Date: Wed, 15 Nov 2017 19:34:13 +0000 [thread overview]
Message-ID: <20171115193414.7678-2-julien.grall@linaro.org> (raw)
In-Reply-To: <20171115193414.7678-1-julien.grall@linaro.org>
Currently, gvirt_to_maddr return -EFAULT when the translation failed.
It might be useful to return the PAR_EL1 (Physical Address Register)
in such a case to get a better idea of the reason.
So modify the return value to use 0 on sucess or return the PAR on
failure.
The callers are modified to reflect the change of the return value.
Note that with the change in gvirt_to_maddr, ma needs to be initialized
to avoid GCC been confused (i.e value may be unitialized) with the new
construction.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
xen/arch/arm/domain_build.c | 8 ++++----
xen/arch/arm/kernel.c | 8 ++++----
xen/arch/arm/p2m.c | 6 +++---
xen/include/asm-arm/mm.h | 9 +++++++--
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index bf29299707..c74f4dd69d 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2002,15 +2002,15 @@ static void initrd_load(struct kernel_info *kinfo)
for ( offs = 0; offs < len; )
{
- int rc;
- paddr_t s, l, ma;
+ uint64_t par;
+ paddr_t s, l, ma = 0;
void *dst;
s = offs & ~PAGE_MASK;
l = min(PAGE_SIZE - s, len);
- rc = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE);
- if ( rc )
+ par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE);
+ if ( par )
{
panic("Unable to translate guest address");
return;
diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index c2755a9ab9..a6c6413712 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -167,15 +167,15 @@ static void kernel_zimage_load(struct kernel_info *info)
paddr, load_addr, load_addr + len);
for ( offs = 0; offs < len; )
{
- int rc;
- paddr_t s, l, ma;
+ uint64_t par;
+ paddr_t s, l, ma = 0;
void *dst;
s = offs & ~PAGE_MASK;
l = min(PAGE_SIZE - s, len);
- rc = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE);
- if ( rc )
+ par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE);
+ if ( par )
{
panic("Unable to map translate guest address");
return;
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 68b488997d..f6b3d8e421 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1414,7 +1414,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
struct p2m_domain *p2m = p2m_get_hostp2m(d);
struct page_info *page = NULL;
paddr_t maddr = 0;
- int rc;
+ uint64_t par;
/*
* XXX: To support a different vCPU, we would need to load the
@@ -1425,9 +1425,9 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
p2m_read_lock(p2m);
- rc = gvirt_to_maddr(va, &maddr, flags);
+ par = gvirt_to_maddr(va, &maddr, flags);
- if ( rc )
+ if ( par )
goto err;
if ( !mfn_valid(maddr_to_mfn(maddr)) )
diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index cd6dfb54b9..ad2f2a43dc 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -266,11 +266,16 @@ static inline void *maddr_to_virt(paddr_t ma)
}
#endif
-static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags)
+/*
+ * Translate a guest virtual address to a machine address.
+ * Return the fault information if the translation has failed else 0.
+ */
+static inline uint64_t gvirt_to_maddr(vaddr_t va, paddr_t *pa,
+ unsigned int flags)
{
uint64_t par = gva_to_ma_par(va, flags);
if ( par & PAR_F )
- return -EFAULT;
+ return par;
*pa = (par & PADDR_MASK & PAGE_MASK) | ((unsigned long) va & ~PAGE_MASK);
return 0;
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-11-15 19:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 19:34 [PATCH for-4.10 0/2] xen/arm: Add more debug in get_page_from_gva Julien Grall
2017-11-15 19:34 ` Julien Grall [this message]
2017-11-16 1:35 ` [PATCH for-4.10 1/2] xen/arm: mm: Change the return value of gvirt_to_maddr Stefano Stabellini
2017-11-15 19:34 ` [PATCH for-4.10 2/2] xen/arm: p2m: Add more debug in get_page_from_gva Julien Grall
2017-11-15 19:43 ` Andrew Cooper
2017-11-15 21:42 ` Julien Grall
2017-11-16 1:36 ` Stefano Stabellini
2017-11-16 8:50 ` Julien Grall
2017-11-16 19:00 ` 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=20171115193414.7678-2-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--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).