On 8/28/2026 10:06 AM, Peter Fang wrote:
On Mon, Aug 17, 2026 at 04:38:49PM +0800, Xiaoyao Li wrote:
+
+static u8 vm_type;
+static gpa_t ucall_mmio_gpa;
+
+void ucall_arch_init(struct kvm_vm *vm, gpa_t mmio_gpa)
+{
+ vm_type = vm->type;
vm_type is u8 but vm->type is unsigned long
+ sync_global_to_guest(vm, vm_type);
It works and it looks simple. But we have the architectural approach to test
if a guest is TD guest, by checking the CPUID 0x21.
Since checking CPUID 0x21 is not complex, and as a bonus it can help test if
TDX module behaves correctly for CPUID leaf 0x21, I think we should switch
to use CPUID 0x21 to check if it is TDX VM in guest code?
Hmm... This makes me wonder if vm->arch.s_bit below could be replaced
with the same architectural approach. GPAW is available through
TDG.VP.INFO or the initial RBX value. This does require a bit more
plumbing though.
I'm afraid not. Because below is host code, and vm->arch.s_bit is not
used in guest code.
Or are suggesting something like dropping the
if (is_tdx_vm(vm)) {
ucall_mmio_gpa = UCALL_MMIO_GPA | vm->arch.s_bit;
sync_global_to_guest(vm, ucall_mmio_gpa);
}
entirely and use below hardcoded value instead in guest code?
UCALL_MMIO_GPA | 1 << (GPAW - 1)
+ if (is_tdx_vm(vm)) {
+ ucall_mmio_gpa = UCALL_MMIO_GPA | vm->arch.s_bit;
So the passed-in @mmio_gpa is not used. Why cannot use the mmio_gpa,
slot0->region.guest_phys_addr + slot0->region.memory_size
chosen by __vm_create()?
Looks like this was discussed previously [1]. Maybe at least a comment
here would help?
yeah. A comment surely will help.
[1] https://lore.kernel.org/all/[email protected]/