Skip to content

Commit ba63701

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Fix pKVM page-tracking comments
Most of the comments relating to pKVM page-tracking in nvhe/memory.h are now either slightly outdated or outright wrong. Fix the comments. Signed-off-by: Quentin Perret <qperret@google.com> Link: https://lore.kernel.org/r/20250416152648.2982950-3-qperret@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 5db1bef commit ba63701

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

arch/arm64/kvm/hyp/include/nvhe/memory.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@
88
#include <linux/types.h>
99

1010
/*
11-
* Bits 0-1 are reserved to track the memory ownership state of each page:
12-
* 00: The page is owned exclusively by the page-table owner.
13-
* 01: The page is owned by the page-table owner, but is shared
14-
* with another entity.
15-
* 10: The page is shared with, but not owned by the page-table owner.
16-
* 11: Reserved for future use (lending).
11+
* Bits 0-1 are used to encode the memory ownership state of each page from the
12+
* point of view of a pKVM "component" (host, hyp, guest, ... see enum
13+
* pkvm_component_id):
14+
* 00: The page is owned and exclusively accessible by the component;
15+
* 01: The page is owned and accessible by the component, but is also
16+
* accessible by another component;
17+
* 10: The page is accessible but not owned by the component;
18+
* The storage of this state depends on the component: either in the
19+
* hyp_vmemmap for the host state or in PTE software bits for the hypervisor
20+
* and guests.
1721
*/
1822
enum pkvm_page_state {
1923
PKVM_PAGE_OWNED = 0ULL,
2024
PKVM_PAGE_SHARED_OWNED = BIT(0),
2125
PKVM_PAGE_SHARED_BORROWED = BIT(1),
22-
__PKVM_PAGE_RESERVED = BIT(0) | BIT(1),
23-
24-
/* Meta-states which aren't encoded directly in the PTE's SW bits */
26+
__PKVM_PAGE_RESERVED = BIT(0) | BIT(1),
27+
28+
/*
29+
* 'Meta-states' are not stored directly in PTE SW bits for hyp and
30+
* guest states, but inferred from the context (e.g. invalid PTE
31+
* entries). For the host, meta-states are stored directly in the
32+
* struct hyp_page.
33+
*/
2534
PKVM_NOPAGE = BIT(2),
2635
};
2736
#define PKVM_PAGE_META_STATES_MASK (~__PKVM_PAGE_RESERVED)
@@ -44,7 +53,7 @@ struct hyp_page {
4453
u16 refcount;
4554
u8 order;
4655

47-
/* Host (non-meta) state. Guarded by the host stage-2 lock. */
56+
/* Host state. Guarded by the host stage-2 lock. */
4857
enum pkvm_page_state host_state : 8;
4958

5059
u32 host_share_guest_count;

0 commit comments

Comments
 (0)