diff mbox series

[Xen-devel,RESEND,for-4.13] xen/arm: mm: Clear boot pagetables before bringing-up each secondary CPU

Message ID 20190921100836.21396-1-julien.grall@arm.com
State New
Headers show
Series [Xen-devel,RESEND,for-4.13] xen/arm: mm: Clear boot pagetables before bringing-up each secondary CPU | expand

Commit Message

Julien Grall Sept. 21, 2019, 10:08 a.m. UTC
At the moment, boot pagetables are only cleared once at boot. This means
when booting CPU2 (and onwards) then boot pagetables will not be
cleared.

To keep the interface exactly the same for all secondary CPU, the boot
pagetables are now cleared before bringing-up each secondary CPU.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

Comments

Volodymyr Babchuk Sept. 24, 2019, 2:13 p.m. UTC | #1
Julien Grall writes:

> At the moment, boot pagetables are only cleared once at boot. This means
> when booting CPU2 (and onwards) then boot pagetables will not be
> cleared.
>
> To keep the interface exactly the same for all secondary CPU, the boot
> pagetables are now cleared before bringing-up each secondary CPU.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
Taking into account fixed remark below:

Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

> ---
>  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 1129dc28c8..e14ee76ff8 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>  
>      switch_ttbr(ttbr);
>  
> -    /* Clear the copy of the boot pagetables. Each secondary CPU
> -     * rebuilds these itself (see head.S) */
> +    xen_pt_enforce_wnx();
> +
> +#ifdef CONFIG_ARM_32
> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
> +#endif
> +}
> +
> +static void clear_boot_pagetables(void)
> +{
> +    /*
> +     * Clear the copy of the boot pagetables. Each secondary CPU
> +     * rebuilds these itself (see head.S)
Missing full stop.

> +     */
>      clear_table(boot_pgtable);
>  #ifdef CONFIG_ARM_64
>      clear_table(boot_first);
> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>  #endif
>      clear_table(boot_second);
>      clear_table(boot_third);
> -
> -    xen_pt_enforce_wnx();
> -
> -#ifdef CONFIG_ARM_32
> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
> -#endif
>  }
>  
>  #ifdef CONFIG_ARM_64
>  int init_secondary_pagetables(int cpu)
>  {
> +    clear_boot_pagetables();
> +
>      /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>       * pagetables, but rewrite it each time for consistency with 32 bit. */
>      init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>      per_cpu(xen_pgtable, cpu) = first;
>      per_cpu(xen_dommap, cpu) = domheap;
>  
> +    clear_boot_pagetables();
> +
>      /* Set init_ttbr for this CPU coming up */
>      init_ttbr = __pa(first);
>      clean_dcache(init_ttbr);
Julien Grall Oct. 2, 2019, 5:47 p.m. UTC | #2
Ping.

On 9/21/19 11:08 AM, Julien Grall wrote:
> At the moment, boot pagetables are only cleared once at boot. This means
> when booting CPU2 (and onwards) then boot pagetables will not be
> cleared.
> 
> To keep the interface exactly the same for all secondary CPU, the boot
> pagetables are now cleared before bringing-up each secondary CPU.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>   xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>   1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 1129dc28c8..e14ee76ff8 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>   
>       switch_ttbr(ttbr);
>   
> -    /* Clear the copy of the boot pagetables. Each secondary CPU
> -     * rebuilds these itself (see head.S) */
> +    xen_pt_enforce_wnx();
> +
> +#ifdef CONFIG_ARM_32
> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
> +#endif
> +}
> +
> +static void clear_boot_pagetables(void)
> +{
> +    /*
> +     * Clear the copy of the boot pagetables. Each secondary CPU
> +     * rebuilds these itself (see head.S)
> +     */
>       clear_table(boot_pgtable);
>   #ifdef CONFIG_ARM_64
>       clear_table(boot_first);
> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>   #endif
>       clear_table(boot_second);
>       clear_table(boot_third);
> -
> -    xen_pt_enforce_wnx();
> -
> -#ifdef CONFIG_ARM_32
> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
> -#endif
>   }
>   
>   #ifdef CONFIG_ARM_64
>   int init_secondary_pagetables(int cpu)
>   {
> +    clear_boot_pagetables();
> +
>       /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>        * pagetables, but rewrite it each time for consistency with 32 bit. */
>       init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>       per_cpu(xen_pgtable, cpu) = first;
>       per_cpu(xen_dommap, cpu) = domheap;
>   
> +    clear_boot_pagetables();
> +
>       /* Set init_ttbr for this CPU coming up */
>       init_ttbr = __pa(first);
>       clean_dcache(init_ttbr);
>
Julien Grall Oct. 2, 2019, 5:47 p.m. UTC | #3
Gentle ping.

On 9/21/19 11:08 AM, Julien Grall wrote:
> At the moment, boot pagetables are only cleared once at boot. This means
> when booting CPU2 (and onwards) then boot pagetables will not be
> cleared.
> 
> To keep the interface exactly the same for all secondary CPU, the boot
> pagetables are now cleared before bringing-up each secondary CPU.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>   xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>   1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 1129dc28c8..e14ee76ff8 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>   
>       switch_ttbr(ttbr);
>   
> -    /* Clear the copy of the boot pagetables. Each secondary CPU
> -     * rebuilds these itself (see head.S) */
> +    xen_pt_enforce_wnx();
> +
> +#ifdef CONFIG_ARM_32
> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
> +#endif
> +}
> +
> +static void clear_boot_pagetables(void)
> +{
> +    /*
> +     * Clear the copy of the boot pagetables. Each secondary CPU
> +     * rebuilds these itself (see head.S)
> +     */
>       clear_table(boot_pgtable);
>   #ifdef CONFIG_ARM_64
>       clear_table(boot_first);
> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>   #endif
>       clear_table(boot_second);
>       clear_table(boot_third);
> -
> -    xen_pt_enforce_wnx();
> -
> -#ifdef CONFIG_ARM_32
> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
> -#endif
>   }
>   
>   #ifdef CONFIG_ARM_64
>   int init_secondary_pagetables(int cpu)
>   {
> +    clear_boot_pagetables();
> +
>       /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>        * pagetables, but rewrite it each time for consistency with 32 bit. */
>       init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>       per_cpu(xen_pgtable, cpu) = first;
>       per_cpu(xen_dommap, cpu) = domheap;
>   
> +    clear_boot_pagetables();
> +
>       /* Set init_ttbr for this CPU coming up */
>       init_ttbr = __pa(first);
>       clean_dcache(init_ttbr);
>
Stefano Stabellini Oct. 3, 2019, 1:22 a.m. UTC | #4
On Sat, 21 Sep 2019, Julien Grall wrote:
> At the moment, boot pagetables are only cleared once at boot. This means
> when booting CPU2 (and onwards) then boot pagetables will not be
> cleared.
> 
> To keep the interface exactly the same for all secondary CPU, the boot
> pagetables are now cleared before bringing-up each secondary CPU.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

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


> ---
>  xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 1129dc28c8..e14ee76ff8 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>  
>      switch_ttbr(ttbr);
>  
> -    /* Clear the copy of the boot pagetables. Each secondary CPU
> -     * rebuilds these itself (see head.S) */
> +    xen_pt_enforce_wnx();
> +
> +#ifdef CONFIG_ARM_32
> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
> +#endif
> +}
> +
> +static void clear_boot_pagetables(void)
> +{
> +    /*
> +     * Clear the copy of the boot pagetables. Each secondary CPU
> +     * rebuilds these itself (see head.S)
> +     */
>      clear_table(boot_pgtable);
>  #ifdef CONFIG_ARM_64
>      clear_table(boot_first);
> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>  #endif
>      clear_table(boot_second);
>      clear_table(boot_third);
> -
> -    xen_pt_enforce_wnx();
> -
> -#ifdef CONFIG_ARM_32
> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
> -#endif
>  }
>  
>  #ifdef CONFIG_ARM_64
>  int init_secondary_pagetables(int cpu)
>  {
> +    clear_boot_pagetables();
> +
>      /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>       * pagetables, but rewrite it each time for consistency with 32 bit. */
>      init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>      per_cpu(xen_pgtable, cpu) = first;
>      per_cpu(xen_dommap, cpu) = domheap;
>  
> +    clear_boot_pagetables();
> +
>      /* Set init_ttbr for this CPU coming up */
>      init_ttbr = __pa(first);
>      clean_dcache(init_ttbr);
> -- 
> 2.11.0
>
Julien Grall Oct. 10, 2019, 2:51 p.m. UTC | #5
+Juergen

On 03/10/2019 02:22, Stefano Stabellini wrote:
> On Sat, 21 Sep 2019, Julien Grall wrote:
>> At the moment, boot pagetables are only cleared once at boot. This means
>> when booting CPU2 (and onwards) then boot pagetables will not be
>> cleared.
>>
>> To keep the interface exactly the same for all secondary CPU, the boot
>> pagetables are now cleared before bringing-up each secondary CPU.
>>
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> 
>> ---
>>   xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>>   1 file changed, 18 insertions(+), 9 deletions(-)
>>
>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>> index 1129dc28c8..e14ee76ff8 100644
>> --- a/xen/arch/arm/mm.c
>> +++ b/xen/arch/arm/mm.c
>> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>>   
>>       switch_ttbr(ttbr);
>>   
>> -    /* Clear the copy of the boot pagetables. Each secondary CPU
>> -     * rebuilds these itself (see head.S) */
>> +    xen_pt_enforce_wnx();
>> +
>> +#ifdef CONFIG_ARM_32
>> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
>> +#endif
>> +}
>> +
>> +static void clear_boot_pagetables(void)
>> +{
>> +    /*
>> +     * Clear the copy of the boot pagetables. Each secondary CPU
>> +     * rebuilds these itself (see head.S)
>> +     */
>>       clear_table(boot_pgtable);
>>   #ifdef CONFIG_ARM_64
>>       clear_table(boot_first);
>> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
>>   #endif
>>       clear_table(boot_second);
>>       clear_table(boot_third);
>> -
>> -    xen_pt_enforce_wnx();
>> -
>> -#ifdef CONFIG_ARM_32
>> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
>> -#endif
>>   }
>>   
>>   #ifdef CONFIG_ARM_64
>>   int init_secondary_pagetables(int cpu)
>>   {
>> +    clear_boot_pagetables();
>> +
>>       /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>>        * pagetables, but rewrite it each time for consistency with 32 bit. */
>>       init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
>> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>>       per_cpu(xen_pgtable, cpu) = first;
>>       per_cpu(xen_dommap, cpu) = domheap;
>>   
>> +    clear_boot_pagetables();
>> +
>>       /* Set init_ttbr for this CPU coming up */
>>       init_ttbr = __pa(first);
>>       clean_dcache(init_ttbr);
>> -- 
>> 2.11.0
>>
Julien Grall Oct. 15, 2019, 4:36 p.m. UTC | #6
Hi,

I actually forgot to CC Juergen. No wonder why I had no answer :(.

Cheers,

On 10/10/19 3:51 PM, Julien Grall wrote:
> +Juergen
> 
> On 03/10/2019 02:22, Stefano Stabellini wrote:
>> On Sat, 21 Sep 2019, Julien Grall wrote:
>>> At the moment, boot pagetables are only cleared once at boot. This means
>>> when booting CPU2 (and onwards) then boot pagetables will not be
>>> cleared.
>>>
>>> To keep the interface exactly the same for all secondary CPU, the boot
>>> pagetables are now cleared before bringing-up each secondary CPU.
>>>
>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>
>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
>>
>>
>>> ---
>>>   xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>>>   1 file changed, 18 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>>> index 1129dc28c8..e14ee76ff8 100644
>>> --- a/xen/arch/arm/mm.c
>>> +++ b/xen/arch/arm/mm.c
>>> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long 
>>> boot_phys_offset)
>>>       switch_ttbr(ttbr);
>>> -    /* Clear the copy of the boot pagetables. Each secondary CPU
>>> -     * rebuilds these itself (see head.S) */
>>> +    xen_pt_enforce_wnx();
>>> +
>>> +#ifdef CONFIG_ARM_32
>>> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>>> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
>>> +#endif
>>> +}
>>> +
>>> +static void clear_boot_pagetables(void)
>>> +{
>>> +    /*
>>> +     * Clear the copy of the boot pagetables. Each secondary CPU
>>> +     * rebuilds these itself (see head.S)
>>> +     */
>>>       clear_table(boot_pgtable);
>>>   #ifdef CONFIG_ARM_64
>>>       clear_table(boot_first);
>>> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long 
>>> boot_phys_offset)
>>>   #endif
>>>       clear_table(boot_second);
>>>       clear_table(boot_third);
>>> -
>>> -    xen_pt_enforce_wnx();
>>> -
>>> -#ifdef CONFIG_ARM_32
>>> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>>> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
>>> -#endif
>>>   }
>>>   #ifdef CONFIG_ARM_64
>>>   int init_secondary_pagetables(int cpu)
>>>   {
>>> +    clear_boot_pagetables();
>>> +
>>>       /* Set init_ttbr for this CPU coming up. All CPus share a 
>>> single setof
>>>        * pagetables, but rewrite it each time for consistency with 32 
>>> bit. */
>>>       init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
>>> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>>>       per_cpu(xen_pgtable, cpu) = first;
>>>       per_cpu(xen_dommap, cpu) = domheap;
>>> +    clear_boot_pagetables();
>>> +
>>>       /* Set init_ttbr for this CPU coming up */
>>>       init_ttbr = __pa(first);
>>>       clean_dcache(init_ttbr);
>>> -- 
>>> 2.11.0
>>>
>
Julien Grall Oct. 16, 2019, 11:19 a.m. UTC | #7
Hi,

Argh forgot again. Maybe the 3rd will be better?

Sorry for the noise.

Cheers,

On 15/10/2019 17:36, Julien Grall wrote:
> Hi,
> 
> I actually forgot to CC Juergen. No wonder why I had no answer :(.
> 
> Cheers,
> 
> On 10/10/19 3:51 PM, Julien Grall wrote:
>> +Juergen
>>
>> On 03/10/2019 02:22, Stefano Stabellini wrote:
>>> On Sat, 21 Sep 2019, Julien Grall wrote:
>>>> At the moment, boot pagetables are only cleared once at boot. This means
>>>> when booting CPU2 (and onwards) then boot pagetables will not be
>>>> cleared.
>>>>
>>>> To keep the interface exactly the same for all secondary CPU, the boot
>>>> pagetables are now cleared before bringing-up each secondary CPU.
>>>>
>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>
>>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
>>>
>>>
>>>> ---
>>>>   xen/arch/arm/mm.c | 27 ++++++++++++++++++---------
>>>>   1 file changed, 18 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>>>> index 1129dc28c8..e14ee76ff8 100644
>>>> --- a/xen/arch/arm/mm.c
>>>> +++ b/xen/arch/arm/mm.c
>>>> @@ -704,8 +704,20 @@ void __init setup_pagetables(unsigned long 
>>>> boot_phys_offset)
>>>>       switch_ttbr(ttbr);
>>>> -    /* Clear the copy of the boot pagetables. Each secondary CPU
>>>> -     * rebuilds these itself (see head.S) */
>>>> +    xen_pt_enforce_wnx();
>>>> +
>>>> +#ifdef CONFIG_ARM_32
>>>> +    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>>>> +    per_cpu(xen_dommap, 0) = cpu0_dommap;
>>>> +#endif
>>>> +}
>>>> +
>>>> +static void clear_boot_pagetables(void)
>>>> +{
>>>> +    /*
>>>> +     * Clear the copy of the boot pagetables. Each secondary CPU
>>>> +     * rebuilds these itself (see head.S)
>>>> +     */
>>>>       clear_table(boot_pgtable);
>>>>   #ifdef CONFIG_ARM_64
>>>>       clear_table(boot_first);
>>>> @@ -713,18 +725,13 @@ void __init setup_pagetables(unsigned long 
>>>> boot_phys_offset)
>>>>   #endif
>>>>       clear_table(boot_second);
>>>>       clear_table(boot_third);
>>>> -
>>>> -    xen_pt_enforce_wnx();
>>>> -
>>>> -#ifdef CONFIG_ARM_32
>>>> -    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
>>>> -    per_cpu(xen_dommap, 0) = cpu0_dommap;
>>>> -#endif
>>>>   }
>>>>   #ifdef CONFIG_ARM_64
>>>>   int init_secondary_pagetables(int cpu)
>>>>   {
>>>> +    clear_boot_pagetables();
>>>> +
>>>>       /* Set init_ttbr for this CPU coming up. All CPus share a single setof
>>>>        * pagetables, but rewrite it each time for consistency with 32 bit. */
>>>>       init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
>>>> @@ -767,6 +774,8 @@ int init_secondary_pagetables(int cpu)
>>>>       per_cpu(xen_pgtable, cpu) = first;
>>>>       per_cpu(xen_dommap, cpu) = domheap;
>>>> +    clear_boot_pagetables();
>>>> +
>>>>       /* Set init_ttbr for this CPU coming up */
>>>>       init_ttbr = __pa(first);
>>>>       clean_dcache(init_ttbr);
>>>> -- 
>>>> 2.11.0
>>>>
>>
>
Juergen Gross Oct. 16, 2019, 11:22 a.m. UTC | #8
On 16.10.19 13:19, Julien Grall wrote:
> Hi,
> 
> Argh forgot again. Maybe the 3rd will be better?

Yes! You made it! ;-)

> 
> Sorry for the noise.
> 
> Cheers,
> 
> On 15/10/2019 17:36, Julien Grall wrote:
>> Hi,
>>
>> I actually forgot to CC Juergen. No wonder why I had no answer :(.
>>
>> Cheers,
>>
>> On 10/10/19 3:51 PM, Julien Grall wrote:
>>> +Juergen
>>>
>>> On 03/10/2019 02:22, Stefano Stabellini wrote:
>>>> On Sat, 21 Sep 2019, Julien Grall wrote:
>>>>> At the moment, boot pagetables are only cleared once at boot. This 
>>>>> means
>>>>> when booting CPU2 (and onwards) then boot pagetables will not be
>>>>> cleared.
>>>>>
>>>>> To keep the interface exactly the same for all secondary CPU, the boot
>>>>> pagetables are now cleared before bringing-up each secondary CPU.
>>>>>
>>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>>
>>>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 1129dc28c8..e14ee76ff8 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -704,8 +704,20 @@  void __init setup_pagetables(unsigned long boot_phys_offset)
 
     switch_ttbr(ttbr);
 
-    /* Clear the copy of the boot pagetables. Each secondary CPU
-     * rebuilds these itself (see head.S) */
+    xen_pt_enforce_wnx();
+
+#ifdef CONFIG_ARM_32
+    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
+    per_cpu(xen_dommap, 0) = cpu0_dommap;
+#endif
+}
+
+static void clear_boot_pagetables(void)
+{
+    /*
+     * Clear the copy of the boot pagetables. Each secondary CPU
+     * rebuilds these itself (see head.S)
+     */
     clear_table(boot_pgtable);
 #ifdef CONFIG_ARM_64
     clear_table(boot_first);
@@ -713,18 +725,13 @@  void __init setup_pagetables(unsigned long boot_phys_offset)
 #endif
     clear_table(boot_second);
     clear_table(boot_third);
-
-    xen_pt_enforce_wnx();
-
-#ifdef CONFIG_ARM_32
-    per_cpu(xen_pgtable, 0) = cpu0_pgtable;
-    per_cpu(xen_dommap, 0) = cpu0_dommap;
-#endif
 }
 
 #ifdef CONFIG_ARM_64
 int init_secondary_pagetables(int cpu)
 {
+    clear_boot_pagetables();
+
     /* Set init_ttbr for this CPU coming up. All CPus share a single setof
      * pagetables, but rewrite it each time for consistency with 32 bit. */
     init_ttbr = (uintptr_t) xen_pgtable + phys_offset;
@@ -767,6 +774,8 @@  int init_secondary_pagetables(int cpu)
     per_cpu(xen_pgtable, cpu) = first;
     per_cpu(xen_dommap, cpu) = domheap;
 
+    clear_boot_pagetables();
+
     /* Set init_ttbr for this CPU coming up */
     init_ttbr = __pa(first);
     clean_dcache(init_ttbr);