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(-)