From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: "Xen-devel@lists.xensource.com" <Xen-devel@lists.xensource.com>
Subject: [RFC PATCH 6/16]: PVH xen: Define pvh guest and header changes..
Date: Fri, 11 Jan 2013 17:51:38 -0800 [thread overview]
Message-ID: <20130111175138.26477708@mantra.us.oracle.com> (raw)
In this patch, we define pvh guest in struct domain{}. That was found
to be easiest, I tried with just using PV type, and then just hvm type,
but too many if statements to see if it was running in HVM container.
adding is_pvh seems easiest.
There are some other header changes for use by PVH code later.
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/desc.h
--- a/xen/include/asm-x86/desc.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/desc.h Fri Jan 11 16:27:46 2013 -0800
@@ -38,7 +38,8 @@
#ifndef __ASSEMBLY__
-#define GUEST_KERNEL_RPL(d) (is_pv_32bit_domain(d) ? 1 : 3)
+#define GUEST_KERNEL_RPL(d) (is_pvh_domain(d) ? 0 : \
+ is_pv_32bit_domain(d) ? 1 : 3)
/* Fix up the RPL of a guest segment selector. */
#define __fixup_guest_selector(d, sel) \
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/domain.h Fri Jan 11 16:27:46 2013 -0800
@@ -16,7 +16,7 @@
#define is_pv_32on64_domain(d) (is_pv_32bit_domain(d))
#define is_pv_32on64_vcpu(v) (is_pv_32on64_domain((v)->domain))
-#define is_hvm_pv_evtchn_domain(d) (is_hvm_domain(d) && \
+#define is_hvm_pv_evtchn_domain(d) (is_hvm_or_pvh_domain(d) && \
d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector)
#define is_hvm_pv_evtchn_vcpu(v) (is_hvm_pv_evtchn_domain(v->domain))
@@ -252,10 +252,9 @@ struct arch_domain
struct list_head pdev_list;
- union {
- struct pv_domain pv_domain;
- struct hvm_domain hvm_domain;
- };
+ /* PVH : pvh uses fields from both pv and hvm, so separate the union */
+ struct pv_domain pv_domain;
+ struct hvm_domain hvm_domain;
struct paging_domain paging;
struct p2m_domain *p2m;
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/event.h
--- a/xen/include/asm-x86/event.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/event.h Fri Jan 11 16:27:46 2013 -0800
@@ -18,7 +18,7 @@ int hvm_local_events_need_delivery(struc
static inline int local_events_need_delivery(void)
{
struct vcpu *v = current;
- return (is_hvm_vcpu(v) ? hvm_local_events_need_delivery(v) :
+ return (is_hvm_or_pvh_vcpu(v) ? hvm_local_events_need_delivery(v) :
(vcpu_info(v, evtchn_upcall_pending) &&
!vcpu_info(v, evtchn_upcall_mask)));
}
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/guest_access.h
--- a/xen/include/asm-x86/guest_access.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/guest_access.h Fri Jan 11 16:27:46 2013 -0800
@@ -14,27 +14,27 @@
/* Raw access functions: no type checking. */
#define raw_copy_to_guest(dst, src, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
copy_to_user_hvm((dst), (src), (len)) : \
copy_to_user((dst), (src), (len)))
#define raw_copy_from_guest(dst, src, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
copy_from_user_hvm((dst), (src), (len)) : \
copy_from_user((dst), (src), (len)))
#define raw_clear_guest(dst, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
clear_user_hvm((dst), (len)) : \
clear_user((dst), (len)))
#define __raw_copy_to_guest(dst, src, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
copy_to_user_hvm((dst), (src), (len)) : \
__copy_to_user((dst), (src), (len)))
#define __raw_copy_from_guest(dst, src, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
copy_from_user_hvm((dst), (src), (len)) : \
__copy_from_user((dst), (src), (len)))
#define __raw_clear_guest(dst, len) \
- (is_hvm_vcpu(current) ? \
+ (is_hvm_or_pvh_vcpu(current) ? \
clear_user_hvm((dst), (len)) : \
clear_user((dst), (len)))
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/system.h
--- a/xen/include/asm-x86/system.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/system.h Fri Jan 11 16:27:46 2013 -0800
@@ -4,9 +4,15 @@
#include <xen/lib.h>
#include <asm/bitops.h>
+/* We need vcpu because during context switch, going from pure PV to PVH,
+ * in save_segments(), current has been updated to next, and no longer pointing
+ * to the pure PV. BTW, for PVH, we update regs->selectors on each vmexit */
#define read_segment_register(vcpu, regs, name) \
({ u16 __sel; \
- asm volatile ( "movw %%" STR(name) ",%0" : "=r" (__sel) ); \
+ if (is_pvh_vcpu(v)) \
+ __sel = regs->name; \
+ else \
+ asm volatile ( "movw %%" STR(name) ",%0" : "=r" (__sel) ); \
__sel; \
})
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/asm-x86/x86_64/regs.h
--- a/xen/include/asm-x86/x86_64/regs.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/asm-x86/x86_64/regs.h Fri Jan 11 16:27:46 2013 -0800
@@ -11,9 +11,10 @@
#define ring_3(r) (((r)->cs & 3) == 3)
#define guest_kernel_mode(v, r) \
+ ( is_pvh_vcpu(v) ? ({BUG_ON(v!=current); ring_0(r);}) : \
(!is_pv_32bit_vcpu(v) ? \
(ring_3(r) && ((v)->arch.flags & TF_kernel_mode)) : \
- (ring_1(r)))
+ (ring_1(r))) )
#define permit_softint(dpl, v, r) \
((dpl) >= (guest_kernel_mode(v, r) ? 1 : 3))
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/public/domctl.h
--- a/xen/include/public/domctl.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/public/domctl.h Fri Jan 11 16:27:46 2013 -0800
@@ -89,6 +89,10 @@ 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 -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/xen/lib.h Fri Jan 11 16:27:46 2013 -0800
@@ -45,6 +45,14 @@ do {
#define ASSERT(p) do { if ( 0 && (p) ); } while (0)
#endif
+/* While PVH feature is experimental, make it an unconditional assert */
+#define PVH_ASSERT(p) \
+ do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
+#define NO_PVH_ASSERT_VCPU(v) \
+ do { if (is_pvh_vcpu(v)) PVH_ASSERT(0); } while (0)
+#define NO_PVH_ASSERT_DOMAIN(d) \
+ do { if (is_pvh_domain(d)) PVH_ASSERT(0); } while (0)
+
#define ABS(_x) ({ \
typeof(_x) __x = (_x); \
(__x < 0) ? -__x : __x; \
diff -r fadb3f2f5d97 -r 5af39353f3f9 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Fri Jan 11 16:25:27 2013 -0800
+++ b/xen/include/xen/sched.h Fri Jan 11 16:27:46 2013 -0800
@@ -230,6 +230,9 @@ struct mem_event_per_domain
struct mem_event_domain access;
};
+/* PVH is a PV guest running in HVM container. While is_hvm is false for it,
+ * it uses many of the HVM data structs.
+ */
struct domain
{
domid_t domain_id;
@@ -278,6 +281,7 @@ struct domain
/* Is this an HVM guest? */
bool_t is_hvm;
+ bool_t is_pvh; /* see above for description */
#ifdef HAS_PASSTHROUGH
/* Does this guest need iommu mappings? */
bool_t need_iommu;
@@ -449,6 +453,10 @@ 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().
@@ -713,8 +721,12 @@ void watchdog_domain_destroy(struct doma
#define is_hvm_domain(d) ((d)->is_hvm)
#define is_hvm_vcpu(v) (is_hvm_domain(v->domain))
+#define is_pvh_domain(d) ((d)->is_pvh)
+#define is_pvh_vcpu(v) (is_pvh_domain(v->domain))
#define is_pinned_vcpu(v) ((v)->domain->is_pinned || \
cpumask_weight((v)->cpu_affinity) == 1)
+#define is_hvm_or_pvh_domain(d) (is_hvm_domain(d) || is_pvh_domain(d))
+#define is_hvm_or_pvh_vcpu(v) (is_hvm_or_pvh_domain(v->domain))
#ifdef HAS_PASSTHROUGH
#define need_iommu(d) ((d)->need_iommu)
#else
next reply other threads:[~2013-01-12 1:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 1:51 Mukesh Rathor [this message]
2013-01-14 11:38 ` [RFC PATCH 6/16]: PVH xen: Define pvh guest and header changes Jan Beulich
2013-01-16 0:37 ` Mukesh Rathor
2013-01-16 9:53 ` Jan Beulich
2013-01-31 1:21 ` Mukesh Rathor
2013-01-24 15:34 ` Tim Deegan
2013-01-25 1:56 ` Mukesh Rathor
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=20130111175138.26477708@mantra.us.oracle.com \
--to=mukesh.rathor@oracle.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 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).