diff mbox

[RFC,XEN,02/16] x86_64/mm: explicitly specify the location to place the M2P table

Message ID 20161010003235.4213-3-haozhong.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Haozhong Zhang Oct. 10, 2016, 12:32 a.m. UTC
A reserved area on each pmem region is used to place the M2P table.
However, it's not at the beginning of the pmem region, so we need to
specify the location explicitly when creating the M2P table.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_64/mm.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Konrad Rzeszutek Wilk Dec. 9, 2016, 9:38 p.m. UTC | #1
On Mon, Oct 10, 2016 at 08:32:21AM +0800, Haozhong Zhang wrote:
> A reserved area on each pmem region is used to place the M2P table.
> However, it's not at the beginning of the pmem region, so we need to
> specify the location explicitly when creating the M2P table.
> 
> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
>  xen/arch/x86/x86_64/mm.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
> index 33f226a..5c0f527 100644
> --- a/xen/arch/x86/x86_64/mm.c
> +++ b/xen/arch/x86/x86_64/mm.c
> @@ -317,7 +317,8 @@ void destroy_m2p_mapping(struct mem_hotadd_info *info)
>   * spfn/epfn: the pfn ranges to be setup
>   * free_s/free_e: the pfn ranges that is free still
>   */
> -static int setup_compat_m2p_table(struct mem_hotadd_info *info)
> +static int setup_compat_m2p_table(struct mem_hotadd_info *info,
> +                                  struct mem_hotadd_info *alloc_info)
>  {
>      unsigned long i, va, smap, emap, rwva, epfn = info->epfn, mfn;
>      unsigned int n;
> @@ -371,7 +372,7 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info)
>          if ( n == CNT )
>              continue;
>  
> -        mfn = alloc_hotadd_mfn(info);
> +        mfn = alloc_hotadd_mfn(alloc_info);
>          err = map_pages_to_xen(rwva, mfn, 1UL << PAGETABLE_ORDER,
>                                 PAGE_HYPERVISOR);
>          if ( err )
> @@ -391,7 +392,8 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info)
>   * Allocate and map the machine-to-phys table.
>   * The L3 for RO/RWRW MPT and the L2 for compatible MPT should be setup already
>   */
> -static int setup_m2p_table(struct mem_hotadd_info *info)
> +static int setup_m2p_table(struct mem_hotadd_info *info,
> +                           struct mem_hotadd_info *alloc_info)
>  {
>      unsigned long i, va, smap, emap;
>      unsigned int n;
> @@ -440,7 +442,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info)
>                  break;
>          if ( n < CNT )
>          {
> -            unsigned long mfn = alloc_hotadd_mfn(info);
> +            unsigned long mfn = alloc_hotadd_mfn(alloc_info);
>  
>              ret = map_pages_to_xen(
>                          RDWR_MPT_VIRT_START + i * sizeof(unsigned long),
> @@ -485,7 +487,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info)
>  #undef CNT
>  #undef MFN
>  
> -    ret = setup_compat_m2p_table(info);
> +    ret = setup_compat_m2p_table(info, alloc_info);
>  error:
>      return ret;
>  }
> @@ -1427,7 +1429,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
>      total_pages += epfn - spfn;
>  
>      set_pdx_range(spfn, epfn);
> -    ret = setup_m2p_table(&info);
> +    ret = setup_m2p_table(&info, &info);

I am not sure I follow this logic. You are passing the same contents, it
is just that 'alloc_info' and 'info' are aliased together?
Haozhong Zhang Dec. 12, 2016, 2:31 a.m. UTC | #2
On 12/09/16 16:38 -0500, Konrad Rzeszutek Wilk wrote:
>On Mon, Oct 10, 2016 at 08:32:21AM +0800, Haozhong Zhang wrote:
>> A reserved area on each pmem region is used to place the M2P table.
>> However, it's not at the beginning of the pmem region, so we need to
>> specify the location explicitly when creating the M2P table.
>>
>> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
>> ---
>> Cc: Jan Beulich <jbeulich@suse.com>
>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>> ---
>>  xen/arch/x86/x86_64/mm.c | 14 ++++++++------
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
>> index 33f226a..5c0f527 100644
>> --- a/xen/arch/x86/x86_64/mm.c
>> +++ b/xen/arch/x86/x86_64/mm.c
>> @@ -317,7 +317,8 @@ void destroy_m2p_mapping(struct mem_hotadd_info *info)
>>   * spfn/epfn: the pfn ranges to be setup
>>   * free_s/free_e: the pfn ranges that is free still
>>   */
>> -static int setup_compat_m2p_table(struct mem_hotadd_info *info)
>> +static int setup_compat_m2p_table(struct mem_hotadd_info *info,
>> +                                  struct mem_hotadd_info *alloc_info)
>>  {
>>      unsigned long i, va, smap, emap, rwva, epfn = info->epfn, mfn;
>>      unsigned int n;
>> @@ -371,7 +372,7 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info)
>>          if ( n == CNT )
>>              continue;
>>
>> -        mfn = alloc_hotadd_mfn(info);
>> +        mfn = alloc_hotadd_mfn(alloc_info);
>>          err = map_pages_to_xen(rwva, mfn, 1UL << PAGETABLE_ORDER,
>>                                 PAGE_HYPERVISOR);
>>          if ( err )
>> @@ -391,7 +392,8 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info)
>>   * Allocate and map the machine-to-phys table.
>>   * The L3 for RO/RWRW MPT and the L2 for compatible MPT should be setup already
>>   */
>> -static int setup_m2p_table(struct mem_hotadd_info *info)
>> +static int setup_m2p_table(struct mem_hotadd_info *info,
>> +                           struct mem_hotadd_info *alloc_info)
>>  {
>>      unsigned long i, va, smap, emap;
>>      unsigned int n;
>> @@ -440,7 +442,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info)
>>                  break;
>>          if ( n < CNT )
>>          {
>> -            unsigned long mfn = alloc_hotadd_mfn(info);
>> +            unsigned long mfn = alloc_hotadd_mfn(alloc_info);
>>
>>              ret = map_pages_to_xen(
>>                          RDWR_MPT_VIRT_START + i * sizeof(unsigned long),
>> @@ -485,7 +487,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info)
>>  #undef CNT
>>  #undef MFN
>>
>> -    ret = setup_compat_m2p_table(info);
>> +    ret = setup_compat_m2p_table(info, alloc_info);
>>  error:
>>      return ret;
>>  }
>> @@ -1427,7 +1429,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
>>      total_pages += epfn - spfn;
>>
>>      set_pdx_range(spfn, epfn);
>> -    ret = setup_m2p_table(&info);
>> +    ret = setup_m2p_table(&info, &info);
>
>I am not sure I follow this logic. You are passing the same contents, it
>is just that 'alloc_info' and 'info' are aliased together?
>

Similarly to patch 1, the two parameters of setup_m2p_table() are
identical for the ordinary RAM, and can be different for NVDIMM.

Haozhong
Jan Beulich Dec. 12, 2016, 8:26 a.m. UTC | #3
>>> On 12.12.16 at 03:31, <haozhong.zhang@intel.com> wrote:
> On 12/09/16 16:38 -0500, Konrad Rzeszutek Wilk wrote:
>>On Mon, Oct 10, 2016 at 08:32:21AM +0800, Haozhong Zhang wrote:
>>> @@ -1427,7 +1429,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
>>>      total_pages += epfn - spfn;
>>>
>>>      set_pdx_range(spfn, epfn);
>>> -    ret = setup_m2p_table(&info);
>>> +    ret = setup_m2p_table(&info, &info);
>>
>>I am not sure I follow this logic. You are passing the same contents, it
>>is just that 'alloc_info' and 'info' are aliased together?
>>
> 
> Similarly to patch 1, the two parameters of setup_m2p_table() are
> identical for the ordinary RAM, and can be different for NVDIMM.

And the same comments as for patch 1 apply here then.

Jan
Haozhong Zhang Dec. 12, 2016, 8:35 a.m. UTC | #4
On 12/12/16 01:26 -0700, Jan Beulich wrote:
>>>> On 12.12.16 at 03:31, <haozhong.zhang@intel.com> wrote:
>> On 12/09/16 16:38 -0500, Konrad Rzeszutek Wilk wrote:
>>>On Mon, Oct 10, 2016 at 08:32:21AM +0800, Haozhong Zhang wrote:
>>>> @@ -1427,7 +1429,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
>>>>      total_pages += epfn - spfn;
>>>>
>>>>      set_pdx_range(spfn, epfn);
>>>> -    ret = setup_m2p_table(&info);
>>>> +    ret = setup_m2p_table(&info, &info);
>>>
>>>I am not sure I follow this logic. You are passing the same contents, it
>>>is just that 'alloc_info' and 'info' are aliased together?
>>>
>>
>> Similarly to patch 1, the two parameters of setup_m2p_table() are
>> identical for the ordinary RAM, and can be different for NVDIMM.
>
>And the same comments as for patch 1 apply here then.
>
>Jan
>

I'll add comments and clarify in commit messages for both patch 1 and
patch 2 in the next version.

Thanks,
Haozhong
diff mbox

Patch

diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
index 33f226a..5c0f527 100644
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -317,7 +317,8 @@  void destroy_m2p_mapping(struct mem_hotadd_info *info)
  * spfn/epfn: the pfn ranges to be setup
  * free_s/free_e: the pfn ranges that is free still
  */
-static int setup_compat_m2p_table(struct mem_hotadd_info *info)
+static int setup_compat_m2p_table(struct mem_hotadd_info *info,
+                                  struct mem_hotadd_info *alloc_info)
 {
     unsigned long i, va, smap, emap, rwva, epfn = info->epfn, mfn;
     unsigned int n;
@@ -371,7 +372,7 @@  static int setup_compat_m2p_table(struct mem_hotadd_info *info)
         if ( n == CNT )
             continue;
 
-        mfn = alloc_hotadd_mfn(info);
+        mfn = alloc_hotadd_mfn(alloc_info);
         err = map_pages_to_xen(rwva, mfn, 1UL << PAGETABLE_ORDER,
                                PAGE_HYPERVISOR);
         if ( err )
@@ -391,7 +392,8 @@  static int setup_compat_m2p_table(struct mem_hotadd_info *info)
  * Allocate and map the machine-to-phys table.
  * The L3 for RO/RWRW MPT and the L2 for compatible MPT should be setup already
  */
-static int setup_m2p_table(struct mem_hotadd_info *info)
+static int setup_m2p_table(struct mem_hotadd_info *info,
+                           struct mem_hotadd_info *alloc_info)
 {
     unsigned long i, va, smap, emap;
     unsigned int n;
@@ -440,7 +442,7 @@  static int setup_m2p_table(struct mem_hotadd_info *info)
                 break;
         if ( n < CNT )
         {
-            unsigned long mfn = alloc_hotadd_mfn(info);
+            unsigned long mfn = alloc_hotadd_mfn(alloc_info);
 
             ret = map_pages_to_xen(
                         RDWR_MPT_VIRT_START + i * sizeof(unsigned long),
@@ -485,7 +487,7 @@  static int setup_m2p_table(struct mem_hotadd_info *info)
 #undef CNT
 #undef MFN
 
-    ret = setup_compat_m2p_table(info);
+    ret = setup_compat_m2p_table(info, alloc_info);
 error:
     return ret;
 }
@@ -1427,7 +1429,7 @@  int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)
     total_pages += epfn - spfn;
 
     set_pdx_range(spfn, epfn);
-    ret = setup_m2p_table(&info);
+    ret = setup_m2p_table(&info, &info);
 
     if ( ret )
         goto destroy_m2p;