On Thu, Sep 29, 2016 at 01:23:27PM +0200, Radim Krčmář wrote: > The default (auto) emulates the current behavior. > > Signed-off-by: Radim Krčmář <rkrc...@redhat.com> > --- > hw/i386/intel_iommu.c | 20 +++++++++++++++++++- > include/hw/i386/intel_iommu.h | 1 + > 2 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c > index eb488c14625d..47141cea64f4 100644 > --- a/hw/i386/intel_iommu.c > +++ b/hw/i386/intel_iommu.c > @@ -2011,6 +2011,8 @@ static const MemoryRegionOps vtd_mem_ops = { > > static Property vtd_properties[] = { > DEFINE_PROP_UINT32("version", IntelIOMMUState, version, 0), > + DEFINE_PROP_ON_OFF_AUTO("eim", IntelIOMMUState, intr_eim, > + ON_OFF_AUTO_AUTO), > DEFINE_PROP_END_OF_LIST(), > }; > > @@ -2367,7 +2369,11 @@ static void vtd_init(IntelIOMMUState *s) > s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO; > > if (x86_iommu->intr_supported) { > - s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHMV; > + s->ecap |= VTD_ECAP_IR | VTD_ECAP_MHMV; > + if (s->intr_eim == ON_OFF_AUTO_ON) { > + s->ecap |= VTD_ECAP_EIM; > + } > + assert(s->intr_eim != ON_OFF_AUTO_AUTO); > } > > vtd_reset_context_cache(s); > @@ -2466,6 +2472,18 @@ static void vtd_realize(DeviceState *dev, Error **errp) > exit(1); > } > > + if (s->intr_eim == ON_OFF_AUTO_ON && !x86_iommu->intr_supported) { > + error_report("intel-iommu,eim=on cannot be selected without " > + "intremap=on."); > + exit(1); > + } > + if (s->intr_eim == ON_OFF_AUTO_AUTO && !x86_iommu->intr_supported) { > + s->intr_eim = ON_OFF_AUTO_OFF; > + } > + if (s->intr_eim == ON_OFF_AUTO_AUTO) { > + s->intr_eim = ON_OFF_AUTO_ON; > + }
A single if() instead of above two might be nicer: if (s->intr_eim == ON_OFF_AUTO_AUTO) { e->intr_eim = x86_iommu->intr_supported ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; } Otherwise good to me. Thanks, -- peterx