Fix arch_scrub_control_stack for x86-64-windows

Where the guard pages have a different size.
This commit is contained in:
Stas Boukarev 2026-03-14 20:16:06 +03:00
parent b2e5e1dea4
commit 155348fa9f
3 changed files with 10 additions and 12 deletions

View file

@ -2321,12 +2321,12 @@ scrub_thread_control_stack(struct thread *th)
#ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
/* On these targets scrubbing from C is a bad idea, so we punt to
* a routine in $ARCH-assem.S. */
extern void arch_scrub_control_stack(struct thread *, os_vm_address_t, os_vm_address_t)
extern void arch_scrub_control_stack(struct thread *, os_vm_address_t, os_vm_address_t, unsigned)
#ifdef LISP_FEATURE_X86_64
__attribute__((sysv_abi))
#endif
;
arch_scrub_control_stack(th, guard_page_address, hard_guard_page_address);
arch_scrub_control_stack(th, guard_page_address, hard_guard_page_address, STACK_GUARD_SIZE);
#else
os_vm_address_t sp = (os_vm_address_t)access_control_stack_pointer(th);
#ifdef LISP_FEATURE_STACK_GROWS_DOWNWARD_NOT_UPWARD

View file

@ -401,7 +401,8 @@ GNAME(arch_scrub_control_stack):
* A (struct thread *) in RDI,
* the address of the guard page in RSI, and
* the address of the hard guard page in RDX.
* We may trash RAX, RCX, and R8-R11 with impunity.
* guard size is in RCX
* We may trash RAX, and R8-R11 with impunity.
* [RSP] is our return address, [RSP-8] is the first
* stack slot to scrub. */
@ -409,13 +410,9 @@ GNAME(arch_scrub_control_stack):
* guard page upper bound in R8, and our hard guard
* page upper bound in R9. */
lea -8(%rsp), %rax
#ifdef LISP_FEATURE_WIN32
LOAD_PIC_VAR(win32_page_size, %r9)
#else
LOAD_PIC_VAR(os_vm_page_size, %r9)
#endif
lea (%rsi,%r9), %r8
lea (%rdx,%r9), %r9
lea (%rsi,%rcx), %r8
Lea (%rdx,%rcx), %r9
/* Now we begin our main scrub loop. */
ascs_outer_loop:

View file

@ -692,10 +692,11 @@ GNAME(post_signal_tramp):
.globl GNAME(arch_scrub_control_stack)
TYPE(GNAME(arch_scrub_control_stack))
GNAME(arch_scrub_control_stack):
/* We are passed three parameters:
/* We are passed four parameters:
* A (struct thread *) at [ESP+4],
* the address of the guard page at [ESP+8], and
* the address of the hard guard page at [ESP+12].
* guard size in [ESP+16]
* We may trash EAX, ECX, and EDX with impunity.
* [ESP] is our return address, [ESP-4] is the first
* stack slot to scrub. */
@ -704,7 +705,7 @@ GNAME(arch_scrub_control_stack):
* guard page upper bound in ECX, and our hard guard
* page upper bound in EDX. */
lea -4(%esp), %eax
mov GNAME(os_vm_page_size),%edx
mov 16(%esp),%edx
mov %edx, %ecx
add 8(%esp), %ecx
add 12(%esp), %edx