* [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa
2006-12-12 13:55 [PATCH 0/3] KVM: Some more fixes Avi Kivity
@ 2006-12-12 13:57 ` Avi Kivity
0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-12 13:57 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
They're not on speaking terms.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/svm.c
===================================================================
--- linux-2.6.orig/drivers/kvm/svm.c
+++ linux-2.6/drivers/kvm/svm.c
@@ -377,6 +377,7 @@ static __init int svm_hardware_setup(voi
void *msrpm_va;
int r;
+ kvm_emulator_want_group7_invlpg();
iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
@@ -1628,9 +1629,7 @@ static struct kvm_arch_ops svm_arch_ops
static int __init svm_init(void)
{
- kvm_emulator_want_group7_invlpg();
- kvm_init_arch(&svm_arch_ops, THIS_MODULE);
- return 0;
+ return kvm_init_arch(&svm_arch_ops, THIS_MODULE);
}
static void __exit svm_exit(void)
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -2000,8 +2000,7 @@ static struct kvm_arch_ops vmx_arch_ops
static int __init vmx_init(void)
{
- kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
- return 0;
+ return kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
}
static void __exit vmx_exit(void)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/3] KVM: Updates
@ 2006-12-13 12:42 Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:42 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, Andrew Morton, Ingo Molnar
A cleanup and two AMD SVM fixes (the STAR MSR on 32-bit hosts, and the
floating point unit state on all AMD hosts).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa
2006-12-13 12:42 [PATCH 0/3] KVM: Updates Avi Kivity
@ 2006-12-13 12:43 ` Avi Kivity
2006-12-13 12:44 ` Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: add valid_vcpu() helper Avi Kivity
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:43 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
They're not on speaking terms.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/svm.c
===================================================================
--- linux-2.6.orig/drivers/kvm/svm.c
+++ linux-2.6/drivers/kvm/svm.c
@@ -377,6 +377,7 @@ static __init int svm_hardware_setup(voi
void *msrpm_va;
int r;
+ kvm_emulator_want_group7_invlpg();
iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
@@ -1628,9 +1629,7 @@ static struct kvm_arch_ops svm_arch_ops
static int __init svm_init(void)
{
- kvm_emulator_want_group7_invlpg();
- kvm_init_arch(&svm_arch_ops, THIS_MODULE);
- return 0;
+ return kvm_init_arch(&svm_arch_ops, THIS_MODULE);
}
static void __exit svm_exit(void)
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -2000,8 +2000,7 @@ static struct kvm_arch_ops vmx_arch_ops
static int __init vmx_init(void)
{
- kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
- return 0;
+ return kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
}
static void __exit vmx_exit(void)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] KVM: add valid_vcpu() helper
2006-12-13 12:42 [PATCH 0/3] KVM: Updates Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
@ 2006-12-13 12:43 ` Avi Kivity
2006-12-13 12:44 ` [PATCH 2/3] KVM: AMD SVM: handle MSR_STAR in 32-bit mode Avi Kivity
2006-12-13 12:45 ` [PATCH 3/3] KVM: AMD SVM: Save and restore the floating point unit state Avi Kivity
3 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:43 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
From: James Morris <jmorris@namei.org>
Consolidate the logic for checking whether a vcpu index is valid. Also,
use likely(), as a valid value should be the overwhelmingly common case.
Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -113,6 +113,11 @@ unsigned long segment_base(u16 selector)
}
EXPORT_SYMBOL_GPL(segment_base);
+static inline int valid_vcpu(int n)
+{
+ return likely(n >= 0 && n < KVM_MAX_VCPUS);
+}
+
int kvm_read_guest(struct kvm_vcpu *vcpu,
gva_t addr,
unsigned long size,
@@ -494,7 +499,7 @@ static int kvm_dev_ioctl_create_vcpu(str
struct kvm_vcpu *vcpu;
r = -EINVAL;
- if (n < 0 || n >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(n))
goto out;
vcpu = &kvm->vcpus[n];
@@ -1179,7 +1184,7 @@ static int kvm_dev_ioctl_run(struct kvm
struct kvm_vcpu *vcpu;
int r;
- if (kvm_run->vcpu < 0 || kvm_run->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(kvm_run->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, kvm_run->vcpu);
@@ -1208,7 +1213,7 @@ static int kvm_dev_ioctl_get_regs(struct
{
struct kvm_vcpu *vcpu;
- if (regs->vcpu < 0 || regs->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(regs->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, regs->vcpu);
@@ -1254,7 +1259,7 @@ static int kvm_dev_ioctl_set_regs(struct
{
struct kvm_vcpu *vcpu;
- if (regs->vcpu < 0 || regs->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(regs->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, regs->vcpu);
@@ -1301,7 +1306,7 @@ static int kvm_dev_ioctl_get_sregs(struc
struct kvm_vcpu *vcpu;
struct descriptor_table dt;
- if (sregs->vcpu < 0 || sregs->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(sregs->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, sregs->vcpu);
if (!vcpu)
@@ -1353,7 +1358,7 @@ static int kvm_dev_ioctl_set_sregs(struc
int i;
struct descriptor_table dt;
- if (sregs->vcpu < 0 || sregs->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(sregs->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, sregs->vcpu);
if (!vcpu)
@@ -1444,7 +1449,7 @@ static int __msr_io(struct kvm *kvm, str
struct kvm_vcpu *vcpu;
int i;
- if (msrs->vcpu < 0 || msrs->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(msrs->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, msrs->vcpu);
@@ -1537,7 +1542,7 @@ static int kvm_dev_ioctl_interrupt(struc
{
struct kvm_vcpu *vcpu;
- if (irq->vcpu < 0 || irq->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(irq->vcpu))
return -EINVAL;
if (irq->irq < 0 || irq->irq >= 256)
return -EINVAL;
@@ -1559,7 +1564,7 @@ static int kvm_dev_ioctl_debug_guest(str
struct kvm_vcpu *vcpu;
int r;
- if (dbg->vcpu < 0 || dbg->vcpu >= KVM_MAX_VCPUS)
+ if (!valid_vcpu(dbg->vcpu))
return -EINVAL;
vcpu = vcpu_load(kvm, dbg->vcpu);
if (!vcpu)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa
2006-12-13 12:43 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
@ 2006-12-13 12:44 ` Avi Kivity
0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:44 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
Avi Kivity wrote:
> They're not on speaking terms.
>
>
Please disregard - this patch was already sent. Slippery fingers.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] KVM: AMD SVM: handle MSR_STAR in 32-bit mode
2006-12-13 12:42 [PATCH 0/3] KVM: Updates Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: add valid_vcpu() helper Avi Kivity
@ 2006-12-13 12:44 ` Avi Kivity
2006-12-13 12:45 ` [PATCH 3/3] KVM: AMD SVM: Save and restore the floating point unit state Avi Kivity
3 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:44 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
This is necessary for linux guests.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/svm.c
===================================================================
--- linux-2.6.orig/drivers/kvm/svm.c
+++ linux-2.6/drivers/kvm/svm.c
@@ -402,11 +402,11 @@ static __init int svm_hardware_setup(voi
set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1);
set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1);
set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1);
- set_msr_interception(msrpm_va, MSR_STAR, 1, 1);
set_msr_interception(msrpm_va, MSR_LSTAR, 1, 1);
set_msr_interception(msrpm_va, MSR_CSTAR, 1, 1);
set_msr_interception(msrpm_va, MSR_SYSCALL_MASK, 1, 1);
#endif
+ set_msr_interception(msrpm_va, MSR_K6_STAR, 1, 1);
set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_CS, 1, 1);
set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_ESP, 1, 1);
set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_EIP, 1, 1);
@@ -1098,10 +1098,10 @@ static int svm_get_msr(struct kvm_vcpu *
case MSR_IA32_APICBASE:
*data = vcpu->apic_base;
break;
-#ifdef CONFIG_X86_64
- case MSR_STAR:
+ case MSR_K6_STAR:
*data = vcpu->svm->vmcb->save.star;
break;
+#ifdef CONFIG_X86_64
case MSR_LSTAR:
*data = vcpu->svm->vmcb->save.lstar;
break;
@@ -1173,10 +1173,10 @@ static int svm_set_msr(struct kvm_vcpu *
case MSR_IA32_APICBASE:
vcpu->apic_base = data;
break;
-#ifdef CONFIG_X86_64_
- case MSR_STAR:
+ case MSR_K6_STAR:
vcpu->svm->vmcb->save.star = data;
break;
+#ifdef CONFIG_X86_64_
case MSR_LSTAR:
vcpu->svm->vmcb->save.lstar = data;
break;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] KVM: AMD SVM: Save and restore the floating point unit state
2006-12-13 12:42 [PATCH 0/3] KVM: Updates Avi Kivity
` (2 preceding siblings ...)
2006-12-13 12:44 ` [PATCH 2/3] KVM: AMD SVM: handle MSR_STAR in 32-bit mode Avi Kivity
@ 2006-12-13 12:45 ` Avi Kivity
3 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2006-12-13 12:45 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
Fixes sf bug 1614113 (segfaults in nbench).
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/svm.c
===================================================================
--- linux-2.6.orig/drivers/kvm/svm.c
+++ linux-2.6/drivers/kvm/svm.c
@@ -575,6 +575,8 @@ static int svm_create_vcpu(struct kvm_vc
memset(vcpu->svm->db_regs, 0, sizeof(vcpu->svm->db_regs));
init_vmcb(vcpu->svm->vmcb);
+ fx_init(vcpu);
+
return 0;
out2:
@@ -1387,6 +1389,10 @@ again:
save_db_regs(vcpu->svm->host_db_regs);
load_db_regs(vcpu->svm->db_regs);
}
+
+ fx_save(vcpu->host_fx_image);
+ fx_restore(vcpu->guest_fx_image);
+
asm volatile (
#ifdef CONFIG_X86_64
"push %%rbx; push %%rcx; push %%rdx;"
@@ -1496,6 +1502,9 @@ again:
#endif
: "cc", "memory" );
+ fx_save(vcpu->guest_fx_image);
+ fx_restore(vcpu->host_fx_image);
+
if ((vcpu->svm->vmcb->save.dr7 & 0xff))
load_db_regs(vcpu->svm->host_db_regs);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-12-13 13:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 12:42 [PATCH 0/3] KVM: Updates Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
2006-12-13 12:44 ` Avi Kivity
2006-12-13 12:43 ` [PATCH 1/3] KVM: add valid_vcpu() helper Avi Kivity
2006-12-13 12:44 ` [PATCH 2/3] KVM: AMD SVM: handle MSR_STAR in 32-bit mode Avi Kivity
2006-12-13 12:45 ` [PATCH 3/3] KVM: AMD SVM: Save and restore the floating point unit state Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2006-12-12 13:55 [PATCH 0/3] KVM: Some more fixes Avi Kivity
2006-12-12 13:57 ` [PATCH 1/3] KVM: Disallow the kvm-amd module on intel hardware, and vice versa Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox