8
8
#include <linux/types.h>
9
9
10
10
/*
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.
17
21
*/
18
22
enum pkvm_page_state {
19
23
PKVM_PAGE_OWNED = 0ULL ,
20
24
PKVM_PAGE_SHARED_OWNED = BIT (0 ),
21
25
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
+ */
25
34
PKVM_NOPAGE = BIT (2 ),
26
35
};
27
36
#define PKVM_PAGE_META_STATES_MASK (~__PKVM_PAGE_RESERVED)
@@ -44,7 +53,7 @@ struct hyp_page {
44
53
u16 refcount ;
45
54
u8 order ;
46
55
47
- /* Host (non-meta) state. Guarded by the host stage-2 lock. */
56
+ /* Host state. Guarded by the host stage-2 lock. */
48
57
enum pkvm_page_state host_state : 8 ;
49
58
50
59
u32 host_share_guest_count ;
0 commit comments