quoted hunk ↗ jump to hunk
From: Kirill A. Shutemov <redacted>
Sent: Friday, June 28, 2024 3:05 AM
To: Dexuan Cui <decui@microsoft.com>
quoted
[...]
static bool tdx_enc_status_changed(unsigned long vaddr, int numpages,
[...]
This patch collied with kexec changes. tdx_kexec_finish() calls
tdx_enc_status_changed() after clearing pte, so slow_virt_to_phys()
crashes on in.
Daxuan, could you check if the fixup below works for you on vmalloc
addresses?
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index ef8ec2425998..5e455c883bcc 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -813,8 +813,15 @@ static bool tdx_enc_status_changed(unsigned
long vaddr, int numpages, bool enc)
step = PAGE_SIZE;
for (addr = start; addr < end; addr += step) {
- phys_addr_t start_pa = slow_virt_to_phys((void *)addr);
- phys_addr_t end_pa = start_pa + step;
+ phys_addr_t start_pa;
+ phys_addr_t end_pa;
+
+ if (virt_addr_valid(addr))
+ start_pa = __pa(addr);
+ else
+ start_pa = slow_virt_to_phys((void *)addr);
+
+ end_pa = start_pa + step;
if (!tdx_enc_status_changed_phys(start_pa, end_pa, enc))
return false;
--
Kiryl Shutsemau / Kirill A. Shutemov
Hi Kirill, your fixup works for me.
BTW, I just realized that virt_addr_valid() returns false for a vmalloc'd address.
Thanks,
Dexuan