KVM/riscv fixes for 5.18, take #2

- Remove 's' & 'u' as valid ISA extension
 
  - Restrict the extensions that can be disabled
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEZdn75s5e6LHDQ+f/rUjsVaLHLAcFAmJhdVEACgkQrUjsVaLH
 LAdpZQ/+JKICZ9bimd25lNZSDecvVpMApg6FYmNyYFoMT917+VaNIQIQJt54NZk5
 9yeP8eBdoTLEzj48Ib0EYHmBCXEve2Tzj8pQ9FiP34YWCHK+zxytagGoRcSaqsXH
 VObLiezwzNknBg6on8gzTh7woxW6EE+KQ7N+gxarVizFBUG4dicSGfDL8fXr7W2g
 /mJjs1zJOGD02rz9X/02PHMWXFTL1QEQH5HZHCi5NV2Xh8nFiJUcgEjx9eaweY0V
 56cDRGEj7/P+QI3Ulr6f5Vy897aGNr1JR9XHEMCQ2qkgeOtinRYSp7w008x5FcCE
 1PbfZAr51J4B4VbN+sbgQiX64hRyZJ46SPZIrvYp9mJWfY5FALweI51ikzVzkLbW
 TWLNXTM8QofzUjtNmGr7by4Fr0/5XYwS2TTZ6ScQEREg/rMLg0blG3F5AnlVFVF9
 TUFeNjaAnenjMRE+tfNSF2BF/K4u43gFkVx/FTL2cFPIXrUwuRvveZ1YCls9zVFt
 4xM0EpVAsaYVsnzW9qxDyU7Fs0RInTvSmt+2lu0ZxhWdF4P/NzuRogIJ0M8j58d6
 BDcHH77yb+tSDjMTo68112WvEWVLYK1upDYh8RBdRitccrcgflibQDjwgLjf97iP
 gRXkt5klHSElAnFZ7yFNKKzXd1tF2TPU8QNvu+2z2T4OMefifY4=
 =RKx8
 -----END PGP SIGNATURE-----

Merge tag 'kvm-riscv-fixes-5.18-2' of https://github.com/kvm-riscv/linux into HEAD

KVM/riscv fixes for 5.18, take #2

- Remove 's' & 'u' as valid ISA extension

- Do not allow disabling the base extensions 'i'/'m'/'a'/'c'
This commit is contained in:
Paolo Bonzini 2022-04-21 11:58:57 -04:00
commit 012c722569
1 changed files with 12 additions and 9 deletions

View File

@ -38,14 +38,16 @@ const struct kvm_stats_header kvm_vcpu_stats_header = {
sizeof(kvm_vcpu_stats_desc),
};
#define KVM_RISCV_ISA_ALLOWED (riscv_isa_extension_mask(a) | \
riscv_isa_extension_mask(c) | \
riscv_isa_extension_mask(d) | \
riscv_isa_extension_mask(f) | \
riscv_isa_extension_mask(i) | \
riscv_isa_extension_mask(m) | \
riscv_isa_extension_mask(s) | \
riscv_isa_extension_mask(u))
#define KVM_RISCV_ISA_DISABLE_ALLOWED (riscv_isa_extension_mask(d) | \
riscv_isa_extension_mask(f))
#define KVM_RISCV_ISA_DISABLE_NOT_ALLOWED (riscv_isa_extension_mask(a) | \
riscv_isa_extension_mask(c) | \
riscv_isa_extension_mask(i) | \
riscv_isa_extension_mask(m))
#define KVM_RISCV_ISA_ALLOWED (KVM_RISCV_ISA_DISABLE_ALLOWED | \
KVM_RISCV_ISA_DISABLE_NOT_ALLOWED)
static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu)
{
@ -219,7 +221,8 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
switch (reg_num) {
case KVM_REG_RISCV_CONFIG_REG(isa):
if (!vcpu->arch.ran_atleast_once) {
vcpu->arch.isa = reg_val;
/* Ignore the disable request for these extensions */
vcpu->arch.isa = reg_val | KVM_RISCV_ISA_DISABLE_NOT_ALLOWED;
vcpu->arch.isa &= riscv_isa_extension_base(NULL);
vcpu->arch.isa &= KVM_RISCV_ISA_ALLOWED;
kvm_riscv_vcpu_fp_reset(vcpu);