Skip to content

Commit 5751991

Browse files
committed
KVM: TDX: Set gfn_direct_bits to shared bit
JIRA: https://issues.redhat.com/browse/RHEL-15711 Upstream status: https://git.kernel.org/pub/scm/virt/kvm/kvm.git Make the direct root handle memslot GFNs at an alias with the TDX shared bit set. For TDX shared memory, the memslot GFNs need to be mapped at an alias with the shared bit set. These shared mappings will be mapped on the KVM MMU's "direct" root. The direct root has it's mappings shifted by applying "gfn_direct_bits" as a mask. The concept of "GPAW" (guest physical address width) determines the location of the shared bit. So set gfn_direct_bits based on this, to map shared memory at the proper GPA. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Co-developed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Co-developed-by: Yan Zhao <yan.y.zhao@intel.com> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20241112073613.22100-1-yan.y.zhao@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit e0fbb3b) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 11199ae commit 5751991

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/x86/kvm/vmx/tdx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,11 @@ static int tdx_td_init(struct kvm *kvm, struct kvm_tdx_cmd *cmd)
10511051
kvm_tdx->attributes = td_params->attributes;
10521052
kvm_tdx->xfam = td_params->xfam;
10531053

1054+
if (td_params->config_flags & TDX_CONFIG_FLAGS_MAX_GPAW)
1055+
kvm->arch.gfn_direct_bits = TDX_SHARED_BIT_PWL_5;
1056+
else
1057+
kvm->arch.gfn_direct_bits = TDX_SHARED_BIT_PWL_4;
1058+
10541059
kvm_tdx->state = TD_STATE_INITIALIZED;
10551060
out:
10561061
/* kfree() accepts NULL. */

0 commit comments

Comments
 (0)