* [PATCH 0/4] Add support for XMM fast hypercalls @ 2021-04-07 21:29 Siddharth Chandrasekaran 2021-04-08 15:28 ` Wei Liu 0 siblings, 1 reply; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-07 21:29 UTC (permalink / raw) To: kys, haiyangz, sthemmin, wei.liu, tglx, mingo, bp, x86, hpa, pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro Cc: sidcha, graf, eyakovl, linux-hyperv, linux-kernel, kvm Hyper-V supports the use of XMM registers to perform fast hypercalls. This allows guests to take advantage of the improved performance of the fast hypercall interface even though a hypercall may require more than (the current maximum of) two general purpose registers. The XMM fast hypercall interface uses an additional six XMM registers (XMM0 to XMM5) to allow the caller to pass an input parameter block of up to 112 bytes. Hyper-V can also return data back to the guest in the remaining XMM registers that are not used by the current hypercall. Although the Hyper-v TLFS mentions that a guest cannot use this feature unless the hypervisor advertises support for it, some hypercalls which we plan on upstreaming in future uses them anyway. This patchset adds necessary infrastructure for handling input/output via XMM registers and patches kvm_hv_flush_tlb() to use xmm input arguments. ~ Sid. Siddharth Chandrasekaran (4): KVM: x86: Move FPU register accessors into fpu.h KVM: hyper-v: Collect hypercall params into struct KVM: x86: kvm_hv_flush_tlb use inputs from XMM registers KVM: hyper-v: Advertise support for fast XMM hypercalls arch/x86/include/asm/hyperv-tlfs.h | 4 +- arch/x86/kvm/emulate.c | 138 +++-------------- arch/x86/kvm/fpu.h | 140 +++++++++++++++++ arch/x86/kvm/hyperv.c | 241 +++++++++++++++++++---------- 4 files changed, 322 insertions(+), 201 deletions(-) create mode 100644 arch/x86/kvm/fpu.h -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-07 21:29 [PATCH 0/4] Add support for XMM fast hypercalls Siddharth Chandrasekaran @ 2021-04-08 15:28 ` Wei Liu 2021-04-08 15:30 ` Paolo Bonzini 0 siblings, 1 reply; 12+ messages in thread From: Wei Liu @ 2021-04-08 15:28 UTC (permalink / raw) To: Siddharth Chandrasekaran Cc: kys, haiyangz, sthemmin, wei.liu, tglx, mingo, bp, x86, hpa, pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Wed, Apr 07, 2021 at 11:29:26PM +0200, Siddharth Chandrasekaran wrote: > Hyper-V supports the use of XMM registers to perform fast hypercalls. > This allows guests to take advantage of the improved performance of the > fast hypercall interface even though a hypercall may require more than > (the current maximum of) two general purpose registers. > > The XMM fast hypercall interface uses an additional six XMM registers > (XMM0 to XMM5) to allow the caller to pass an input parameter block of > up to 112 bytes. Hyper-V can also return data back to the guest in the > remaining XMM registers that are not used by the current hypercall. > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > unless the hypervisor advertises support for it, some hypercalls which > we plan on upstreaming in future uses them anyway. No, please don't do this. Check the feature bit(s) before you issue hypercalls which rely on the extended interface. Wei. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:28 ` Wei Liu @ 2021-04-08 15:30 ` Paolo Bonzini 2021-04-08 15:38 ` Wei Liu 2021-04-08 15:40 ` Siddharth Chandrasekaran 0 siblings, 2 replies; 12+ messages in thread From: Paolo Bonzini @ 2021-04-08 15:30 UTC (permalink / raw) To: Wei Liu, Siddharth Chandrasekaran Cc: kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On 08/04/21 17:28, Wei Liu wrote: >> Although the Hyper-v TLFS mentions that a guest cannot use this feature >> unless the hypervisor advertises support for it, some hypercalls which >> we plan on upstreaming in future uses them anyway. > > No, please don't do this. Check the feature bit(s) before you issue > hypercalls which rely on the extended interface. Perhaps Siddharth should clarify this, but I read it as Hyper-V being buggy and using XMM arguments unconditionally. Paolo ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:30 ` Paolo Bonzini @ 2021-04-08 15:38 ` Wei Liu 2021-04-08 16:21 ` Siddharth Chandrasekaran 2021-04-08 15:40 ` Siddharth Chandrasekaran 1 sibling, 1 reply; 12+ messages in thread From: Wei Liu @ 2021-04-08 15:38 UTC (permalink / raw) To: Paolo Bonzini Cc: Wei Liu, Siddharth Chandrasekaran, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 05:30:26PM +0200, Paolo Bonzini wrote: > On 08/04/21 17:28, Wei Liu wrote: > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > unless the hypervisor advertises support for it, some hypercalls which > > > we plan on upstreaming in future uses them anyway. > > > > No, please don't do this. Check the feature bit(s) before you issue > > hypercalls which rely on the extended interface. > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being buggy > and using XMM arguments unconditionally. > There is no code in upstream Linux that uses the XMM fast hypercall interface at the moment. If there is such code, it has bugs in it and should be fixed. :-) Wei. > Paolo > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:38 ` Wei Liu @ 2021-04-08 16:21 ` Siddharth Chandrasekaran 0 siblings, 0 replies; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-08 16:21 UTC (permalink / raw) To: Wei Liu Cc: Paolo Bonzini, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 03:38:13PM +0000, Wei Liu wrote: > On Thu, Apr 08, 2021 at 05:30:26PM +0200, Paolo Bonzini wrote: > > On 08/04/21 17:28, Wei Liu wrote: > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > > unless the hypervisor advertises support for it, some hypercalls which > > > > we plan on upstreaming in future uses them anyway. > > > > > > No, please don't do this. Check the feature bit(s) before you issue > > > hypercalls which rely on the extended interface. > > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being buggy > > and using XMM arguments unconditionally. > > > > There is no code in upstream Linux that uses the XMM fast hypercall > interface at the moment. > > If there is such code, it has bugs in it and should be fixed. :-) None of the existing hypercalls are buggy. These are some hypercalls we are working on (and planning on upstreaming in the near future). ~ Sid. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:30 ` Paolo Bonzini 2021-04-08 15:38 ` Wei Liu @ 2021-04-08 15:40 ` Siddharth Chandrasekaran 2021-04-08 15:48 ` Paolo Bonzini 1 sibling, 1 reply; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-08 15:40 UTC (permalink / raw) To: Paolo Bonzini Cc: Wei Liu, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 05:30:26PM +0200, Paolo Bonzini wrote: > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. > > > > On 08/04/21 17:28, Wei Liu wrote: > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > unless the hypervisor advertises support for it, some hypercalls which > > > we plan on upstreaming in future uses them anyway. > > > > No, please don't do this. Check the feature bit(s) before you issue > > hypercalls which rely on the extended interface. > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being > buggy and using XMM arguments unconditionally. The guest is at fault here as it expects Hyper-V to consume arguments from XMM registers for certain hypercalls (that we are working) even if we didn't expose the feature via CPUID bits. ~ Sid. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:40 ` Siddharth Chandrasekaran @ 2021-04-08 15:48 ` Paolo Bonzini 2021-04-08 15:54 ` Siddharth Chandrasekaran 0 siblings, 1 reply; 12+ messages in thread From: Paolo Bonzini @ 2021-04-08 15:48 UTC (permalink / raw) To: Siddharth Chandrasekaran Cc: Wei Liu, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On 08/04/21 17:40, Siddharth Chandrasekaran wrote: >>>> Although the Hyper-v TLFS mentions that a guest cannot use this feature >>>> unless the hypervisor advertises support for it, some hypercalls which >>>> we plan on upstreaming in future uses them anyway. >>> No, please don't do this. Check the feature bit(s) before you issue >>> hypercalls which rely on the extended interface. >> Perhaps Siddharth should clarify this, but I read it as Hyper-V being >> buggy and using XMM arguments unconditionally. > The guest is at fault here as it expects Hyper-V to consume arguments > from XMM registers for certain hypercalls (that we are working) even if > we didn't expose the feature via CPUID bits. What guest is that? Paolo ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:48 ` Paolo Bonzini @ 2021-04-08 15:54 ` Siddharth Chandrasekaran 2021-04-08 16:30 ` Wei Liu 0 siblings, 1 reply; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-08 15:54 UTC (permalink / raw) To: Paolo Bonzini Cc: Wei Liu, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: > > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > > > unless the hypervisor advertises support for it, some hypercalls which > > > > > we plan on upstreaming in future uses them anyway. > > > > No, please don't do this. Check the feature bit(s) before you issue > > > > hypercalls which rely on the extended interface. > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being > > > buggy and using XMM arguments unconditionally. > > The guest is at fault here as it expects Hyper-V to consume arguments > > from XMM registers for certain hypercalls (that we are working) even if > > we didn't expose the feature via CPUID bits. > > What guest is that? It is a Windows Server 2016. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 15:54 ` Siddharth Chandrasekaran @ 2021-04-08 16:30 ` Wei Liu 2021-04-08 17:45 ` Siddharth Chandrasekaran 0 siblings, 1 reply; 12+ messages in thread From: Wei Liu @ 2021-04-08 16:30 UTC (permalink / raw) To: Siddharth Chandrasekaran Cc: Paolo Bonzini, Wei Liu, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 05:54:43PM +0200, Siddharth Chandrasekaran wrote: > On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: > > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: > > > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > > > > unless the hypervisor advertises support for it, some hypercalls which > > > > > > we plan on upstreaming in future uses them anyway. > > > > > No, please don't do this. Check the feature bit(s) before you issue > > > > > hypercalls which rely on the extended interface. > > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being > > > > buggy and using XMM arguments unconditionally. > > > The guest is at fault here as it expects Hyper-V to consume arguments > > > from XMM registers for certain hypercalls (that we are working) even if > > > we didn't expose the feature via CPUID bits. > > > > What guest is that? > > It is a Windows Server 2016. Can you be more specific? Are you implementing some hypercalls from TLFS? If so, which ones? Wei. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 16:30 ` Wei Liu @ 2021-04-08 17:45 ` Siddharth Chandrasekaran 2021-04-09 7:42 ` Vitaly Kuznetsov 0 siblings, 1 reply; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-08 17:45 UTC (permalink / raw) To: Wei Liu Cc: Paolo Bonzini, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, vkuznets, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm On Thu, Apr 08, 2021 at 04:30:18PM +0000, Wei Liu wrote: > On Thu, Apr 08, 2021 at 05:54:43PM +0200, Siddharth Chandrasekaran wrote: > > On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: > > > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: > > > > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > > > > > > > unless the hypervisor advertises support for it, some hypercalls which > > > > > > > we plan on upstreaming in future uses them anyway. > > > > > > No, please don't do this. Check the feature bit(s) before you issue > > > > > > hypercalls which rely on the extended interface. > > > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being > > > > > buggy and using XMM arguments unconditionally. > > > > The guest is at fault here as it expects Hyper-V to consume arguments > > > > from XMM registers for certain hypercalls (that we are working) even if > > > > we didn't expose the feature via CPUID bits. > > > > > > What guest is that? > > > > It is a Windows Server 2016. > > Can you be more specific? Are you implementing some hypercalls from > TLFS? If so, which ones? Yes all of them are from TLFS. We are implementing VSM and there are a bunch of hypercalls that we have implemented to manage VTL switches, memory protection and virtual interrupts. The following 3 hypercalls that use the XMM fast hypercalls are relevant to this patch set: HvCallModifyVtlProtectionMask HvGetVpRegisters HvSetVpRegisters ~ Sid. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-08 17:45 ` Siddharth Chandrasekaran @ 2021-04-09 7:42 ` Vitaly Kuznetsov 2021-04-09 7:59 ` Siddharth Chandrasekaran 0 siblings, 1 reply; 12+ messages in thread From: Vitaly Kuznetsov @ 2021-04-09 7:42 UTC (permalink / raw) To: Siddharth Chandrasekaran Cc: Paolo Bonzini, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm, Wei Liu Siddharth Chandrasekaran <sidcha@amazon.de> writes: > On Thu, Apr 08, 2021 at 04:30:18PM +0000, Wei Liu wrote: >> On Thu, Apr 08, 2021 at 05:54:43PM +0200, Siddharth Chandrasekaran wrote: >> > On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: >> > > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: >> > > > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature >> > > > > > > unless the hypervisor advertises support for it, some hypercalls which >> > > > > > > we plan on upstreaming in future uses them anyway. >> > > > > > No, please don't do this. Check the feature bit(s) before you issue >> > > > > > hypercalls which rely on the extended interface. >> > > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being >> > > > > buggy and using XMM arguments unconditionally. >> > > > The guest is at fault here as it expects Hyper-V to consume arguments >> > > > from XMM registers for certain hypercalls (that we are working) even if >> > > > we didn't expose the feature via CPUID bits. >> > > >> > > What guest is that? >> > >> > It is a Windows Server 2016. >> >> Can you be more specific? Are you implementing some hypercalls from >> TLFS? If so, which ones? > > Yes all of them are from TLFS. We are implementing VSM and there are a > bunch of hypercalls that we have implemented to manage VTL switches, > memory protection and virtual interrupts. Wow, sounds awesome! Do you plan to upstream this work? > The following 3 hypercalls that use the XMM fast hypercalls are relevant > to this patch set: > > HvCallModifyVtlProtectionMask > HvGetVpRegisters > HvSetVpRegisters It seems AccessVSM and AccessVpRegisters privilges have implicit dependency on XMM input/output. This will need to be enforced in KVM userspace. -- Vitaly ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Add support for XMM fast hypercalls 2021-04-09 7:42 ` Vitaly Kuznetsov @ 2021-04-09 7:59 ` Siddharth Chandrasekaran 0 siblings, 0 replies; 12+ messages in thread From: Siddharth Chandrasekaran @ 2021-04-09 7:59 UTC (permalink / raw) To: Vitaly Kuznetsov Cc: Paolo Bonzini, kys, haiyangz, sthemmin, tglx, mingo, bp, x86, hpa, seanjc, wanpengli, jmattson, joro, graf, eyakovl, linux-hyperv, linux-kernel, kvm, Wei Liu On Fri, Apr 09, 2021 at 09:42:41AM +0200, Vitaly Kuznetsov wrote: > Siddharth Chandrasekaran <sidcha@amazon.de> writes: > > On Thu, Apr 08, 2021 at 04:30:18PM +0000, Wei Liu wrote: > >> On Thu, Apr 08, 2021 at 05:54:43PM +0200, Siddharth Chandrasekaran wrote: > >> > On Thu, Apr 08, 2021 at 05:48:19PM +0200, Paolo Bonzini wrote: > >> > > On 08/04/21 17:40, Siddharth Chandrasekaran wrote: > >> > > > > > > Although the Hyper-v TLFS mentions that a guest cannot use this feature > >> > > > > > > unless the hypervisor advertises support for it, some hypercalls which > >> > > > > > > we plan on upstreaming in future uses them anyway. > >> > > > > > No, please don't do this. Check the feature bit(s) before you issue > >> > > > > > hypercalls which rely on the extended interface. > >> > > > > Perhaps Siddharth should clarify this, but I read it as Hyper-V being > >> > > > > buggy and using XMM arguments unconditionally. > >> > > > The guest is at fault here as it expects Hyper-V to consume arguments > >> > > > from XMM registers for certain hypercalls (that we are working) even if > >> > > > we didn't expose the feature via CPUID bits. > >> > > > >> > > What guest is that? > >> > > >> > It is a Windows Server 2016. > >> > >> Can you be more specific? Are you implementing some hypercalls from > >> TLFS? If so, which ones? > > > > Yes all of them are from TLFS. We are implementing VSM and there are a > > bunch of hypercalls that we have implemented to manage VTL switches, > > memory protection and virtual interrupts. > > Wow, sounds awesome! Do you plan to upstream this work? Yes, that is the plan :-) > > The following 3 hypercalls that use the XMM fast hypercalls are relevant > > to this patch set: > > > > HvCallModifyVtlProtectionMask > > HvGetVpRegisters > > HvSetVpRegisters > > It seems AccessVSM and AccessVpRegisters privilges have implicit > dependency on XMM input/output. This will need to be enforced in KVM > userspace. Noted. ~ Sid. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-04-09 8:01 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-07 21:29 [PATCH 0/4] Add support for XMM fast hypercalls Siddharth Chandrasekaran 2021-04-08 15:28 ` Wei Liu 2021-04-08 15:30 ` Paolo Bonzini 2021-04-08 15:38 ` Wei Liu 2021-04-08 16:21 ` Siddharth Chandrasekaran 2021-04-08 15:40 ` Siddharth Chandrasekaran 2021-04-08 15:48 ` Paolo Bonzini 2021-04-08 15:54 ` Siddharth Chandrasekaran 2021-04-08 16:30 ` Wei Liu 2021-04-08 17:45 ` Siddharth Chandrasekaran 2021-04-09 7:42 ` Vitaly Kuznetsov 2021-04-09 7:59 ` Siddharth Chandrasekaran
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.