aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorSheng Yang <sheng@linux.intel.com>2009-12-18 03:48:46 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:35:40 -0500
commit0e85188049afacdfce9c026144142264981bbabb (patch)
tree773021a2bd3a799e2814e750ad85ff016f51fccf /arch/x86
parentbe43f83dada2cf0e9e01c9a0ba42977c5bd70f9d (diff)
KVM: Add cpuid_update() callback to kvm_x86_ops
Sometime, we need to adjust some state in order to reflect guest CPUID setting, e.g. if we don't expose rdtscp to guest, we won't want to enable it on hardware. cpuid_update() is introduced for this purpose. Also export kvm_find_cpuid_entry() for later use. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/kvm_host.h1
-rw-r--r--arch/x86/kvm/svm.c6
-rw-r--r--arch/x86/kvm/vmx.c6
-rw-r--r--arch/x86/kvm/x86.c3
4 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e9f4f12ec3c4..7ff0ea371e3c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -459,6 +459,7 @@ struct kvm_x86_ops {
459 int (*hardware_setup)(void); /* __init */ 459 int (*hardware_setup)(void); /* __init */
460 void (*hardware_unsetup)(void); /* __exit */ 460 void (*hardware_unsetup)(void); /* __exit */
461 bool (*cpu_has_accelerated_tpr)(void); 461 bool (*cpu_has_accelerated_tpr)(void);
462 void (*cpuid_update)(struct kvm_vcpu *vcpu);
462 463
463 /* Create, but do not attach this VCPU */ 464 /* Create, but do not attach this VCPU */
464 struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id); 465 struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1d9b33843c80..41777e6d9761 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2852,6 +2852,10 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
2852 return 0; 2852 return 0;
2853} 2853}
2854 2854
2855static void svm_cpuid_update(struct kvm_vcpu *vcpu)
2856{
2857}
2858
2855static const struct trace_print_flags svm_exit_reasons_str[] = { 2859static const struct trace_print_flags svm_exit_reasons_str[] = {
2856 { SVM_EXIT_READ_CR0, "read_cr0" }, 2860 { SVM_EXIT_READ_CR0, "read_cr0" },
2857 { SVM_EXIT_READ_CR3, "read_cr3" }, 2861 { SVM_EXIT_READ_CR3, "read_cr3" },
@@ -2976,6 +2980,8 @@ static struct kvm_x86_ops svm_x86_ops = {
2976 2980
2977 .exit_reasons_str = svm_exit_reasons_str, 2981 .exit_reasons_str = svm_exit_reasons_str,
2978 .gb_page_enable = svm_gb_page_enable, 2982 .gb_page_enable = svm_gb_page_enable,
2983
2984 .cpuid_update = svm_cpuid_update,
2979}; 2985};
2980 2986
2981static int __init svm_init(void) 2987static int __init svm_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f8f2fdc26894..75e8931e96c7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3988,6 +3988,10 @@ static bool vmx_gb_page_enable(void)
3988 return false; 3988 return false;
3989} 3989}
3990 3990
3991static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
3992{
3993}
3994
3991static struct kvm_x86_ops vmx_x86_ops = { 3995static struct kvm_x86_ops vmx_x86_ops = {
3992 .cpu_has_kvm_support = cpu_has_kvm_support, 3996 .cpu_has_kvm_support = cpu_has_kvm_support,
3993 .disabled_by_bios = vmx_disabled_by_bios, 3997 .disabled_by_bios = vmx_disabled_by_bios,
@@ -4052,6 +4056,8 @@ static struct kvm_x86_ops vmx_x86_ops = {
4052 4056
4053 .exit_reasons_str = vmx_exit_reasons_str, 4057 .exit_reasons_str = vmx_exit_reasons_str,
4054 .gb_page_enable = vmx_gb_page_enable, 4058 .gb_page_enable = vmx_gb_page_enable,
4059
4060 .cpuid_update = vmx_cpuid_update,
4055}; 4061};
4056 4062
4057static int __init vmx_init(void) 4063static int __init vmx_init(void)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4e7bbc49b7e4..e5ac21f992f0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1574,6 +1574,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
1574 cpuid_fix_nx_cap(vcpu); 1574 cpuid_fix_nx_cap(vcpu);
1575 r = 0; 1575 r = 0;
1576 kvm_apic_set_version(vcpu); 1576 kvm_apic_set_version(vcpu);
1577 kvm_x86_ops->cpuid_update(vcpu);
1577 1578
1578out_free: 1579out_free:
1579 vfree(cpuid_entries); 1580 vfree(cpuid_entries);
@@ -1596,6 +1597,7 @@ static int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
1596 goto out; 1597 goto out;
1597 vcpu->arch.cpuid_nent = cpuid->nent; 1598 vcpu->arch.cpuid_nent = cpuid->nent;
1598 kvm_apic_set_version(vcpu); 1599 kvm_apic_set_version(vcpu);
1600 kvm_x86_ops->cpuid_update(vcpu);
1599 return 0; 1601 return 0;
1600 1602
1601out: 1603out:
@@ -3733,6 +3735,7 @@ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
3733 } 3735 }
3734 return best; 3736 return best;
3735} 3737}
3738EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry);
3736 3739
3737int cpuid_maxphyaddr(struct kvm_vcpu *vcpu) 3740int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
3738{ 3741{