Commit 6ad0bad
committed
x86/tdx: Use PFN directly for mapping guest private memory
Remove struct page assumptions/constraints in the SEAMCALL wrapper APIs for
mapping guest private memory and have them take PFN directly.
Having core TDX make assumptions that guest private memory must be backed
by struct page (and/or folio) will create subtle dependencies on how
KVM/guest_memfd allocates/manages memory (e.g., whether it uses memory
allocated from core MM, if the memory is refcounted, or if the folio is
split) that are easily avoided. [1].
KVM's MMUs work with PFNs. This is very much an intentional design choice.
It ensures that the KVM MMUs remain flexible and are not too tied to the
regular CPU MMUs and the kernel code around them. Using 'struct page' for
TDX guest memory is not a good fit anywhere near the KVM MMU code [2].
Use "kvm_pfn_t pfn" for type safety. Using this KVM type is appropriate
since APIs tdh_mem_page_add() and tdh_mem_page_aug() are exported to KVM
only.
[ Yan: Replace "u64 pfn" with "kvm_pfn_t pfn" ]
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/all/aWgyhmTJphGQqO0Y@google.com [1]
Link: https://lore.kernel.org/all/ac7V0g2q2hN3dU5u@google.com [2]
Acked-by: Kiryl Shutsemau <kas@kernel.org>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20260430014929.24210-1-yan.y.zhao@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent e1a31ca commit 6ad0bad
3 files changed
Lines changed: 20 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
192 | | - | |
| 193 | + | |
| 194 | + | |
193 | 195 | | |
194 | 196 | | |
195 | | - | |
| 197 | + | |
| 198 | + | |
196 | 199 | | |
197 | 200 | | |
198 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1624 | 1624 | | |
1625 | 1625 | | |
1626 | 1626 | | |
1627 | | - | |
1628 | | - | |
| 1627 | + | |
| 1628 | + | |
1629 | 1629 | | |
1630 | 1630 | | |
1631 | 1631 | | |
| |||
1639 | 1639 | | |
1640 | 1640 | | |
1641 | 1641 | | |
1642 | | - | |
1643 | 1642 | | |
1644 | 1643 | | |
1645 | 1644 | | |
1646 | 1645 | | |
1647 | | - | |
| 1646 | + | |
1648 | 1647 | | |
1649 | 1648 | | |
1650 | 1649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
1568 | 1567 | | |
1569 | 1568 | | |
1570 | 1569 | | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
1571 | 1575 | | |
1572 | 1576 | | |
1573 | 1577 | | |
| |||
1594 | 1598 | | |
1595 | 1599 | | |
1596 | 1600 | | |
1597 | | - | |
| 1601 | + | |
| 1602 | + | |
1598 | 1603 | | |
1599 | 1604 | | |
1600 | 1605 | | |
1601 | 1606 | | |
1602 | | - | |
| 1607 | + | |
1603 | 1608 | | |
1604 | 1609 | | |
1605 | 1610 | | |
1606 | 1611 | | |
1607 | | - | |
| 1612 | + | |
1608 | 1613 | | |
1609 | 1614 | | |
1610 | 1615 | | |
| |||
1647 | 1652 | | |
1648 | 1653 | | |
1649 | 1654 | | |
1650 | | - | |
| 1655 | + | |
1651 | 1656 | | |
1652 | 1657 | | |
1653 | 1658 | | |
1654 | 1659 | | |
1655 | | - | |
| 1660 | + | |
1656 | 1661 | | |
1657 | 1662 | | |
1658 | 1663 | | |
1659 | | - | |
| 1664 | + | |
1660 | 1665 | | |
1661 | 1666 | | |
1662 | 1667 | | |
| |||
0 commit comments