History

Merge branch 'kvm-updates/3.4' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull a few KVM fixes from Avi Kivity: "A bunch of powerpc KVM fixes, a guest and a host RCU fix (unrelated), and a small build fix." * 'kvm-updates/3.4' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: Resolve RCU vs. async page fault problem KVM: VMX: vmx_set_cr0 expects kvm->srcu locked KVM: PMU: Fix integer constant is too large warning in kvm_pmu_set_msr() KVM: PPC: Book3S: PR: Fix preemption KVM: PPC: Save/Restore CR over vcpu_run KVM: PPC: Book3S HV: Save and restore CR in __kvmppc_vcore_entry KVM: PPC: Book3S HV: Fix kvm_alloc_linear in case where no linears exist KVM: PPC: Book3S: Compile fix for ppc32 in HIOR access code

Linus Torvalds committed 14 years ago

Commit a3fac082 parents 664481e e0875928 files · +36 −12Browse files

Unified · Split

8 files
  1. arch/powerpc/kvm/book3s_hv_builtin.c +5 −4
  2. arch/powerpc/kvm/book3s_hv_interrupts.S +6 −2
  3. arch/powerpc/kvm/book3s_interrupts.S +7 −0
  4. arch/powerpc/kvm/book3s_pr.c +5 −4
  5. arch/powerpc/kvm/booke_interrupts.S +6 −1
  6. arch/x86/kernel/kvm.c +4 −0
  7. arch/x86/kvm/pmu.c +1 −1
  8. arch/x86/kvm/vmx.c +2 −0
arch/powerpc/kvm/book3s_hv_builtin.c+5−4
@@ -173,9 +173,9 @@ static void __init kvm_linear_init_one(ulong size, int count, int type) · 172 unmodified lines
173173
174174 static struct kvmppc_linear_info *kvm_alloc_linear(int type)
175175 {
176− struct kvmppc_linear_info *ri;
176+ struct kvmppc_linear_info *ri, *ret;
177177
178− ri = NULL;
178+ ret = NULL;
179179 spin_lock(&linear_lock);
180180 list_for_each_entry(ri, &free_linears, list) {
181181 if (ri->type != type)
@@ -183,11 +183,12 @@ static struct kvmppc_linear_info *kvm_alloc_linear(int type) · 1 unmodified line
183183
184184 list_del(&ri->list);
185185 atomic_inc(&ri->use_count);
186+ memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT);
187+ ret = ri;
186188 break;
187189 }
188190 spin_unlock(&linear_lock);
189− memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT);
190− return ri;
191+ return ret;
191192 }
192193
193194 static void kvm_release_linear(struct kvmppc_linear_info *ri)
arch/powerpc/kvm/book3s_hv_interrupts.S+6−2
@@ -46,8 +46,10 @@ _GLOBAL(__kvmppc_vcore_entry) · 45 unmodified lines
4646 /* Save host state to the stack */
4747 stdu r1, -SWITCH_FRAME_SIZE(r1)
4848
49− /* Save non-volatile registers (r14 - r31) */
49+ /* Save non-volatile registers (r14 - r31) and CR */
5050 SAVE_NVGPRS(r1)
51+ mfcr r3
52+ std r3, _CCR(r1)
5153
5254 /* Save host DSCR */
5355 BEGIN_FTR_SECTION
@@ -157,8 +159,10 @@ kvmppc_handler_highmem: · 103 unmodified lines
157159 * R13 = PACA
158160 */
159161
160− /* Restore non-volatile host registers (r14 - r31) */
162+ /* Restore non-volatile host registers (r14 - r31) and CR */
161163 REST_NVGPRS(r1)
164+ ld r4, _CCR(r1)
165+ mtcr r4
162166
163167 addi r1, r1, SWITCH_FRAME_SIZE
164168 ld r0, PPC_LR_STKOFF(r1)
arch/powerpc/kvm/book3s_interrupts.S+7−0
@@ -84,6 +84,10 @@ kvm_start_entry: · 83 unmodified lines
8484 /* Save non-volatile registers (r14 - r31) */
8585 SAVE_NVGPRS(r1)
8686
87+ /* Save CR */
88+ mfcr r14
89+ stw r14, _CCR(r1)
90+
8791 /* Save LR */
8892 PPC_STL r0, _LINK(r1)
8993
@@ -165,6 +169,9 @@ kvm_exit_loop: · 75 unmodified lines
165169 PPC_LL r4, _LINK(r1)
166170 mtlr r4
167171
172+ lwz r14, _CCR(r1)
173+ mtcr r14
174+
168175 /* Restore non-volatile host registers (r14 - r31) */
169176 REST_NVGPRS(r1)
170177
arch/powerpc/kvm/book3s_pr.c+5−4
@@ -777,6 +777,7 @@ program_interrupt: · 776 unmodified lines
777777 }
778778 }
779779
780+ preempt_disable();
780781 if (!(r & RESUME_HOST)) {
781782 /* To avoid clobbering exit_reason, only check for signals if
782783 * we aren't already exiting to userspace for some other
@@ -798,8 +799,6 @@ program_interrupt: · 15 unmodified lines
798799 run->exit_reason = KVM_EXIT_INTR;
799800 r = -EINTR;
800801 } else {
801− preempt_disable();
802−
803802 /* In case an interrupt came in that was triggered
804803 * from userspace (like DEC), we need to check what
805804 * to inject now! */
@@ -881,7 +880,8 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 75 unmodified lines
881880
882881 switch (reg->id) {
883882 case KVM_REG_PPC_HIOR:
884− r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
883+ r = copy_to_user((u64 __user *)(long)reg->addr,
884+ &to_book3s(vcpu)->hior, sizeof(u64));
885885 break;
886886 default:
887887 break;
@@ -896,7 +896,8 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 8 unmodified lines
896896
897897 switch (reg->id) {
898898 case KVM_REG_PPC_HIOR:
899− r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
899+ r = copy_from_user(&to_book3s(vcpu)->hior,
900+ (u64 __user *)(long)reg->addr, sizeof(u64));
900901 if (!r)
901902 to_book3s(vcpu)->hior_explicit = true;
902903 break;
arch/powerpc/kvm/booke_interrupts.S+6−1
@@ -34,7 +34,8 @@ · 33 unmodified lines
3434 /* r2 is special: it holds 'current', and it made nonvolatile in the
3535 * kernel with the -ffixed-r2 gcc option. */
3636 #define HOST_R2 12
37−#define HOST_NV_GPRS 16
37+#define HOST_CR 16
38+#define HOST_NV_GPRS 20
3839 #define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4))
3940 #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4)
4041 #define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
@@ -296,8 +297,10 @@ heavyweight_exit: · 255 unmodified lines
296297
297298 /* Return to kvm_vcpu_run(). */
298299 lwz r4, HOST_STACK_LR(r1)
300+ lwz r5, HOST_CR(r1)
299301 addi r1, r1, HOST_STACK_SIZE
300302 mtlr r4
303+ mtcr r5
301304 /* r3 still contains the return code from kvmppc_handle_exit(). */
302305 blr
303306
@@ -314,6 +317,8 @@ _GLOBAL(__kvmppc_vcpu_run) · 10 unmodified lines
314317 stw r3, HOST_RUN(r1)
315318 mflr r3
316319 stw r3, HOST_STACK_LR(r1)
320+ mfcr r5
321+ stw r5, HOST_CR(r1)
317322
318323 /* Save host non-volatile register state to stack. */
319324 stw r14, HOST_NV_GPR(r14)(r1)
arch/x86/kernel/kvm.c+4−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include <asm/traps.h>
3939 #include <asm/desc.h>
4040 #include <asm/tlbflush.h>
41+#include <asm/idle.h>
4142
4243 static int kvmapf = 1;
4344
@@ -253,7 +254,10 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code) · 209 unmodified lines
253254 kvm_async_pf_task_wait((u32)read_cr2());
254255 break;
255256 case KVM_PV_REASON_PAGE_READY:
257+ rcu_irq_enter();
258+ exit_idle();
256259 kvm_async_pf_task_wake((u32)read_cr2());
260+ rcu_irq_exit();
257261 break;
258262 }
259263 }
arch/x86/kvm/pmu.c+1−1
@@ -369,7 +369,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data) · 368 unmodified lines
369369 case MSR_CORE_PERF_FIXED_CTR_CTRL:
370370 if (pmu->fixed_ctr_ctrl == data)
371371 return 0;
372− if (!(data & 0xfffffffffffff444)) {
372+ if (!(data & 0xfffffffffffff444ull)) {
373373 reprogram_fixed_counters(pmu, data);
374374 return 0;
375375 }
arch/x86/kvm/vmx.c+2−0
@@ -3906,7 +3906,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) · 3905 unmodified lines
39063906 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
39073907
39083908 vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
3909+ vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
39093910 vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */
3911+ srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
39103912 vmx_set_cr4(&vmx->vcpu, 0);
39113913 vmx_set_efer(&vmx->vcpu, 0);
39123914 vmx_fpu_activate(&vmx->vcpu);