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

Message ID 20221222230458.3828342-1-vannapurve@google.com
Headers
Series Execute hypercalls from guests according to cpu |

Message

Vishal Annapurve Dec. 22, 2022, 11:04 p.m. UTC
  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(-)
  

Comments

Paolo Bonzini Dec. 23, 2022, 5:37 p.m. UTC | #1
> 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
  
Vishal Annapurve Dec. 23, 2022, 10:36 p.m. UTC | #2
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