Skip to content

Commit d4fc42a

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Move enum pkvm_page_state to memory.h
In order to prepare the way for storing page-tracking information in pKVM's vmemmap, move the enum pkvm_page_state definition to nvhe/memory.h. No functional changes intended. Tested-by: Fuad Tabba <[email protected]> Reviewed-by: Fuad Tabba <[email protected]> Signed-off-by: Quentin Perret <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent a1a1f1f commit d4fc42a

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,10 @@
1111
#include <asm/kvm_mmu.h>
1212
#include <asm/kvm_pgtable.h>
1313
#include <asm/virt.h>
14+
#include <nvhe/memory.h>
1415
#include <nvhe/pkvm.h>
1516
#include <nvhe/spinlock.h>
1617

17-
/*
18-
* SW bits 0-1 are reserved to track the memory ownership state of each page:
19-
* 00: The page is owned exclusively by the page-table owner.
20-
* 01: The page is owned by the page-table owner, but is shared
21-
* with another entity.
22-
* 10: The page is shared with, but not owned by the page-table owner.
23-
* 11: Reserved for future use (lending).
24-
*/
25-
enum pkvm_page_state {
26-
PKVM_PAGE_OWNED = 0ULL,
27-
PKVM_PAGE_SHARED_OWNED = BIT(0),
28-
PKVM_PAGE_SHARED_BORROWED = BIT(1),
29-
__PKVM_PAGE_RESERVED = BIT(0) | BIT(1),
30-
31-
/* Meta-states which aren't encoded directly in the PTE's SW bits */
32-
PKVM_NOPAGE = BIT(2),
33-
};
34-
#define PKVM_PAGE_META_STATES_MASK (~__PKVM_PAGE_RESERVED)
35-
36-
#define PKVM_PAGE_STATE_PROT_MASK (KVM_PGTABLE_PROT_SW0 | KVM_PGTABLE_PROT_SW1)
37-
static inline enum kvm_pgtable_prot pkvm_mkstate(enum kvm_pgtable_prot prot,
38-
enum pkvm_page_state state)
39-
{
40-
prot &= ~PKVM_PAGE_STATE_PROT_MASK;
41-
prot |= FIELD_PREP(PKVM_PAGE_STATE_PROT_MASK, state);
42-
return prot;
43-
}
44-
45-
static inline enum pkvm_page_state pkvm_getstate(enum kvm_pgtable_prot prot)
46-
{
47-
return FIELD_GET(PKVM_PAGE_STATE_PROT_MASK, prot);
48-
}
49-
5018
struct host_mmu {
5119
struct kvm_arch arch;
5220
struct kvm_pgtable pgt;

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@
77

88
#include <linux/types.h>
99

10+
/*
11+
* SW 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).
17+
*/
18+
enum pkvm_page_state {
19+
PKVM_PAGE_OWNED = 0ULL,
20+
PKVM_PAGE_SHARED_OWNED = BIT(0),
21+
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 */
25+
PKVM_NOPAGE = BIT(2),
26+
};
27+
#define PKVM_PAGE_META_STATES_MASK (~__PKVM_PAGE_RESERVED)
28+
29+
#define PKVM_PAGE_STATE_PROT_MASK (KVM_PGTABLE_PROT_SW0 | KVM_PGTABLE_PROT_SW1)
30+
static inline enum kvm_pgtable_prot pkvm_mkstate(enum kvm_pgtable_prot prot,
31+
enum pkvm_page_state state)
32+
{
33+
prot &= ~PKVM_PAGE_STATE_PROT_MASK;
34+
prot |= FIELD_PREP(PKVM_PAGE_STATE_PROT_MASK, state);
35+
return prot;
36+
}
37+
38+
static inline enum pkvm_page_state pkvm_getstate(enum kvm_pgtable_prot prot)
39+
{
40+
return FIELD_GET(PKVM_PAGE_STATE_PROT_MASK, prot);
41+
}
42+
1043
struct hyp_page {
1144
unsigned short refcount;
1245
unsigned short order;

0 commit comments

Comments
 (0)