diff options
| -rw-r--r-- | arch/powerpc/kvm/book3s_hv_builtin.c | 9 | ||||
| -rw-r--r-- | arch/powerpc/kvm/book3s_hv_interrupts.S | 8 | ||||
| -rw-r--r-- | arch/powerpc/kvm/book3s_interrupts.S | 7 | ||||
| -rw-r--r-- | arch/powerpc/kvm/book3s_pr.c | 9 | ||||
| -rw-r--r-- | arch/powerpc/kvm/booke_interrupts.S | 7 | ||||
| -rw-r--r-- | arch/x86/kernel/kvm.c | 4 | ||||
| -rw-r--r-- | arch/x86/kvm/pmu.c | 2 | ||||
| -rw-r--r-- | arch/x86/kvm/vmx.c | 2 |
8 files changed, 36 insertions, 12 deletions
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c index bed1279aa6a8..e1b60f56f2a1 100644 --- a/arch/powerpc/kvm/book3s_hv_builtin.c +++ b/arch/powerpc/kvm/book3s_hv_builtin.c | |||
| @@ -173,9 +173,9 @@ static void __init kvm_linear_init_one(ulong size, int count, int type) | |||
| 173 | 173 | ||
| 174 | static struct kvmppc_linear_info *kvm_alloc_linear(int type) | 174 | static struct kvmppc_linear_info *kvm_alloc_linear(int type) |
| 175 | { | 175 | { |
| 176 | struct kvmppc_linear_info *ri; | 176 | struct kvmppc_linear_info *ri, *ret; |
| 177 | 177 | ||
| 178 | ri = NULL; | 178 | ret = NULL; |
| 179 | spin_lock(&linear_lock); | 179 | spin_lock(&linear_lock); |
| 180 | list_for_each_entry(ri, &free_linears, list) { | 180 | list_for_each_entry(ri, &free_linears, list) { |
| 181 | if (ri->type != type) | 181 | if (ri->type != type) |
| @@ -183,11 +183,12 @@ static struct kvmppc_linear_info *kvm_alloc_linear(int type) | |||
| 183 | 183 | ||
| 184 | list_del(&ri->list); | 184 | list_del(&ri->list); |
| 185 | atomic_inc(&ri->use_count); | 185 | atomic_inc(&ri->use_count); |
| 186 | memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT); | ||
| 187 | ret = ri; | ||
| 186 | break; | 188 | break; |
| 187 | } | 189 | } |
| 188 | spin_unlock(&linear_lock); | 190 | spin_unlock(&linear_lock); |
| 189 | memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT); | 191 | return ret; |
| 190 | return ri; | ||
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | static void kvm_release_linear(struct kvmppc_linear_info *ri) | 194 | static void kvm_release_linear(struct kvmppc_linear_info *ri) |
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S index 3f7b674dd4bf..d3fb4df02c41 100644 --- a/arch/powerpc/kvm/book3s_hv_interrupts.S +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S | |||
| @@ -46,8 +46,10 @@ _GLOBAL(__kvmppc_vcore_entry) | |||
| 46 | /* Save host state to the stack */ | 46 | /* Save host state to the stack */ |
| 47 | stdu r1, -SWITCH_FRAME_SIZE(r1) | 47 | stdu r1, -SWITCH_FRAME_SIZE(r1) |
| 48 | 48 | ||
| 49 | /* Save non-volatile registers (r14 - r31) */ | 49 | /* Save non-volatile registers (r14 - r31) and CR */ |
| 50 | SAVE_NVGPRS(r1) | 50 | SAVE_NVGPRS(r1) |
| 51 | mfcr r3 | ||
| 52 | std r3, _CCR(r1) | ||
| 51 | 53 | ||
| 52 | /* Save host DSCR */ | 54 | /* Save host DSCR */ |
| 53 | BEGIN_FTR_SECTION | 55 | BEGIN_FTR_SECTION |
| @@ -157,8 +159,10 @@ kvmppc_handler_highmem: | |||
| 157 | * R13 = PACA | 159 | * R13 = PACA |
| 158 | */ | 160 | */ |
| 159 | 161 | ||
| 160 | /* Restore non-volatile host registers (r14 - r31) */ | 162 | /* Restore non-volatile host registers (r14 - r31) and CR */ |
| 161 | REST_NVGPRS(r1) | 163 | REST_NVGPRS(r1) |
| 164 | ld r4, _CCR(r1) | ||
| 165 | mtcr r4 | ||
| 162 | 166 | ||
| 163 | addi r1, r1, SWITCH_FRAME_SIZE | 167 | addi r1, r1, SWITCH_FRAME_SIZE |
| 164 | ld r0, PPC_LR_STKOFF(r1) | 168 | ld r0, PPC_LR_STKOFF(r1) |
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index 0a8515a5c042..3e35383bdb21 100644 --- a/arch/powerpc/kvm/book3s_interrupts.S +++ b/arch/powerpc/kvm/book3s_interrupts.S | |||
| @@ -84,6 +84,10 @@ kvm_start_entry: | |||
| 84 | /* Save non-volatile registers (r14 - r31) */ | 84 | /* Save non-volatile registers (r14 - r31) */ |
| 85 | SAVE_NVGPRS(r1) | 85 | SAVE_NVGPRS(r1) |
| 86 | 86 | ||
| 87 | /* Save CR */ | ||
| 88 | mfcr r14 | ||
| 89 | stw r14, _CCR(r1) | ||
| 90 | |||
| 87 | /* Save LR */ | 91 | /* Save LR */ |
| 88 | PPC_STL r0, _LINK(r1) | 92 | PPC_STL r0, _LINK(r1) |
| 89 | 93 | ||
| @@ -165,6 +169,9 @@ kvm_exit_loop: | |||
| 165 | PPC_LL r4, _LINK(r1) | 169 | PPC_LL r4, _LINK(r1) |
| 166 | mtlr r4 | 170 | mtlr r4 |
| 167 | 171 | ||
| 172 | lwz r14, _CCR(r1) | ||
| 173 | mtcr r14 | ||
| 174 | |||
| 168 | /* Restore non-volatile host registers (r14 - r31) */ | 175 | /* Restore non-volatile host registers (r14 - r31) */ |
| 169 | REST_NVGPRS(r1) | 176 | REST_NVGPRS(r1) |
| 170 | 177 | ||
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 642d88574b07..7759053d391b 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
| @@ -777,6 +777,7 @@ program_interrupt: | |||
| 777 | } | 777 | } |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | preempt_disable(); | ||
| 780 | if (!(r & RESUME_HOST)) { | 781 | if (!(r & RESUME_HOST)) { |
| 781 | /* To avoid clobbering exit_reason, only check for signals if | 782 | /* To avoid clobbering exit_reason, only check for signals if |
| 782 | * we aren't already exiting to userspace for some other | 783 | * we aren't already exiting to userspace for some other |
| @@ -798,8 +799,6 @@ program_interrupt: | |||
| 798 | run->exit_reason = KVM_EXIT_INTR; | 799 | run->exit_reason = KVM_EXIT_INTR; |
| 799 | r = -EINTR; | 800 | r = -EINTR; |
| 800 | } else { | 801 | } else { |
| 801 | preempt_disable(); | ||
| 802 | |||
| 803 | /* In case an interrupt came in that was triggered | 802 | /* In case an interrupt came in that was triggered |
| 804 | * from userspace (like DEC), we need to check what | 803 | * from userspace (like DEC), we need to check what |
| 805 | * to inject now! */ | 804 | * to inject now! */ |
| @@ -881,7 +880,8 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) | |||
| 881 | 880 | ||
| 882 | switch (reg->id) { | 881 | switch (reg->id) { |
| 883 | case KVM_REG_PPC_HIOR: | 882 | 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)); | ||
| 885 | break; | 885 | break; |
| 886 | default: | 886 | default: |
| 887 | break; | 887 | break; |
| @@ -896,7 +896,8 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) | |||
| 896 | 896 | ||
| 897 | switch (reg->id) { | 897 | switch (reg->id) { |
| 898 | case KVM_REG_PPC_HIOR: | 898 | 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)); | ||
| 900 | if (!r) | 901 | if (!r) |
| 901 | to_book3s(vcpu)->hior_explicit = true; | 902 | to_book3s(vcpu)->hior_explicit = true; |
| 902 | break; | 903 | break; |
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S index 10d8ef602e5c..c8c4b878795a 100644 --- a/arch/powerpc/kvm/booke_interrupts.S +++ b/arch/powerpc/kvm/booke_interrupts.S | |||
| @@ -34,7 +34,8 @@ | |||
| 34 | /* r2 is special: it holds 'current', and it made nonvolatile in the | 34 | /* r2 is special: it holds 'current', and it made nonvolatile in the |
| 35 | * kernel with the -ffixed-r2 gcc option. */ | 35 | * kernel with the -ffixed-r2 gcc option. */ |
| 36 | #define HOST_R2 12 | 36 | #define HOST_R2 12 |
| 37 | #define HOST_NV_GPRS 16 | 37 | #define HOST_CR 16 |
| 38 | #define HOST_NV_GPRS 20 | ||
| 38 | #define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4)) | 39 | #define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4)) |
| 39 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4) | 40 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4) |
| 40 | #define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */ | 41 | #define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */ |
| @@ -296,8 +297,10 @@ heavyweight_exit: | |||
| 296 | 297 | ||
| 297 | /* Return to kvm_vcpu_run(). */ | 298 | /* Return to kvm_vcpu_run(). */ |
| 298 | lwz r4, HOST_STACK_LR(r1) | 299 | lwz r4, HOST_STACK_LR(r1) |
| 300 | lwz r5, HOST_CR(r1) | ||
| 299 | addi r1, r1, HOST_STACK_SIZE | 301 | addi r1, r1, HOST_STACK_SIZE |
| 300 | mtlr r4 | 302 | mtlr r4 |
| 303 | mtcr r5 | ||
| 301 | /* r3 still contains the return code from kvmppc_handle_exit(). */ | 304 | /* r3 still contains the return code from kvmppc_handle_exit(). */ |
| 302 | blr | 305 | blr |
| 303 | 306 | ||
| @@ -314,6 +317,8 @@ _GLOBAL(__kvmppc_vcpu_run) | |||
| 314 | stw r3, HOST_RUN(r1) | 317 | stw r3, HOST_RUN(r1) |
| 315 | mflr r3 | 318 | mflr r3 |
| 316 | stw r3, HOST_STACK_LR(r1) | 319 | stw r3, HOST_STACK_LR(r1) |
| 320 | mfcr r5 | ||
| 321 | stw r5, HOST_CR(r1) | ||
| 317 | 322 | ||
| 318 | /* Save host non-volatile register state to stack. */ | 323 | /* Save host non-volatile register state to stack. */ |
| 319 | stw r14, HOST_NV_GPR(r14)(r1) | 324 | stw r14, HOST_NV_GPR(r14)(r1) |
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 694d801bf606..b8ba6e4a27e4 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <asm/traps.h> | 38 | #include <asm/traps.h> |
| 39 | #include <asm/desc.h> | 39 | #include <asm/desc.h> |
| 40 | #include <asm/tlbflush.h> | 40 | #include <asm/tlbflush.h> |
| 41 | #include <asm/idle.h> | ||
| 41 | 42 | ||
| 42 | static int kvmapf = 1; | 43 | static int kvmapf = 1; |
| 43 | 44 | ||
| @@ -253,7 +254,10 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
| 253 | kvm_async_pf_task_wait((u32)read_cr2()); | 254 | kvm_async_pf_task_wait((u32)read_cr2()); |
| 254 | break; | 255 | break; |
| 255 | case KVM_PV_REASON_PAGE_READY: | 256 | case KVM_PV_REASON_PAGE_READY: |
| 257 | rcu_irq_enter(); | ||
| 258 | exit_idle(); | ||
| 256 | kvm_async_pf_task_wake((u32)read_cr2()); | 259 | kvm_async_pf_task_wake((u32)read_cr2()); |
| 260 | rcu_irq_exit(); | ||
| 257 | break; | 261 | break; |
| 258 | } | 262 | } |
| 259 | } | 263 | } |
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index a73f0c104813..173df38dbda5 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c | |||
| @@ -369,7 +369,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data) | |||
| 369 | case MSR_CORE_PERF_FIXED_CTR_CTRL: | 369 | case MSR_CORE_PERF_FIXED_CTR_CTRL: |
| 370 | if (pmu->fixed_ctr_ctrl == data) | 370 | if (pmu->fixed_ctr_ctrl == data) |
| 371 | return 0; | 371 | return 0; |
| 372 | if (!(data & 0xfffffffffffff444)) { | 372 | if (!(data & 0xfffffffffffff444ull)) { |
| 373 | reprogram_fixed_counters(pmu, data); | 373 | reprogram_fixed_counters(pmu, data); |
| 374 | return 0; | 374 | return 0; |
| 375 | } | 375 | } |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 280751c84724..ad85adfef843 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
| @@ -3906,7 +3906,9 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) | |||
| 3906 | vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); | 3906 | vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); |
| 3907 | 3907 | ||
| 3908 | vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; | 3908 | vmx->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; |
| 3909 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
| 3909 | vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ | 3910 | vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ |
| 3911 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | ||
| 3910 | vmx_set_cr4(&vmx->vcpu, 0); | 3912 | vmx_set_cr4(&vmx->vcpu, 0); |
| 3911 | vmx_set_efer(&vmx->vcpu, 0); | 3913 | vmx_set_efer(&vmx->vcpu, 0); |
| 3912 | vmx_fpu_activate(&vmx->vcpu); | 3914 | vmx_fpu_activate(&vmx->vcpu); |
