.data
.p2align PAGE_SHIFT
-/* Mapping of first 4G of memory in 2M superpages. Uses 4x 4k pages. */
+/* Mapping of first 2M of memory in 4k pages. Uses 1x 4k page. */
+GLOBAL(l1_identmap)
+ .long 0, 0 /* Unmap page at 0 to catch errors with NULL pointers. */
+ .rept L1_PT_ENTRIES - 1
+ .long (((. - l1_identmap) / 8) << (PAGE_ORDER_4K + PAGE_SHIFT)) + \
+ _PAGE_USER + _PAGE_RW + _PAGE_PRESENT
+ .long 0
+ .endr
+
+/* Mappings up to 4G in 2M superpages. Uses 4x 4k pages. */
GLOBAL(l2_identmap)
- .rept (4 * L2_PT_ENTRIES)
+ .long l1_identmap + _PAGE_USER + _PAGE_RW + _PAGE_PRESENT
+ .long 0
+ .rept (4 * L2_PT_ENTRIES) - 1
.long (((. - l2_identmap) / 8) << (PAGE_ORDER_2M + PAGE_SHIFT)) + \
_PAGE_PSE + _PAGE_USER + _PAGE_RW + _PAGE_PRESENT
.long 0
write_fs(__USER_DS);
write_gs(__USER_DS);
+ /* Unmap page at 0 to catch errors with NULL pointers. */
+ rc = hypercall_update_va_mapping(NULL, 0, 2);
+ if ( rc )
+ panic("Failed to unmap page at NULL: %d\n", rc);
+
#ifdef __x86_64__
/*
* Set the user pagetables (only applicable to 64bit PV).
}
}
+static void test_NULL_unmapped(void)
+{
+ extern unsigned long label_test_NULL_unmapped[];
+ unsigned long tmp;
+
+ printk("Test: NULL unmapped\n");
+
+ xtf_exlog_start();
+
+ asm volatile ("label_test_NULL_unmapped: mov 0, %0; 2:"
+ _ASM_EXTABLE(label_test_NULL_unmapped, 2b)
+ : "=q" (tmp) :: "memory");
+
+ if ( check_nr_entries(1) )
+ check_exlog_entry(0, __KERN_CS,
+ (unsigned long)&label_test_NULL_unmapped,
+ X86_EXC_PF, 0);
+
+ xtf_exlog_stop();
+}
+
void test_main(void)
{
printk("XTF Selftests\n");
test_extable();
test_exlog();
test_exec_user();
+ test_NULL_unmapped();
xtf_success();
}