All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 03/12] Nested Virtualization: function hooks
@ 2010-12-20 16:04 Christoph Egger
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Egger @ 2010-12-20 16:04 UTC (permalink / raw)
  To: xen-devel

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


-- 
---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_nh03_hooks.diff --]
[-- Type: text/x-diff, Size: 5740 bytes --]

# HG changeset patch
# User cegger
# Date 1292839430 -3600
add nestedhvm function hooks for svm/vmx specific code

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

diff -r 0797c3ecd8fd -r e43ab6fb0ee2 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3485,6 +3485,89 @@ int hvm_debug_op(struct vcpu *v, int32_t
 }
 
 
+int nhvm_vcpu_initialise(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_initialise)
+        return hvm_funcs.nhvm_vcpu_initialise(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_destroy(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_destroy)
+        return hvm_funcs.nhvm_vcpu_destroy(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_reset(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_reset)
+        return hvm_funcs.nhvm_vcpu_reset(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
+{
+    if (hvm_funcs.nhvm_vcpu_hostrestore)
+        return hvm_funcs.nhvm_vcpu_hostrestore(v, regs);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
+                     uint64_t exitcode)
+{
+    if (hvm_funcs.nhvm_vcpu_vmexit)
+        return hvm_funcs.nhvm_vcpu_vmexit(v, regs, exitcode);
+    return -EOPNOTSUPP;
+}
+
+int
+nhvm_vcpu_vmexit_trap(struct vcpu *v, unsigned int trapnr,
+                       int errcode, unsigned long cr2)
+{
+    return hvm_funcs.nhvm_vcpu_vmexit_trap(v, trapnr, errcode, cr2);
+}
+
+uint64_t nhvm_vcpu_guestcr3(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_guestcr3)
+        return hvm_funcs.nhvm_vcpu_guestcr3(v);
+    return -EOPNOTSUPP;
+}
+
+uint64_t nhvm_vcpu_hostcr3(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_hostcr3)
+        return hvm_funcs.nhvm_vcpu_hostcr3(v);
+    return -EOPNOTSUPP;
+}
+
+uint32_t nhvm_vcpu_asid(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_asid)
+        return hvm_funcs.nhvm_vcpu_asid(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vmcx_guest_intercepts_trap(struct vcpu *v, unsigned int trap)
+{
+    if (hvm_funcs.nhvm_vmcx_guest_intercepts_trap)
+        return hvm_funcs.nhvm_vmcx_guest_intercepts_trap(v, trap);
+    return -EOPNOTSUPP;
+}
+
+bool_t nhvm_vmcx_hap_enabled(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vmcx_hap_enabled)
+        return hvm_funcs.nhvm_vmcx_hap_enabled(v);
+    return -EOPNOTSUPP;
+}
+
+enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v)
+{
+    return hvm_funcs.nhvm_intr_blocked(v);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 0797c3ecd8fd -r e43ab6fb0ee2 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -145,6 +145,27 @@ struct hvm_function_table {
     void (*set_uc_mode)(struct vcpu *v);
     void (*set_info_guest)(struct vcpu *v);
     void (*set_rdtsc_exiting)(struct vcpu *v, bool_t);
+
+    /* Nested HVM */
+    int (*nhvm_vcpu_initialise)(struct vcpu *v);
+    int (*nhvm_vcpu_destroy)(struct vcpu *v);
+    int (*nhvm_vcpu_reset)(struct vcpu *v);
+    int (*nhvm_vcpu_hostrestore)(struct vcpu *v,
+                                struct cpu_user_regs *regs);
+    int (*nhvm_vcpu_vmexit)(struct vcpu *v, struct cpu_user_regs *regs,
+                                uint64_t exitcode);
+    int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v,
+                                unsigned int trapnr,
+                                int errcode,
+                                unsigned long cr2);
+    uint64_t (*nhvm_vcpu_guestcr3)(struct vcpu *v);
+    uint64_t (*nhvm_vcpu_hostcr3)(struct vcpu *v);
+    uint32_t (*nhvm_vcpu_asid)(struct vcpu *v);
+    int (*nhvm_vmcx_guest_intercepts_trap)(struct vcpu *v, unsigned int trapnr);
+
+    bool_t (*nhvm_vmcx_hap_enabled)(struct vcpu *v);
+
+    enum hvm_intblk (*nhvm_intr_blocked)(struct vcpu *v);
 };
 
 extern struct hvm_function_table hvm_funcs;
@@ -368,4 +389,44 @@ bool_t hvm_hap_nested_page_fault(unsigne
 int hvm_x2apic_msr_read(struct vcpu *v, unsigned int msr, uint64_t *msr_content);
 int hvm_x2apic_msr_write(struct vcpu *v, unsigned int msr, uint64_t msr_content);
 
+/*
+ * Nested HVM
+ */
+
+/* Initialize vcpu's struct nestedhvm */
+int nhvm_vcpu_initialise(struct vcpu *v);
+/* Destroy and free vcpu's struct nestedhvm */
+int nhvm_vcpu_destroy(struct vcpu *v);
+/* Reset vcpu's state when l1 guest disables nested virtualization */
+int nhvm_vcpu_reset(struct vcpu *v);
+/* Restores l1 guest state */
+int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs);
+/* Fill l1 guest's VMCB/VMCS with data provided by generic exit codes
+ * (do conversion as needed), other misc SVM/VMX specific tweaks to make
+ * it work */
+int nhvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
+                     uint64_t exitcode);
+/* inject vmexit into l1 guest. l1 guest will see a VMEXIT due to
+ * 'trapnr' exception.
+ */ 
+int nhvm_vcpu_vmexit_trap(struct vcpu *v,
+    unsigned int trapnr, int errcode, unsigned long cr2);
+
+/* returns l2 guest cr3 in l2 guest physical address space. */
+uint64_t nhvm_vcpu_guestcr3(struct vcpu *v);
+/* returns l1 guest's cr3 that points to the page table used to
+ * translate l2 guest physical address to l1 guest physical address.
+ */
+uint64_t nhvm_vcpu_hostcr3(struct vcpu *v);
+/* returns the asid number l1 guest wants to use to run the l2 guest */
+uint32_t nhvm_vcpu_asid(struct vcpu *v);
+
+/* returns true, when l1 guest intercepts the specified trap */
+int nhvm_vmcx_guest_intercepts_trap(struct vcpu *v, unsigned int trapnr);
+
+/* returns true when l1 guest wants to use hap to run l2 guest */
+bool_t nhvm_vmcx_hap_enabled(struct vcpu *v);
+/* interrupt */
+enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v);
+
 #endif /* __ASM_X86_HVM_HVM_H__ */

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

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

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

* RE: [PATCH 03/12] Nested Virtualization: function hooks
  2011-03-09 14:23 Christoph Egger
@ 2011-03-28 14:03 ` Dong, Eddie
  0 siblings, 0 replies; 3+ messages in thread
From: Dong, Eddie @ 2011-03-28 14:03 UTC (permalink / raw)
  To: Christoph Egger, xen-devel; +Cc: Dong, Eddie

Acked by eddie.dong@intel.com

-----Original Message-----
From: xen-devel-bounces@lists.xensource.com [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Christoph Egger
Sent: Wednesday, March 09, 2011 10:23 PM
To: xen-devel@lists.xensource.com
Subject: [Xen-devel] [PATCH 03/12] Nested Virtualization: function hooks


--
---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

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

* [PATCH 03/12] Nested Virtualization: function hooks
@ 2011-03-09 14:23 Christoph Egger
  2011-03-28 14:03 ` Dong, Eddie
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Egger @ 2011-03-09 14:23 UTC (permalink / raw)
  To: xen-devel

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


-- 
---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_nh03_hooks.diff --]
[-- Type: text/x-diff, Size: 6007 bytes --]

# HG changeset patch
# User cegger
# Date 1298892104 -3600
add nestedhvm function hooks for svm/vmx specific code

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

diff -r 254911296b47 -r 216ffee07118 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3853,6 +3853,89 @@ int hvm_memory_event_int3(unsigned long 
 }
 #endif /* __x86_64__ */
 
+int nhvm_vcpu_initialise(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_initialise)
+        return hvm_funcs.nhvm_vcpu_initialise(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_destroy(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_destroy)
+        return hvm_funcs.nhvm_vcpu_destroy(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_reset(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_reset)
+        return hvm_funcs.nhvm_vcpu_reset(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
+{
+    if (hvm_funcs.nhvm_vcpu_hostrestore)
+        return hvm_funcs.nhvm_vcpu_hostrestore(v, regs);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
+                     uint64_t exitcode)
+{
+    if (hvm_funcs.nhvm_vcpu_vmexit)
+        return hvm_funcs.nhvm_vcpu_vmexit(v, regs, exitcode);
+    return -EOPNOTSUPP;
+}
+
+int
+nhvm_vcpu_vmexit_trap(struct vcpu *v, unsigned int trapnr,
+                       int errcode, unsigned long cr2)
+{
+    return hvm_funcs.nhvm_vcpu_vmexit_trap(v, trapnr, errcode, cr2);
+}
+
+uint64_t nhvm_vcpu_guestcr3(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_guestcr3)
+        return hvm_funcs.nhvm_vcpu_guestcr3(v);
+    return -EOPNOTSUPP;
+}
+
+uint64_t nhvm_vcpu_hostcr3(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_hostcr3)
+        return hvm_funcs.nhvm_vcpu_hostcr3(v);
+    return -EOPNOTSUPP;
+}
+
+uint32_t nhvm_vcpu_asid(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vcpu_asid)
+        return hvm_funcs.nhvm_vcpu_asid(v);
+    return -EOPNOTSUPP;
+}
+
+int nhvm_vmcx_guest_intercepts_trap(struct vcpu *v, unsigned int trap)
+{
+    if (hvm_funcs.nhvm_vmcx_guest_intercepts_trap)
+        return hvm_funcs.nhvm_vmcx_guest_intercepts_trap(v, trap);
+    return -EOPNOTSUPP;
+}
+
+bool_t nhvm_vmcx_hap_enabled(struct vcpu *v)
+{
+    if (hvm_funcs.nhvm_vmcx_hap_enabled)
+        return hvm_funcs.nhvm_vmcx_hap_enabled(v);
+    return -EOPNOTSUPP;
+}
+
+enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v)
+{
+    return hvm_funcs.nhvm_intr_blocked(v);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 254911296b47 -r 216ffee07118 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -145,6 +145,27 @@ struct hvm_function_table {
     void (*set_uc_mode)(struct vcpu *v);
     void (*set_info_guest)(struct vcpu *v);
     void (*set_rdtsc_exiting)(struct vcpu *v, bool_t);
+
+    /* Nested HVM */
+    int (*nhvm_vcpu_initialise)(struct vcpu *v);
+    int (*nhvm_vcpu_destroy)(struct vcpu *v);
+    int (*nhvm_vcpu_reset)(struct vcpu *v);
+    int (*nhvm_vcpu_hostrestore)(struct vcpu *v,
+                                struct cpu_user_regs *regs);
+    int (*nhvm_vcpu_vmexit)(struct vcpu *v, struct cpu_user_regs *regs,
+                                uint64_t exitcode);
+    int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v,
+                                unsigned int trapnr,
+                                int errcode,
+                                unsigned long cr2);
+    uint64_t (*nhvm_vcpu_guestcr3)(struct vcpu *v);
+    uint64_t (*nhvm_vcpu_hostcr3)(struct vcpu *v);
+    uint32_t (*nhvm_vcpu_asid)(struct vcpu *v);
+    int (*nhvm_vmcx_guest_intercepts_trap)(struct vcpu *v, unsigned int trapnr);
+
+    bool_t (*nhvm_vmcx_hap_enabled)(struct vcpu *v);
+
+    enum hvm_intblk (*nhvm_intr_blocked)(struct vcpu *v);
 };
 
 extern struct hvm_function_table hvm_funcs;
@@ -378,7 +399,6 @@ int hvm_x2apic_msr_write(struct vcpu *v,
 void hvm_memory_event_cr0(unsigned long value, unsigned long old);
 void hvm_memory_event_cr3(unsigned long value, unsigned long old);
 void hvm_memory_event_cr4(unsigned long value, unsigned long old);
-
 /* Called for current VCPU on int3: returns -1 if no listener */
 int hvm_memory_event_int3(unsigned long gla);
 #else
@@ -392,4 +412,44 @@ static inline int hvm_memory_event_int3(
 { return 0; }
 #endif
 
+/*
+ * Nested HVM
+ */
+
+/* Initialize vcpu's struct nestedhvm */
+int nhvm_vcpu_initialise(struct vcpu *v);
+/* Destroy and free vcpu's struct nestedhvm */
+int nhvm_vcpu_destroy(struct vcpu *v);
+/* Reset vcpu's state when l1 guest disables nested virtualization */
+int nhvm_vcpu_reset(struct vcpu *v);
+/* Restores l1 guest state */
+int nhvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs);
+/* Fill l1 guest's VMCB/VMCS with data provided by generic exit codes
+ * (do conversion as needed), other misc SVM/VMX specific tweaks to make
+ * it work */
+int nhvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
+                     uint64_t exitcode);
+/* inject vmexit into l1 guest. l1 guest will see a VMEXIT due to
+ * 'trapnr' exception.
+ */ 
+int nhvm_vcpu_vmexit_trap(struct vcpu *v,
+    unsigned int trapnr, int errcode, unsigned long cr2);
+
+/* returns l2 guest cr3 in l2 guest physical address space. */
+uint64_t nhvm_vcpu_guestcr3(struct vcpu *v);
+/* returns l1 guest's cr3 that points to the page table used to
+ * translate l2 guest physical address to l1 guest physical address.
+ */
+uint64_t nhvm_vcpu_hostcr3(struct vcpu *v);
+/* returns the asid number l1 guest wants to use to run the l2 guest */
+uint32_t nhvm_vcpu_asid(struct vcpu *v);
+
+/* returns true, when l1 guest intercepts the specified trap */
+int nhvm_vmcx_guest_intercepts_trap(struct vcpu *v, unsigned int trapnr);
+
+/* returns true when l1 guest wants to use hap to run l2 guest */
+bool_t nhvm_vmcx_hap_enabled(struct vcpu *v);
+/* interrupt */
+enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v);
+
 #endif /* __ASM_X86_HVM_HVM_H__ */

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

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

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

end of thread, other threads:[~2011-03-28 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20 16:04 [PATCH 03/12] Nested Virtualization: function hooks Christoph Egger
2011-03-09 14:23 Christoph Egger
2011-03-28 14:03 ` Dong, Eddie

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.