Skip to content

Commit 06ab2b8

Browse files
lifeixlijinxia
authored andcommitted
hv: mmu: add 1GB page capability check when CPU boot
Add 1GB large page support limit on our platform. Tracked-On: #1124 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 58fffcd commit 06ab2b8

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ static int hardware_detect_support(void)
227227
return -ENODEV;
228228
}
229229

230+
if (!cpu_has_cap(X86_FEATURE_PAGE1GB)) {
231+
pr_fatal("%s, not support 1GB page\n", __func__);
232+
return -ENODEV;
233+
}
234+
230235
if (!cpu_has_cap(X86_FEATURE_VMX)) {
231236
pr_fatal("%s, vmx not supported\n", __func__);
232237
return -ENODEV;

hypervisor/arch/x86/mmu.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ int check_vmx_mmu_cap(void)
131131
return -ENODEV;
132132
}
133133

134+
if (!cpu_has_vmx_ept_cap(VMX_EPT_1GB_PAGE)) {
135+
pr_fatal("%s, ept not support 1GB large page\n", __func__);
136+
return -ENODEV;
137+
}
138+
134139
return 0;
135140
}
136141

@@ -187,18 +192,6 @@ void invept(struct vcpu *vcpu)
187192
}
188193
}
189194

190-
bool check_mmu_1gb_support(enum _page_table_type page_table_type)
191-
{
192-
bool status = false;
193-
194-
if (page_table_type == PTT_EPT) {
195-
status = cpu_has_vmx_ept_cap(VMX_EPT_1GB_PAGE);
196-
} else {
197-
status = cpu_has_cap(X86_FEATURE_PAGE1GB);
198-
}
199-
return status;
200-
}
201-
202195
uint64_t get_paging_pml4(void)
203196
{
204197
/* Return address to caller */

hypervisor/common/vm_load.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
197197
* reserving. Current strategy is "total_mem_size in Giga -
198198
* remained 1G pages" for reserving.
199199
*/
200-
if (is_vm0(vm) && check_mmu_1gb_support(PTT_PRIMARY)) {
200+
if (is_vm0(vm)) {
201201
int32_t reserving_1g_pages;
202202

203203
#ifdef CONFIG_REMAIN_1G_PAGES

hypervisor/include/arch/x86/mmu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ static inline void mem_write64(void *addr, uint64_t data)
287287
}
288288

289289
uint64_t get_paging_pml4(void);
290-
bool check_mmu_1gb_support(enum _page_table_type page_table_type);
291290
void *alloc_paging_struct(void);
292291
void free_paging_struct(void *ptr);
293292
void enable_paging(uint64_t pml4_base_addr);

0 commit comments

Comments
 (0)