diff mbox series

[Xen-devel,for-4.12,4/8] xen/arm: domain_build: Don't switch to the guest P2M when copying data

Message ID 20181128164939.8329-5-julien.grall@arm.com
State Superseded
Headers show
Series xen/arm: Workaround for Cortex-A76 erratum 1165522 | expand

Commit Message

Julien Grall Nov. 28, 2018, 4:49 p.m. UTC
Until recently, kernel/initrd/dtb were loaded using guest VA and
therefore requiring to restore temporarily the P2M. This reworked in a
series of commits (up to 9292086 "xen/arm: domain_build: Use
copy_to_guest_phys_flush_dcache in dtb_load") to use a guest PA.

This will also help a follow-up patch which will require
p2m_{save,restore}_state to work in pair to workaround an erratum.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 13 -------------
 1 file changed, 13 deletions(-)

Comments

Andrii Anisov Dec. 21, 2018, 3:16 p.m. UTC | #1
On 28.11.18 18:49, Julien Grall wrote:
> Until recently, kernel/initrd/dtb were loaded using guest VA and
> therefore requiring to restore temporarily the P2M. This reworked in a
> series of commits (up to 9292086 "xen/arm: domain_build: Use
> copy_to_guest_phys_flush_dcache in dtb_load") to use a guest PA.
> 
> This will also help a follow-up patch which will require
> p2m_{save,restore}_state to work in pair to workaround an erratum.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Andrii Anisov <andrii_anisov@epam.com>
Stefano Stabellini Jan. 24, 2019, 12:08 a.m. UTC | #2
On Wed, 28 Nov 2018, Julien Grall wrote:
> Until recently, kernel/initrd/dtb were loaded using guest VA and
> therefore requiring to restore temporarily the P2M. This reworked in a
                                                          ^ was

> series of commits (up to 9292086 "xen/arm: domain_build: Use
> copy_to_guest_phys_flush_dcache in dtb_load") to use a guest PA.
> 
> This will also help a follow-up patch which will require
> p2m_{save,restore}_state to work in pair to workaround an erratum.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/arm/domain_build.c | 13 -------------
>  1 file changed, 13 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index b0ec3f0b72..ffbf7c6760 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1920,7 +1920,6 @@ static void __init find_gnttab_region(struct domain *d,
>  
>  static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
>  {
> -    struct vcpu *saved_current;
>      int i, cpu;
>      struct vcpu *v = d->vcpu[0];
>      struct cpu_user_regs *regs = &v->arch.cpu_info->guest_cpu_user_regs;
> @@ -1942,14 +1941,6 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
>  #endif
>  
>      /*
> -     * The following loads use the domain's p2m and require current to
> -     * be a vcpu of the domain, temporarily switch
> -     */
> -    saved_current = current;
> -    p2m_restore_state(v);
> -    set_current(v);
> -
> -    /*
>       * kernel_load will determine the placement of the kernel as well
>       * as the initrd & fdt in RAM, so call it first.
>       */
> @@ -1958,10 +1949,6 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
>      initrd_load(kinfo);
>      dtb_load(kinfo);
>  
> -    /* Now that we are done restore the original p2m and current. */
> -    set_current(saved_current);
> -    p2m_restore_state(saved_current);
> -
>      memset(regs, 0, sizeof(*regs));
>  
>      regs->pc = (register_t)kinfo->entry;

Nice cleanup!

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

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index b0ec3f0b72..ffbf7c6760 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1920,7 +1920,6 @@  static void __init find_gnttab_region(struct domain *d,
 
 static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
 {
-    struct vcpu *saved_current;
     int i, cpu;
     struct vcpu *v = d->vcpu[0];
     struct cpu_user_regs *regs = &v->arch.cpu_info->guest_cpu_user_regs;
@@ -1942,14 +1941,6 @@  static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
 #endif
 
     /*
-     * The following loads use the domain's p2m and require current to
-     * be a vcpu of the domain, temporarily switch
-     */
-    saved_current = current;
-    p2m_restore_state(v);
-    set_current(v);
-
-    /*
      * kernel_load will determine the placement of the kernel as well
      * as the initrd & fdt in RAM, so call it first.
      */
@@ -1958,10 +1949,6 @@  static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
     initrd_load(kinfo);
     dtb_load(kinfo);
 
-    /* Now that we are done restore the original p2m and current. */
-    set_current(saved_current);
-    p2m_restore_state(saved_current);
-
     memset(regs, 0, sizeof(*regs));
 
     regs->pc = (register_t)kinfo->entry;