diff mbox series

[Xen-devel,v5,04/16] xen/arm: mm: Remove unused M2P code

Message ID 20180314182009.14274-5-julien.grall@arm.com
State Superseded
Headers show
Series xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN | expand

Commit Message

Julien Grall March 14, 2018, 6:19 p.m. UTC
From: Julien Grall <julien.grall@arm.com>

Arm does not have an M2P and very unlikely to get one in the future,
therefore don't keep defines that are not necessary in the common code.

At the same time move the remaining M2P define just above just above
set_gpfn_from_mfn to keep all the dummy helpers for M2P together.

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

---

Cc: Stefano Stabellini <sstabellini@kernel.org>

    Changes in v4:
        - Patch added.
---
 xen/include/asm-arm/mm.h | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

Comments

Alan Robinson March 15, 2018, 7:20 a.m. UTC | #1
Hi Julien,

> At the same time move the remaining M2P define just above just above
> set_gpfn_from_mfn to keep all the dummy helpers for M2P together.

  At the same time move the remaining M2P define just above
  set_gpfn_from_mfn to keep all the dummy helpers for M2P together.

can't really evaluate the actual code..

Alan
George Dunlap March 15, 2018, 4:25 p.m. UTC | #2
On Wed, Mar 14, 2018 at 6:19 PM,  <julien.grall@arm.com> wrote:
> From: Julien Grall <julien.grall@arm.com>
>
> Arm does not have an M2P and very unlikely to get one in the future,
> therefore don't keep defines that are not necessary in the common code.
>
> At the same time move the remaining M2P define just above just above
> set_gpfn_from_mfn to keep all the dummy helpers for M2P together.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
>
> ---
>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
>
>     Changes in v4:
>         - Patch added.
> ---
>  xen/include/asm-arm/mm.h | 25 ++++---------------------
>  1 file changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
> index 4d5563b0ce..c03f4ad674 100644
> --- a/xen/include/asm-arm/mm.h
> +++ b/xen/include/asm-arm/mm.h
> @@ -320,33 +320,16 @@ 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);
>
> -/*
> - * The MPT (machine->physical mapping table) is an array of word-sized
> - * values, indexed on machine frame number. It is expected that guest OSes
> - * will use it to store a "physical" frame number to give the appearance of
> - * contiguous (or near contiguous) physical memory.
> - */
> -#undef  machine_to_phys_mapping
> -#define machine_to_phys_mapping  ((unsigned long *)RDWR_MPT_VIRT_START)
> -#define INVALID_M2P_ENTRY        (~0UL)
> -#define VALID_M2P(_e)            (!((_e) & (1UL<<(BITS_PER_LONG-1))))
> -#define SHARED_M2P_ENTRY         (~0UL - 1UL)
> -#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
> -
> -#define _set_gpfn_from_mfn(mfn, pfn) ({                        \
> -    struct domain *d = page_get_owner(__mfn_to_page(mfn));     \
> -    if(d && (d == dom_cow))                                    \
> -        machine_to_phys_mapping[(mfn)] = SHARED_M2P_ENTRY;     \
> -    else                                                       \
> -        machine_to_phys_mapping[(mfn)] = (pfn);                \
> -    })
> -
>  static inline void put_gfn(struct domain *d, unsigned long gfn) {}
>  static inline int relinquish_shared_pages(struct domain *d)
>  {
>      return 0;
>  }
>
> +#define INVALID_M2P_ENTRY        (~0UL)
> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)

I think I might add a comment here like this:

"ARM doesn't have an M2P, but common code expects a handful of
M2P-related defines and functions.  Provide dummy versions of these."

Other than that looks good:

Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Julien Grall March 20, 2018, 8:34 a.m. UTC | #3
On 03/15/2018 07:20 AM, Alan Robinson wrote:
> Hi Julien,

Hi Alan,

>> At the same time move the remaining M2P define just above just above
>> set_gpfn_from_mfn to keep all the dummy helpers for M2P together.
> 
>    At the same time move the remaining M2P define just above
>    set_gpfn_from_mfn to keep all the dummy helpers for M2P together.

Thank you for looking at the patch. I will update the commit message on 
the next version.

Cheers,
Julien Grall March 20, 2018, 9:09 a.m. UTC | #4
Hi George,

On 03/15/2018 04:25 PM, George Dunlap wrote:
> On Wed, Mar 14, 2018 at 6:19 PM,  <julien.grall@arm.com> wrote:
>> From: Julien Grall <julien.grall@arm.com>
>>
>> Arm does not have an M2P and very unlikely to get one in the future,
>> therefore don't keep defines that are not necessary in the common code.
>>
>> At the same time move the remaining M2P define just above just above
>> set_gpfn_from_mfn to keep all the dummy helpers for M2P together.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>
>> ---
>>
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>
>>      Changes in v4:
>>          - Patch added.
>> ---
>>   xen/include/asm-arm/mm.h | 25 ++++---------------------
>>   1 file changed, 4 insertions(+), 21 deletions(-)
>>
>> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
>> index 4d5563b0ce..c03f4ad674 100644
>> --- a/xen/include/asm-arm/mm.h
>> +++ b/xen/include/asm-arm/mm.h
>> @@ -320,33 +320,16 @@ 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);
>>
>> -/*
>> - * The MPT (machine->physical mapping table) is an array of word-sized
>> - * values, indexed on machine frame number. It is expected that guest OSes
>> - * will use it to store a "physical" frame number to give the appearance of
>> - * contiguous (or near contiguous) physical memory.
>> - */
>> -#undef  machine_to_phys_mapping
>> -#define machine_to_phys_mapping  ((unsigned long *)RDWR_MPT_VIRT_START)
>> -#define INVALID_M2P_ENTRY        (~0UL)
>> -#define VALID_M2P(_e)            (!((_e) & (1UL<<(BITS_PER_LONG-1))))
>> -#define SHARED_M2P_ENTRY         (~0UL - 1UL)
>> -#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
>> -
>> -#define _set_gpfn_from_mfn(mfn, pfn) ({                        \
>> -    struct domain *d = page_get_owner(__mfn_to_page(mfn));     \
>> -    if(d && (d == dom_cow))                                    \
>> -        machine_to_phys_mapping[(mfn)] = SHARED_M2P_ENTRY;     \
>> -    else                                                       \
>> -        machine_to_phys_mapping[(mfn)] = (pfn);                \
>> -    })
>> -
>>   static inline void put_gfn(struct domain *d, unsigned long gfn) {}
>>   static inline int relinquish_shared_pages(struct domain *d)
>>   {
>>       return 0;
>>   }
>>
>> +#define INVALID_M2P_ENTRY        (~0UL)
>> +#define SHARED_M2P_ENTRY         (~0UL - 1UL)
>> +#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
> 
> I think I might add a comment here like this:
> 
> "ARM doesn't have an M2P, but common code expects a handful of
> M2P-related defines and functions.  Provide dummy versions of these."

I will add that in the next version.

> 
> Other than that looks good:
> 
> Reviewed-by: George Dunlap <george.dunlap@citrix.com>

Thank you!

Cheers,
diff mbox series

Patch

diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index 4d5563b0ce..c03f4ad674 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -320,33 +320,16 @@  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);
 
-/*
- * The MPT (machine->physical mapping table) is an array of word-sized
- * values, indexed on machine frame number. It is expected that guest OSes
- * will use it to store a "physical" frame number to give the appearance of
- * contiguous (or near contiguous) physical memory.
- */
-#undef  machine_to_phys_mapping
-#define machine_to_phys_mapping  ((unsigned long *)RDWR_MPT_VIRT_START)
-#define INVALID_M2P_ENTRY        (~0UL)
-#define VALID_M2P(_e)            (!((_e) & (1UL<<(BITS_PER_LONG-1))))
-#define SHARED_M2P_ENTRY         (~0UL - 1UL)
-#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
-
-#define _set_gpfn_from_mfn(mfn, pfn) ({                        \
-    struct domain *d = page_get_owner(__mfn_to_page(mfn));     \
-    if(d && (d == dom_cow))                                    \
-        machine_to_phys_mapping[(mfn)] = SHARED_M2P_ENTRY;     \
-    else                                                       \
-        machine_to_phys_mapping[(mfn)] = (pfn);                \
-    })
-
 static inline void put_gfn(struct domain *d, unsigned long gfn) {}
 static inline int relinquish_shared_pages(struct domain *d)
 {
     return 0;
 }
 
+#define INVALID_M2P_ENTRY        (~0UL)
+#define SHARED_M2P_ENTRY         (~0UL - 1UL)
+#define SHARED_M2P(_e)           ((_e) == SHARED_M2P_ENTRY)
+
 /* Xen always owns P2M on ARM */
 #define set_gpfn_from_mfn(mfn, pfn) do { (void) (mfn), (void)(pfn); } while (0)
 #define mfn_to_gmfn(_d, mfn)  (mfn)