Skip to content

Conversation

@maluka-dmytro
Copy link
Contributor

Add a few convenient helpers, to reduce code duplication and improve code readability (especially with upcoming changes for guest MMU support, which will use these helpers too):

  • for_each_pkvm_page() macro for iterating through struct pkvm_pages for all pages in the given memory range (same as pKVM-ARM's for_each_hyp_page())
  • pkvm_pgtable_max_size() returning max size of the VA space for the given page table
  • host_mmu_pte_prot() returning the needed property bits for host MMU PTEs

Dmytro Maluka added 8 commits January 4, 2026 16:35
We already have several places in the code where we traverse struct
pkvm_page structures for all pages in the given memory range. With guest
MMU support there will be even more such cases.

So introduce a convenient helper macro for_each_pkvm_page() for that, to
reduce code duplication and improve code readability.

Based on pKVM-ARM's for_each_hyp_page(), although the implementation is
not exactly the same.

Fixes: 54b3050 ("pKVM: x86: Set initial host memory page state")
Signed-off-by: Dmytro Maluka <[email protected]>
…te()

Fixes: e5bdafb ("pKVM: x86: Add memory page donation between host and hypervisor")
Signed-off-by: Dmytro Maluka <[email protected]>
…are_hyp()

Fixes: 168a157 ("pKVM: x86: Add support to share/unshare host memory pages with pKVM")
Signed-off-by: Dmytro Maluka <[email protected]>
We already have a couple of places where we calculate the max size of
the VA space that can be mapped by the given page table, and with guest
MMU there will be more such places. So introduce helper function
pkvm_pgtable_max_size() for that.

Fixes: ca66f34 ("pKVM: x86: Switch to use buddy allocator for the hyp mmu")
Signed-off-by: Dmytro Maluka <[email protected]>
…ate()

Fixes: 7666056 ("pKVM: x86: Set the initial page state for host MMIO pages")
Signed-off-by: Dmytro Maluka <[email protected]>
We have several places with calc_pte_perm() + calc_pte_memtype()
boilerplate code for calculating property bits for host MMU PTEs,
and with guest MMU support we will have more such cases. So introduce
a convenient helper host_mmu_pte_prot() for that.

Fixes: e5bdafb ("pKVM: x86: Add memory page donation between host and hypervisor")
Signed-off-by: Dmytro Maluka <[email protected]>
…mmio_locked()

Fixes: 1bcae0c ("pKVM: x86: Add MMIO donation from hyp to host")
Signed-off-by: Dmytro Maluka <[email protected]>
Fixes: e365103 ("pKVM: x86: Remove pkvm_host_mmu_map/unmap")
Signed-off-by: Dmytro Maluka <[email protected]>
@cxdong cxdong merged commit 2713532 into intel-staging:pkvm-v6.18 Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants