Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: nv: Allow userspace to set PSR_MODE_EL2x

We were not allowing userspace to set a more privileged mode for the VCPU
than EL1, but we should allow this when nested virtualization is enabled
for the VCPU.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230209175820.1939006-6-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

authored by

Christoffer Dall and committed by
Oliver Upton
1d05d51b 2fb32357

+6
+6
arch/arm64/kvm/guest.c
··· 24 24 #include <asm/fpsimd.h> 25 25 #include <asm/kvm.h> 26 26 #include <asm/kvm_emulate.h> 27 + #include <asm/kvm_nested.h> 27 28 #include <asm/sigcontext.h> 28 29 29 30 #include "trace.h" ··· 254 253 if (!vcpu_el1_is_32bit(vcpu)) 255 254 return -EINVAL; 256 255 break; 256 + case PSR_MODE_EL2h: 257 + case PSR_MODE_EL2t: 258 + if (!vcpu_has_nv(vcpu)) 259 + return -EINVAL; 260 + fallthrough; 257 261 case PSR_MODE_EL0t: 258 262 case PSR_MODE_EL1t: 259 263 case PSR_MODE_EL1h: