mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ANDROID: KVM: arm64: Repurpose a byte of 'order' for flags in 'struct hyp_page'
In preparation for poisoning guest memory pages in the pKVM hypervisor when being reclaimed by the host, introduce a new 'flags' field in 'struct hyp_page' so that we will be able to track on a per-page basis whether or not poisoning is required. Rather than increase the total size of the structure, shrink the 16-bit 'order' field to a single byte and use the recovered space for the new field. Signed-off-by: Quentin Perret <qperret@google.com> Signed-off-by: Will Deacon <willdeacon@google.com> Bug: 233587962 Change-Id: I8eb1f7ed8da0374b878a315eb1a6f867d0f379a9
This commit is contained in:
committed by
Will Deacon
parent
d598e5fead
commit
0cd896e32e
@@ -7,7 +7,7 @@
|
||||
#include <nvhe/memory.h>
|
||||
#include <nvhe/spinlock.h>
|
||||
|
||||
#define HYP_NO_ORDER USHRT_MAX
|
||||
#define HYP_NO_ORDER 0xff
|
||||
|
||||
struct hyp_pool {
|
||||
/*
|
||||
@@ -19,11 +19,11 @@ struct hyp_pool {
|
||||
struct list_head free_area[MAX_ORDER];
|
||||
phys_addr_t range_start;
|
||||
phys_addr_t range_end;
|
||||
unsigned short max_order;
|
||||
u8 max_order;
|
||||
};
|
||||
|
||||
/* Allocation */
|
||||
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order);
|
||||
void *hyp_alloc_pages(struct hyp_pool *pool, u8 order);
|
||||
void hyp_split_page(struct hyp_page *page);
|
||||
void hyp_get_page(struct hyp_pool *pool, void *addr);
|
||||
void hyp_put_page(struct hyp_pool *pool, void *addr);
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
struct hyp_page {
|
||||
unsigned short refcount;
|
||||
unsigned short order;
|
||||
u8 order;
|
||||
u8 flags;
|
||||
};
|
||||
|
||||
extern u64 __hyp_vmemmap;
|
||||
|
||||
@@ -32,7 +32,7 @@ u64 __hyp_vmemmap;
|
||||
*/
|
||||
static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool,
|
||||
struct hyp_page *p,
|
||||
unsigned short order)
|
||||
u8 order)
|
||||
{
|
||||
phys_addr_t addr = hyp_page_to_phys(p);
|
||||
|
||||
@@ -51,7 +51,7 @@ static struct hyp_page *__find_buddy_nocheck(struct hyp_pool *pool,
|
||||
/* Find a buddy page currently available for allocation */
|
||||
static struct hyp_page *__find_buddy_avail(struct hyp_pool *pool,
|
||||
struct hyp_page *p,
|
||||
unsigned short order)
|
||||
u8 order)
|
||||
{
|
||||
struct hyp_page *buddy = __find_buddy_nocheck(pool, p, order);
|
||||
|
||||
@@ -94,8 +94,8 @@ static void __hyp_attach_page(struct hyp_pool *pool,
|
||||
struct hyp_page *p)
|
||||
{
|
||||
phys_addr_t phys = hyp_page_to_phys(p);
|
||||
unsigned short order = p->order;
|
||||
struct hyp_page *buddy;
|
||||
u8 order = p->order;
|
||||
|
||||
memset(hyp_page_to_virt(p), 0, PAGE_SIZE << p->order);
|
||||
|
||||
@@ -128,7 +128,7 @@ insert:
|
||||
|
||||
static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool,
|
||||
struct hyp_page *p,
|
||||
unsigned short order)
|
||||
u8 order)
|
||||
{
|
||||
struct hyp_page *buddy;
|
||||
|
||||
@@ -182,7 +182,7 @@ void hyp_get_page(struct hyp_pool *pool, void *addr)
|
||||
|
||||
void hyp_split_page(struct hyp_page *p)
|
||||
{
|
||||
unsigned short order = p->order;
|
||||
u8 order = p->order;
|
||||
unsigned int i;
|
||||
|
||||
p->order = 0;
|
||||
@@ -194,10 +194,10 @@ void hyp_split_page(struct hyp_page *p)
|
||||
}
|
||||
}
|
||||
|
||||
void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order)
|
||||
void *hyp_alloc_pages(struct hyp_pool *pool, u8 order)
|
||||
{
|
||||
unsigned short i = order;
|
||||
struct hyp_page *p;
|
||||
u8 i = order;
|
||||
|
||||
hyp_spin_lock(&pool->lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user