xen/arm: mm: Change the return value of gvirt_to_maddr

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 success 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 uninitialized) with the new
construction.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Julien Grall authored and Stefano Stabellini committed 2017-11-15 17:35:49 -08:00
1 parent b9ee1fd7b9
commit 17a33f943e
4 files changed
+18 -13

No files matched your search

+4 -4
View File
@@ -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;
+4 -4
View File
@@ -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;
+3 -3
View File
@@ -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)) )
+7 -2
View File
@@ -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;
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.