projects
/
powerpc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] md: convert compile time warnings into runtime warnings
[powerpc.git]
/
drivers
/
kvm
/
vmx.c
diff --git
a/drivers/kvm/vmx.c
b/drivers/kvm/vmx.c
index
1e640b8
..
bfa0ce4
100644
(file)
--- a/
drivers/kvm/vmx.c
+++ b/
drivers/kvm/vmx.c
@@
-19,6
+19,7
@@
#include "vmx.h"
#include "kvm_vmx.h"
#include <linux/module.h>
#include "vmx.h"
#include "kvm_vmx.h"
#include <linux/module.h>
+#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/profile.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/profile.h>
@@
-27,7
+28,6
@@
#include "segment_descriptor.h"
#include "segment_descriptor.h"
-
MODULE_AUTHOR("Qumranet");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Qumranet");
MODULE_LICENSE("GPL");
@@
-76,7
+76,7
@@
static const u32 vmx_msr_index[] = {
#endif
MSR_EFER, MSR_K6_STAR,
};
#endif
MSR_EFER, MSR_K6_STAR,
};
-#define NR_VMX_MSR
(sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)
)
+#define NR_VMX_MSR
ARRAY_SIZE(vmx_msr_index
)
static inline int is_page_fault(u32 intr_info)
{
static inline int is_page_fault(u32 intr_info)
{
@@
-204,7
+204,7
@@
static void vmcs_write64(unsigned long field, u64 value)
* Switches to specified vcpu, until a matching vcpu_put(), but assumes
* vcpu mutex is already taken.
*/
* Switches to specified vcpu, until a matching vcpu_put(), but assumes
* vcpu mutex is already taken.
*/
-static
struct kvm_vcpu *
vmx_vcpu_load(struct kvm_vcpu *vcpu)
+static
void
vmx_vcpu_load(struct kvm_vcpu *vcpu)
{
u64 phys_addr = __pa(vcpu->vmcs);
int cpu;
{
u64 phys_addr = __pa(vcpu->vmcs);
int cpu;
@@
-242,7
+242,6
@@
static struct kvm_vcpu *vmx_vcpu_load(struct kvm_vcpu *vcpu)
rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
}
rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
}
- return vcpu;
}
static void vmx_vcpu_put(struct kvm_vcpu *vcpu)
}
static void vmx_vcpu_put(struct kvm_vcpu *vcpu)
@@
-372,10
+371,10
@@
static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
data = vmcs_read32(GUEST_SYSENTER_CS);
break;
case MSR_IA32_SYSENTER_EIP:
data = vmcs_read32(GUEST_SYSENTER_CS);
break;
case MSR_IA32_SYSENTER_EIP:
- data = vmcs_read
32
(GUEST_SYSENTER_EIP);
+ data = vmcs_read
l
(GUEST_SYSENTER_EIP);
break;
case MSR_IA32_SYSENTER_ESP:
break;
case MSR_IA32_SYSENTER_ESP:
- data = vmcs_read
32
(GUEST_SYSENTER_ESP);
+ data = vmcs_read
l
(GUEST_SYSENTER_ESP);
break;
default:
msr = find_msr_entry(vcpu, msr_index);
break;
default:
msr = find_msr_entry(vcpu, msr_index);
@@
-413,15
+412,14
@@
static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
vmcs_write32(GUEST_SYSENTER_CS, data);
break;
case MSR_IA32_SYSENTER_EIP:
vmcs_write32(GUEST_SYSENTER_CS, data);
break;
case MSR_IA32_SYSENTER_EIP:
- vmcs_write
32
(GUEST_SYSENTER_EIP, data);
+ vmcs_write
l
(GUEST_SYSENTER_EIP, data);
break;
case MSR_IA32_SYSENTER_ESP:
break;
case MSR_IA32_SYSENTER_ESP:
- vmcs_write
32
(GUEST_SYSENTER_ESP, data);
+ vmcs_write
l
(GUEST_SYSENTER_ESP, data);
break;
break;
- case MSR_IA32_TIME_STAMP_COUNTER:
{
+ case MSR_IA32_TIME_STAMP_COUNTER:
guest_write_tsc(data);
break;
guest_write_tsc(data);
break;
- }
default:
msr = find_msr_entry(vcpu, msr_index);
if (msr) {
default:
msr = find_msr_entry(vcpu, msr_index);
if (msr) {
@@
-793,6
+791,9
@@
static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
*/
static void vmx_set_cr0_no_modeswitch(struct kvm_vcpu *vcpu, unsigned long cr0)
{
*/
static void vmx_set_cr0_no_modeswitch(struct kvm_vcpu *vcpu, unsigned long cr0)
{
+ if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK))
+ enter_rmode(vcpu);
+
vcpu->rmode.active = ((cr0 & CR0_PE_MASK) == 0);
update_exception_bitmap(vcpu);
vmcs_writel(CR0_READ_SHADOW, cr0);
vcpu->rmode.active = ((cr0 & CR0_PE_MASK) == 0);
update_exception_bitmap(vcpu);
vmcs_writel(CR0_READ_SHADOW, cr0);
@@
-1467,6
+1468,18
@@
static int handle_io(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
return 0;
}
return 0;
}
+static void
+vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall)
+{
+ /*
+ * Patch in the VMCALL instruction:
+ */
+ hypercall[0] = 0x0f;
+ hypercall[1] = 0x01;
+ hypercall[2] = 0xc1;
+ hypercall[3] = 0xc3;
+}
+
static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u64 exit_qualification;
static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u64 exit_qualification;
@@
-1643,6
+1656,12
@@
static int handle_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
return 0;
}
return 0;
}
+static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
+{
+ vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP)+3);
+ return kvm_hypercall(vcpu, kvm_run);
+}
+
/*
* The exit handlers return 1 if the exit was handled fully and guest execution
* may resume. Otherwise they set the kvm_run parameter to indicate what needs
/*
* The exit handlers return 1 if the exit was handled fully and guest execution
* may resume. Otherwise they set the kvm_run parameter to indicate what needs
@@
-1661,6
+1680,7
@@
static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu,
[EXIT_REASON_MSR_WRITE] = handle_wrmsr,
[EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window,
[EXIT_REASON_HLT] = handle_halt,
[EXIT_REASON_MSR_WRITE] = handle_wrmsr,
[EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window,
[EXIT_REASON_HLT] = handle_halt,
+ [EXIT_REASON_VMCALL] = handle_vmcall,
};
static const int kvm_vmx_max_exit_handlers =
};
static const int kvm_vmx_max_exit_handlers =
@@
-1879,12
+1899,6
@@
again:
asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
- /*
- * Profile KVM exit RIPs:
- */
- if (unlikely(prof_on == KVM_PROFILING))
- profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP));
-
kvm_run->exit_type = 0;
if (fail) {
kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
kvm_run->exit_type = 0;
if (fail) {
kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
@@
-1907,6
+1921,12
@@
again:
reload_tss();
}
reload_tss();
}
+ /*
+ * Profile KVM exit RIPs:
+ */
+ if (unlikely(prof_on == KVM_PROFILING))
+ profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP));
+
vcpu->launched = 1;
kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
r = kvm_handle_exit(kvm_run, vcpu);
vcpu->launched = 1;
kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
r = kvm_handle_exit(kvm_run, vcpu);
@@
-2062,6
+2082,7
@@
static struct kvm_arch_ops vmx_arch_ops = {
.run = vmx_vcpu_run,
.skip_emulated_instruction = skip_emulated_instruction,
.vcpu_setup = vmx_vcpu_setup,
.run = vmx_vcpu_run,
.skip_emulated_instruction = skip_emulated_instruction,
.vcpu_setup = vmx_vcpu_setup,
+ .patch_hypercall = vmx_patch_hypercall,
};
static int __init vmx_init(void)
};
static int __init vmx_init(void)