• Marc Zyngier's avatar
    KVM: arm64: Fix 32bit PC wrap-around · 0225fd5e
    Marc Zyngier authored
    In the unlikely event that a 32bit vcpu traps into the hypervisor
    on an instruction that is located right at the end of the 32bit
    range, the emulation of that instruction is going to increment
    PC past the 32bit range. This isn't great, as userspace can then
    observe this value and get a bit confused.
    
    Conversly, userspace can do things like (in the context of a 64bit
    guest that is capable of 32bit EL0) setting PSTATE to AArch64-EL0,
    set PC to a 64bit value, change PSTATE to AArch32-USR, and observe
    that PC hasn't been truncated. More confusion.
    
    Fix both by:
    - truncating PC increments for 32bit guests
    - sanitizing all 32bit regs every time a core reg is changed by
      userspace, and that PSTATE indicates a 32bit mode.
    
    Cc: stable@vger.kernel.org
    Acked-by: default avatarWill Deacon <will@kernel.org>
    Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
    0225fd5e
guest.c 22.2 KB