xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v15 06/19] pvh: Introduce PVH guest type
Date: Mon, 11 Nov 2013 14:57:08 +0000	[thread overview]
Message-ID: <1384181841-22739-7-git-send-email-george.dunlap@eu.citrix.com> (raw)
In-Reply-To: <1384181841-22739-1-git-send-email-george.dunlap@eu.citrix.com>

Introduce new PVH guest type, flags to create it, and ways to identify it.

To begin with, it will inherit functionality marked hvm_container.

Code to actually check for hardware support, in the VMX case, will be added
in future patches.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
---
v15:
 - Check for hardware support for PVH domains in hvm_domain_initialise
 - Move HAP check to hvm_domain_initialise as well
v13: Changed if/else in getdomaininfo into a switch statement as requested.

CC: Jan Beulich <jbeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Keir Fraser <keir@xen.org>
---
 xen/arch/x86/hvm/hvm.c        |   19 +++++++++++++++++++
 xen/common/domain.c           |    2 ++
 xen/common/domctl.c           |   24 +++++++++++++++++++++---
 xen/include/asm-x86/hvm/hvm.h |    3 +++
 xen/include/public/domctl.h   |    8 +++++++-
 xen/include/xen/sched.h       |   11 ++++++++++-
 6 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 7aa1e8a..0a9c922 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -145,6 +145,9 @@ static int __init hvm_enable(void)
         printk("\n");
     }
 
+    if ( !fns->pvh_supported )
+        printk("HVM: PVH mode not supported on this platform\n");
+
     /*
      * Allow direct access to the PC debug ports 0x80 and 0xed (they are
      * often used for I/O delays, but the vmexits simply slow things down).
@@ -522,6 +525,22 @@ int hvm_domain_initialise(struct domain *d)
         return -EINVAL;
     }
 
+    if ( is_pvh_domain(d) )
+    {
+        if ( !hvm_funcs.pvh_supported )
+        {
+            gdprintk(XENLOG_WARNING, "Attempt to create a PVH guest "
+                     "on a system without necessary hardware support.\n");
+            return -EINVAL;
+        }
+        if ( !hap_enabled(d) )
+        {
+            printk(XENLOG_INFO "PVH guest must have HAP on\n");
+            return -EINVAL;
+        }
+
+    }
+
     spin_lock_init(&d->arch.hvm_domain.irq_lock);
     spin_lock_init(&d->arch.hvm_domain.uc_lock);
 
diff --git a/xen/common/domain.c b/xen/common/domain.c
index f39b28d..52b7cea 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -239,6 +239,8 @@ struct domain *domain_create(
 
     if ( domcr_flags & DOMCRF_hvm )
         d->guest_type = guest_type_hvm;
+    else if ( domcr_flags & DOMCRF_pvh )
+        d->guest_type = guest_type_pvh;
 
     if ( domid == 0 )
     {
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 870eef1..552669d 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -185,8 +185,17 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
         (d->debugger_attached           ? XEN_DOMINF_debugged : 0) |
         d->shutdown_code << XEN_DOMINF_shutdownshift;
 
-    if ( is_hvm_domain(d) )
+    switch(d->guest_type)
+    {
+    case guest_type_hvm:
         info->flags |= XEN_DOMINF_hvm_guest;
+        break;
+    case guest_type_pvh:
+        info->flags |= XEN_DOMINF_pvh_guest;
+        break;
+    default:
+        break;
+    }
 
     xsm_security_domaininfo(d, info);
 
@@ -412,8 +421,11 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
         ret = -EINVAL;
         if ( supervisor_mode_kernel ||
              (op->u.createdomain.flags &
-             ~(XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap |
-               XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off)) )
+             ~(XEN_DOMCTL_CDF_hvm_guest
+               | XEN_DOMCTL_CDF_pvh_guest
+               | XEN_DOMCTL_CDF_hap
+               | XEN_DOMCTL_CDF_s3_integrity
+               | XEN_DOMCTL_CDF_oos_off)) )
             break;
 
         dom = op->domain;
@@ -440,9 +452,15 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             rover = dom;
         }
 
+        if ( (op->u.createdomain.flags & XEN_DOMCTL_CDF_hvm_guest)
+             && (op->u.createdomain.flags & XEN_DOMCTL_CDF_pvh_guest) )
+            return -EINVAL;
+
         domcr_flags = 0;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hvm_guest )
             domcr_flags |= DOMCRF_hvm;
+        if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_pvh_guest )
+            domcr_flags |= DOMCRF_pvh;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_hap )
             domcr_flags |= DOMCRF_hap;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_s3_integrity )
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index c9afb56..ccca5df 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -90,6 +90,9 @@ struct hvm_function_table {
     /* Support Hardware-Assisted Paging? */
     int hap_supported;
 
+    /* Necessary hardware support for PVH mode? */
+    int pvh_supported;
+
     /* Indicate HAP capabilities. */
     int hap_capabilities;
 
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index d4e479f..c79dabe 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -47,7 +47,7 @@ struct xen_domctl_createdomain {
     /* IN parameters */
     uint32_t ssidref;
     xen_domain_handle_t handle;
- /* Is this an HVM guest (as opposed to a PV guest)? */
+ /* Is this an HVM guest (as opposed to a PVH or PV guest)? */
 #define _XEN_DOMCTL_CDF_hvm_guest     0
 #define XEN_DOMCTL_CDF_hvm_guest      (1U<<_XEN_DOMCTL_CDF_hvm_guest)
  /* Use hardware-assisted paging if available? */
@@ -59,6 +59,9 @@ struct xen_domctl_createdomain {
  /* Disable out-of-sync shadow page tables? */
 #define _XEN_DOMCTL_CDF_oos_off       3
 #define XEN_DOMCTL_CDF_oos_off        (1U<<_XEN_DOMCTL_CDF_oos_off)
+ /* Is this a PVH guest (as opposed to an HVM or PV guest)? */
+#define _XEN_DOMCTL_CDF_pvh_guest     4
+#define XEN_DOMCTL_CDF_pvh_guest      (1U<<_XEN_DOMCTL_CDF_pvh_guest)
     uint32_t flags;
 };
 typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
@@ -89,6 +92,9 @@ struct xen_domctl_getdomaininfo {
  /* Being debugged.  */
 #define _XEN_DOMINF_debugged  6
 #define XEN_DOMINF_debugged   (1U<<_XEN_DOMINF_debugged)
+/* domain is PVH */
+#define _XEN_DOMINF_pvh_guest 7
+#define XEN_DOMINF_pvh_guest   (1U<<_XEN_DOMINF_pvh_guest)
  /* XEN_DOMINF_shutdown guest-supplied code.  */
 #define XEN_DOMINF_shutdownmask 255
 #define XEN_DOMINF_shutdownshift 16
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index a9dd15f..6d78bf9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -259,8 +259,12 @@ struct mem_event_per_domain
 
 struct evtchn_port_ops;
 
+/*
+ * PVH is a PV guest running in an HVM container.  is_hvm_* checks
+ * will be false, but has_hvm_container_* checks will be true.
+ */
 enum guest_type {
-    guest_type_pv, guest_type_hvm
+    guest_type_pv, guest_type_pvh, guest_type_hvm
 };
 
 struct domain
@@ -500,6 +504,9 @@ struct domain *domain_create(
  /* DOMCRF_oos_off: dont use out-of-sync optimization for shadow page tables */
 #define _DOMCRF_oos_off         4
 #define DOMCRF_oos_off          (1U<<_DOMCRF_oos_off)
+ /* DOMCRF_pvh: Create PV domain in HVM container. */
+#define _DOMCRF_pvh            5
+#define DOMCRF_pvh             (1U<<_DOMCRF_pvh)
 
 /*
  * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
@@ -778,6 +785,8 @@ void watchdog_domain_destroy(struct domain *d);
 
 #define is_pv_domain(d) ((d)->guest_type == guest_type_pv)
 #define is_pv_vcpu(v)   (is_pv_domain((v)->domain))
+#define is_pvh_domain(d) ((d)->guest_type == guest_type_pvh)
+#define is_pvh_vcpu(v)   (is_pvh_domain((v)->domain))
 #define is_hvm_domain(d) ((d)->guest_type == guest_type_hvm)
 #define is_hvm_vcpu(v)   (is_hvm_domain(v->domain))
 #define has_hvm_container_domain(d) ((d)->guest_type != guest_type_pv)
-- 
1.7.9.5

  parent reply	other threads:[~2013-11-11 14:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11 14:57 [PATCH v15 00/18] Introduce PVH domU support George Dunlap
2013-11-11 14:57 ` [PATCH v15 01/19] Allow vmx_update_debug_state to be called when v!=current George Dunlap
2013-11-11 14:57 ` [PATCH v15 02/19] libxc: Move temporary grant table mapping to end of memory George Dunlap
2013-11-11 14:57 ` [PATCH v15 03/19] pvh prep: code motion George Dunlap
2013-11-11 14:57 ` [PATCH v15 04/19] pvh: Tolerate HVM guests having no ioreq page George Dunlap
2013-11-11 14:57 ` [PATCH v15 05/19] pvh prep: Introduce pv guest type and has_hvm_container macros George Dunlap
2013-11-12 13:34   ` Jan Beulich
2013-11-12 15:12     ` George Dunlap
2013-11-11 14:57 ` George Dunlap [this message]
2013-11-11 14:57 ` [PATCH v15 07/19] pvh: Disable unneeded features of HVM containers George Dunlap
2013-11-12 13:51   ` Jan Beulich
2013-11-12 14:56     ` George Dunlap
2013-11-12 15:03       ` Jan Beulich
2013-11-12 15:08         ` George Dunlap
2013-11-11 14:57 ` [PATCH v15 08/19] pvh: vmx-specific changes George Dunlap
2013-11-12 14:03   ` Jan Beulich
2013-11-12 15:06     ` George Dunlap
2013-11-12 15:24       ` Jan Beulich
2013-11-11 14:57 ` [PATCH v15 09/19] pvh: Do not allow PVH guests to change paging modes George Dunlap
2013-11-11 14:57 ` [PATCH v15 10/19] pvh: PVH access to hypercalls George Dunlap
2013-11-11 14:57 ` [PATCH v15 11/19] pvh: Use PV e820 George Dunlap
2013-11-11 14:57 ` [PATCH v15 12/19] pvh: Set up more PV stuff in set_info_guest George Dunlap
2013-11-11 14:57 ` [PATCH v15 13/19] pvh: PV cpuid George Dunlap
2013-11-11 14:57 ` [PATCH v15 14/19] pvh: Use PV handlers for PIO George Dunlap
2013-11-12 14:33   ` Jan Beulich
2013-11-12 16:54     ` George Dunlap
2013-11-12 17:00       ` Jan Beulich
2013-11-11 14:57 ` [PATCH v15 15/19] pvh: Disable 32-bit guest support for now George Dunlap
2013-11-11 14:57 ` [PATCH v15 16/19] pvh: Restrict tsc_mode to NEVER_EMULATE " George Dunlap
2013-11-11 14:57 ` [PATCH v15 17/19] pvh: Documentation George Dunlap
2013-11-11 14:57 ` [PATCH v15 18/19] pvh tools: libxc changes to build a PVH guest George Dunlap
2013-11-12 11:33   ` Ian Jackson
2013-11-11 14:57 ` [PATCH v15 19/19] pvh tools: libxl changes to create " George Dunlap
2013-11-12 11:38   ` Ian Jackson
2013-11-11 15:30 ` [PATCH v15 00/18] Introduce PVH domU support George Dunlap
2013-11-11 17:17 ` Keir Fraser
2013-11-12  7:19 ` Dong, Eddie

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=1384181841-22739-7-git-send-email-george.dunlap@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).