All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v3 02/16] x86: introduce and use a set of internal emulation flags
Date: Tue, 4 Sep 2018 17:15:19 +0100	[thread overview]
Message-ID: <20180904161533.11575-3-wei.liu2@citrix.com> (raw)
In-Reply-To: <20180904161533.11575-1-wei.liu2@citrix.com>

Use these flags in has_* tests and emulation_flags_ok.

Not using raw flags directly enabling DCE to kick in for has_* tests
while at the same time making sure emulation_flags_ok won't go out of
sync.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v3: new
---
 xen/arch/x86/domain.c        | 13 ++++++----
 xen/include/asm-x86/domain.h | 57 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index cd1419e740..313ebb3221 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -403,19 +403,22 @@ void vcpu_destroy(struct vcpu *v)
 
 static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
 {
+#ifdef CONFIG_HVM
+    /* This doesn't catch !CONFIG_HVM case but it is better than nothing */
+    BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
+#endif
 
     if ( is_hvm_domain(d) )
     {
         if ( is_hardware_domain(d) &&
-             emflags != (XEN_X86_EMU_VPCI | XEN_X86_EMU_LAPIC |
-                         XEN_X86_EMU_IOAPIC) )
+             emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) )
             return false;
         if ( !is_hardware_domain(d) &&
-             emflags != (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI) &&
-             emflags != XEN_X86_EMU_LAPIC )
+             emflags != (X86_EMU_ALL & ~X86_EMU_VPCI) &&
+             emflags != X86_EMU_LAPIC )
             return false;
     }
-    else if ( emflags != 0 && emflags != XEN_X86_EMU_PIT )
+    else if ( emflags != 0 && emflags != X86_EMU_PIT )
     {
         /* PV or classic PVH. */
         return false;
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index c7cdf974bf..4da4353de7 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -440,18 +440,51 @@ struct arch_domain
     uint32_t emulation_flags;
 } __cacheline_aligned;
 
-#define has_vlapic(d)      (!!((d)->arch.emulation_flags & XEN_X86_EMU_LAPIC))
-#define has_vhpet(d)       (!!((d)->arch.emulation_flags & XEN_X86_EMU_HPET))
-#define has_vpm(d)         (!!((d)->arch.emulation_flags & XEN_X86_EMU_PM))
-#define has_vrtc(d)        (!!((d)->arch.emulation_flags & XEN_X86_EMU_RTC))
-#define has_vioapic(d)     (!!((d)->arch.emulation_flags & XEN_X86_EMU_IOAPIC))
-#define has_vpic(d)        (!!((d)->arch.emulation_flags & XEN_X86_EMU_PIC))
-#define has_vvga(d)        (!!((d)->arch.emulation_flags & XEN_X86_EMU_VGA))
-#define has_viommu(d)      (!!((d)->arch.emulation_flags & XEN_X86_EMU_IOMMU))
-#define has_vpit(d)        (!!((d)->arch.emulation_flags & XEN_X86_EMU_PIT))
-#define has_pirq(d)        (!!((d)->arch.emulation_flags & \
-                            XEN_X86_EMU_USE_PIRQ))
-#define has_vpci(d)        (!!((d)->arch.emulation_flags & XEN_X86_EMU_VPCI))
+#ifdef CONFIG_HVM
+#define X86_EMU_LAPIC    XEN_X86_EMU_LAPIC
+#define X86_EMU_HPET     XEN_X86_EMU_HPET
+#define X86_EMU_PM       XEN_X86_EMU_PM
+#define X86_EMU_RTC      XEN_X86_EMU_RTC
+#define X86_EMU_IOAPIC   XEN_X86_EMU_IOAPIC
+#define X86_EMU_PIC      XEN_X86_EMU_PIC
+#define X86_EMU_VGA      XEN_X86_EMU_VGA
+#define X86_EMU_IOMMU    XEN_X86_EMU_IOMMU
+#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ
+#define X86_EMU_VPCI     XEN_X86_EMU_VPCI
+#else
+#define X86_EMU_LAPIC    0
+#define X86_EMU_HPET     0
+#define X86_EMU_PM       0
+#define X86_EMU_RTC      0
+#define X86_EMU_IOAPIC   0
+#define X86_EMU_PIC      0
+#define X86_EMU_VGA      0
+#define X86_EMU_IOMMU    0
+#define X86_EMU_USE_PIRQ 0
+#define X86_EMU_VPCI     0
+#endif
+
+#define X86_EMU_PIT     XEN_X86_EMU_PIT
+
+/* This must match XEN_X86_EMU_ALL in xen.h */
+#define X86_EMU_ALL             (X86_EMU_LAPIC | X86_EMU_HPET |         \
+                                 X86_EMU_PM | X86_EMU_RTC |             \
+                                 X86_EMU_IOAPIC | X86_EMU_PIC |         \
+                                 X86_EMU_VGA | X86_EMU_IOMMU |          \
+                                 X86_EMU_PIT | X86_EMU_USE_PIRQ |       \
+                                 X86_EMU_VPCI)
+
+#define has_vlapic(d)      (!!((d)->arch.emulation_flags & X86_EMU_LAPIC))
+#define has_vhpet(d)       (!!((d)->arch.emulation_flags & X86_EMU_HPET))
+#define has_vpm(d)         (!!((d)->arch.emulation_flags & X86_EMU_PM))
+#define has_vrtc(d)        (!!((d)->arch.emulation_flags & X86_EMU_RTC))
+#define has_vioapic(d)     (!!((d)->arch.emulation_flags & X86_EMU_IOAPIC))
+#define has_vpic(d)        (!!((d)->arch.emulation_flags & X86_EMU_PIC))
+#define has_vvga(d)        (!!((d)->arch.emulation_flags & X86_EMU_VGA))
+#define has_viommu(d)      (!!((d)->arch.emulation_flags & X86_EMU_IOMMU))
+#define has_vpit(d)        (!!((d)->arch.emulation_flags & X86_EMU_PIT))
+#define has_pirq(d)        (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ))
+#define has_vpci(d)        (!!((d)->arch.emulation_flags & X86_EMU_VPCI))
 
 #define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-09-04 16:15 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 16:15 [PATCH v3 00/16] Make CONFIG_HVM work Wei Liu
2018-09-04 16:15 ` [PATCH v3 01/16] x86: change name of parameter for various invlpg functions Wei Liu
2018-09-06 11:12   ` George Dunlap
2018-09-13 16:11   ` George Dunlap
2018-09-04 16:15 ` Wei Liu [this message]
2018-09-06 13:27   ` [PATCH v3 02/16] x86: introduce and use a set of internal emulation flags Jan Beulich
2018-09-06 13:47     ` Wei Liu
2018-09-04 16:15 ` [PATCH v3 03/16] x86: XENMEM_resource_ioreq_server is HVM only Wei Liu
2018-09-04 16:24   ` Paul Durrant
2018-09-04 16:42   ` Wei Liu
2018-09-06 13:29     ` Jan Beulich
2018-09-04 16:15 ` [PATCH v3 04/16] x86: monitor.o is currently " Wei Liu
2018-09-04 16:35   ` Razvan Cojocaru
2018-09-04 16:15 ` [PATCH v3 05/16] x86: PIT emulation is common to both PV and HVM Wei Liu
2018-09-06 14:26   ` Jan Beulich
2018-09-04 16:15 ` [PATCH v3 06/16] libxl: don't set PoD target for PV guests Wei Liu
2018-09-07 13:44   ` Ian Jackson
2018-09-04 16:15 ` [PATCH v3 07/16] x86/p2m/pod: make it build with !CONFIG_HVM Wei Liu
2018-09-04 17:08   ` Razvan Cojocaru
2018-09-04 17:10     ` Razvan Cojocaru
2018-09-04 17:24   ` Julien Grall
2018-09-06 10:57     ` Wei Liu
2018-09-06 15:30       ` George Dunlap
2018-09-06 15:05   ` Jan Beulich
2018-09-06 16:06     ` George Dunlap
2018-09-04 16:15 ` [PATCH v3 08/16] x86/hvm: rearrange content of hvm.h Wei Liu
2018-09-07  6:52   ` Jan Beulich
2018-09-04 16:15 ` [PATCH v3 09/16] x86: provide stubs, declarations and macros in hvm.h Wei Liu
2018-09-07  7:02   ` Jan Beulich
2018-09-13 15:31     ` Wei Liu
2018-09-04 16:15 ` [PATCH v3 10/16] x86/mm: put nested p2m code under CONFIG_HVM Wei Liu
2018-09-06 16:20   ` George Dunlap
2018-09-13 15:46     ` Wei Liu
2018-09-13 16:01       ` George Dunlap
2018-09-07  7:06   ` Jan Beulich
2018-09-13 15:07     ` Wei Liu
2018-09-14  8:01       ` Jan Beulich
2018-09-04 16:15 ` [PATCH v3 11/16] x86/mm: put HVM only " Wei Liu
2018-09-04 17:10   ` Razvan Cojocaru
2018-09-07  7:12   ` Jan Beulich
2018-09-07 21:27   ` Tamas K Lengyel
2018-09-13 15:43     ` Wei Liu
2018-09-13 16:31       ` Tamas K Lengyel
2018-09-04 16:15 ` [PATCH v3 12/16] x86/mm: put paging_update_nestedmode " Wei Liu
2018-09-13 16:39   ` George Dunlap
2018-09-04 16:15 ` [PATCH v3 13/16] xen: connect guest creation with CONFIG_{HVM, PV} Wei Liu
2018-09-04 16:15 ` [PATCH v3 14/16] x86: expose CONFIG_HVM Wei Liu
2018-09-07  7:15   ` Jan Beulich
2018-09-13 16:01     ` Wei Liu
2018-09-14  8:07       ` Jan Beulich
2018-09-14 10:36         ` Wei Liu
2018-09-04 16:15 ` [PATCH v3 15/16] x86/pvshim: disable HVM for PV shim Wei Liu
2018-09-07  7:18   ` Jan Beulich
2018-09-07  7:46     ` Wei Liu
2018-09-07  7:48       ` Wei Liu
2018-09-04 16:15 ` [PATCH v3 16/16] xen: decouple HVM and IOMMU capabilities Wei Liu
2018-09-13 15:52   ` Ian Jackson

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=20180904161533.11575-3-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.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 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.