Both Intel and AMD need this page and currently allocate it
programmatically. We can safe some logic, specifically error handling,
by reserving the page in the cell structure.
Signed-off-by: Jan Kiszka <
jan.k...@siemens.com>
---
hypervisor/arch/x86/include/asm/cell.h | 3 +++
hypervisor/arch/x86/svm.c | 9 ++-------
hypervisor/arch/x86/vmx.c | 9 ++-------
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/hypervisor/arch/x86/include/asm/cell.h b/hypervisor/arch/x86/include/asm/cell.h
index 81050c5..668620d 100644
--- a/hypervisor/arch/x86/include/asm/cell.h
+++ b/hypervisor/arch/x86/include/asm/cell.h
@@ -92,6 +92,9 @@ struct cell {
u8 padding[PAGE_SIZE];
} __attribute__((aligned(PAGE_SIZE))) comm_page;
/**< Page containing the communication region (shared with cell). */
+
+ /** Buffer for the EPT/NPT root-level page table. */
+ u8 __attribute__((aligned(PAGE_SIZE))) root_table_page[PAGE_SIZE];
};
extern struct cell root_cell;
diff --git a/hypervisor/arch/x86/svm.c b/hypervisor/arch/x86/svm.c
index b824472..bc72327 100644
--- a/hypervisor/arch/x86/svm.c
+++ b/hypervisor/arch/x86/svm.c
@@ -298,9 +298,7 @@ int vcpu_vendor_cell_init(struct cell *cell)
/* build root NPT of cell */
cell->svm.npt_structs.root_paging = npt_paging;
- cell->svm.npt_structs.root_table = page_alloc(&mem_pool, 1);
- if (!cell->svm.npt_structs.root_table)
- goto err_free_iopm;
+ cell->svm.npt_structs.root_table = (page_table_t)cell->root_table_page;
if (!has_avic) {
/*
@@ -320,12 +318,10 @@ int vcpu_vendor_cell_init(struct cell *cell)
PAGING_NON_COHERENT);
}
if (err)
- goto err_free_root_table;
+ goto err_free_iopm;
return 0;
-err_free_root_table:
- page_free(&mem_pool, cell->svm.npt_structs.root_table, 1);
err_free_iopm:
page_free(&mem_pool, cell->svm.iopm, 3);
@@ -362,7 +358,6 @@ void vcpu_vendor_cell_exit(struct cell *cell)
{
paging_destroy(&cell->svm.npt_structs, XAPIC_BASE, PAGE_SIZE,
PAGING_NON_COHERENT);
- page_free(&mem_pool, cell->svm.npt_structs.root_table, 1);
page_free(&mem_pool, cell->svm.iopm, 3);
}
diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c
index 575cc70..d922f0f 100644
--- a/hypervisor/arch/x86/vmx.c
+++ b/hypervisor/arch/x86/vmx.c
@@ -335,9 +335,7 @@ int vcpu_vendor_cell_init(struct cell *cell)
/* build root EPT of cell */
cell->vmx.ept_structs.root_paging = ept_paging;
- cell->vmx.ept_structs.root_table = page_alloc(&mem_pool, 1);
- if (!cell->vmx.ept_structs.root_table)
- goto err_free_io_bitmap;
+ cell->vmx.ept_structs.root_table = (page_table_t)cell->root_table_page;
err = paging_create(&cell->vmx.ept_structs,
paging_hvirt2phys(apic_access_page),
@@ -345,12 +343,10 @@ int vcpu_vendor_cell_init(struct cell *cell)
EPT_FLAG_READ | EPT_FLAG_WRITE | EPT_FLAG_WB_TYPE,
PAGING_NON_COHERENT);
if (err)
- goto err_free_root_table;
+ goto err_free_io_bitmap;
return 0;
-err_free_root_table:
- page_free(&mem_pool, cell->vmx.ept_structs.root_table, 1);
err_free_io_bitmap:
page_free(&mem_pool, cell->vmx.io_bitmap, 2);
@@ -387,7 +383,6 @@ void vcpu_vendor_cell_exit(struct cell *cell)
{
paging_destroy(&cell->vmx.ept_structs, XAPIC_BASE, PAGE_SIZE,
PAGING_NON_COHERENT);
- page_free(&mem_pool, cell->vmx.ept_structs.root_table, 1);
page_free(&mem_pool, cell->vmx.io_bitmap, 2);
}
--
2.1.4