void memguard_guard_stack(void *p)
{
- BUILD_BUG_ON((PRIMARY_STACK_SIZE + PAGE_SIZE) > STACK_SIZE);
- p = (void *)((unsigned long)p + STACK_SIZE -
- PRIMARY_STACK_SIZE - PAGE_SIZE);
- memguard_guard_range(p, PAGE_SIZE);
+ /* IST_MAX IST pages + at least 1 guard page + primary stack. */
+ BUILD_BUG_ON((IST_MAX + 1) * PAGE_SIZE + PRIMARY_STACK_SIZE > STACK_SIZE);
+
+ memguard_guard_range(p + IST_MAX * PAGE_SIZE,
+ STACK_SIZE - PRIMARY_STACK_SIZE - IST_MAX * PAGE_SIZE);
}
void memguard_unguard_stack(void *p)
{
- p = (void *)((unsigned long)p + STACK_SIZE -
- PRIMARY_STACK_SIZE - PAGE_SIZE);
- memguard_unguard_range(p, PAGE_SIZE);
+ memguard_unguard_range(p + IST_MAX * PAGE_SIZE,
+ STACK_SIZE - PRIMARY_STACK_SIZE - IST_MAX * PAGE_SIZE);
}
void arch_dump_shared_mem_info(void)
unsigned char *stub_page;
unsigned int offset;
- /* IST_MAX IST pages + 1 syscall page + 1 guard page + primary stack. */
- BUILD_BUG_ON((IST_MAX + 2) * PAGE_SIZE + PRIMARY_STACK_SIZE > STACK_SIZE);
+ /* IST_MAX IST pages + at least 1 guard page + primary stack. */
+ BUILD_BUG_ON((IST_MAX + 1) * PAGE_SIZE + PRIMARY_STACK_SIZE > STACK_SIZE);
stub_page = map_domain_page(_mfn(this_cpu(stubs.mfn)));
*
* 7 - Primary stack (with a struct cpu_info at the top)
* 6 - Primary stack
- * 5 - Optionally not preset (MEMORY_GUARD)
- * 4 - unused
- * 3 - Syscall trampolines
+ * 5 - Optionally not present (MEMORY_GUARD)
+ * 4 - Unused; optionally not present (MEMORY_GUARD)
+ * 3 - Unused; optionally not present (MEMORY_GUARD)
* 2 - MCE IST stack
* 1 - NMI IST stack
* 0 - Double Fault IST stack