[V3 PATCH 0/2] Execute hypercalls from guests according to cpu

Vishal Annapurve posted 2 patches 2 years, 8 months ago
.../selftests/kvm/include/x86_64/processor.h  |  3 ++
.../selftests/kvm/lib/x86_64/processor.c      | 51 +++++++++++++++++--
2 files changed, 49 insertions(+), 5 deletions(-)
[V3 PATCH 0/2] Execute hypercalls from guests according to cpu
Posted by Vishal Annapurve 2 years, 8 months ago
Confidential VMs(CVMs) need to execute hypercall instruction as per the CPU
type. Normally KVM emulates the vmcall/vmmcall instruction by patching
the guest code at runtime. Such a guest memory manipulation by KVM is
not allowed with CVMs.

This series adds support of executing hypercall as per the native cpu
type queried using cpuid instruction. CPU vendor type is stored after
one time execution of cpuid instruction to be reused later.

Changes in v3:
1) Guest logic is modified to not rely on host cpu type and instead query
cpu vendor using cpuid instruction.
2) Existing callers of vmmcall/vmcall are not updated to avoid enforcing
native hypercall instruction across all users which are mostly
non-confidential usecases.

v2:
https://lore.kernel.org/all/20220915000448.1674802-1-vannapurve@google.com/

More discussion around this change:
https://lore.kernel.org/lkml/Y1Hhw40H58EmZ6lK@google.com/

Vishal Annapurve (2):
  KVM: selftests: x86: Cache the cpu vendor type
  KVM: selftests: x86: Add native hypercall support

 .../selftests/kvm/include/x86_64/processor.h  |  3 ++
 .../selftests/kvm/lib/x86_64/processor.c      | 51 +++++++++++++++++--
 2 files changed, 49 insertions(+), 5 deletions(-)

-- 
2.39.0.314.g84b9a713c41-goog
Re: [V3 PATCH 0/2] Execute hypercalls from guests according to cpu
Posted by Paolo Bonzini 2 years, 8 months ago
> This series adds support of executing hypercall as per the native cpu
> type queried using cpuid instruction. CPU vendor type is stored after
> one time execution of cpuid instruction to be reused later.

Makes sense, are you going to add more patches that use the new function?

Paolo
Re: [V3 PATCH 0/2] Execute hypercalls from guests according to cpu
Posted by Vishal Annapurve 2 years, 8 months ago
On Fri, Dec 23, 2022 at 9:38 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> > This series adds support of executing hypercall as per the native cpu
> > type queried using cpuid instruction. CPU vendor type is stored after
> > one time execution of cpuid instruction to be reused later.
>
> Makes sense, are you going to add more patches that use the new function?
>
> Paolo
>
>

Yeah, another series [1] uploaded recently, uses this newly added function.

[1] https://lore.kernel.org/lkml/20221223001352.3873203-1-vannapurve@google.com/

- Vishal