All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 11/14] Nested Virtualization: interrupts (svm specific)
Date: Thu, 5 Aug 2010 17:04:20 +0200	[thread overview]
Message-ID: <201008051704.20849.Christoph.Egger@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]


Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_nh11_svm_interrupt.diff --]
[-- Type: text/x-diff, Size: 3411 bytes --]

# HG changeset patch
# User cegger
# Date 1281004719 -7200
Implement SVM specific interrupt handling

diff -r c6a5143c1c33 -r 092d43f1ba2a xen/arch/x86/hvm/svm/entry.S
--- a/xen/arch/x86/hvm/svm/entry.S
+++ b/xen/arch/x86/hvm/svm/entry.S
@@ -56,6 +56,11 @@ ENTRY(svm_asm_do_resume)
         call svm_intr_assist
 
         get_current(bx)
+
+        movl NESTEDHVM_hostflags(r(bx)),%eax
+        and $NESTEDHVM_forcevmexit,%eax
+        jnz svm_stgi_label
+
         CLGI
 
         mov  VCPU_processor(r(bx)),%eax
diff -r c6a5143c1c33 -r 092d43f1ba2a xen/arch/x86/hvm/svm/intr.c
--- a/xen/arch/x86/hvm/svm/intr.c
+++ b/xen/arch/x86/hvm/svm/intr.c
@@ -33,6 +33,7 @@
 #include <asm/hvm/vlapic.h>
 #include <asm/hvm/svm/svm.h>
 #include <asm/hvm/svm/intr.h>
+#include <asm/hvm/nestedhvm.h> /* for nestedhvm_vcpu_in_guestmode */
 #include <xen/event.h>
 #include <xen/kernel.h>
 #include <public/hvm/ioreq.h>
@@ -58,7 +59,7 @@ static void svm_inject_nmi(struct vcpu *
      */
     vmcb->general1_intercepts |= GENERAL1_INTERCEPT_IRET;
 }
-    
+
 static void svm_inject_extint(struct vcpu *v, int vector)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -72,7 +73,7 @@ static void svm_inject_extint(struct vcp
     ASSERT(vmcb->eventinj.fields.v == 0);
     vmcb->eventinj = event;
 }
-    
+
 static void enable_intr_window(struct vcpu *v, struct hvm_intack intack)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -117,15 +118,46 @@ asmlinkage void svm_intr_assist(void)
     struct vcpu *v = current;
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     struct hvm_intack intack;
+    enum hvm_intblk intblk;
 
     /* Crank the handle on interrupt state. */
     pt_update_irq(v);
 
     do {
+        int rc;
+
         intack = hvm_vcpu_has_pending_irq(v);
         if ( likely(intack.source == hvm_intsrc_none) )
             return;
 
+        intblk = hvm_interrupt_blocked(v, intack);
+        if ( intblk == hvm_intblk_gif ) {
+            ASSERT(nestedhvm_enabled(v->domain));
+            return;
+        }
+
+        /* Interrupts for the nested guest are already
+         * in the vmcb.
+         */
+        if ( nestedhvm_enabled(v->domain) && nestedhvm_vcpu_in_guestmode(v) )
+        {
+            rc = nestedhvm_vcpu_interrupt(v, intack);
+            switch (rc) {
+            case NESTEDHVM_INTR_NOTINTERCEPTED:
+                /* Inject interrupt into 2nd level guest directly. */
+                break;	
+            case NESTEDHVM_INTR_NOTHANDLED:
+            case NESTEDHVM_INTR_FORCEVMEXIT:
+                return;
+            case NESTEDHVM_INTR_MASKED:
+                /* Guest already enabled an interrupt window. */
+                return;
+            default:
+                panic("%s: nestedhvm_vcpu_interrupt can't handle value 0x%x\n",
+                    __func__, rc);
+            }
+        }
+
         /*
          * Pending IRQs must be delayed if:
          * 1. An event is already pending. This is despite the fact that SVM
@@ -140,8 +172,7 @@ asmlinkage void svm_intr_assist(void)
          *      have cleared the interrupt out of the IRR.
          * 2. The IRQ is masked.
          */
-        if ( unlikely(vmcb->eventinj.fields.v) ||
-             hvm_interrupt_blocked(v, intack) )
+        if ( unlikely(vmcb->eventinj.fields.v) || intblk )
         {
             enable_intr_window(v, intack);
             return;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2010-08-05 15:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201008051704.20849.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /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 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.