Skip to content

Commit 5c24ba2

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: "x86 guest: - Avoid false positive for check that only matters on AMD processors x86: - Give a hint when Win2016 might fail to boot due to XSAVES && !XSAVEC configuration - Do not allow creating an in-kernel PIT unless an IOAPIC already exists RISC-V: - Allow ISA extensions that were enabled for bare metal in 6.8 (Zbc, scalar and vector crypto, Zfh[min], Zihintntl, Zvfh[min], Zfa) S390: - fix CC for successful PQAP instruction - fix a race when creating a shadow page" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: x86/coco: Define cc_vendor without CONFIG_ARCH_HAS_CC_PLATFORM x86/kvm: Fix SEV check in sev_map_percpu_data() KVM: x86: Give a hint when Win2016 might fail to boot due to XSAVES erratum KVM: x86: Check irqchip mode before create PIT KVM: riscv: selftests: Add Zfa extension to get-reg-list test RISC-V: KVM: Allow Zfa extension for Guest/VM KVM: riscv: selftests: Add Zvfh[min] extensions to get-reg-list test RISC-V: KVM: Allow Zvfh[min] extensions for Guest/VM KVM: riscv: selftests: Add Zihintntl extension to get-reg-list test RISC-V: KVM: Allow Zihintntl extension for Guest/VM KVM: riscv: selftests: Add Zfh[min] extensions to get-reg-list test RISC-V: KVM: Allow Zfh[min] extensions for Guest/VM KVM: riscv: selftests: Add vector crypto extensions to get-reg-list test RISC-V: KVM: Allow vector crypto extensions for Guest/VM KVM: riscv: selftests: Add scaler crypto extensions to get-reg-list test RISC-V: KVM: Allow scalar crypto extensions for Guest/VM KVM: riscv: selftests: Add Zbc extension to get-reg-list test RISC-V: KVM: Allow Zbc extension for Guest/VM KVM: s390: fix cc for successful PQAP KVM: s390: vsie: fix race during shadow creation
2 parents c8d80f8 + e459647 commit 5c24ba2

File tree

12 files changed

+263
-6
lines changed

12 files changed

+263
-6
lines changed

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,33 @@ enum KVM_RISCV_ISA_EXT_ID {
139139
KVM_RISCV_ISA_EXT_ZIHPM,
140140
KVM_RISCV_ISA_EXT_SMSTATEEN,
141141
KVM_RISCV_ISA_EXT_ZICOND,
142+
KVM_RISCV_ISA_EXT_ZBC,
143+
KVM_RISCV_ISA_EXT_ZBKB,
144+
KVM_RISCV_ISA_EXT_ZBKC,
145+
KVM_RISCV_ISA_EXT_ZBKX,
146+
KVM_RISCV_ISA_EXT_ZKND,
147+
KVM_RISCV_ISA_EXT_ZKNE,
148+
KVM_RISCV_ISA_EXT_ZKNH,
149+
KVM_RISCV_ISA_EXT_ZKR,
150+
KVM_RISCV_ISA_EXT_ZKSED,
151+
KVM_RISCV_ISA_EXT_ZKSH,
152+
KVM_RISCV_ISA_EXT_ZKT,
153+
KVM_RISCV_ISA_EXT_ZVBB,
154+
KVM_RISCV_ISA_EXT_ZVBC,
155+
KVM_RISCV_ISA_EXT_ZVKB,
156+
KVM_RISCV_ISA_EXT_ZVKG,
157+
KVM_RISCV_ISA_EXT_ZVKNED,
158+
KVM_RISCV_ISA_EXT_ZVKNHA,
159+
KVM_RISCV_ISA_EXT_ZVKNHB,
160+
KVM_RISCV_ISA_EXT_ZVKSED,
161+
KVM_RISCV_ISA_EXT_ZVKSH,
162+
KVM_RISCV_ISA_EXT_ZVKT,
163+
KVM_RISCV_ISA_EXT_ZFH,
164+
KVM_RISCV_ISA_EXT_ZFHMIN,
165+
KVM_RISCV_ISA_EXT_ZIHINTNTL,
166+
KVM_RISCV_ISA_EXT_ZVFH,
167+
KVM_RISCV_ISA_EXT_ZVFHMIN,
168+
KVM_RISCV_ISA_EXT_ZFA,
142169
KVM_RISCV_ISA_EXT_MAX,
143170
};
144171

arch/riscv/kvm/vcpu_onereg.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,42 @@ static const unsigned long kvm_isa_ext_arr[] = {
4242
KVM_ISA_EXT_ARR(SVPBMT),
4343
KVM_ISA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vcpu_base2isa_ext(unsigned long base_ext)
@@ -92,13 +119,40 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)
92119
case KVM_RISCV_ISA_EXT_SVNAPOT:
93120
case KVM_RISCV_ISA_EXT_ZBA:
94121
case KVM_RISCV_ISA_EXT_ZBB:
122+
case KVM_RISCV_ISA_EXT_ZBC:
123+
case KVM_RISCV_ISA_EXT_ZBKB:
124+
case KVM_RISCV_ISA_EXT_ZBKC:
125+
case KVM_RISCV_ISA_EXT_ZBKX:
95126
case KVM_RISCV_ISA_EXT_ZBS:
127+
case KVM_RISCV_ISA_EXT_ZFA:
128+
case KVM_RISCV_ISA_EXT_ZFH:
129+
case KVM_RISCV_ISA_EXT_ZFHMIN:
96130
case KVM_RISCV_ISA_EXT_ZICNTR:
97131
case KVM_RISCV_ISA_EXT_ZICOND:
98132
case KVM_RISCV_ISA_EXT_ZICSR:
99133
case KVM_RISCV_ISA_EXT_ZIFENCEI:
134+
case KVM_RISCV_ISA_EXT_ZIHINTNTL:
100135
case KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
101136
case KVM_RISCV_ISA_EXT_ZIHPM:
137+
case KVM_RISCV_ISA_EXT_ZKND:
138+
case KVM_RISCV_ISA_EXT_ZKNE:
139+
case KVM_RISCV_ISA_EXT_ZKNH:
140+
case KVM_RISCV_ISA_EXT_ZKR:
141+
case KVM_RISCV_ISA_EXT_ZKSED:
142+
case KVM_RISCV_ISA_EXT_ZKSH:
143+
case KVM_RISCV_ISA_EXT_ZKT:
144+
case KVM_RISCV_ISA_EXT_ZVBB:
145+
case KVM_RISCV_ISA_EXT_ZVBC:
146+
case KVM_RISCV_ISA_EXT_ZVFH:
147+
case KVM_RISCV_ISA_EXT_ZVFHMIN:
148+
case KVM_RISCV_ISA_EXT_ZVKB:
149+
case KVM_RISCV_ISA_EXT_ZVKG:
150+
case KVM_RISCV_ISA_EXT_ZVKNED:
151+
case KVM_RISCV_ISA_EXT_ZVKNHA:
152+
case KVM_RISCV_ISA_EXT_ZVKNHB:
153+
case KVM_RISCV_ISA_EXT_ZVKSED:
154+
case KVM_RISCV_ISA_EXT_ZVKSH:
155+
case KVM_RISCV_ISA_EXT_ZVKT:
102156
return false;
103157
/* Extensions which can be disabled using Smstateen */
104158
case KVM_RISCV_ISA_EXT_SSAIA:

arch/s390/kvm/priv.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,12 @@ static int handle_pqap(struct kvm_vcpu *vcpu)
676676
if (vcpu->kvm->arch.crypto.pqap_hook) {
677677
pqap_hook = *vcpu->kvm->arch.crypto.pqap_hook;
678678
ret = pqap_hook(vcpu);
679-
if (!ret && vcpu->run->s.regs.gprs[1] & 0x00ff0000)
680-
kvm_s390_set_psw_cc(vcpu, 3);
679+
if (!ret) {
680+
if (vcpu->run->s.regs.gprs[1] & 0x00ff0000)
681+
kvm_s390_set_psw_cc(vcpu, 3);
682+
else
683+
kvm_s390_set_psw_cc(vcpu, 0);
684+
}
681685
up_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem);
682686
return ret;
683687
}

arch/s390/kvm/vsie.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,6 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
12351235
gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
12361236
if (IS_ERR(gmap))
12371237
return PTR_ERR(gmap);
1238-
gmap->private = vcpu->kvm;
12391238
vcpu->kvm->stat.gmap_shadow_create++;
12401239
WRITE_ONCE(vsie_page->gmap, gmap);
12411240
return 0;

arch/s390/mm/gmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
16911691
return ERR_PTR(-ENOMEM);
16921692
new->mm = parent->mm;
16931693
new->parent = gmap_get(parent);
1694+
new->private = parent->private;
16941695
new->orig_asce = asce;
16951696
new->edat_level = edat_level;
16961697
new->initialized = false;

arch/x86/include/asm/coco.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ enum cc_vendor {
1010
CC_VENDOR_INTEL,
1111
};
1212

13-
extern enum cc_vendor cc_vendor;
14-
1513
#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
14+
extern enum cc_vendor cc_vendor;
1615
void cc_set_mask(u64 mask);
1716
u64 cc_mkenc(u64 val);
1817
u64 cc_mkdec(u64 val);
1918
#else
19+
#define cc_vendor (CC_VENDOR_NONE)
20+
2021
static inline u64 cc_mkenc(u64 val)
2122
{
2223
return val;

arch/x86/include/asm/kvm_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,8 @@ struct kvm_hv {
11451145
unsigned int synic_auto_eoi_used;
11461146

11471147
struct kvm_hv_syndbg hv_syndbg;
1148+
1149+
bool xsaves_xsavec_checked;
11481150
};
11491151
#endif
11501152

arch/x86/kernel/kvm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ static void __init sev_map_percpu_data(void)
434434
{
435435
int cpu;
436436

437-
if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
437+
if (cc_vendor != CC_VENDOR_AMD ||
438+
!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
438439
return;
439440

440441
for_each_possible_cpu(cpu) {

arch/x86/kvm/hyperv.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,56 @@ static bool hv_check_msr_access(struct kvm_vcpu_hv *hv_vcpu, u32 msr)
13221322
return false;
13231323
}
13241324

1325+
#define KVM_HV_WIN2016_GUEST_ID 0x1040a00003839
1326+
#define KVM_HV_WIN2016_GUEST_ID_MASK (~GENMASK_ULL(23, 16)) /* mask out the service version */
1327+
1328+
/*
1329+
* Hyper-V enabled Windows Server 2016 SMP VMs fail to boot in !XSAVES && XSAVEC
1330+
* configuration.
1331+
* Such configuration can result from, for example, AMD Erratum 1386 workaround.
1332+
*
1333+
* Print a notice so users aren't left wondering what's suddenly gone wrong.
1334+
*/
1335+
static void __kvm_hv_xsaves_xsavec_maybe_warn(struct kvm_vcpu *vcpu)
1336+
{
1337+
struct kvm *kvm = vcpu->kvm;
1338+
struct kvm_hv *hv = to_kvm_hv(kvm);
1339+
1340+
/* Check again under the hv_lock. */
1341+
if (hv->xsaves_xsavec_checked)
1342+
return;
1343+
1344+
if ((hv->hv_guest_os_id & KVM_HV_WIN2016_GUEST_ID_MASK) !=
1345+
KVM_HV_WIN2016_GUEST_ID)
1346+
return;
1347+
1348+
hv->xsaves_xsavec_checked = true;
1349+
1350+
/* UP configurations aren't affected */
1351+
if (atomic_read(&kvm->online_vcpus) < 2)
1352+
return;
1353+
1354+
if (guest_cpuid_has(vcpu, X86_FEATURE_XSAVES) ||
1355+
!guest_cpuid_has(vcpu, X86_FEATURE_XSAVEC))
1356+
return;
1357+
1358+
pr_notice_ratelimited("Booting SMP Windows KVM VM with !XSAVES && XSAVEC. "
1359+
"If it fails to boot try disabling XSAVEC in the VM config.\n");
1360+
}
1361+
1362+
void kvm_hv_xsaves_xsavec_maybe_warn(struct kvm_vcpu *vcpu)
1363+
{
1364+
struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
1365+
1366+
if (!vcpu->arch.hyperv_enabled ||
1367+
hv->xsaves_xsavec_checked)
1368+
return;
1369+
1370+
mutex_lock(&hv->hv_lock);
1371+
__kvm_hv_xsaves_xsavec_maybe_warn(vcpu);
1372+
mutex_unlock(&hv->hv_lock);
1373+
}
1374+
13251375
static int kvm_hv_set_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data,
13261376
bool host)
13271377
{

arch/x86/kvm/hyperv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
182182
struct pvclock_vcpu_time_info *hv_clock);
183183
void kvm_hv_request_tsc_page_update(struct kvm *kvm);
184184

185+
void kvm_hv_xsaves_xsavec_maybe_warn(struct kvm_vcpu *vcpu);
186+
185187
void kvm_hv_init_vm(struct kvm *kvm);
186188
void kvm_hv_destroy_vm(struct kvm *kvm);
187189
int kvm_hv_vcpu_init(struct kvm_vcpu *vcpu);
@@ -267,6 +269,7 @@ int kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu);
267269
static inline void kvm_hv_setup_tsc_page(struct kvm *kvm,
268270
struct pvclock_vcpu_time_info *hv_clock) {}
269271
static inline void kvm_hv_request_tsc_page_update(struct kvm *kvm) {}
272+
static inline void kvm_hv_xsaves_xsavec_maybe_warn(struct kvm_vcpu *vcpu) {}
270273
static inline void kvm_hv_init_vm(struct kvm *kvm) {}
271274
static inline void kvm_hv_destroy_vm(struct kvm *kvm) {}
272275
static inline int kvm_hv_vcpu_init(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)