Re: [Xen-devel] [PATCH for-4.12 v2 11/17] xen/arm: p2m: Extend p2m_get_entry to return the value of bit[0] (valid bit)

2018-12-07 Thread Julien Grall

Hi Ravzan,

On 04/12/2018 20:35, Razvan Cojocaru wrote:

On 12/4/18 10:26 PM, Julien Grall wrote:

With the recent changes, a P2M entry may be populated but may as not
valid. In some situation, it would be useful to know whether the entry


I think you mean to say "may not be valid"?


Correct. I will fix it in the next version.




has been marked available to guest in order to perform a specific
action. So extend p2m_get_entry to return the value of bit[0] (valid bit).

Signed-off-by: Julien Grall 


Other than that,

Acked-by: Razvan Cojocaru 


Thank you for the review!

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH for-4.12 v2 11/17] xen/arm: p2m: Extend p2m_get_entry to return the value of bit[0] (valid bit)

2018-12-06 Thread Stefano Stabellini
On Tue, 4 Dec 2018, Razvan Cojocaru wrote:
> On 12/4/18 10:26 PM, Julien Grall wrote:
> > With the recent changes, a P2M entry may be populated but may as not
> > valid. In some situation, it would be useful to know whether the entry
> 
> I think you mean to say "may not be valid"?
> 
> > has been marked available to guest in order to perform a specific
> > action. So extend p2m_get_entry to return the value of bit[0] (valid bit).
> > 
> > Signed-off-by: Julien Grall 
> 
> Other than that,
> 
> Acked-by: Razvan Cojocaru 

Same here:

Reviewed-by: Stefano Stabellini 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH for-4.12 v2 11/17] xen/arm: p2m: Extend p2m_get_entry to return the value of bit[0] (valid bit)

2018-12-04 Thread Razvan Cojocaru
On 12/4/18 10:26 PM, Julien Grall wrote:
> With the recent changes, a P2M entry may be populated but may as not
> valid. In some situation, it would be useful to know whether the entry

I think you mean to say "may not be valid"?

> has been marked available to guest in order to perform a specific
> action. So extend p2m_get_entry to return the value of bit[0] (valid bit).
> 
> Signed-off-by: Julien Grall 

Other than that,

Acked-by: Razvan Cojocaru 


Thanks,
Razvan

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH for-4.12 v2 11/17] xen/arm: p2m: Extend p2m_get_entry to return the value of bit[0] (valid bit)

2018-12-04 Thread Julien Grall
With the recent changes, a P2M entry may be populated but may as not
valid. In some situation, it would be useful to know whether the entry
has been marked available to guest in order to perform a specific
action. So extend p2m_get_entry to return the value of bit[0] (valid bit).

Signed-off-by: Julien Grall 

---
Changes in v2:
- Don't use _valid
---
 xen/arch/arm/mem_access.c |  6 +++---
 xen/arch/arm/p2m.c| 18 ++
 xen/include/asm-arm/p2m.h |  3 ++-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
index f911937ccf..db49372a2c 100644
--- a/xen/arch/arm/mem_access.c
+++ b/xen/arch/arm/mem_access.c
@@ -71,7 +71,7 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn,
  * No setting was found in the Radix tree. Check if the
  * entry exists in the page-tables.
  */
-mfn_t mfn = p2m_get_entry(p2m, gfn, NULL, NULL, NULL);
+mfn_t mfn = p2m_get_entry(p2m, gfn, NULL, NULL, NULL, NULL);
 
 if ( mfn_eq(mfn, INVALID_MFN) )
 return -ESRCH;
@@ -200,7 +200,7 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned 
long flag,
  * We had a mem_access permission limiting the access, but the page type
  * could also be limiting, so we need to check that as well.
  */
-mfn = p2m_get_entry(p2m, gfn, , NULL, NULL);
+mfn = p2m_get_entry(p2m, gfn, , NULL, NULL, NULL);
 if ( mfn_eq(mfn, INVALID_MFN) )
 goto err;
 
@@ -406,7 +406,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, 
uint32_t nr,
   gfn = gfn_next_boundary(gfn, order) )
 {
 p2m_type_t t;
-mfn_t mfn = p2m_get_entry(p2m, gfn, , NULL, );
+mfn_t mfn = p2m_get_entry(p2m, gfn, , NULL, , NULL);
 
 
 if ( !mfn_eq(mfn, INVALID_MFN) )
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 4e0ddbf70b..c713226561 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -298,10 +298,14 @@ static int p2m_next_level(struct p2m_domain *p2m, bool 
read_only,
  *
  * If the entry is not present, INVALID_MFN will be returned and the
  * page_order will be set according to the order of the invalid range.
+ *
+ * valid will contain the value of bit[0] (e.g valid bit) of the
+ * entry.
  */
 mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn,
 p2m_type_t *t, p2m_access_t *a,
-unsigned int *page_order)
+unsigned int *page_order,
+bool *valid)
 {
 paddr_t addr = gfn_to_gaddr(gfn);
 unsigned int level = 0;
@@ -326,6 +330,9 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn,
 
 *t = p2m_invalid;
 
+if ( valid )
+*valid = false;
+
 /* XXX: Check if the mapping is lower than the mapped gfn */
 
 /* This gfn is higher than the highest the p2m map currently holds */
@@ -371,6 +378,9 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn,
  * to the GFN.
  */
 mfn = mfn_add(mfn, gfn_x(gfn) & ((1UL << level_orders[level]) - 1));
+
+if ( valid )
+*valid = lpae_is_valid(entry);
 }
 
 out_unmap:
@@ -389,7 +399,7 @@ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t)
 struct p2m_domain *p2m = p2m_get_hostp2m(d);
 
 p2m_read_lock(p2m);
-mfn = p2m_get_entry(p2m, gfn, t, NULL, NULL);
+mfn = p2m_get_entry(p2m, gfn, t, NULL, NULL, NULL);
 p2m_read_unlock(p2m);
 
 return mfn;
@@ -1471,7 +1481,7 @@ int relinquish_p2m_mapping(struct domain *d)
 for ( ; gfn_x(start) < gfn_x(end);
   start = gfn_next_boundary(start, order) )
 {
-mfn_t mfn = p2m_get_entry(p2m, start, , NULL, );
+mfn_t mfn = p2m_get_entry(p2m, start, , NULL, , NULL);
 
 count++;
 /*
@@ -1534,7 +1544,7 @@ int p2m_cache_flush_range(struct domain *d, gfn_t start, 
gfn_t end)
 
 for ( ; gfn_x(start) < gfn_x(end); start = next_gfn )
 {
-mfn_t mfn = p2m_get_entry(p2m, start, , NULL, );
+mfn_t mfn = p2m_get_entry(p2m, start, , NULL, , NULL);
 
 next_gfn = gfn_next_boundary(start, order);
 
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 5858f97e9c..7c1d930b1d 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -213,7 +213,8 @@ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t 
*t);
  */
 mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn,
 p2m_type_t *t, p2m_access_t *a,
-unsigned int *page_order);
+unsigned int *page_order,
+bool *valid);
 
 /*
  * Direct set a p2m entry: only for use by the P2M code.
-- 
2.11.0


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel