KVM/arm64 fixes for 5.13, take #2
- Another state update on exit to userspace fix - Prevent the creation of mixed 32/64 VMs -----BEGIN PGP SIGNATURE----- iQJCBAABCgAtFiEEn9UcU+C1Yxj9lZw9I9DQutE9ekMFAmCvdGkPHG1hekBrZXJu ZWwub3JnAAoJECPQ0LrRPXpDyxYP90X4vSdDvewU+xtyD84g4UEyzAnHbjaSWL/i 59vXVqqLPhGkUillWCIdKGWz9q27Ixs1PyMrySIoM+U1hARLQ3MdE2nUBfKZRg9W oLArFSPDYstyGpdG0B5YB8bXiF8ePXesWQ0lwx/02KGKNLo+t5FEeVVg7zf7eVkv 9dwItKtnmU8LiUhGtYrHuogDX9KRuuK7SH+ouF4kwf5FMy24k2IfZSUQP1Sj/hNC oA9iqWCA6XgQkaVLnxqXmPpY6krUDgbQsFZK92XpQRngJa8FoFQr6EMgHBTrBIat LKIIacqKXZQgRk9ala60Jyf4REYZ5600HzaIUhU4cI9EZA7R4zXy6mX+F/PU7b46 NQVXLNYxpzy7ETlzXUApoi8l88mKuR6sJgQrJku1TBu97778MMEjiuk5n51Pjj2F p+bkRx2X5ctEIQx6RNTmVi4VIcF8+dbRqkgChDmaP/9CVXZGn8J6Wd8j28C7B+sJ s3qFeWI/sYvGmf2cBuq6tYHVT9TnVu43Ypq2nhTzwGXdjhbFH1y/I2ZeVUGAvQdl N1/Lg4QWjpm/UNBcFUVUr34rf5GnNgKPkT668Yt0bhsthVOE6YZrK7Szbc+ert+1 QkFWZuglLc014NegHyjUybooTykrvBhDzyTU9PhTQ5YU9hyq81eN+i+LgH+rPJjM UmAVeCo= =lGh1 -----END PGP SIGNATURE----- Merge tag 'kvmarm-fixes-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD KVM/arm64 fixes for 5.13, take #2 - Another state update on exit to userspace fix - Prevent the creation of mixed 32/64 VMs
This commit is contained in:
commit
a3d2ec9d3c
@ -463,4 +463,9 @@ static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
|
||||
vcpu->arch.flags |= KVM_ARM64_INCREMENT_PC;
|
||||
}
|
||||
|
||||
static inline bool vcpu_has_feature(struct kvm_vcpu *vcpu, int feature)
|
||||
{
|
||||
return test_bit(feature, vcpu->arch.features);
|
||||
}
|
||||
|
||||
#endif /* __ARM64_KVM_EMULATE_H__ */
|
||||
|
@ -720,11 +720,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (run->immediate_exit)
|
||||
return -EINTR;
|
||||
|
||||
vcpu_load(vcpu);
|
||||
|
||||
if (run->immediate_exit) {
|
||||
ret = -EINTR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
kvm_sigset_activate(vcpu);
|
||||
|
||||
ret = 1;
|
||||
@ -897,6 +899,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
|
||||
|
||||
kvm_sigset_deactivate(vcpu);
|
||||
|
||||
out:
|
||||
/*
|
||||
* In the unlikely event that we are returning to userspace
|
||||
* with pending exceptions or PC adjustment, commit these
|
||||
|
@ -166,6 +166,25 @@ static int kvm_vcpu_enable_ptrauth(struct kvm_vcpu *vcpu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
struct kvm_vcpu *tmp;
|
||||
bool is32bit;
|
||||
int i;
|
||||
|
||||
is32bit = vcpu_has_feature(vcpu, KVM_ARM_VCPU_EL1_32BIT);
|
||||
if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit)
|
||||
return false;
|
||||
|
||||
/* Check that the vcpus are either all 32bit or all 64bit */
|
||||
kvm_for_each_vcpu(i, tmp, vcpu->kvm) {
|
||||
if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_reset_vcpu - sets core registers and sys_regs to reset value
|
||||
* @vcpu: The VCPU pointer
|
||||
@ -217,13 +236,14 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
|
||||
}
|
||||
}
|
||||
|
||||
if (!vcpu_allowed_register_width(vcpu)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (vcpu->arch.target) {
|
||||
default:
|
||||
if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) {
|
||||
if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
pstate = VCPU_RESET_PSTATE_SVC;
|
||||
} else {
|
||||
pstate = VCPU_RESET_PSTATE_EL1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user