All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
@ 2014-02-21 17:57 ` Liu, Jinsong
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-21 17:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gleb, hpa, kvm, linux-kernel, qemu-devel

>From 8b3a3b1f08c166e0c2cdc6162e6fa95d9c7ad2ec Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Sat, 22 Feb 2014 08:53:27 +0800
Subject: [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest

This patch enable Intel MPX feature to guest.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
 arch/x86/kvm/cpuid.c |    2 +-
 arch/x86/kvm/x86.c   |    6 ++++++
 arch/x86/kvm/x86.h   |    3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index b241325..b377d83 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -303,7 +303,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 	/* cpuid 7.0.ebx */
 	const u32 kvm_supported_word9_x86_features =
 		F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) |
-		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
+		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
 		F(ADX);
 
 	/* all calls to cpuid_count() should be made on the same cpu */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 89e4e27..3570e71 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -599,6 +599,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
 	u64 old_xcr0 = vcpu->arch.xcr0;
 	u64 valid_bits;
 
+	if (!kvm_x86_ops->mpx_supported || !kvm_x86_ops->mpx_supported())
+		xcr0 &= ~(XSTATE_BNDREGS | XSTATE_BNDCSR);
+
 	/* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now  */
 	if (index != XCR_XFEATURE_ENABLED_MASK)
 		return 1;
@@ -616,6 +619,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
 	if (xcr0 & ~valid_bits)
 		return 1;
 
+	if ((!(xcr0 & XSTATE_BNDREGS)) != (!(xcr0 & XSTATE_BNDCSR)))
+		return 1;
+
 	kvm_put_guest_xcr0(vcpu);
 	vcpu->arch.xcr0 = xcr0;
 
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 8da5823..392ecbf 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -122,7 +122,8 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
 	gva_t addr, void *val, unsigned int bytes,
 	struct x86_exception *exception);
 
-#define KVM_SUPPORTED_XCR0	(XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
+#define KVM_SUPPORTED_XCR0     (XSTATE_FP | XSTATE_SSE | XSTATE_YMM \
+				| XSTATE_BNDREGS | XSTATE_BNDCSR)
 extern u64 host_xcr0;
 
 extern unsigned int min_timer_period_us;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
@ 2014-02-21 17:57 ` Liu, Jinsong
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-21 17:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, linux-kernel, kvm, gleb, hpa

>From 8b3a3b1f08c166e0c2cdc6162e6fa95d9c7ad2ec Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Sat, 22 Feb 2014 08:53:27 +0800
Subject: [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest

This patch enable Intel MPX feature to guest.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
 arch/x86/kvm/cpuid.c |    2 +-
 arch/x86/kvm/x86.c   |    6 ++++++
 arch/x86/kvm/x86.h   |    3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index b241325..b377d83 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -303,7 +303,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 	/* cpuid 7.0.ebx */
 	const u32 kvm_supported_word9_x86_features =
 		F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) |
-		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
+		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
 		F(ADX);
 
 	/* all calls to cpuid_count() should be made on the same cpu */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 89e4e27..3570e71 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -599,6 +599,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
 	u64 old_xcr0 = vcpu->arch.xcr0;
 	u64 valid_bits;
 
+	if (!kvm_x86_ops->mpx_supported || !kvm_x86_ops->mpx_supported())
+		xcr0 &= ~(XSTATE_BNDREGS | XSTATE_BNDCSR);
+
 	/* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now  */
 	if (index != XCR_XFEATURE_ENABLED_MASK)
 		return 1;
@@ -616,6 +619,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
 	if (xcr0 & ~valid_bits)
 		return 1;
 
+	if ((!(xcr0 & XSTATE_BNDREGS)) != (!(xcr0 & XSTATE_BNDCSR)))
+		return 1;
+
 	kvm_put_guest_xcr0(vcpu);
 	vcpu->arch.xcr0 = xcr0;
 
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 8da5823..392ecbf 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -122,7 +122,8 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
 	gva_t addr, void *val, unsigned int bytes,
 	struct x86_exception *exception);
 
-#define KVM_SUPPORTED_XCR0	(XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
+#define KVM_SUPPORTED_XCR0     (XSTATE_FP | XSTATE_SSE | XSTATE_YMM \
+				| XSTATE_BNDREGS | XSTATE_BNDCSR)
 extern u64 host_xcr0;
 
 extern unsigned int min_timer_period_us;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
  2014-02-21 17:57 ` [Qemu-devel] " Liu, Jinsong
@ 2014-02-21 18:07   ` Paolo Bonzini
  -1 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2014-02-21 18:07 UTC (permalink / raw)
  To: Liu, Jinsong; +Cc: gleb, hpa, kvm, linux-kernel, qemu-devel

Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>  		F(ADX);

MPX also needs to be conditional on mpx_supported here, like it is done 
with f_rdtscp for example.

Paolo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
@ 2014-02-21 18:07   ` Paolo Bonzini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2014-02-21 18:07 UTC (permalink / raw)
  To: Liu, Jinsong; +Cc: qemu-devel, linux-kernel, kvm, gleb, hpa

Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>  		F(ADX);

MPX also needs to be conditional on mpx_supported here, like it is done 
with f_rdtscp for example.

Paolo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
  2014-02-21 18:07   ` [Qemu-devel] " Paolo Bonzini
@ 2014-02-24  3:40     ` Liu, Jinsong
  -1 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-24  3:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gleb, hpa, kvm, linux-kernel, qemu-devel

Paolo Bonzini wrote:
> Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
>> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
>> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>>  		F(ADX);
> 
> MPX also needs to be conditional on mpx_supported here, like it is
> done with f_rdtscp for example.
> 
> Paolo

Yes, has updated and sent out.

Thanks,
Jinsong

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
@ 2014-02-24  3:40     ` Liu, Jinsong
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-24  3:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, linux-kernel, kvm, gleb, hpa

Paolo Bonzini wrote:
> Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
>> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
>> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>>  		F(ADX);
> 
> MPX also needs to be conditional on mpx_supported here, like it is
> done with f_rdtscp for example.
> 
> Paolo

Yes, has updated and sent out.

Thanks,
Jinsong

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
       [not found]   ` <DE8DF0795D48FD4CA783C40EC82923350150D2A4@SHSMSX101.ccr.corp.intel.com>
@ 2014-02-24 10:48       ` Liu, Jinsong
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-24 10:48 UTC (permalink / raw)
  To: Liu, Jinsong, 'Paolo Bonzini'
  Cc: 'gleb@redhat.com', 'hpa@zytor.com',
	'kvm@vger.kernel.org',
	'linux-kernel@vger.kernel.org',
	'qemu-devel@nongnu.org'

Liu, Jinsong wrote:
> Paolo Bonzini wrote:
>> Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
>>> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
>>> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>>>  		F(ADX);
>> 
>> MPX also needs to be conditional on mpx_supported here, like it is
>> done with f_rdtscp for example.
>> 
>> Paolo
> 
> Yes, has updated and sent out.
> 
> Thanks,
> Jinsong

Seems some issues when I send via git send-email.
Re-send it under Windows, please ignore if you receive PATCH v5 twice.

Thanks,
Jinsong

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest
@ 2014-02-24 10:48       ` Liu, Jinsong
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Jinsong @ 2014-02-24 10:48 UTC (permalink / raw)
  To: Liu, Jinsong, 'Paolo Bonzini'
  Cc: 'qemu-devel@nongnu.org',
	'linux-kernel@vger.kernel.org',
	'kvm@vger.kernel.org', 'gleb@redhat.com',
	'hpa@zytor.com'

Liu, Jinsong wrote:
> Paolo Bonzini wrote:
>> Il 21/02/2014 18:57, Liu, Jinsong ha scritto:
>>> -		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) |
>>> +		F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(MPX) | F(RDSEED) |
>>>  		F(ADX);
>> 
>> MPX also needs to be conditional on mpx_supported here, like it is
>> done with f_rdtscp for example.
>> 
>> Paolo
> 
> Yes, has updated and sent out.
> 
> Thanks,
> Jinsong

Seems some issues when I send via git send-email.
Re-send it under Windows, please ignore if you receive PATCH v5 twice.

Thanks,
Jinsong

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-02-24 10:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 17:57 [PATCH v4 3/3] KVM: x86: Enable Intel MPX for guest Liu, Jinsong
2014-02-21 17:57 ` [Qemu-devel] " Liu, Jinsong
2014-02-21 18:07 ` Paolo Bonzini
2014-02-21 18:07   ` [Qemu-devel] " Paolo Bonzini
2014-02-24  3:40   ` Liu, Jinsong
2014-02-24  3:40     ` [Qemu-devel] " Liu, Jinsong
     [not found]   ` <DE8DF0795D48FD4CA783C40EC82923350150D2A4@SHSMSX101.ccr.corp.intel.com>
2014-02-24 10:48     ` Liu, Jinsong
2014-02-24 10:48       ` [Qemu-devel] " Liu, Jinsong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.