Re: [PATCH 08/13] x86/virt/tdx: Add SEAMCALL wrappers to add TD private pages

Edgecombe, Rick P
2025-01-15T00:49:26Z

On Wed, 2025-01-15 at 00:32 +0100, Paolo Bonzini wrote:
> I've pushed to kvm-coco-queue; if you have some time to double check
> what I did that's great, otherwise if I don't hear from you I'll post
> around noon European time the v3 of this series.

Level handling and gpa encoding looks fine to me.

I get a build error:

In file included from /home/rpedgeco/repos/linux/include/asm-
generic/memory_model.h:5,
from arch/x86/include/asm/page.h:89,
from linux/arch/x86/include/asm/processor.h:20,
from linux/arch/x86/include/asm/timex.h:5,
from linux/include/linux/timex.h:67,
from linux/include/linux/clocksource.h:13,
from linux/include/linux/clockchips.h:14,
from linux/arch/x86/kernel/i8253.c:6:
linux/arch/x86/include/asm/tdx.h: In function ‘mk_keyed_paddr’:
linux/include/asm-generic/memory_model.h:38:58: error: ‘vmemmap’ undeclared
(first use in this function); did you mean ‘mem_map’?
38 | #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
| ^~~~~~~

...and needed this:

diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 201f2e910411..a8a6fbd7bf71 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -35,6 +35,7 @@

#include <uapi/asm/mce.h>
#include <asm/tdx_global_metadata.h>
+#include <linux/pgtable.h>

/*
* Used by the #VE exception handler to gather the #VE exception

Nit, whitespace errors:

+static inline u64 mk_keyed_paddr(u16 hkid, struct page *page)
+{
+ u64 ret;
+
+ ret = page_to_phys(page);
+ /* KeyID bits are just above the physical address bits: */
+ ret |= hkid << boot_cpu_data.x86_phys_bits;
+
^ extra tab here
+ return ret;
+}
+

+static inline int pg_level_to_tdx_sept_level(enum pg_level level)
+{
+ WARN_ON_ONCE(level == PG_LEVEL_NONE);
+ return level - 1;
+ ^ spaces instead of tabs
+
+}

Lastly, TD's are not booting for me, with a QEMU error. Still debugging this.