From 6ef31c643abc5ce46651ef4f6ddb3ba4ff1e8621 Mon Sep 17 00:00:00 2001 From: Jinyang He Date: Wed, 21 Jun 2023 10:47:30 +0800 Subject: [PATCH] Set STACK_MARGIN_MAX to four times of pagesize on LoongArch64 It fixed a test named tstack. Actually, Linux user get the stacktop is incorrect in current. The value of stack pointer when enter the procedure is thought as it is in the highest stack page. But if the parameters is enough large, lager than 16k, most of arch will also fail this test. Since the LoongArch default pagesize is 16k, it fail often because stack-layout-randomization causes the stackpointer underflow to next page. I had tried fixed it in rtl/linux/[arch]/si_*. But because the codes is unworthy and hardly the parameters is enough large, just expand STACK_MARGIN_MAX for simplicity. --- rtl/inc/system.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc index 08a1997736..d7cf2eeb04 100644 --- a/rtl/inc/system.inc +++ b/rtl/inc/system.inc @@ -48,6 +48,8 @@ const STACK_MARGIN_MAX = 64; { Stack size margin for stack checking } {$elseif defined(CPUZ80)} STACK_MARGIN_MAX = 64; { Stack size margin for stack checking } +{$elseif defined(CPULOONGARCH64)} + STACK_MARGIN_MAX = 65536; { Stack size margin for stack checking } {$else} STACK_MARGIN_MAX = 16384; { Stack size margin for stack checking } {$endif}