diff mbox series

[RFCv2,09/15] xen/arm32: mm: Re-implement setup_xenheap_mappings() using map_pages_to_xen()

Message ID 20210425201318.15447-10-julien@xen.org (mailing list archive)
State New, archived
Headers show
Series xen/arm: mm: Remove open-coding mappings | expand

Commit Message

Julien Grall April 25, 2021, 8:13 p.m. UTC
From: Julien Grall <jgrall@amazon.com>

Now that map_pages_to_xen() has been extended to support 2MB mappings,
we can replace the create_mappings() call by map_pages_to_xen() call.

Signed-off-by: Julien Grall <jgrall@amazon.com>

---
    Changes in v2:
        - New patch

    TODOs:
        - add support for contiguous mapping
---
 xen/arch/arm/mm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Stefano Stabellini May 12, 2021, 10:07 p.m. UTC | #1
On Sun, 25 Apr 2021, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> Now that map_pages_to_xen() has been extended to support 2MB mappings,
> we can replace the create_mappings() call by map_pages_to_xen() call.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> ---
>     Changes in v2:
>         - New patch
> 
>     TODOs:
>         - add support for contiguous mapping
> ---
>  xen/arch/arm/mm.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 5c17cafff847..19ecf73542ce 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -806,7 +806,12 @@ void mmu_init_secondary_cpu(void)
>  void __init setup_xenheap_mappings(unsigned long base_mfn,
>                                     unsigned long nr_mfns)
>  {
> -    create_mappings(xen_second, XENHEAP_VIRT_START, base_mfn, nr_mfns, MB(32));
> +    int rc;
> +
> +    rc = map_pages_to_xen(XENHEAP_VIRT_START, base_mfn, nr_mfns,
> +                          PAGE_HYPERVISOR_RW | _PAGE_BLOCK);
> +    if ( rc )
> +        panic("Unable to setup the xenheap mappings.\n");
>  
>      /* Record where the xenheap is, for translation routines. */
>      xenheap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE;

I get the following build error:

mm.c: In function ‘setup_xenheap_mappings’:
mm.c:811:47: error: incompatible type for argument 2 of ‘map_pages_to_xen’
     rc = map_pages_to_xen(XENHEAP_VIRT_START, base_mfn, nr_mfns,
                                               ^~~~~~~~
In file included from mm.c:24:0:
/local/repos/xen-upstream/xen/include/xen/mm.h:89:5: note: expected ‘mfn_t {aka struct <anonymous>}’ but argument is of type ‘long unsigned int’
 int map_pages_to_xen(
     ^~~~~~~~~~~~~~~~

I think base_mfn needs to be converted to mfn_t
Julien Grall May 13, 2021, 5:55 p.m. UTC | #2
Hi Stefano,

On 12/05/2021 23:07, Stefano Stabellini wrote:
> On Sun, 25 Apr 2021, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> Now that map_pages_to_xen() has been extended to support 2MB mappings,
>> we can replace the create_mappings() call by map_pages_to_xen() call.
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>>
>> ---
>>      Changes in v2:
>>          - New patch
>>
>>      TODOs:
>>          - add support for contiguous mapping
>> ---
>>   xen/arch/arm/mm.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>> index 5c17cafff847..19ecf73542ce 100644
>> --- a/xen/arch/arm/mm.c
>> +++ b/xen/arch/arm/mm.c
>> @@ -806,7 +806,12 @@ void mmu_init_secondary_cpu(void)
>>   void __init setup_xenheap_mappings(unsigned long base_mfn,
>>                                      unsigned long nr_mfns)
>>   {
>> -    create_mappings(xen_second, XENHEAP_VIRT_START, base_mfn, nr_mfns, MB(32));
>> +    int rc;
>> +
>> +    rc = map_pages_to_xen(XENHEAP_VIRT_START, base_mfn, nr_mfns,
>> +                          PAGE_HYPERVISOR_RW | _PAGE_BLOCK);
>> +    if ( rc )
>> +        panic("Unable to setup the xenheap mappings.\n");
>>   
>>       /* Record where the xenheap is, for translation routines. */
>>       xenheap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE;
> 
> I get the following build error:
> 
> mm.c: In function ‘setup_xenheap_mappings’:
> mm.c:811:47: error: incompatible type for argument 2 of ‘map_pages_to_xen’
>       rc = map_pages_to_xen(XENHEAP_VIRT_START, base_mfn, nr_mfns,
>                                                 ^~~~~~~~
> In file included from mm.c:24:0:
> /local/repos/xen-upstream/xen/include/xen/mm.h:89:5: note: expected ‘mfn_t {aka struct <anonymous>}’ but argument is of type ‘long unsigned int’
>   int map_pages_to_xen(
>       ^~~~~~~~~~~~~~~~
> 
> I think base_mfn needs to be converted to mfn_t

You are right. I think my scripts are build testing arm32 with debug=n. 
I will fix it and respin.

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 5c17cafff847..19ecf73542ce 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -806,7 +806,12 @@  void mmu_init_secondary_cpu(void)
 void __init setup_xenheap_mappings(unsigned long base_mfn,
                                    unsigned long nr_mfns)
 {
-    create_mappings(xen_second, XENHEAP_VIRT_START, base_mfn, nr_mfns, MB(32));
+    int rc;
+
+    rc = map_pages_to_xen(XENHEAP_VIRT_START, base_mfn, nr_mfns,
+                          PAGE_HYPERVISOR_RW | _PAGE_BLOCK);
+    if ( rc )
+        panic("Unable to setup the xenheap mappings.\n");
 
     /* Record where the xenheap is, for translation routines. */
     xenheap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE;