[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/2] xen+tools: Report Interrupt Controller Virtualization capabilities on x86


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jane Malalane <Jane.Malalane@xxxxxxxxxx>
  • Date: Mon, 7 Mar 2022 12:17:56 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qh3cHb5mreaFkEXdWWDpEitO5nyXMiy2B62z+zdAVis=; b=QU5Rxi+wEoP+vv1npxYl+BprJRA1Y865H1VQaX5aNjzNz6v1rmNMOcQz6nqo3RsHx+3Nv2PYLgMrj48oNf/zfoykFCD6UxFGDXTPVJhXdqBO0z1jT/Y0YCl/W0I4vpqRhutT/lJ0CSxVQF+AU/CAK6FprOts6IV1C0labgPBGtxzNofqCu2Xl4DGU6ZGsuqC7btpkDlCpiAt8miDDCVEuvL5+TA9R9AJYinuf4nFjaCKM54PeyRjzj9TrxcSyHUt0C1yB8wES2fJBnjUl96Cd4b1bUsTjr3fJvm9d/2F3yZ7/N0ObUvhDTh0IMQY/7Ccfr47Wg5fFl8ska6AdgQZqA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hMDhT/NjEwvarhOO2aKrSJMnq++Lu17JqHty5zl2wcTuWn3cCydmst4cK4y5qrpwO/3Rt5juGAAqBUnxqW4rqutR/n0o+OcR8Tc5YpeGUChYdSBr4FwtPyJw0E7sC9fCzZaQSbEgOTFU+s+QI/lL8guELywOmW8uy1C5WmHy8NmLwd9ieh1s2KHnWFsP2jxGZrPQ3oI3aq0wrCB8BzvEZqUGwCcuJ+wJ4oo3MY1v/lsNqXX3UOZrPYv52LpdTn16NTK5Rm7D/ZXtJxneFLjvxI0C7XnXSCLWyXVoldwP6D1qTdbFPqN7CeFMlm+D94aH6RRXN+N8/SfW3FhsDntdpA==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, "Juergen Gross" <jgross@xxxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, "George Dunlap" <George.Dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 07 Mar 2022 12:18:14 +0000
  • Ironport-data: A9a23:kS62zaIJAPbY/tB4FE+RfJUlxSXFcZb7ZxGr2PjKsXjdYENShmNRy WZMUW2GOP/eYmWjKo0kaYvi8EMBup/VmoNhSQVlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA148IMsdoUg7wbRh2dY32YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 O92u5ewYCNxB7ySxs1MCAABGAVjIqITrdcrIVDn2SCS50jPcn+qyPRyFkA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ogeQVBEWk9Q96U 4OSdkHNDSdNykZsS++2njELz9C+qjGzEnLv5ak854Fd2gDAMsMj3YbNu/YKDwNeOAvP+tiKH P23Lshm9PUQwVvUi3NPAhiYwGsnayvqLvWJTo9QzI34giHij2lrJTgFQKD4xsYWzRThZ8/7G nsiWXCl+aemsD+7iWZ+37Y7pxQltek4MBEHtawhs8cLSipohq0Zb5mR6aJsFkO0aOSARcR4Z zxSiUbToNOAkDqDyeISNzWqlDdOQMVmjvfIJmj8CPeSILCNWkH4oF69Pxkm1PimjsdVZdHof 92NiuixupqJAKFkyLn69fSURZ20kKyvHo5iOYWy2dSSI0EddZq3MYiFexuYeM99Q/Bmcga+d NVfYrhDTdtACSnRmGcunMqzM2nX3w1EBvDSk8eutaN2zwTmHxi1UMXyMEWg39FrfsGOtV5zv WBNr4tmKBFT8cQY644DOAdQdGvAmiIRR7XKmqdLVnuCalCMXPQrJz85qkz+YiRCdE15Yp3nI 6EXEJTtGY0dU6rAcqS3IdT+hSIW2m5VSSF8LAW23G4gMyLeFPGC1zwdLl1qbrSnxw2OLyvZ8 qO
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYLkaMjdZBkrS3CkWZwGsOatNz36ytiXSAgABT+oCAAQaGAIAE+jyA
  • Thread-topic: [PATCH v4 1/2] xen+tools: Report Interrupt Controller Virtualization capabilities on x86

On 04/03/2022 08:17, Jan Beulich wrote:
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments 
> unless you have verified the sender and know the content is safe.
> 
> On 03.03.2022 17:37, Jane Malalane wrote:
>> On 03/03/2022 11:37, Jan Beulich wrote:
>>> On 02.03.2022 16:00, Jane Malalane wrote:
>>>> Add XEN_SYSCTL_PHYSCAP_ARCH_ASSISTED_xapic and
>>>> XEN_SYSCTL_PHYSCAP_ARCH_ASSISTED_x2apic to report accelerated xapic
>>>> and x2apic, on x86 hardware.
>>>> No such features are currently implemented on AMD hardware.
>>>>
>>>> For that purpose, also add an arch-specific "capabilities" parameter
>>>> to struct xen_sysctl_physinfo.
>>>>
>>>> Note that this interface is intended to be compatible with AMD so that
>>>> AVIC support can be introduced in a future patch. Unlike Intel that
>>>> has multiple controls for APIC Virtualization, AMD has one global
>>>> 'AVIC Enable' control bit, so fine-graining of APIC virtualization
>>>> control cannot be done on a common interface. Therefore, for xAPIC HW
>>>> assisted virtualization support to be reported, HW must support
>>>> virtualize_apic_accesses as well as apic_reg_virt.
>>>
>>> Okay, here you now describe _what_ is being implemented, but I'm
>>> afraid it still lacks justification (beyond making this re-usable for
>>> AVIC, which imo can only be a secondary goal). You actually say ...
Is the following any better...?

"Add XEN_SYSCTL_PHYSCAP_ARCH_ASSISTED_xapic and
XEN_SYSCTL_PHYSCAP_ARCH_ASSISTED_x2apic to report accelerated xapic
and x2apic, on x86 hardware.
No such features are currently implemented on AMD hardware.

HW assisted xAPIC virtualization will be reported if HW, at the minimum, 
  supports virtualize_apic_accesses as this feature alone means that an 
access to the APIC page will cause an APIC-access VM exit. An 
APIC-access VM exit provides a VMM with information about the access 
causing the VM exit, unlike a regular EPT fault, thus simplifying some 
internal handling.

HW assisted x2APIC virtualization will be reported if HW supports 
virtualize_x2apic_mode and, at least, either apic_reg_virt or 
virtual_intr_delivery. This is due to apic_reg_virt and 
virtual_intr_delivery preventing a VM exit from occuring or at least 
replacing a regular EPT fault VM-exit with an APIC-access VM-exit on 
read and write APIC accesses, respectively.
This also means that sysctl follows the conditionals in 
vmx_vlapic_msr_changed().

For that purpose, also add an arch-specific "capabilities" parameter
to struct xen_sysctl_physinfo.

Note that this interface is intended to be compatible with AMD so that
AVIC support can be introduced in a future patch. Unlike Intel that
has multiple controls for APIC Virtualization, AMD has one global
'AVIC Enable' control bit, so fine-graining of APIC virtualization
control cannot be done on a common interface."

I previously didn't add here any info about the assistance that each CPU 
bit provides to avoid repitition, as I talk about that in patch 2, but I 
interpreted from your comment that it might be helpful to add that here 
too.
>>>
>>>> For x2APIC HW
>>>> assisted virtualization reporting, virtualize_x2apic_mode must be
>>>> supported alongside apic_reg_virt and virtual_intr_delivery.
>>>>
>>>> Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>>> Signed-off-by: Jane Malalane <jane.malalane@xxxxxxxxxx>
>>>>
>>>> v4:
>>>>    * Fallback to the original v2/v1 conditions for setting
>>>>      assisted_xapic_available and assisted_x2apic_available so that in
>>>>      the future APIC virtualization can be exposed on AMD hardware
>>>>      since fine-graining of "AVIC" is not supported, i.e., AMD solely
>>>>      uses "AVIC Enable". This also means that sysctl mimics what's
>>>>      exposed in CPUID.
>>>
>>> ... more here: You claim similarity with CPUID. That's a possible route,
>>> but we need to be clear that these CPUID flags are optimization hints
>>> for the guest to use, while the new control is intended to be a functional
>>> one. Hence it's not obvious that CPUID wants following, and not instead
>>> the conditionals used in vmx_vlapic_msr_changed() (or yet something else).
>>>
>>> What's worse though: What you say is true for x2APIC, but not for xAPIC.
>>> Which effectively is in line with vmx_vlapic_msr_changed() and CPUID
>>> handling also agreeing as far as x2APIC is concerned, but disagreeing on
>>> the xAPIC side. I can only once again try to express that it may well be
>>> that pre-existing code wants adjusting before actually making the changes
>>> you're after.
>>
>>
>> I've been thinking about this. Considering what you say, I propose:
>>
>> - having assisted_x2apic_available = cpu_has_vmx_virtualize_x2apic_mode
>> && (cpu_has_vmx_apic_reg_virt || cpu_has_vmx_virtual_intr_delivery).
>> This would mean that on Intel CPUs has_assisted_x2apic==1 would signify
>> that there is at least "some" assistance*, whereas on AMD it would
>> signify that there is full assistance (assistance here meaning no VM-exits).
>> * apic_reg_virt prevents VM exits on execution of RDMSR and
>> virtual_intr_delivery prevents VM exits on execution of RDMSR, from what
>> I've gathered.
> 
> I agree with this part of the plan.
> 
>> - having assisted_xapic_available = cpu_has_vmx_virtualize_apic_accesses
>> && cpu_has_vmx_apic_reg_virt because apic_reg_virt is neccessary for
>> "any" assistance.
> 
> Not exactly, aiui: cpu_has_vmx_virtualize_apic_accesses alone is beneficial
> because a separate VM exit is then used, simplifying some internal handling.
> There might actually be room for improvement in our handling of this, as we
> presently use the exit qualification only to accelerate EOI writes.
I agree with you, by "assistance" in my response I meant "no VM-exits" 
but yes there is assistance, beyond absence of a VM exit, with 
virtualize_apic_acesses alone.>> - Currently, the code only sets 
SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE if
>> "some" assistance is guaranteed but sets
>> SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES even if no assistance is
>> guaranteed. So the adjustment to the pre-existing code that I propose is
>> adding cpu_has_vmx_apic_reg_virt to the initial check in
>> vmx_vlapic_msr_changed():
>>
>>    void vmx_vlapic_msr_changed(struct vcpu *v)
>>    {
>>        int virtualize_x2apic_mode;
>>        struct vlapic *vlapic = vcpu_vlapic(v);
>>        unsigned int msr;
>>
>>        virtualize_x2apic_mode = ((cpu_has_vmx_apic_reg_virt ||
>>                                   cpu_has_vmx_virtual_intr_delivery) &&
>>                                  cpu_has_vmx_virtualize_x2apic_mode);
>>
>>        if ( !cpu_has_vmx_virtualize_apic_accesses &&
>> +         !cpu_has_vmx_apic_reg_virt &&
>>             !virtualize_x2apic_mode )
>>            return;
> 
> I'd suggest the opposite for the xAPIC case: Leave the condition here
> unchanged, but consider tightening the condition for the CPUID flag.
> That'll bring xAPIC handling more in line with x2APIC one
Sounds good.


Thanks again,

Jane.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.