diff mbox

[v2,10/30] xen/x86: allow the emulated APICs to be enbled for the hardware domain

Message ID 1474991845-27962-11-git-send-email-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Sept. 27, 2016, 3:57 p.m. UTC
Allow the use of both the emulated local APIC and IO APIC for the hardware
domain.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
Changes since RFC:
 - Move the emulation flags check to a separate helper.
---
 xen/arch/x86/domain.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

Comments

Jan Beulich Sept. 29, 2016, 2:26 p.m. UTC | #1
>>> On 27.09.16 at 17:57, <roger.pau@citrix.com> wrote:
> +static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
> +{
> +
> +    if ( is_hvm_domain(d) )
> +    {
> +        if ( is_hardware_domain(d) &&
> +             emflags != (XEN_X86_EMU_PIT|XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC))
> +            return false;
> +        if ( !is_hardware_domain(d) &&
> +             emflags != XEN_X86_EMU_ALL && emflags != 0 )
> +            return false;
> +    }
> +    else
> +    {
> +        /* PV or classic PVH. */
> +        if ( is_hardware_domain(d) && emflags != XEN_X86_EMU_PIT )
> +            return false;
> +        if ( !is_hardware_domain(d) && emflags != 0 )
> +            return false;

Previous code permitted XEN_X86_EMU_PIT also for the non-hardware
domains afaict. You shouldn't change behavior without saying so and
explaining why.

Jan
Roger Pau Monné Sept. 30, 2016, 3:44 p.m. UTC | #2
On Thu, Sep 29, 2016 at 08:26:04AM -0600, Jan Beulich wrote:
> >>> On 27.09.16 at 17:57, <roger.pau@citrix.com> wrote:
> > +static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
> > +{
> > +
> > +    if ( is_hvm_domain(d) )
> > +    {
> > +        if ( is_hardware_domain(d) &&
> > +             emflags != (XEN_X86_EMU_PIT|XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC))
> > +            return false;
> > +        if ( !is_hardware_domain(d) &&
> > +             emflags != XEN_X86_EMU_ALL && emflags != 0 )
> > +            return false;
> > +    }
> > +    else
> > +    {
> > +        /* PV or classic PVH. */
> > +        if ( is_hardware_domain(d) && emflags != XEN_X86_EMU_PIT )
> > +            return false;
> > +        if ( !is_hardware_domain(d) && emflags != 0 )
> > +            return false;
> 
> Previous code permitted XEN_X86_EMU_PIT also for the non-hardware
> domains afaict. You shouldn't change behavior without saying so and
> explaining why.

Done. I'm not really sure if the emulated PIT makes much sense for a PV 
domain, also because I don't think libxl ever enabled the PIT for a PV 
domain, but alas this should be discussed in a separate patch and not 
batched in this commit.

Roger.
diff mbox

Patch

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 3c4b094..332e7f0 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -509,6 +509,29 @@  void vcpu_destroy(struct vcpu *v)
         xfree(v->arch.pv_vcpu.trap_ctxt);
 }
 
+static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
+{
+
+    if ( is_hvm_domain(d) )
+    {
+        if ( is_hardware_domain(d) &&
+             emflags != (XEN_X86_EMU_PIT|XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC))
+            return false;
+        if ( !is_hardware_domain(d) &&
+             emflags != XEN_X86_EMU_ALL && emflags != 0 )
+            return false;
+    }
+    else
+    {
+        /* PV or classic PVH. */
+        if ( is_hardware_domain(d) && emflags != XEN_X86_EMU_PIT )
+            return false;
+        if ( !is_hardware_domain(d) && emflags != 0 )
+            return false;
+    }
+    return true;
+}
+
 int arch_domain_create(struct domain *d, unsigned int domcr_flags,
                        struct xen_arch_domainconfig *config)
 {
@@ -553,9 +576,8 @@  int arch_domain_create(struct domain *d, unsigned int domcr_flags,
         }
         if ( is_hardware_domain(d) )
             config->emulation_flags |= XEN_X86_EMU_PIT;
-        if ( config->emulation_flags != 0 &&
-             (config->emulation_flags !=
-              (is_hvm_domain(d) ? XEN_X86_EMU_ALL : XEN_X86_EMU_PIT)) )
+
+        if ( !emulation_flags_ok(d, config->emulation_flags) )
         {
             printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation "
                    "with the current selection of emulators: %#x\n",