• Mark Rutland's avatar
    arm64/arm: xen: enlighten: Fix KPTI checks · 20f3b8ea
    Mark Rutland authored
    When KPTI is in use, we cannot register a runstate region as XEN
    requires that this is always a valid VA, which we cannot guarantee. Due
    to this, xen_starting_cpu() must avoid registering each CPU's runstate
    region, and xen_guest_init() must avoid setting up features that depend
    upon it.
    
    We tried to ensure that in commit:
    
      f88af722 (" xen/arm: do not setup the runstate info page if kpti is enabled")
    
    ... where we added checks for xen_kernel_unmapped_at_usr(), which wraps
    arm64_kernel_unmapped_at_el0() on arm64 and is always false on 32-bit
    arm.
    
    Unfortunately, as xen_guest_init() is an early_initcall, this happens
    before secondary CPUs are booted and arm64 has finalized the
    ARM64_UNMAP_KERNEL_AT_EL0 cpucap which backs
    arm64_kernel_unmapped_at_el0(), and so this can subsequently be set as
    secondary CPUs are onlined. On a big.LITTLE system where the boot CPU
    does not require KPTI but some secondary CPUs do, this will result in
    xen_guest_init() intializing features that depend on the runstate
    region, and xen_starting_cpu() registering the runstate region on some
    CPUs before KPTI is subsequent enabled, resulting the the problems the
    aforementioned commit tried to avoid.
    
    Handle this more robsutly by deferring the initialization of the
    runstate region until secondary CPUs have been initialized and the
    ARM64_UNMAP_KERNEL_AT_EL0 cpucap has been finalized. The per-cpu work is
    moved into a new hotplug starting function which is registered later
    when we're certain that KPTI will not be used.
    
    Fixes: f88af722 ("xen/arm: do not setup the runstate info page if kpti is enabled")
    Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
    Cc: Bertrand Marquis <bertrand.marquis@arm.com>
    Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Stefano Stabellini <sstabellini@kernel.org>
    Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    20f3b8ea
cpuhotplug.h 17.3 KB