diff mbox

Cleanup to reuse is_long_mode()

Message ID 9832F13BD22FB94A829F798DA4A8280501A3C01E87@pdsmsx503.ccr.corp.intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Dong, Eddie March 30, 2009, 2:38 a.m. UTC
Thanks, Eddie




commit 6688a1fbc37330f2c4e16d1a78050b64e1ce5dcc
Author: root <root@eddie-wb.localdomain>
Date:   Mon Mar 30 11:31:10 2009 +0800

    cleanup to reuse is_long_mode(vcpu)
    
    Signed-off-by: Eddie Dong <eddie.dong@intel.com>

Comments

Avi Kivity March 30, 2009, 7:43 a.m. UTC | #1
Dong, Eddie wrote:
>  	struct vcpu_svm *svm = to_svm(vcpu);
>  
>  #ifdef CONFIG_X86_64
> -	if (vcpu->arch.shadow_efer & EFER_LME) {
> +	if (is_long_mode(vcpu)) {
>   

is_long_mode() actually tests EFER_LMA, so this is incorrect.
Dong, Eddie March 30, 2009, 8:24 a.m. UTC | #2
Avi Kivity wrote:
> Dong, Eddie wrote:
>>  	struct vcpu_svm *svm = to_svm(vcpu);
>> 
>>  #ifdef CONFIG_X86_64
>> -	if (vcpu->arch.shadow_efer & EFER_LME) {
>> +	if (is_long_mode(vcpu)) {
>> 
> 
> is_long_mode() actually tests EFER_LMA, so this is incorrect.

Something missing? Here is the definition of is_long_mode, the patch is just for equal replacement.
thx, eddie


static inline int is_long_mode(struct kvm_vcpu *vcpu)
{
#ifdef CONFIG_X86_64
        return vcpu->arch.shadow_efer & EFER_LME;
#else
        return 0;
#endif
}--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity March 30, 2009, 11:46 a.m. UTC | #3
Dong, Eddie wrote:
> Avi Kivity wrote:
>   
>> Dong, Eddie wrote:
>>     
>>>  	struct vcpu_svm *svm = to_svm(vcpu);
>>>
>>>  #ifdef CONFIG_X86_64
>>> -	if (vcpu->arch.shadow_efer & EFER_LME) {
>>> +	if (is_long_mode(vcpu)) {
>>>
>>>       
>> is_long_mode() actually tests EFER_LMA, so this is incorrect.
>>     
>
> Something missing? Here is the definition of is_long_mode, the patch is just for equal replacement.
> thx, eddie
>
>
> static inline int is_long_mode(struct kvm_vcpu *vcpu)
> {
> #ifdef CONFIG_X86_64
>         return vcpu->arch.shadow_efer & EFER_LME;
> #else
>         return 0;
> #endif
> }

You're looking at an old version.  Mine has EFER_LMA.  See 9d642b.
diff mbox

Patch

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index db5021b..affc31d 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -859,7 +859,7 @@  static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 	struct vcpu_svm *svm = to_svm(vcpu);
 
 #ifdef CONFIG_X86_64
-	if (vcpu->arch.shadow_efer & EFER_LME) {
+	if (is_long_mode(vcpu)) {
 		if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
 			vcpu->arch.shadow_efer |= EFER_LMA;
 			svm->vmcb->save.efer |= EFER_LMA | EFER_LME;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9913a1d..b1f1458 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1543,7 +1543,7 @@  static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 		enter_rmode(vcpu);
 
 #ifdef CONFIG_X86_64
-	if (vcpu->arch.shadow_efer & EFER_LME) {
+	if (is_long_mode(vcpu)) {
 		if (!is_paging(vcpu) && (cr0 & X86_CR0_PG))
 			enter_lmode(vcpu);
 		if (is_paging(vcpu) && !(cr0 & X86_CR0_PG))
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index bf6683a..961bd2b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -289,7 +289,7 @@  void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 
 	if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) {
 #ifdef CONFIG_X86_64
-		if ((vcpu->arch.shadow_efer & EFER_LME)) {
+		if (is_long_mode(vcpu)) {
 			int cs_db, cs_l;
 
 			if (!is_pae(vcpu)) {