[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/2] xen/domain: rewrite emulation_flags_ok()



From: Denis Mukhin <dmukhin@xxxxxxxx>

Rewrite emulation_flags_ok() to simplify future modifications.

Also, introduce X86_EMU_{BASELINE,OPTIONAL} helper macros.

No functional change intended.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v1:
- kept use of non-public X86_EMU_XXX flags
- corrected some comments and macro definitions
---
 xen/arch/x86/domain.c             | 29 +++++++++++------------------
 xen/arch/x86/include/asm/domain.h |  6 ++++++
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index f197dad4c0..c64c2c6fef 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -750,25 +750,18 @@ static bool emulation_flags_ok(const struct domain *d, 
uint32_t emflags)
     BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
 #endif
 
-    if ( is_hvm_domain(d) )
-    {
-        if ( is_hardware_domain(d) &&
-             emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) )
-            return false;
-        if ( !is_hardware_domain(d) &&
-             /* HVM PIRQ feature is user-selectable. */
-             (emflags & ~X86_EMU_USE_PIRQ) !=
-             (X86_EMU_ALL & ~(X86_EMU_VPCI | X86_EMU_USE_PIRQ)) &&
-             emflags != X86_EMU_LAPIC )
-            return false;
-    }
-    else if ( emflags != 0 && emflags != X86_EMU_PIT )
-    {
-        /* PV or classic PVH. */
-        return false;
-    }
+    /* PV */
+    if ( !is_hvm_domain(d) )
+        return emflags == 0 || emflags == X86_EMU_PIT;
 
-    return true;
+    /* HVM */
+    if ( is_hardware_domain(d) )
+        return emflags == (X86_EMU_LAPIC |
+                           X86_EMU_IOAPIC |
+                           X86_EMU_VPCI);
+
+    return (emflags & ~X86_EMU_OPTIONAL) == X86_EMU_BASELINE ||
+            emflags == X86_EMU_LAPIC;
 }
 
 void __init arch_init_idle_domain(struct domain *d)
diff --git a/xen/arch/x86/include/asm/domain.h 
b/xen/arch/x86/include/asm/domain.h
index 8c0dea12a5..3a9a9fd80d 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -494,6 +494,12 @@ struct arch_domain
                                  X86_EMU_PIT | X86_EMU_USE_PIRQ |       \
                                  X86_EMU_VPCI)
 
+/* User-selectable features. */
+#define X86_EMU_OPTIONAL        (X86_EMU_USE_PIRQ)
+
+#define X86_EMU_BASELINE        (X86_EMU_ALL & ~(X86_EMU_VPCI | \
+                                                 X86_EMU_OPTIONAL))
+
 #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))
-- 
2.34.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.