Automatically remap this frame as _PAGE_USER.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
#include <arch/idt.h>
#include <arch/lib.h>
+#include <arch/mm.h>
#include <arch/processor.h>
#include <arch/desc.h>
gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE((unsigned long)&tss, 0x67, 0x89);
ltr(GDTE_TSS * 8);
+
+ /*
+ * If we haven't applied blanket PAGE_USER mappings, remap the structures
+ * which specifically want to be user.
+ */
+ if ( !test_wants_user_mappings )
+ {
+ unsigned long gfn = virt_to_gfn(user_stack);
+
+ if ( gfn >= ARRAY_SIZE(l1_identmap) )
+ panic("user_stack[] outside of l1_identmap[]\n");
+
+ l1_identmap[gfn] |= _PAGE_USER;
+
+ write_cr3((unsigned long)&cr3_target);
+ }
}
void __noreturn arch_crash_hard(void)
unsigned int cpu_regs_ss(const struct cpu_regs *regs);
extern uint8_t boot_stack[3 * PAGE_SIZE];
+extern uint8_t user_stack[PAGE_SIZE];
#if defined(CONFIG_PV)
#include <xen/xen.h>
ASSERT(IS_ALIGNED(hypercall_page, PAGE_SIZE), "hypercall_page misaligned");
ASSERT(IS_ALIGNED(boot_stack, PAGE_SIZE), "boot_stack misaligned");
+ASSERT(IS_ALIGNED(user_stack, PAGE_SIZE), "user_stack misaligned");
#ifdef CONFIG_HVM
va += 1UL << L1_PT_SHIFT;
}
}
+ else
+ {
+ /*
+ * If we haven't applied blanket PAGE_USER mappings, remap the
+ * structures which specifically want to be user.
+ */
+ intpte_t nl1e = pte_from_virt(user_stack, PF_SYM(AD, U, RW, P));
+
+ if ( hypercall_update_va_mapping(user_stack, nl1e, UVMF_INVLPG) )
+ panic("Unable to remap user_stack with _PAGE_USER\n");
+ }
#endif
/* Unmap page at 0 to catch errors with NULL pointers. */
* boot_stack[page 1] Top of work stack
*/
uint8_t boot_stack[3 * PAGE_SIZE] __aligned(PAGE_SIZE);
+uint8_t user_stack[PAGE_SIZE] __aligned(PAGE_SIZE);
uint32_t x86_features[FSCAPINTS];
enum x86_vendor x86_vendor;
unsigned int x86_family, x86_model, x86_stepping;
#define XTF_TRAPS_H
#include <xtf/extable.h>
+#include <xtf/test.h>
#include <arch/traps.h>
const char test_title[] = "XSA-183 PoC";
-uint8_t user_stack[PAGE_SIZE] __aligned(PAGE_SIZE);
-
void test_main(void)
{
unsigned long curr_stk, discard;
- intpte_t nl1e = pte_from_virt(user_stack, PF_SYM(AD, U, RW, P));
-
- /* Remap user_stack with _PAGE_USER. */
- if ( hypercall_update_va_mapping(user_stack, nl1e, UVMF_INVLPG) )
- panic("Unable to remap user_stack with _PAGE_USER\n");
/* Load NULL selector to guarantee a fault. */
write_fs(0);