KVM: selftests: Allow tagging protected memory in guest page tables
authorPeter Gonda <pgonda@google.com>
Fri, 23 Feb 2024 00:42:54 +0000 (16:42 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 29 Feb 2024 00:39:49 +0000 (16:39 -0800)
commitbe1bd4c5394ff7eb6f14aaf8005824ed1946bb82
treea7c522307e18d941139c37b6f0ffd7d9c88dbe97
parent31e00dae72fda939a084cda86b068ac9c302a2d3
KVM: selftests: Allow tagging protected memory in guest page tables

Add support for tagging and untagging guest physical address, e.g. to
allow x86's SEV and TDX guests to embed shared vs. private information in
the GPA.  SEV (encryption, a.k.a. C-bit) and TDX (shared, a.k.a. S-bit)
steal bits from the guest's physical address space that is consumed by the
CPU metadata, i.e. effectively aliases the "real" GPA.

Implement generic "tagging" so that the shared vs. private metadata can be
managed by x86 without bleeding too many details into common code.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Vishal Annapurve <vannapurve@google.com>
Cc: Ackerly Tng <ackerleytng@google.com>
cc: Andrew Jones <andrew.jones@linux.dev>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Tested-by: Carlos Bilbao <carlos.bilbao@amd.com>
Originally-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Peter Gonda <pgonda@google.com>
Link: https://lore.kernel.org/r/20240223004258.3104051-8-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/aarch64/kvm_util_arch.h [new file with mode: 0644]
tools/testing/selftests/kvm/include/kvm_util_base.h
tools/testing/selftests/kvm/include/riscv/kvm_util_arch.h [new file with mode: 0644]
tools/testing/selftests/kvm/include/s390x/kvm_util_arch.h [new file with mode: 0644]
tools/testing/selftests/kvm/include/x86_64/kvm_util_arch.h [new file with mode: 0644]
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/x86_64/processor.c