Skip to content

Commit 8c1d54b

Browse files
wangxuewenwangli5665
authored andcommitted
hugemmap15: Add support for loongarch
Before this patch: ./hugemmap15 tst_test.c:1137: TCONF: Signal handler for this architecture hasn't been written After this patch: ./hugemmap15 tst_hugepage.c:84: TINFO: 3 hugepage(s) reserved tst_tmpdir.c:316: TINFO: Using /tmp/LTP_hug7F2RcZ as tmpdir (tmpfs filesystem) tst_test.c:1097: TINFO: Mounting none to /tmp/LTP_hug7F2RcZ/hugetlbfs fstyp=hugetlbfs flags=0 tst_test.c:1900: TINFO: LTP version: 20250130-164-gae2792765 tst_test.c:1904: TINFO: Tested kernel: 6.6.0-27.0.v2503.ky11.loongarch64 #1 SMP Mon Mar 10 13:32:48 UTC 2025 loongarch64 tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz' tst_test.c:1722: TINFO: Overall timeout per run is 0h 00m 30s hugemmap15.c:104: TINFO: SIGILL at 0x7fffedffff80 (sig_expected=0x7fffedffff80) hugemmap15.c:104: TINFO: SIGILL at 0x7fffe9ffff80 (sig_expected=0x7fffe9ffff80) hugemmap15.c:104: TINFO: SIGILL at 0x7fffe5ffff80 (sig_expected=0x7fffe5ffff80) hugemmap15.c:104: TINFO: SIGILL at 0x7fffe1ffff80 (sig_expected=0x7fffe1ffff80) ... hugemmap15.c:104: TINFO: SIGILL at 0x7ffef1ffff80 (sig_expected=0x7ffef1ffff80) hugemmap15.c:104: TINFO: SIGILL at 0x7ffef1ffff80 (sig_expected=0x7ffef1ffff80) hugemmap15.c:221: TPASS: Successfully tested dcache to icache flush Signed-off-by: wangxuewen <wangxuewen@kylinos.cn> Reviewed-by: Li Wang <liwang@redhat.com>
1 parent d202914 commit 8c1d54b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \
2828
defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \
2929
defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) || \
30-
defined(__i386__) || defined(__x86_64__) || defined(__arm__)
30+
defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__loongarch__)
3131

3232
#include <setjmp.h>
3333

@@ -45,7 +45,7 @@ static void cacheflush(void *p)
4545
{
4646
#if defined(__powerpc__)
4747
asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
48-
#elif defined(__arm__) || defined(__aarch64__) || defined(__riscv)
48+
#elif defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__)
4949
__clear_cache(p, p + COPY_SIZE);
5050
#else
5151
(void)p;
@@ -68,7 +68,6 @@ static void jumpfunc(int copy, void *p)
6868
memcpy(p, l, COPY_SIZE);
6969
cacheflush(p);
7070
}
71-
7271
goto *p;
7372
dummy:
7473
tst_res(TWARN, "unreachable?");
@@ -96,6 +95,14 @@ static void sig_handler(int signum, siginfo_t *si, void *uc)
9695
siglongjmp(sig_escape, SUCC_JMP);
9796
siglongjmp(sig_escape, FAIL_JMP + SIGILL);
9897
}
98+
#elif defined(__loongarch__)
99+
if (signum == SIGILL) {
100+
void *pc = (void *)((ucontext_t *)uc)->uc_mcontext.__pc;
101+
tst_res(TINFO, "SIGILL at %p (sig_expected=%p)", pc, sig_expected);
102+
if (pc == sig_expected)
103+
siglongjmp(sig_escape, SUCC_JMP);
104+
siglongjmp(sig_escape, FAIL_JMP + SIGILL);
105+
}
99106
#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__)
100107
/* On x86, zero bytes form a valid instruction:
101108
* add %al,(%eax) (i386)

0 commit comments

Comments
 (0)