Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions arch/x86/kvm/pkvm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ extern u64 __pkvm_vmemmap;
#define pkvm_page_to_virt(page) __pkvm_va(pkvm_page_to_phys(page))
#define pkvm_page_to_pool(page) (((struct pkvm_page *)page)->pool)

/* Caution: __st is evaluated twice. */
#define for_each_pkvm_page(__p, __st, __sz) \
for (struct pkvm_page *__p = pkvm_phys_to_page(PAGE_ALIGN_DOWN(__st)), \
*__e = pkvm_phys_to_page(PAGE_ALIGN((__st) + (__sz))); \
__p < __e; __p++)

/*
* Refcounting for 'struct pkvm_page'.
* pkvm_pool::lock must be held if atomic access to the refcount is required.
Expand Down
7 changes: 1 addition & 6 deletions arch/x86/kvm/pkvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,8 @@ static int fix_hyp_mmu_page_refcnt(void)
static void set_host_mem_pgstate(unsigned long phys, unsigned long size,
enum pkvm_page_state pgstate)
{
unsigned long end = PAGE_ALIGN(phys + size);
struct pkvm_page *page;

for (phys = PAGE_ALIGN_DOWN(phys); phys < end; phys += PAGE_SIZE) {
page = pkvm_phys_to_page(phys);
for_each_pkvm_page(page, phys, size)
page->host_state = pgstate;
}
}

static int check_host_mem_pgstate(unsigned long phys, unsigned long size,
Expand Down