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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
"Bugfixes for x86 and s390"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: nVMX: avoid NULL pointer dereference with incorrect EVMCS GPAs
KVM: x86: Initializing all kvm_lapic_irq fields in ioapic_write_indirect
KVM: VMX: Condition ENCLS-exiting enabling on CPU support for SGX1
KVM: s390: Also reset registers in sync regs for initial cpu reset
KVM: fix Kconfig menu text for -Werror
KVM: x86: remove stale comment from struct x86_emulate_ctxt
KVM: x86: clear stale x86_emulate_ctxt->intercept value
KVM: SVM: Fix the svm vmexit code for WRMSR
KVM: X86: Fix dereference null cpufreq policy

+48 -13
+17 -1
arch/s390/kvm/kvm-s390.c
··· 3268 3268 /* Initial reset is a superset of the normal reset */ 3269 3269 kvm_arch_vcpu_ioctl_normal_reset(vcpu); 3270 3270 3271 - /* this equals initial cpu reset in pop, but we don't switch to ESA */ 3271 + /* 3272 + * This equals initial cpu reset in pop, but we don't switch to ESA. 3273 + * We do not only reset the internal data, but also ... 3274 + */ 3272 3275 vcpu->arch.sie_block->gpsw.mask = 0; 3273 3276 vcpu->arch.sie_block->gpsw.addr = 0; 3274 3277 kvm_s390_set_prefix(vcpu, 0); ··· 3281 3278 memset(vcpu->arch.sie_block->gcr, 0, sizeof(vcpu->arch.sie_block->gcr)); 3282 3279 vcpu->arch.sie_block->gcr[0] = CR0_INITIAL_MASK; 3283 3280 vcpu->arch.sie_block->gcr[14] = CR14_INITIAL_MASK; 3281 + 3282 + /* ... the data in sync regs */ 3283 + memset(vcpu->run->s.regs.crs, 0, sizeof(vcpu->run->s.regs.crs)); 3284 + vcpu->run->s.regs.ckc = 0; 3285 + vcpu->run->s.regs.crs[0] = CR0_INITIAL_MASK; 3286 + vcpu->run->s.regs.crs[14] = CR14_INITIAL_MASK; 3287 + vcpu->run->psw_addr = 0; 3288 + vcpu->run->psw_mask = 0; 3289 + vcpu->run->s.regs.todpr = 0; 3290 + vcpu->run->s.regs.cputm = 0; 3291 + vcpu->run->s.regs.ckc = 0; 3292 + vcpu->run->s.regs.pp = 0; 3293 + vcpu->run->s.regs.gbea = 1; 3284 3294 vcpu->run->s.regs.fpc = 0; 3285 3295 vcpu->arch.sie_block->gbea = 1; 3286 3296 vcpu->arch.sie_block->pp = 0;
-1
arch/x86/include/asm/kvm_emulate.h
··· 360 360 u64 d; 361 361 unsigned long _eip; 362 362 struct operand memop; 363 - /* Fields above regs are cleared together. */ 364 363 unsigned long _regs[NR_VCPU_REGS]; 365 364 struct operand *memopp; 366 365 struct fetch_cache fetch;
+1 -1
arch/x86/kvm/Kconfig
··· 68 68 depends on (X86_64 && !KASAN) || !COMPILE_TEST 69 69 depends on EXPERT 70 70 help 71 - Add -Werror to the build flags for (and only for) i915.ko. 71 + Add -Werror to the build flags for KVM. 72 72 73 73 If in doubt, say "N". 74 74
+1
arch/x86/kvm/emulate.c
··· 5173 5173 ctxt->fetch.ptr = ctxt->fetch.data; 5174 5174 ctxt->fetch.end = ctxt->fetch.data + insn_len; 5175 5175 ctxt->opcode_len = 1; 5176 + ctxt->intercept = x86_intercept_none; 5176 5177 if (insn_len > 0) 5177 5178 memcpy(ctxt->fetch.data, insn, insn_len); 5178 5179 else {
+5 -2
arch/x86/kvm/ioapic.c
··· 378 378 if (e->fields.delivery_mode == APIC_DM_FIXED) { 379 379 struct kvm_lapic_irq irq; 380 380 381 - irq.shorthand = APIC_DEST_NOSHORT; 382 381 irq.vector = e->fields.vector; 383 382 irq.delivery_mode = e->fields.delivery_mode << 8; 384 - irq.dest_id = e->fields.dest_id; 385 383 irq.dest_mode = 386 384 kvm_lapic_irq_dest_mode(!!e->fields.dest_mode); 385 + irq.level = false; 386 + irq.trig_mode = e->fields.trig_mode; 387 + irq.shorthand = APIC_DEST_NOSHORT; 388 + irq.dest_id = e->fields.dest_id; 389 + irq.msi_redir_hint = false; 387 390 bitmap_zero(&vcpu_bitmap, 16); 388 391 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq, 389 392 &vcpu_bitmap);
+2 -1
arch/x86/kvm/svm.c
··· 6312 6312 enum exit_fastpath_completion *exit_fastpath) 6313 6313 { 6314 6314 if (!is_guest_mode(vcpu) && 6315 - to_svm(vcpu)->vmcb->control.exit_code == EXIT_REASON_MSR_WRITE) 6315 + to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_MSR && 6316 + to_svm(vcpu)->vmcb->control.exit_info_1) 6316 6317 *exit_fastpath = handle_fastpath_set_msr_irqoff(vcpu); 6317 6318 } 6318 6319
+3 -2
arch/x86/kvm/vmx/nested.c
··· 224 224 return; 225 225 226 226 kvm_vcpu_unmap(vcpu, &vmx->nested.hv_evmcs_map, true); 227 - vmx->nested.hv_evmcs_vmptr = -1ull; 227 + vmx->nested.hv_evmcs_vmptr = 0; 228 228 vmx->nested.hv_evmcs = NULL; 229 229 } 230 230 ··· 1923 1923 if (!nested_enlightened_vmentry(vcpu, &evmcs_gpa)) 1924 1924 return 1; 1925 1925 1926 - if (unlikely(evmcs_gpa != vmx->nested.hv_evmcs_vmptr)) { 1926 + if (unlikely(!vmx->nested.hv_evmcs || 1927 + evmcs_gpa != vmx->nested.hv_evmcs_vmptr)) { 1927 1928 if (!vmx->nested.hv_evmcs) 1928 1929 vmx->nested.current_vmptr = -1ull; 1929 1930
+14 -2
arch/x86/kvm/vmx/vmx.c
··· 2338 2338 kvm_cpu_vmxoff(); 2339 2339 } 2340 2340 2341 + /* 2342 + * There is no X86_FEATURE for SGX yet, but anyway we need to query CPUID 2343 + * directly instead of going through cpu_has(), to ensure KVM is trapping 2344 + * ENCLS whenever it's supported in hardware. It does not matter whether 2345 + * the host OS supports or has enabled SGX. 2346 + */ 2347 + static bool cpu_has_sgx(void) 2348 + { 2349 + return cpuid_eax(0) >= 0x12 && (cpuid_eax(0x12) & BIT(0)); 2350 + } 2351 + 2341 2352 static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, 2342 2353 u32 msr, u32 *result) 2343 2354 { ··· 2429 2418 SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE | 2430 2419 SECONDARY_EXEC_PT_USE_GPA | 2431 2420 SECONDARY_EXEC_PT_CONCEAL_VMX | 2432 - SECONDARY_EXEC_ENABLE_VMFUNC | 2433 - SECONDARY_EXEC_ENCLS_EXITING; 2421 + SECONDARY_EXEC_ENABLE_VMFUNC; 2422 + if (cpu_has_sgx()) 2423 + opt2 |= SECONDARY_EXEC_ENCLS_EXITING; 2434 2424 if (adjust_vmx_controls(min2, opt2, 2435 2425 MSR_IA32_VMX_PROCBASED_CTLS2, 2436 2426 &_cpu_based_2nd_exec_control) < 0)
+5 -3
arch/x86/kvm/x86.c
··· 7195 7195 7196 7196 cpu = get_cpu(); 7197 7197 policy = cpufreq_cpu_get(cpu); 7198 - if (policy && policy->cpuinfo.max_freq) 7199 - max_tsc_khz = policy->cpuinfo.max_freq; 7198 + if (policy) { 7199 + if (policy->cpuinfo.max_freq) 7200 + max_tsc_khz = policy->cpuinfo.max_freq; 7201 + cpufreq_cpu_put(policy); 7202 + } 7200 7203 put_cpu(); 7201 - cpufreq_cpu_put(policy); 7202 7204 #endif 7203 7205 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, 7204 7206 CPUFREQ_TRANSITION_NOTIFIER);