Skip to content

Commit

Permalink
xen/arm: do not setup the runstate info page if kpti is enabled
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
CC: Bertrand Marquis <Bertrand.Marquis@arm.com>
CC: boris.ostrovsky@oracle.com
CC: jgross@suse.com
Link: https://lore.kernel.org/r/20200924234955.15455-1-sstabellini@kernel.org
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
  • Loading branch information
Stefano Stabellini authored and Boris Ostrovsky committed Oct 4, 2020
1 parent bba91dd commit f88af72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions arch/arm/include/asm/xen/page.h
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#include <xen/arm/page.h>

static inline bool xen_kernel_unmapped_at_usr(void)
{
return false;
}
6 changes: 4 additions & 2 deletions arch/arm/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions arch/arm64/include/asm/xen/page.h
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit f88af72

Please sign in to comment.