|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC 03/12] xen/x86: allow the emulated APICs to be enbled for the hardware domain
On Fri, Jul 29, 2016 at 06:50:48PM +0100, Andrew Cooper wrote:
> On 29/07/16 17:28, Roger Pau Monne wrote:
> > 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)) )
> > + emflags |= XEN_X86_EMU_PIT;
> > +
> > + if ( (is_hardware_domain(d) ?
> > + (is_hvm_domain(d) && emflags !=
> > + (XEN_X86_EMU_PIT|XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC)) :
> > + (emflags && (is_hvm_domain(d) ? (emflags != XEN_X86_EMU_ALL)
> > :
> > + (emflags !=
> > XEN_X86_EMU_PIT)))) )
>
> This is getting very complicated.
>
> It is rather important (security wise) and not a hotpath. Could I
> please request that you move this logic to a helper such as:
>
> static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
>
> and make this more readable. Any decent compiler will inline and
> simplify it appropriately.
Thanks, I've now moved it to a helper as suggested:
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;
}
Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |