mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 20:22:46 +00:00
hv: replace the CONFIG_PLATFORM_RAM_SIZE with get_e820_ram_size for vept
Now the vept table was allocate dynamically, but the table size of vept was calculated by the CONFIG_PLATFORM_RAM_SIZE which was predefined by config tool. It's not complete change and can't support single binary for different boards/platforms. So this patch will replace the CONFIG_PLATFORM_RAM_SIZE and get the top ram size from hv_E820 interface for vept. Tracked-On: #6690 Acked-by: Anthony Xu <anthony.xu@intel.com> Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
This commit is contained in:
parent
5432b52b12
commit
b7a99f4530
@ -289,7 +289,7 @@ void init_pcpu_post(uint16_t pcpu_id)
|
||||
/*
|
||||
* Reserve memory from platform E820 for shadow EPT 4K pages
|
||||
*/
|
||||
reserve_buffer_for_sept_pages();
|
||||
allocate_buffer_for_sept_pages();
|
||||
|
||||
pcpu_sync = ALL_CPUS_MASK;
|
||||
/* Start all secondary cores */
|
||||
|
@ -26,27 +26,42 @@ static spinlock_t nept_desc_bucket_lock;
|
||||
* and sharing of memory between L2 VMs.
|
||||
*
|
||||
* Page table entry need 8 bytes to represent every 4K page frame.
|
||||
* Total number of bytes = (CONFIG_PLATFORM_RAM_SIZE/4096) * 8
|
||||
* Number of pages needed = Total number of bytes needed/4096
|
||||
* Total number of bytes = (get_e820_ram_size() / PAGE_SIZE) * 8
|
||||
* Number of pages needed = Total number of bytes needed/PAGE_SIZE
|
||||
*/
|
||||
#define TOTAL_SEPT_4K_PAGES_SIZE ((CONFIG_PLATFORM_RAM_SIZE * 8UL) / 4096UL)
|
||||
#define TOTAL_SEPT_4K_PAGES_NUM (TOTAL_SEPT_4K_PAGES_SIZE / PAGE_SIZE)
|
||||
static uint64_t get_total_vept_4k_page_size(void)
|
||||
{
|
||||
return (get_e820_ram_size() * 8UL) / PAGE_SIZE;
|
||||
}
|
||||
|
||||
static uint64_t get_total_vept_4k_page_num(void)
|
||||
{
|
||||
return get_total_vept_4k_page_size() / PAGE_SIZE;
|
||||
}
|
||||
|
||||
static struct page_pool sept_page_pool;
|
||||
static struct page *sept_pages;
|
||||
static uint64_t sept_page_bitmap[TOTAL_SEPT_4K_PAGES_NUM / 64U];
|
||||
static uint64_t *sept_page_bitmap;
|
||||
|
||||
static void allocate_vept_bitmap(void)
|
||||
{
|
||||
sept_page_bitmap = e820_alloc_memory((get_total_4k_page_num() / 64U), ~0UL);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Reserve space for SEPT 4K pages from platform E820 table
|
||||
* At moment, we only support nested VMX for Service VM.
|
||||
*/
|
||||
void reserve_buffer_for_sept_pages(void)
|
||||
void allocate_buffer_for_sept_pages(void)
|
||||
{
|
||||
uint64_t page_base;
|
||||
|
||||
page_base = e820_alloc_memory(TOTAL_SEPT_4K_PAGES_SIZE, ~0UL);
|
||||
set_paging_supervisor(page_base, TOTAL_SEPT_4K_PAGES_SIZE);
|
||||
page_base = e820_alloc_memory(get_total_vept_4k_page_size(), ~0UL);
|
||||
|
||||
set_paging_supervisor(page_base, get_total_vept_4k_page_size());
|
||||
|
||||
sept_pages = (struct page *)page_base;
|
||||
allocate_vept_bitmap();
|
||||
}
|
||||
|
||||
static bool is_present_ept_entry(uint64_t ept_entry)
|
||||
@ -535,7 +550,7 @@ int32_t invept_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
void init_vept(void)
|
||||
{
|
||||
sept_page_pool.start_page = sept_pages;
|
||||
sept_page_pool.bitmap_size = TOTAL_SEPT_4K_PAGES_NUM / 64U;
|
||||
sept_page_pool.bitmap_size = get_total_vept_4k_page_num() / 64U;
|
||||
sept_page_pool.bitmap = sept_page_bitmap;
|
||||
sept_page_pool.dummy_page = NULL;
|
||||
spinlock_init(&sept_page_pool.lock);
|
||||
|
@ -38,7 +38,7 @@ struct nept_desc {
|
||||
uint32_t ref_count;
|
||||
};
|
||||
|
||||
void reserve_buffer_for_sept_pages(void);
|
||||
void allocate_buffer_for_sept_pages(void);
|
||||
void init_vept(void);
|
||||
uint64_t get_shadow_eptp(uint64_t guest_eptp);
|
||||
struct nept_desc *get_nept_desc(uint64_t guest_eptp);
|
||||
@ -46,6 +46,6 @@ void put_nept_desc(uint64_t guest_eptp);
|
||||
bool handle_l2_ept_violation(struct acrn_vcpu *vcpu);
|
||||
int32_t invept_vmexit_handler(struct acrn_vcpu *vcpu);
|
||||
#else
|
||||
static inline void reserve_buffer_for_sept_pages(void) {};
|
||||
static inline void allocate_buffer_for_sept_pages(void) {};
|
||||
#endif /* CONFIG_NVMX_ENABLED */
|
||||
#endif /* VEPT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user