mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>
Cc: Alexander Graf <agraf@suse.de>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 02/12] kvm/svm: add helper functions for global interrupt flag
Date: Wed, 29 Jul 2009 14:56:22 +0200	[thread overview]
Message-ID: <1248872192-30881-3-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1248872192-30881-1-git-send-email-joerg.roedel@amd.com>

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/svm.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 27d26c3..9f69b25 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -136,6 +136,21 @@ static inline bool is_nested(struct vcpu_svm *svm)
 	return svm->nested_vmcb;
 }
 
+static inline void enable_gif(struct vcpu_svm *svm)
+{
+	svm->vcpu.arch.hflags |= HF_GIF_MASK;
+}
+
+static inline void disable_gif(struct vcpu_svm *svm)
+{
+	svm->vcpu.arch.hflags &= ~HF_GIF_MASK;
+}
+
+static inline bool gif_set(struct vcpu_svm *svm)
+{
+	return !!(svm->vcpu.arch.hflags & HF_GIF_MASK);
+}
+
 static unsigned long iopm_base;
 
 struct kvm_ldttss_desc {
@@ -630,7 +645,7 @@ static void init_vmcb(struct vcpu_svm *svm)
 	force_new_asid(&svm->vcpu);
 
 	svm->nested_vmcb = 0;
-	svm->vcpu.arch.hflags = HF_GIF_MASK;
+	enable_gif(svm);
 }
 
 static int svm_vcpu_reset(struct kvm_vcpu *vcpu)
@@ -1638,7 +1653,7 @@ static int nested_svm_vmexit_real(struct vcpu_svm *svm, void *arg1,
 	svm->vmcb->save.cpl = 0;
 	svm->vmcb->control.exit_int_info = 0;
 
-	svm->vcpu.arch.hflags &= ~HF_GIF_MASK;
+	disable_gif(svm);
 	/* Exit nested SVM mode */
 	svm->nested_vmcb = 0;
 
@@ -1770,7 +1785,7 @@ static int nested_svm_vmrun(struct vcpu_svm *svm, void *arg1,
 	svm->vmcb->control.event_inj = nested_vmcb->control.event_inj;
 	svm->vmcb->control.event_inj_err = nested_vmcb->control.event_inj_err;
 
-	svm->vcpu.arch.hflags |= HF_GIF_MASK;
+	enable_gif(svm);
 
 	return 0;
 }
@@ -1859,7 +1874,7 @@ static int stgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
 
-	svm->vcpu.arch.hflags |= HF_GIF_MASK;
+	enable_gif(svm);
 
 	return 1;
 }
@@ -1872,7 +1887,7 @@ static int clgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
 
-	svm->vcpu.arch.hflags &= ~HF_GIF_MASK;
+	disable_gif(svm);
 
 	/* After a CLGI no interrupts should come */
 	svm_clear_vintr(svm);
@@ -2359,7 +2374,7 @@ static void svm_set_irq(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_svm *svm = to_svm(vcpu);
 
-	BUG_ON(!(svm->vcpu.arch.hflags & HF_GIF_MASK));
+	BUG_ON(!(gif_set(svm)));
 
 	svm->vmcb->control.event_inj = vcpu->arch.interrupt.nr |
 		SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_INTR;
@@ -2390,7 +2405,7 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu)
 	struct vmcb *vmcb = svm->vmcb;
 	return (vmcb->save.rflags & X86_EFLAGS_IF) &&
 		!(vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) &&
-		(svm->vcpu.arch.hflags & HF_GIF_MASK) &&
+		gif_set(svm) &&
 		!is_nested(svm);
 }
 
@@ -2405,7 +2420,7 @@ static void enable_irq_window(struct kvm_vcpu *vcpu)
 	 * GIF becomes 1, because that's a separate STGI/VMRUN intercept.
 	 * The next time we get that intercept, this function will be
 	 * called again though and we'll get the vintr intercept. */
-	if (svm->vcpu.arch.hflags & HF_GIF_MASK) {
+	if (gif_set(svm)) {
 		svm_set_vintr(svm);
 		svm_inject_irq(svm, 0x0);
 	}
-- 
1.6.3.3



  parent reply	other threads:[~2009-07-29 12:57 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29 12:56 [PATCH 0/12] Nested SVM cleanups Joerg Roedel
2009-07-29 12:56 ` [PATCH 01/12] kvm/svm: make nested svm debugging runtime configurable Joerg Roedel
2009-07-29 13:22   ` Alexander Graf
2009-07-29 12:56 ` Joerg Roedel [this message]
2009-07-29 13:15   ` [PATCH 02/12] kvm/svm: add helper functions for global interrupt flag Alexander Graf
2009-07-29 13:44     ` Joerg Roedel
2009-07-29 12:56 ` [PATCH 03/12] kvm/svm: optimize nested #vmexit Joerg Roedel
2009-07-29 13:23   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 04/12] kvm/svm: optimize nested vmrun Joerg Roedel
2009-07-29 13:27   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 05/12] kvm/svm: copy only necessary parts of the control area on vmrun/vmexit Joerg Roedel
2009-07-29 13:30   ` Alexander Graf
2009-07-29 13:47     ` Joerg Roedel
2009-07-29 13:48       ` Alexander Graf
2009-07-29 12:56 ` [PATCH 06/12] kvm/svm: complete interrupts after handling nested exits Joerg Roedel
2009-07-29 13:46   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 07/12] kvm/svm: move nested svm state into seperate struct Joerg Roedel
2009-07-29 13:49   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 08/12] kvm/svm: cache nested intercepts Joerg Roedel
2009-07-29 13:13   ` Avi Kivity
2009-07-29 13:13     ` Joerg Roedel
2009-07-29 13:26       ` Avi Kivity
2009-07-29 13:47         ` Joerg Roedel
2009-07-29 13:50   ` Alexander Graf
2009-07-29 13:52     ` Joerg Roedel
2009-07-29 12:56 ` [PATCH 09/12] kvm/svm: consolidate nested_svm_exit_handled Joerg Roedel
2009-07-29 13:56   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 10/12] kvm/svm: do nested vmexit in nested_svm_exit_handled Joerg Roedel
2009-07-29 14:15   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 11/12] kvm/svm: handle #pf intercepts in nested_svm_exit_handled directly Joerg Roedel
2009-07-29 14:20   ` Alexander Graf
2009-07-29 14:44     ` Avi Kivity
2009-07-29 14:41       ` Alexander Graf
2009-07-29 14:49         ` Avi Kivity
2009-07-29 14:46           ` Alexander Graf
2009-07-29 12:56 ` [PATCH 12/12] kvm/svm: simplify nested_svm_check_exception Joerg Roedel
2009-07-29 14:21   ` Alexander Graf
2009-07-29 13:05 ` [PATCH 0/12] Nested SVM cleanups Avi Kivity
2009-07-29 13:09   ` Joerg Roedel
2009-07-29 13:31     ` Avi Kivity
2009-07-29 13:32     ` Avi Kivity
2009-07-29 13:29       ` Alexander Graf
2009-07-29 13:38       ` Joerg Roedel
2009-07-29 13:48         ` Avi Kivity
2009-07-29 13:48           ` Joerg Roedel
2009-07-29 13:59             ` Avi Kivity
2009-07-29 13:58               ` Joerg Roedel
2009-07-29 14:07                 ` Avi Kivity
2009-07-29 13:06 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1248872192-30881-3-git-send-email-joerg.roedel@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®