From: Wei Liu Subject: Re: [PATCH v6 11/29] xen/x86: add bitmap of enabled emulated devices Date: Fri, 4 Sep 2015 13:25:37 +0100 Message-ID: <20150904122537.GC27133@zion.uk.xensource.com> References: <1441368548-43465-1-git-send-email-roger.pau@citrix.com> <1441368548-43465-12-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZXq3p-0001hZ-4D for xen-devel@lists.xenproject.org; Fri, 04 Sep 2015 12:25:41 +0000 Content-Disposition: inline In-Reply-To: <1441368548-43465-12-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: Wei Liu , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , Jan Beulich , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Fri, Sep 04, 2015 at 02:08:50PM +0200, Roger Pau Monne wrote: > Introduce a bitmap in x86 xen_arch_domainconfig that allows enabling or > disabling specific devices emulated inside of Xen for HVM guests. > = > Signed-off-by: Roger Pau Monn=E9 > Reviewed-by: Andrew Cooper > Cc: Ian Jackson > Cc: Stefano Stabellini > Cc: Ian Campbell > Cc: Wei Liu > Cc: Jan Beulich > Cc: Andrew Cooper > --- > Changes since v4: > - Add a check to make sure the emulation bitmap is sane (undefined bits = are > all 0s). > - Add Andrew Cooper Reviewed-by. > = > Changes since v3: > - Return EOPNOTSUPP instead of ENOPERM if an invalid emulation mask is > used. > - Fix error messages (prefix them with d%d and use %#x instead of 0x%x). > - Clearly state in the public header that emulation_flags should only be > used with HVM guests. > - Add a XEN_X86 prefix to the emulation flags defines. > - Properly parenthese the has_* marcos. > --- > tools/libxl/libxl_x86.c | 8 ++++++-- > xen/arch/x86/domain.c | 23 +++++++++++++++++++++++ > xen/include/asm-x86/domain.h | 13 +++++++++++++ > xen/include/public/arch-x86/xen.h | 21 ++++++++++++++++++++- > 4 files changed, 62 insertions(+), 3 deletions(-) > = > diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c > index 9276126..9ecd85d 100644 > --- a/tools/libxl/libxl_x86.c > +++ b/tools/libxl/libxl_x86.c > @@ -7,8 +7,12 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, > libxl_domain_config *d_config, > xc_domain_configuration_t *xc_conf= ig) > { > - /* No specific configuration right now */ > - > + if (d_config->c_info.type =3D=3D LIBXL_DOMAIN_TYPE_HVM) > + xc_config->emulation_flags =3D (XEN_X86_EMU_LAPIC | XEN_X86_EMU_= HPET | > + XEN_X86_EMU_PMTIMER | XEN_X86_EMU_= RTC | > + XEN_X86_EMU_IOAPIC | XEN_X86_EMU_P= IC | > + XEN_X86_EMU_PMU | XEN_X86_EMU_VGA | > + XEN_X86_EMU_IOMMU); > return 0; > } > = > diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c > index 045f6ff..fe9504f 100644 > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -555,6 +555,29 @@ int arch_domain_create(struct domain *d, unsigned in= t domcr_flags, > d->domain_id); > } > = > + if ( is_hvm_domain(d) ) > + { > + uint32_t emulation_mask =3D (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPE= T | > + XEN_X86_EMU_PMTIMER | XEN_X86_EMU_RTC= | > + XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC | > + XEN_X86_EMU_PMU | XEN_X86_EMU_VGA | > + XEN_X86_EMU_IOMMU); This is repetitive. Could you consolidate all these to #define XEN_X86_EMU_ALL ... ? Or am I talking non-sense? Wei.