Skip to content

Commit cc047a6

Browse files
Yunhong Jiangallenpais
authored andcommitted
x86/hyperv/vtl: Mark the wakeup mailbox page as private
The current code maps MMIO devices as shared (decrypted) by default in a confidential computing VM. In a TDX environment, secondary CPUs are booted using the Multiprocessor Wakeup Structure defined in the ACPI specification. The virtual firmware and the operating system function in the guest context, without intervention from the VMM. Map the physical memory of the mailbox as private. Use the is_private_mmio() callback. Reviewed-by: Michael Kelley <[email protected]> Signed-off-by: Yunhong Jiang <[email protected]> Signed-off-by: Ricardo Neri <[email protected]>
1 parent 1da55cf commit cc047a6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/x86/hyperv/hv_vtl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,27 @@ static bool __init hv_vtl_msi_ext_dest_id(void)
3535
return true;
3636
}
3737

38+
static inline bool within_page(u64 addr, u64 start)
39+
{
40+
return addr >= start && addr < (start + PAGE_SIZE);
41+
}
42+
43+
static bool hv_vtl_is_private_mmio_tdx(u64 addr)
44+
{
45+
u64 mb_addr = acpi_get_mp_wakeup_mailbox_paddr();
46+
47+
return mb_addr && within_page(addr, mb_addr);
48+
}
49+
3850
void __init hv_vtl_init_platform(void)
3951
{
4052
pr_info("Linux runs in Hyper-V Virtual Trust Level\n");
4153

4254
/* There is no paravisor present if we are here. */
4355
if (hv_isolation_type_tdx()) {
4456
x86_init.resources.realmode_limit = SZ_4G;
57+
x86_platform.hyper.is_private_mmio = hv_vtl_is_private_mmio_tdx;
58+
4559
} else {
4660
x86_platform.realmode_reserve = x86_init_noop;
4761
x86_platform.realmode_init = x86_init_noop;

0 commit comments

Comments
 (0)