All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jane Malalane <jane.malalane@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>, Wei Liu <wl@xen.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Juergen Gross <jgross@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Christian Lindig <christian.lindig@citrix.com>,
	David Scott <dave@recoil.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v8 2/2] x86/xen: Allow per-domain usage of hardware virtualized APIC
Date: Wed, 23 Mar 2022 12:57:43 +0100	[thread overview]
Message-ID: <YjsLN5Kre4BdRlI1@Air-de-Roger> (raw)
In-Reply-To: <YjL4J9wDGCtc/rRv@Air-de-Roger>

On Thu, Mar 17, 2022 at 09:58:15AM +0100, Roger Pau Monné wrote:
> On Wed, Mar 16, 2022 at 09:13:15AM +0000, Jane Malalane wrote:
> > Introduce a new per-domain creation x86 specific flag to
> > select whether hardware assisted virtualization should be used for
> > x{2}APIC.
> > 
> > A per-domain option is added to xl in order to select the usage of
> > x{2}APIC hardware assisted virtualization, as well as a global
> > configuration option.
> > 
> > Having all APIC interaction exit to Xen for emulation is slow and can
> > induce much overhead. Hardware can speed up x{2}APIC by decoding the
> > APIC access and providing a VM exit with a more specific exit reason
> > than a regular EPT fault or by altogether avoiding a VM exit.
> > 
> > On the other hand, being able to disable x{2}APIC hardware assisted
> > virtualization can be useful for testing and debugging purposes.
> > 
> > Note: vmx_install_vlapic_mapping doesn't require modifications
> > regardless of whether the guest has "Virtualize APIC accesses" enabled
> > or not, i.e., setting the APIC_ACCESS_ADDR VMCS field is fine so long
> > as virtualize_apic_accesses is supported by the CPU.
> 
> Have you tested migration of guests with this patch applied?
> 
> We need to be careful so that a guest that doesn't have
> assisted_x{2}apic set in the config file can be migrated between hosts
> that have different support for hardware assisted x{2}APIC
> virtualization.
> 
> Ie: we need to make sure the selection of arch_x86.assisted_x{2}apic
> is only present in the migration stream when explicitly set in the
> configuration file.

I've tested this myself, and the behavior seems to be correct. The
selection is only present on the stream when explicitly set by the
user.

> > diff --git a/tools/xl/xl.h b/tools/xl/xl.h
> > index c5c4bedbdd..528deb3feb 100644
> > --- a/tools/xl/xl.h
> > +++ b/tools/xl/xl.h
> > @@ -286,6 +286,8 @@ extern libxl_bitmap global_vm_affinity_mask;
> >  extern libxl_bitmap global_hvm_affinity_mask;
> >  extern libxl_bitmap global_pv_affinity_mask;
> >  extern libxl_domid domid_policy;
> > +extern int assisted_xapic;
> > +extern int assisted_x2apic;
> >  
> >  enum output_format {
> >      OUTPUT_FORMAT_JSON,
> > diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
> > index 117fcdcb2b..f118dc7e97 100644
> > --- a/tools/xl/xl_parse.c
> > +++ b/tools/xl/xl_parse.c
> > @@ -2761,6 +2761,24 @@ skip_usbdev:
> >  
> >      xlu_cfg_get_defbool(config, "vpmu", &b_info->vpmu, 0);
> >  
> > +    if (b_info->type != LIBXL_DOMAIN_TYPE_PV) {
> > +        e = xlu_cfg_get_long(config, "assisted_xapic", &l , 0);
> > +        if ((e == ESRCH && assisted_xapic != -1)) /* use global default if present */
> > +            libxl_defbool_set(&b_info->arch_x86.assisted_xapic, assisted_xapic);
> > +        else if (!e)
> > +            libxl_defbool_set(&b_info->arch_x86.assisted_xapic, l);
> > +        else
> > +            exit(1);
> > +
> > +        e = xlu_cfg_get_long(config, "assisted_x2apic", &l, 0);
> > +        if ((e == ESRCH && assisted_x2apic != -1)) /* use global default if present */
> > +            libxl_defbool_set(&b_info->arch_x86.assisted_x2apic, assisted_x2apic);
> > +        else if (!e)
> > +            libxl_defbool_set(&b_info->arch_x86.assisted_x2apic, l);
> > +        else
> > +        exit(1);
> 
> Indentation seems wrong in the line above.

The chunk above is also logically wrong, because it will exit(1) if
no assisted_x{2}apic option is provided on either the guest or the
global config files.

I think:

        e = xlu_cfg_get_long(config, "assisted_xapic", &l , 0);
        if (!e)
            libxl_defbool_set(&b_info->arch_x86.assisted_xapic, l);
        else if (e != ESRCH)
            exit(1);
        else if (assisted_xapic != -1) /* use global default if present */
            libxl_defbool_set(&b_info->arch_x86.assisted_xapic, assisted_xapic);

        e = xlu_cfg_get_long(config, "assisted_x2apic", &l, 0);
        if (!e)
            libxl_defbool_set(&b_info->arch_x86.assisted_x2apic, l);
        else if (e != ESRCH)
            exit(1);
        else if (assisted_x2apic != -1) /* use global default if present */
            libxl_defbool_set(&b_info->arch_x86.assisted_x2apic,
                              assisted_x2apic);

Is better.

Thanks, Roger.


      reply	other threads:[~2022-03-23 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16  9:13 [PATCH v8 0/2] xen: Report and use hardware APIC virtualization capabilities Jane Malalane
2022-03-16  9:13 ` [PATCH v8 1/2] xen+tools: Report Interrupt Controller Virtualization capabilities on x86 Jane Malalane
2022-03-17  6:12   ` Tian, Kevin
2022-03-23 11:30   ` Roger Pau Monné
2022-03-31 10:58     ` Jane Malalane
2022-03-16  9:13 ` [PATCH v8 2/2] x86/xen: Allow per-domain usage of hardware virtualized APIC Jane Malalane
2022-03-17  8:58   ` Roger Pau Monné
2022-03-23 11:57     ` Roger Pau Monné [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YjsLN5Kre4BdRlI1@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=george.dunlap@citrix.com \
    --cc=jane.malalane@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.