Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1252496 > unrolled thread

[PATCH] KVM: x86: fix eflags state following processor init/reset

Started byWanpeng Li <wanpeng.li@hotmail.com>
First post2015-10-21 08:30 +0200
Last post2015-10-28 09:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] KVM: x86: fix eflags state following processor init/reset Wanpeng Li <wanpeng.li@hotmail.com> - 2015-10-21 08:30 +0200
    Re: [PATCH] KVM: x86: fix eflags state following processor init/reset Wanpeng Li <wanpeng.li@hotmail.com> - 2015-10-28 04:30 +0100
      Re: [PATCH] KVM: x86: fix eflags state following processor init/reset Nadav Amit <nadav.amit@gmail.com> - 2015-10-28 09:20 +0100

#1252496 — [PATCH] KVM: x86: fix eflags state following processor init/reset

FromWanpeng Li <wanpeng.li@hotmail.com>
Date2015-10-21 08:30 +0200
Subject[PATCH] KVM: x86: fix eflags state following processor init/reset
Message-ID<qlV4l-35j-5@gated-at.bofh.it>
Reference SDM 3.4.3:

Following initialization of the processor (either by asserting the 
RESET pin or the INIT pin), the state of the EFLAGS register is 
00000002H.

However, the eflags fixed bit is not set and other bits are also not 
cleared during the init/reset in kvm.

This patch fix it by set eflags register to 00000002H following 
initialization of the processor.

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 arch/x86/kvm/vmx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b680c2e..326f6ea 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4935,6 +4935,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
 	vmx_set_efer(vcpu, 0);
 	vmx_fpu_activate(vcpu);
 	update_exception_bitmap(vcpu);
+	vmx_set_rflags(vcpu, X86_EFLAGS_FIXED);
 
 	vpid_sync_context(vmx->vpid);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1257634

FromWanpeng Li <wanpeng.li@hotmail.com>
Date2015-10-28 04:30 +0100
Message-ID<qopAZ-5Ed-11@gated-at.bofh.it>
In reply to#1252496
Ping, :-)
On 10/21/15 2:28 PM, Wanpeng Li wrote:
> Reference SDM 3.4.3:
>
> Following initialization of the processor (either by asserting the
> RESET pin or the INIT pin), the state of the EFLAGS register is
> 00000002H.
>
> However, the eflags fixed bit is not set and other bits are also not
> cleared during the init/reset in kvm.
>
> This patch fix it by set eflags register to 00000002H following
> initialization of the processor.
>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>   arch/x86/kvm/vmx.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index b680c2e..326f6ea 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -4935,6 +4935,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
>   	vmx_set_efer(vcpu, 0);
>   	vmx_fpu_activate(vcpu);
>   	update_exception_bitmap(vcpu);
> +	vmx_set_rflags(vcpu, X86_EFLAGS_FIXED);
>   
>   	vpid_sync_context(vmx->vpid);
>   }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1257769

FromNadav Amit <nadav.amit@gmail.com>
Date2015-10-28 09:20 +0100
Message-ID<qou7E-6S-5@gated-at.bofh.it>
In reply to#1257634
Here are my 5 cents. Note that vmx_vcpu_reset calls:

	vmcs_writel(GUEST_RFLAGS, 0x02);

(And the RFLAGS value is not cached by KVM, so no consistency problem should
occur.)

You may want to change the value into constant or call a wrapper function
for setting RFLAGS, but I don’t see something broken in the functionality.

Regards,
Nadav

Wanpeng Li <wanpeng.li@hotmail.com> wrote:

> Ping, :-)
> On 10/21/15 2:28 PM, Wanpeng Li wrote:
>> Reference SDM 3.4.3:
>> 
>> Following initialization of the processor (either by asserting the
>> RESET pin or the INIT pin), the state of the EFLAGS register is
>> 00000002H.
>> 
>> However, the eflags fixed bit is not set and other bits are also not
>> cleared during the init/reset in kvm.
>> 
>> This patch fix it by set eflags register to 00000002H following
>> initialization of the processor.
>> 
>> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
>> ---
>>  arch/x86/kvm/vmx.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index b680c2e..326f6ea 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -4935,6 +4935,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
>>  	vmx_set_efer(vcpu, 0);
>>  	vmx_fpu_activate(vcpu);
>>  	update_exception_bitmap(vcpu);
>> +	vmx_set_rflags(vcpu, X86_EFLAGS_FIXED);
>>    	vpid_sync_context(vmx->vpid);
>>  }
> 
> --
> 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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web