[Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Julien Grall posted 14 patches 31 weeks ago

[Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Julien Grall 31 weeks ago
At the moment, Arm is providing a dummy implementation for the M2P
helpers used in common code. However, they are quite isolated and could
be used by other architecture in the future. So move all the helpers in
xen/mm.h.

Signed-off-by: Julien Grall <julien.grall@arm.com>

---
    Changes in v2:
        - Patch added
---
 xen/include/asm-arm/mm.h | 11 -----------
 xen/include/xen/mm.h     | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index 3c03be3bca..d68d1794e5 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -313,17 +313,6 @@ static inline void *page_to_virt(const struct page_info *pg)
 struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
                                     unsigned long flags);
 
-/*
- * Arm does not have an M2P, but common code expects a handful of
- * M2P-related defines and functions. Provide dummy versions of these.
- */
-#define INVALID_M2P_ENTRY        (~0UL)
-#define SHARED_M2P_ENTRY         (~0UL - 1UL)
-#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
-
-/* We don't have a M2P on Arm */
-static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
-
 /* Arch-specific portion of memory_op hypercall. */
 long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg);
 
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3ba7168cc9..07d2d44491 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
     share_xen_page_with_guest(page, dom_xen, flags);
 }
 
+/*
+ * Dummy implementation of M2P-related helpers for common code when
+ * the architecture doesn't have an M2P.
+ */
+#ifndef CONFIG_HAS_M2P
+
+#define INVALID_M2P_ENTRY        (~0UL)
+#define SHARED_M2P_ENTRY         (~0UL - 1UL)
+#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
+
+static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
+
+#endif
+
 #endif /* __XEN_MM_H__ */
-- 
2.11.0


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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by George Dunlap 29 weeks ago
On 5/7/19 4:14 PM, Julien Grall wrote:
> At the moment, Arm is providing a dummy implementation for the M2P
> helpers used in common code. However, they are quite isolated and could
> be used by other architecture in the future. So move all the helpers in
> xen/mm.h.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Acked-by: George Dunlap <george.dunlap@citrix.com>

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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Jan Beulich 31 weeks ago
>>> On 07.05.19 at 17:14, <julien.grall@arm.com> wrote:
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
>      share_xen_page_with_guest(page, dom_xen, flags);
>  }
>  
> +/*
> + * Dummy implementation of M2P-related helpers for common code when
> + * the architecture doesn't have an M2P.
> + */
> +#ifndef CONFIG_HAS_M2P
> +
> +#define INVALID_M2P_ENTRY        (~0UL)
> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
> +
> +static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
> +
> +#endif

In order for things to not be scattered around, could
domain_shared_info_gfn() (see patch 9) move here? It doesn't
look as if this would cause a build issue.

Jan



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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Julien Grall 31 weeks ago

On 10/05/2019 14:28, Jan Beulich wrote:
>>>> On 07.05.19 at 17:14, <julien.grall@arm.com> wrote:
>> --- a/xen/include/xen/mm.h
>> +++ b/xen/include/xen/mm.h
>> @@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
>>       share_xen_page_with_guest(page, dom_xen, flags);
>>   }
>>   
>> +/*
>> + * Dummy implementation of M2P-related helpers for common code when
>> + * the architecture doesn't have an M2P.
>> + */
>> +#ifndef CONFIG_HAS_M2P
>> +
>> +#define INVALID_M2P_ENTRY        (~0UL)
>> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
>> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
>> +
>> +static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
>> +
>> +#endif
> 
> In order for things to not be scattered around, could
> domain_shared_info_gfn() (see patch 9) move here? It doesn't
> look as if this would cause a build issue.

The two are different, one deal with memory, the other with a domain. So the 
current split makes sense.

Cheers,

-- 
Julien Grall

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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Jan Beulich 31 weeks ago
>>> On 10.05.19 at 15:29, <julien.grall@arm.com> wrote:
> On 10/05/2019 14:28, Jan Beulich wrote:
>>>>> On 07.05.19 at 17:14, <julien.grall@arm.com> wrote:
>>> --- a/xen/include/xen/mm.h
>>> +++ b/xen/include/xen/mm.h
>>> @@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
>>>       share_xen_page_with_guest(page, dom_xen, flags);
>>>   }
>>>   
>>> +/*
>>> + * Dummy implementation of M2P-related helpers for common code when
>>> + * the architecture doesn't have an M2P.
>>> + */
>>> +#ifndef CONFIG_HAS_M2P
>>> +
>>> +#define INVALID_M2P_ENTRY        (~0UL)
>>> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
>>> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
>>> +
>>> +static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
>>> +
>>> +#endif
>> 
>> In order for things to not be scattered around, could
>> domain_shared_info_gfn() (see patch 9) move here? It doesn't
>> look as if this would cause a build issue.
> 
> The two are different, one deal with memory, the other with a domain. So the 
> current split makes sense.

Well, that's one perspective to take. The other is that it's mm to obtain
a specific other form of a given address.

Jan



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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Julien Grall 31 weeks ago

On 10/05/2019 14:37, Jan Beulich wrote:
>>>> On 10.05.19 at 15:29, <julien.grall@arm.com> wrote:
>> On 10/05/2019 14:28, Jan Beulich wrote:
>>>>>> On 07.05.19 at 17:14, <julien.grall@arm.com> wrote:
>>>> --- a/xen/include/xen/mm.h
>>>> +++ b/xen/include/xen/mm.h
>>>> @@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
>>>>        share_xen_page_with_guest(page, dom_xen, flags);
>>>>    }
>>>>    
>>>> +/*
>>>> + * Dummy implementation of M2P-related helpers for common code when
>>>> + * the architecture doesn't have an M2P.
>>>> + */
>>>> +#ifndef CONFIG_HAS_M2P
>>>> +
>>>> +#define INVALID_M2P_ENTRY        (~0UL)
>>>> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
>>>> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
>>>> +
>>>> +static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
>>>> +
>>>> +#endif
>>>
>>> In order for things to not be scattered around, could
>>> domain_shared_info_gfn() (see patch 9) move here? It doesn't
>>> look as if this would cause a build issue.
>>
>> The two are different, one deal with memory, the other with a domain. So the
>> current split makes sense.
> 
> Well, that's one perspective to take. The other is that it's mm to obtain
> a specific other form of a given address.
It is just an implementation detail. If I follow your view, we would have a 
single header for everything under the same #ifdef...

Cheers,

-- 
Julien Grall

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

Re: [Xen-devel] [PATCH 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P

Posted by Stefano Stabellini 31 weeks ago
On Tue, 7 May 2019, Julien Grall wrote:
> At the moment, Arm is providing a dummy implementation for the M2P
> helpers used in common code. However, they are quite isolated and could
> be used by other architecture in the future. So move all the helpers in
> xen/mm.h.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>     Changes in v2:
>         - Patch added
> ---
>  xen/include/asm-arm/mm.h | 11 -----------
>  xen/include/xen/mm.h     | 14 ++++++++++++++
>  2 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
> index 3c03be3bca..d68d1794e5 100644
> --- a/xen/include/asm-arm/mm.h
> +++ b/xen/include/asm-arm/mm.h
> @@ -313,17 +313,6 @@ static inline void *page_to_virt(const struct page_info *pg)
>  struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
>                                      unsigned long flags);
>  
> -/*
> - * Arm does not have an M2P, but common code expects a handful of
> - * M2P-related defines and functions. Provide dummy versions of these.
> - */
> -#define INVALID_M2P_ENTRY        (~0UL)
> -#define SHARED_M2P_ENTRY         (~0UL - 1UL)
> -#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
> -
> -/* We don't have a M2P on Arm */
> -static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
> -
>  /* Arch-specific portion of memory_op hypercall. */
>  long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg);
>  
> diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
> index 3ba7168cc9..07d2d44491 100644
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -658,4 +658,18 @@ static inline void share_xen_page_with_privileged_guests(
>      share_xen_page_with_guest(page, dom_xen, flags);
>  }
>  
> +/*
> + * Dummy implementation of M2P-related helpers for common code when
> + * the architecture doesn't have an M2P.
> + */
> +#ifndef CONFIG_HAS_M2P
> +
> +#define INVALID_M2P_ENTRY        (~0UL)
> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
> +
> +static inline void set_pfn_from_mfn(mfn_t mfn, unsigned long pfn) {}
> +
> +#endif
> +
>  #endif /* __XEN_MM_H__ */
> -- 
> 2.11.0
> 

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