xen/arm: do not setup the runstate info page if kpti is enabled
Subsystems (4)
Stefano Stabellini
maintainerPATCH 1/1 xen/arm: do not setup the runstate info page if kpti is enabled
From: Stefano Stabellini <[email protected]>
The VCPUOP_register_runstate_memory_area hypercall takes a virtual address of a buffer as a parameter. The semantics of the hypercall are such that the virtual address should always be valid.
When KPTI is enabled and we are running userspace code, the virtual address is not valid, thus, Linux is violating the semantics of VCPUOP_register_runstate_memory_area.
Do not call VCPUOP_register_runstate_memory_area when KPTI is enabled.
--- arch/arm/include/asm/xen/page.h | 5 +++++ arch/arm/xen/enlighten.c | 6 ++++-- arch/arm64/include/asm/xen/page.h | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-)
arch/arm/include/asm/xen/page.h +5 -0
@@ -1 +1,6 @@#include <xen/arm/page.h> + +static inline bool xen_kernel_unmapped_at_usr (void ) +{ +return false; +}
arch/arm/xen/enlighten.c +4 -2
@@ -158,7 +158,8 @@ static int xen_starting_cpu(unsigned int cpu)BUG_ON (err);per_cpu (xen_vcpu, cpu) = vcpup; -xen_setup_runstate_info (cpu); +if (!xen_kernel_unmapped_at_usr ()) +xen_setup_runstate_info (cpu); after_register_vcpu_info:enable_percpu_irq (xen_events_irq,0 );
@@ -387,7 +388,8 @@ static int __init xen_guest_init(void)return -EINVAL ; } -xen_time_setup_guest (); +if (!xen_kernel_unmapped_at_usr ()) +xen_time_setup_guest ();if (xen_initial_domain ())pvclock_gtod_register_notifier (&xen_pvclock_gtod_notifier);
arch/arm64/include/asm/xen/page.h +6 -0
@@ -1 +1,7 @@#include <xen/arm/page.h> +#include <asm/mmu.h> + +static inline bool xen_kernel_unmapped_at_usr (void ) +{ +return arm64_kernel_unmapped_at_el0 (); +}
Signature · 1 line
2.17.1
Hi,
Quoted 8 lines · Stefano Stabellini
From: Stefano Stabellini <[email protected]>
The
VCPUOP_register_runstate_memory_areahypercall takes a virtual address of a buffer as a parameter. The semantics of the hypercall are such that the virtual address should always be valid.
Quoted 7 lines
When KPTI is enabled and we are running userspace code, the virtual address is not valid, thus, Linux is violating the semantics of
VCPUOP_register_runstate_memory_area.Do not call
VCPUOP_register_runstate_memory_areawhen KPTI is enabled.Signed-off-by Stefano Stabellini <[email protected]>
I tested this on an Arm64 FVP and Errors generated by Xen are not present anymore. Thanks a lot for the patch Stefano.
Cheers,
Bertrand
Quoted 57 lines
---
arch/arm/include/asm/xen/page.h | 5 +++++ arch/arm/xen/enlighten.c | 6 ++++-- arch/arm64/include/asm/xen/page.h | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-)arch/arm/include/asm/xen/page.h +5
-0@@ -1 +1,6 @@#include <xen/arm/page.h> + +static inline bool xen_kernel_unmapped_at_usr (void ) +{ +return false; +}arch/arm/xen/enlighten.c +2
-1@@ -158,7 +158,8 @@ static int xen_starting_cpu(unsigned int cpu)BUG_ON (err);per_cpu (xen_vcpu, cpu) = vcpup; -xen_setup_runstate_info (cpu); +if (!xen_kernel_unmapped_at_usr ()) +xen_setup_runstate_info (cpu);
after_register_vcpu_info:enable_percpu_irq(xen_events_irq, 0);arch/arm/xen/enlighten.c +2
-1@@ -387,7 +388,8 @@ static int __init xen_guest_init(void)return -EINVAL ; } -xen_time_setup_guest (); +if (!xen_kernel_unmapped_at_usr ()) +xen_time_setup_guest ();if (xen_initial_domain ())pvclock_gtod_register_notifier (&xen_pvclock_gtod_notifier);arch/arm64/include/asm/xen/page.h +6
-1@@ -1 +1,7 @@#include <xen/arm/page.h> +#include <asm/mmu.h> + +static inline bool xen_kernel_unmapped_at_usr (void ) +{ +return arm64_kernel_unmapped_at_el0 (); +} --
Quoted 2 lines
2.17.1
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
[email protected]
AppliedQuoted 10 lines · Stefano Stabellini
From: Stefano Stabellini <[email protected]>
The
VCPUOP_register_runstate_memory_areahypercall takes a virtual address of a buffer as a parameter. The semantics of the hypercall are such that the virtual address should always be valid.When KPTI is enabled and we are running userspace code, the virtual address is not valid, thus, Linux is violating the semantics of
VCPUOP_register_runstate_memory_area.
Quoted 6 lines
Do not call
VCPUOP_register_runstate_memory_areawhen KPTI is enabled.Signed-off-by Stefano Stabellini <[email protected]>CC Bertrand Marquis <[email protected]>
Applied to for-linus-5.10
-boris