diff mbox series

[v3,2/3] x86/mm: Introduce altp2m_set_entry_by_page_order

Message ID 20190409120324.13940-2-aisaila@bitdefender.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/3] x86/mm: Introduce altp2m_get_gfn_type_access | expand

Commit Message

Alexandru Stefan ISAILA April 9, 2019, 12:03 p.m. UTC
This patch moves common code from p2m_set_altp2m_mem_access() and
p2m_change_altp2m_gfn() into one function

Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
---
 xen/arch/x86/mm/mem_access.c |  2 +-
 xen/include/asm-x86/p2m.h    | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Tamas K Lengyel April 9, 2019, 1:44 p.m. UTC | #1
On Tue, Apr 9, 2019 at 6:04 AM Alexandru Stefan ISAILA
<aisaila@bitdefender.com> wrote:
>
> This patch moves common code from p2m_set_altp2m_mem_access() and
> p2m_change_altp2m_gfn() into one function
>
> Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
> ---
>  xen/arch/x86/mm/mem_access.c |  2 +-
>  xen/include/asm-x86/p2m.h    | 11 +++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index bf67ddb15a..6a22512555 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -279,7 +279,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>          gfn_t gfn2 = _gfn(gfn_l & mask);
>          mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
>
> -        /* Note: currently it is not safe to remap to a shared entry */
> +       /* Note: currently it is not safe to remap to a shared entry */

This looks like an unrelated change. And I guess this comment should
also be fixed as this is the mem_access setting function, not the
remap function.

>          if ( t != p2m_ram_rw )
>              return -ESRCH;
>
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> index 6de1546d76..90a6c135a7 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -467,6 +467,17 @@ static inline mfn_t altp2m_get_gfn_type_access(
>      return mfn;
>  }
>
> +static inline int altp2m_set_entry_by_page_order(
> +    struct p2m_domain *ap2m, unsigned long gfn,  mfn_t mfn,
> +    unsigned int page_order, p2m_type_t t, p2m_access_t a)
> +{
> +    unsigned long mask = ~((1UL << page_order) - 1);
> +    gfn_t gfn2 = _gfn(gfn & mask);
> +    mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
> +
> +    return ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t, a, 1);
> +}
> +
>  /* Syntactic sugar: most callers will use one of these. */
>  #define get_gfn(d, g, t)         get_gfn_type((d), (g), (t), P2M_ALLOC)
>  #define get_gfn_query(d, g, t)   get_gfn_type((d), (g), (t), 0)
> --
> 2.17.1
>
George Dunlap April 10, 2019, 2:18 p.m. UTC | #2
On 4/9/19 1:03 PM, Alexandru Stefan ISAILA wrote:
> This patch moves common code from p2m_set_altp2m_mem_access() and
> p2m_change_altp2m_gfn() into one function
> 
> Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
> ---
>  xen/arch/x86/mm/mem_access.c |  2 +-
>  xen/include/asm-x86/p2m.h    | 11 +++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index bf67ddb15a..6a22512555 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -279,7 +279,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>          gfn_t gfn2 = _gfn(gfn_l & mask);
>          mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
>  
> -        /* Note: currently it is not safe to remap to a shared entry */
> +	/* Note: currently it is not safe to remap to a shared entry */
>          if ( t != p2m_ram_rw )
>              return -ESRCH;
>  
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> index 6de1546d76..90a6c135a7 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -467,6 +467,17 @@ static inline mfn_t altp2m_get_gfn_type_access(
>      return mfn;
>  }
>  
> +static inline int altp2m_set_entry_by_page_order(
> +    struct p2m_domain *ap2m, unsigned long gfn,  mfn_t mfn,
> +    unsigned int page_order, p2m_type_t t, p2m_access_t a)

This function doesn't seem to be called anywhere in this series.

 -George
Alexandru Stefan ISAILA April 10, 2019, 2:22 p.m. UTC | #3
On 10.04.2019 17:18, George Dunlap wrote:
> On 4/9/19 1:03 PM, Alexandru Stefan ISAILA wrote:
>> This patch moves common code from p2m_set_altp2m_mem_access() and
>> p2m_change_altp2m_gfn() into one function
>>
>> Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
>> ---
>>   xen/arch/x86/mm/mem_access.c |  2 +-
>>   xen/include/asm-x86/p2m.h    | 11 +++++++++++
>>   2 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
>> index bf67ddb15a..6a22512555 100644
>> --- a/xen/arch/x86/mm/mem_access.c
>> +++ b/xen/arch/x86/mm/mem_access.c
>> @@ -279,7 +279,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>>           gfn_t gfn2 = _gfn(gfn_l & mask);
>>           mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
>>   
>> -        /* Note: currently it is not safe to remap to a shared entry */
>> +	/* Note: currently it is not safe to remap to a shared entry */
>>           if ( t != p2m_ram_rw )
>>               return -ESRCH;
>>   
>> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
>> index 6de1546d76..90a6c135a7 100644
>> --- a/xen/include/asm-x86/p2m.h
>> +++ b/xen/include/asm-x86/p2m.h
>> @@ -467,6 +467,17 @@ static inline mfn_t altp2m_get_gfn_type_access(
>>       return mfn;
>>   }
>>   
>> +static inline int altp2m_set_entry_by_page_order(
>> +    struct p2m_domain *ap2m, unsigned long gfn,  mfn_t mfn,
>> +    unsigned int page_order, p2m_type_t t, p2m_access_t a)
> 
> This function doesn't seem to be called anywhere in this series.

Yes I saw that yesterday after sending the patch. The call got lost in 
the  re-base/merge process. Sorry about that, it will go on again in v4

Alex
Jan Beulich May 2, 2019, 2:46 p.m. UTC | #4
>>> On 09.04.19 at 14:03, <aisaila@bitdefender.com> wrote:
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -279,7 +279,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
>          gfn_t gfn2 = _gfn(gfn_l & mask);
>          mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
>  
> -        /* Note: currently it is not safe to remap to a shared entry */
> +	/* Note: currently it is not safe to remap to a shared entry */

Stray and bad (hard tab) change. But you've been meaning
to re-send this anyway.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index bf67ddb15a..6a22512555 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -279,7 +279,7 @@  int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
         gfn_t gfn2 = _gfn(gfn_l & mask);
         mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
 
-        /* Note: currently it is not safe to remap to a shared entry */
+	/* Note: currently it is not safe to remap to a shared entry */
         if ( t != p2m_ram_rw )
             return -ESRCH;
 
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 6de1546d76..90a6c135a7 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -467,6 +467,17 @@  static inline mfn_t altp2m_get_gfn_type_access(
     return mfn;
 }
 
+static inline int altp2m_set_entry_by_page_order(
+    struct p2m_domain *ap2m, unsigned long gfn,  mfn_t mfn,
+    unsigned int page_order, p2m_type_t t, p2m_access_t a)
+{
+    unsigned long mask = ~((1UL << page_order) - 1);
+    gfn_t gfn2 = _gfn(gfn & mask);
+    mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
+
+    return ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t, a, 1);
+}
+
 /* Syntactic sugar: most callers will use one of these. */
 #define get_gfn(d, g, t)         get_gfn_type((d), (g), (t), P2M_ALLOC)
 #define get_gfn_query(d, g, t)   get_gfn_type((d), (g), (t), 0)