kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: x86: vmx: cleanup handle_ept_violation
@ 2014-11-18  9:12 Tiejun Chen
  2014-11-18 10:08 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Tiejun Chen @ 2014-11-18  9:12 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm

Instead, just use PFERR_{FETCH, PRESENT, WRITE}_MASK
inside handle_ept_violation() for slightly better code.

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
---
 arch/x86/kvm/vmx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 284f5c2..22dc60d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5474,11 +5474,11 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
 	trace_kvm_page_fault(gpa, exit_qualification);
 
 	/* It is a write fault? */
-	error_code = exit_qualification & (1U << 1);
+	error_code = exit_qualification & PFERR_WRITE_MASK;
 	/* It is a fetch fault? */
-	error_code |= (exit_qualification & (1U << 2)) << 2;
+	error_code |= (exit_qualification << 2) & PFERR_FETCH_MASK;
 	/* ept page table is present? */
-	error_code |= (exit_qualification >> 3) & 0x1;
+	error_code |= (exit_qualification >> 3) & PFERR_PRESENT_MASK;
 
 	vcpu->arch.exit_qualification = exit_qualification;
 
-- 
1.9.1


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

* Re: [PATCH] kvm: x86: vmx: cleanup handle_ept_violation
  2014-11-18  9:12 [PATCH] kvm: x86: vmx: cleanup handle_ept_violation Tiejun Chen
@ 2014-11-18 10:08 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-11-18 10:08 UTC (permalink / raw)
  To: Tiejun Chen; +Cc: kvm



On 18/11/2014 10:12, Tiejun Chen wrote:
> Instead, just use PFERR_{FETCH, PRESENT, WRITE}_MASK
> inside handle_ept_violation() for slightly better code.
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> ---
>  arch/x86/kvm/vmx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 284f5c2..22dc60d 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -5474,11 +5474,11 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
>  	trace_kvm_page_fault(gpa, exit_qualification);
>  
>  	/* It is a write fault? */
> -	error_code = exit_qualification & (1U << 1);
> +	error_code = exit_qualification & PFERR_WRITE_MASK;
>  	/* It is a fetch fault? */
> -	error_code |= (exit_qualification & (1U << 2)) << 2;
> +	error_code |= (exit_qualification << 2) & PFERR_FETCH_MASK;
>  	/* ept page table is present? */
> -	error_code |= (exit_qualification >> 3) & 0x1;
> +	error_code |= (exit_qualification >> 3) & PFERR_PRESENT_MASK;

Ok.

Paolo

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

end of thread, other threads:[~2014-11-18 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-18  9:12 [PATCH] kvm: x86: vmx: cleanup handle_ept_violation Tiejun Chen
2014-11-18 10:08 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).