Commit 2aedcbde authored by Charles Jacobsen's avatar Charles Jacobsen Committed by Vikram Narayanan
Browse files

Fix PAT initialization, shrink ioremap region for now.

PAT appears to work now with write back memory. Added an
arch check to ensure PAT is valid before VM entry.

The ioremap region was too big (the amount of metadata - bitmaps,
etc. - was too much). I shrunk it for now to 16 MBs. Later, we
can make it slightly larger.
parent 1e5c02ad
......@@ -8,7 +8,7 @@ export LCD_DOMAINS_CFLAGS=-Werror \
-I$(LCD_DOMAINS_INCLUDE) \
-DLCD_DOMAINS \
-DCONFIG_LAZY_THC \
-DLCD_TEST_MODS_PATH=\"$(PWD)/test-mods\"
-DLCD_TEST_MODS_PATH="\"$(PWD)/test-mods\""
# Don't print "Entering directory..." etc.
MAKEFLAGS += --no-print-directory
......
......@@ -272,7 +272,7 @@ static inline hpa_t hva2hpa(hva_t hva)
#define LCD_MODULE_GPA gpa_add(LCD_STACK_GPA, LCD_STACK_SIZE)
/* Unused area in between heap and ioremap space */
#define LCD_IOREMAP_GPA_BASE __gpa(0xc9UL << 40)
#define LCD_IOREMAP_GPA_SIZE (1UL << 45) /* 32 TB set aside for ioremap */
#define LCD_IOREMAP_GPA_SIZE (1UL << 24) /* 16 MB set aside for ioremap */
/* guest virtual addresses */
#define LCD_GV_PAGING_MEM_GVA __gva(gpa_val(LCD_GV_PAGING_MEM_GPA))
......
This diff is collapsed.
......@@ -632,12 +632,12 @@ static int vmx_setup_pat_msr(unsigned char pat_entry, unsigned char pat_type)
{
u64 pat = 0;
if (pat_entry < MAX_PAT_ENTRY) {
if (pat_entry > MAX_PAT_ENTRY) {
LCD_ARCH_ERR("Invalid PAT entry, cannot setup PAT MSR \n");
return -EINVAL;
}
if(pat_type > VALID_PAT_TYPE && !((1 << pat_type) & 0xF3)) {
if(pat_type > VALID_PAT_TYPE) {
LCD_ARCH_ERR("Not a valid PAT type, cannot setup PAT MSR \n");
return -EINVAL;
}
......@@ -3560,6 +3560,36 @@ static int vmx_check_addr_size(struct lcd_arch *t)
return 0;
}
static int vmx_check_pat_msr(struct lcd_arch *t)
{
u64 pat;
unsigned char val;
unsigned int i;
pat = vmcs_readl(GUEST_IA32_PAT);
/*
* Ensure each entry is 0 (UC), 1 (WC), 4 (WT), 5 (WP),
* 6 (WB), or 7 (UC-)
*/
for (i = 0; i <= MAX_PAT_ENTRY; i++) {
val = (pat & (0xFFUL << (i * 8))) >> (i * 8);
if (val != 0UL &&
val != 1UL &&
val != 4UL &&
val != 5UL &&
val != 6UL &&
val != 7UL) {
LCD_ARCH_ERR("Invalid pat type %d in PAT idx %d",
val, i);
return -1;
}
}
return 0;
}
static int vmx_check_guest_ctrl_regs(struct lcd_arch *t)
{
u64 act64;
......@@ -3671,8 +3701,8 @@ static int vmx_check_guest_ctrl_regs(struct lcd_arch *t)
* pat msr
*/
if (vmx_entry_has(t, VM_ENTRY_LOAD_IA32_PAT)) {
LCD_ARCH_ERR("vmentry pat msr load check not implemented");
return -1;
if (vmx_check_pat_msr(t))
return -1;
}
/*
......
#! /bin/bash
#! /bin/bash -e
sudo dmesg -c > /dev/null
sudo insmod test-mods/$@/lcd_test_mod_$@_boot.ko
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment