* [PATCH 0/2] Use host cpuid facilities
@ 2010-10-24 13:38 Avi Kivity
2010-10-24 13:38 ` [PATCH 1/2] KVM: SVM: Replace svm_has() by standard Linux cpuid accessors Avi Kivity
2010-10-24 13:38 ` [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info Avi Kivity
0 siblings, 2 replies; 5+ messages in thread
From: Avi Kivity @ 2010-10-24 13:38 UTC (permalink / raw)
To: Marcelo Tosatti, kvm
Use the host's cpuid facilities to see if features are supporte. This
allows the clearcpuid boot parameter to work, and allows Linux to disable
nx if it is not enabled on all cpus.
Avi Kivity (2):
KVM: SVM: Replace svm_has() by standard Linux cpuid accessors
KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info
arch/x86/kvm/svm.c | 15 +++++----------
arch/x86/kvm/x86.c | 9 +++++++++
2 files changed, 14 insertions(+), 10 deletions(-)
--
1.7.3.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM: SVM: Replace svm_has() by standard Linux cpuid accessors
2010-10-24 13:38 [PATCH 0/2] Use host cpuid facilities Avi Kivity
@ 2010-10-24 13:38 ` Avi Kivity
2010-10-24 13:38 ` [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info Avi Kivity
1 sibling, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-10-24 13:38 UTC (permalink / raw)
To: Marcelo Tosatti, kvm
Instead of querying cpuid directly, use the Linux accessors (boot_cpu_has,
etc.). This allows the things like the clearcpuid kernel command line to
work (when it's fixed wrt scattered cpuid bits).
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/svm.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1a5757a..c6a7798 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -271,11 +271,6 @@ static u32 svm_msrpm_offset(u32 msr)
#define MAX_INST_SIZE 15
-static inline u32 svm_has(u32 feat)
-{
- return svm_features & feat;
-}
-
static inline void clgi(void)
{
asm volatile (__ex(SVM_CLGI));
@@ -381,7 +376,7 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
nested_svm_check_exception(svm, nr, has_error_code, error_code))
return;
- if (nr == BP_VECTOR && !svm_has(SVM_FEATURE_NRIP)) {
+ if (nr == BP_VECTOR && !static_cpu_has(X86_FEATURE_NRIPS)) {
unsigned long rip, old_rip = kvm_rip_read(&svm->vcpu);
/*
@@ -677,7 +672,7 @@ static __init int svm_hardware_setup(void)
svm_features = cpuid_edx(SVM_CPUID_FUNC);
- if (!svm_has(SVM_FEATURE_NPT))
+ if (!boot_cpu_has(X86_FEATURE_NPT))
npt_enabled = false;
if (npt_enabled && !npt) {
@@ -876,7 +871,7 @@ static void init_vmcb(struct vcpu_svm *svm)
svm->nested.vmcb = 0;
svm->vcpu.arch.hflags = 0;
- if (svm_has(SVM_FEATURE_PAUSE_FILTER)) {
+ if (boot_cpu_has(X86_FEATURE_PAUSEFILTER)) {
control->pause_filter_count = 3000;
control->intercept |= (1ULL << INTERCEPT_PAUSE);
}
@@ -2743,7 +2738,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
svm->vmcb->save.sysenter_esp = data;
break;
case MSR_IA32_DEBUGCTLMSR:
- if (!svm_has(SVM_FEATURE_LBRV)) {
+ if (!boot_cpu_has(X86_FEATURE_LBRV)) {
pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
__func__, data);
break;
@@ -3527,7 +3522,7 @@ static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
additional features */
/* Support next_rip if host supports it */
- if (svm_has(SVM_FEATURE_NRIP))
+ if (boot_cpu_has(X86_FEATURE_NRIPS))
entry->edx |= SVM_FEATURE_NRIP;
/* Support NPT for the guest if enabled */
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info
2010-10-24 13:38 [PATCH 0/2] Use host cpuid facilities Avi Kivity
2010-10-24 13:38 ` [PATCH 1/2] KVM: SVM: Replace svm_has() by standard Linux cpuid accessors Avi Kivity
@ 2010-10-24 13:38 ` Avi Kivity
2010-11-01 15:58 ` Marcelo Tosatti
1 sibling, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2010-10-24 13:38 UTC (permalink / raw)
To: Marcelo Tosatti, kvm
This allows Linux to mask cpuid bits if, for example, nx is enabled on only
some cpus.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/x86.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 48ce015..54fda7e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2229,6 +2229,11 @@ out:
return r;
}
+static void cpuid_mask(u32 *word, int wordnum)
+{
+ *word &= boot_cpu_data.x86_capability[wordnum];
+}
+
static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
u32 index)
{
@@ -2303,7 +2308,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
break;
case 1:
entry->edx &= kvm_supported_word0_x86_features;
+ cpuid_mask(&entry->edx, 0);
entry->ecx &= kvm_supported_word4_x86_features;
+ cpuid_mask(&entry->edx, 4);
/* we support x2apic emulation even if host does not support
* it since we emulate x2apic in software */
entry->ecx |= F(X2APIC);
@@ -2394,7 +2401,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
break;
case 0x80000001:
entry->edx &= kvm_supported_word1_x86_features;
+ cpuid_mask(&entry->edx, 1);
entry->ecx &= kvm_supported_word6_x86_features;
+ cpuid_mask(&entry->edx, 6);
break;
}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info
2010-10-24 13:38 ` [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info Avi Kivity
@ 2010-11-01 15:58 ` Marcelo Tosatti
2010-11-09 14:08 ` Avi Kivity
0 siblings, 1 reply; 5+ messages in thread
From: Marcelo Tosatti @ 2010-11-01 15:58 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Sun, Oct 24, 2010 at 03:38:46PM +0200, Avi Kivity wrote:
> This allows Linux to mask cpuid bits if, for example, nx is enabled on only
> some cpus.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
> arch/x86/kvm/x86.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 48ce015..54fda7e 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2229,6 +2229,11 @@ out:
> return r;
> }
>
> +static void cpuid_mask(u32 *word, int wordnum)
> +{
> + *word &= boot_cpu_data.x86_capability[wordnum];
> +}
> +
> static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> u32 index)
> {
> @@ -2303,7 +2308,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> break;
> case 1:
> entry->edx &= kvm_supported_word0_x86_features;
> + cpuid_mask(&entry->edx, 0);
> entry->ecx &= kvm_supported_word4_x86_features;
> + cpuid_mask(&entry->edx, 4);
ecx?
> /* we support x2apic emulation even if host does not support
> * it since we emulate x2apic in software */
> entry->ecx |= F(X2APIC);
> @@ -2394,7 +2401,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> break;
> case 0x80000001:
> entry->edx &= kvm_supported_word1_x86_features;
> + cpuid_mask(&entry->edx, 1);
> entry->ecx &= kvm_supported_word6_x86_features;
> + cpuid_mask(&entry->edx, 6);
ecx?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info
2010-11-01 15:58 ` Marcelo Tosatti
@ 2010-11-09 14:08 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-11-09 14:08 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm
On 11/01/2010 05:58 PM, Marcelo Tosatti wrote:
> On Sun, Oct 24, 2010 at 03:38:46PM +0200, Avi Kivity wrote:
> > This allows Linux to mask cpuid bits if, for example, nx is enabled on only
> > some cpus.
> >
> > Signed-off-by: Avi Kivity<avi@redhat.com>
> > ---
> > arch/x86/kvm/x86.c | 9 +++++++++
> > 1 files changed, 9 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 48ce015..54fda7e 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -2229,6 +2229,11 @@ out:
> > return r;
> > }
> >
> > +static void cpuid_mask(u32 *word, int wordnum)
> > +{
> > + *word&= boot_cpu_data.x86_capability[wordnum];
> > +}
> > +
> > static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> > u32 index)
> > {
> > @@ -2303,7 +2308,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> > break;
> > case 1:
> > entry->edx&= kvm_supported_word0_x86_features;
> > + cpuid_mask(&entry->edx, 0);
> > entry->ecx&= kvm_supported_word4_x86_features;
> > + cpuid_mask(&entry->edx, 4);
>
> ecx?
>
Yes. Will repost.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-09 14:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-24 13:38 [PATCH 0/2] Use host cpuid facilities Avi Kivity
2010-10-24 13:38 ` [PATCH 1/2] KVM: SVM: Replace svm_has() by standard Linux cpuid accessors Avi Kivity
2010-10-24 13:38 ` [PATCH 2/2] KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info Avi Kivity
2010-11-01 15:58 ` Marcelo Tosatti
2010-11-09 14:08 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox