diff --git a/.github/workflows/h2_reg.yml b/.github/workflows/h2_reg.yml index f1273852a..90c30ac7f 100644 --- a/.github/workflows/h2_reg.yml +++ b/.github/workflows/h2_reg.yml @@ -42,21 +42,6 @@ jobs: - name: Build run: make USE_PKW=0 ARCHV=$ARCHV TARGET=opt -j"$(nproc)" - - name: Sanity test - kernel unit test (atomic) - working-directory: kernel/util/atomic/test - run: | - make tst USE_PKW=0 ARCHV=$ARCHV - grep -q "TEST PASSED" results.txt - - - name: Sanity test - booter hello - run: | - hexagon-sim --simulated_returnval \ - --subsystem_base 0xfe28 \ - --cosim_file scripts/timer_v${ARCHV}.cfg \ - -- install/bin/booter booter/hello \ - | tee hello_output.txt - grep -q "Hello, World!" hello_output.txt - - name: Regression test run: | make -O test USE_PKW=0 ARCHV=$ARCHV diff --git a/kernel/traps/tlb/test/test.c b/kernel/traps/tlb/test/test.c index 109dd6dfa..c3bb1b74e 100644 --- a/kernel/traps/tlb/test/test.c +++ b/kernel/traps/tlb/test/test.c @@ -14,6 +14,7 @@ #include #include #include +#include void FAIL(const char *str) { @@ -39,7 +40,7 @@ static inline void TH_tlb_write(unsigned long long int entry, int index) asm volatile (" tlbw(%0,%1) " : : "r"(entry),"r"(index) : "memory"); } -void alloc_until_fail() +void alloc_until_fail(int last_tlb) { int count = 0; int index; @@ -47,16 +48,16 @@ void alloc_until_fail() if (TH_tlb_read(index) != (count|TLBCONST)) FAIL("readback"); count++; } - if (count != 62) FAIL("count"); + if (count != last_tlb - 63) FAIL("count"); if (H2K_gp->pinned_tlb_mask != ~0ULL) FAIL("mask"); if (H2K_gp->last_tlb_index != 63) FAIL("last index"); } -void free_all_0() +void free_all_0(int last_tlb) { int i; printf("freeing...\n"); - for (i = 64; i <= 125; i++) { + for (i = 64; i <= last_tlb; i++) { H2K_tlb_tlbop(TLBOP_TLBFREE,i,0,&a); if ((H2K_gp->pinned_tlb_mask >> (i-64)) & 1) FAIL("tlbmask bit"); if (H2K_gp->last_tlb_index != i) { @@ -67,10 +68,10 @@ void free_all_0() } } -void free_all_1() +void free_all_1(int last_tlb) { int i; - for (i = 65; i <= 125; i++) { + for (i = 65; i <= last_tlb; i++) { H2K_tlb_tlbop(TLBOP_TLBFREE,i,0,&a); if ((H2K_gp->pinned_tlb_mask >> (i-64)) & 1) FAIL("free1 tlbmask bit"); if (H2K_gp->last_tlb_index != 63) FAIL("free1 last entry"); @@ -78,7 +79,7 @@ void free_all_1() } H2K_tlb_tlbop(TLBOP_TLBFREE,64,0,&a); if ((H2K_gp->pinned_tlb_mask >> (64-64)) & 1) FAIL("free1 tlbmask bit/last"); - if (H2K_gp->last_tlb_index != 125) FAIL("free1 last entry/last"); + if (H2K_gp->last_tlb_index != last_tlb) FAIL("free1 last entry/last"); if (TH_tlb_read(64) != 0) FAIL("free1 tlbr/last"); } #define VALID_VPN 0x42000 @@ -87,11 +88,11 @@ void free_all_1() #define ASID 0x12 #define ASID_ENTRY (((unsigned long long int)ASID)<<(32+20)) -void test_readwriteprobe() +void test_readwriteprobe(int last_tlb) { int i; a.ssr_asid = ASID; - for (i = 32; i < 96; i++) { + for (i = 32; i <= last_tlb; i++) { if (H2K_tlb_tlbop(TLBOP_TLBWRITE,i,VALID_TLB_ENTRY,&a) != 0) FAIL("tlbw"); if (H2K_tlb_tlbop(TLBOP_TLBQUERY,VALID_VA,0,&a) != i) FAIL("tlbp"); if (H2K_tlb_tlbop(TLBOP_TLBREAD,i,0,&a) != (VALID_TLB_ENTRY | ASID_ENTRY)) FAIL("tlbr"); @@ -103,31 +104,38 @@ void test_readwriteprobe() void random_test() { - + } int main() { #if ARCHV > 4 int i; + u32_t npages = (u32_t)&H2K_KERNEL_NPAGES; + u32_t tlb_size = H2K_TLB_SIZE; + /* mirrors boot.ref.S: LAST_TLB = TLB_SIZE - NPAGES - 2 - 1 + * (-2 for angel + device pages, -1 for the sub-then-decrement step) */ + int last_tlb = (int)(tlb_size - npages - 3); + u64_t expected_init_mask = (~0ULL) << ((last_tlb + 1) & 0x3F); + __asm__ __volatile(GLOBAL_REG_STR " = %0 " : : "r"(&H2K_kg)); printf("Hello!\n"); - H2K_kg_init(0, 0, 0, 125, 128, 0, 0, 0); + H2K_kg_init(0, 0, 0, last_tlb, tlb_size, 0, 0, 0); printf("initted!\n"); - if (H2K_gp->pinned_tlb_mask != 0xC000000000000000ULL) { + if (H2K_gp->pinned_tlb_mask != expected_init_mask) { FAIL("mask setup"); } - TH_tlb_write(0x01234567cafebabeULL,127); - if (TH_tlb_read(127)!=0x01234567cafebabeULL) FAIL("TH"); - TH_tlb_write(0x01234567deadbeefULL,126); - if (TH_tlb_read(126)!=0x01234567deadbeefULL) FAIL("TH"); + TH_tlb_write(0x01234567cafebabeULL, last_tlb + 2); + if (TH_tlb_read(last_tlb + 2) != 0x01234567cafebabeULL) FAIL("TH"); + TH_tlb_write(0x01234567deadbeefULL, last_tlb + 1); + if (TH_tlb_read(last_tlb + 1) != 0x01234567deadbeefULL) FAIL("TH"); printf("Allocing!\n"); - alloc_until_fail(); - free_all_0(); - alloc_until_fail(); - free_all_1(); + alloc_until_fail(last_tlb); + free_all_0(last_tlb); + alloc_until_fail(last_tlb); + free_all_1(last_tlb); printf("readwriteprobe...\n"); - test_readwriteprobe(); + test_readwriteprobe(last_tlb); printf("Random Testing!\n"); for (i = 0; i < 1000; i++) { random_test(); @@ -136,4 +144,3 @@ int main() puts("TEST PASSED\n"); return 0; } - diff --git a/scripts/Makefile.inc.test b/scripts/Makefile.inc.test index 5f3d64275..f2b8aad81 100644 --- a/scripts/Makefile.inc.test +++ b/scripts/Makefile.inc.test @@ -142,6 +142,8 @@ OPTIMIZE := -O1 KERNEL_INCLUDES := -I ${H2DIR}/kernel/include -I ${H2DIR}/libs/h2/common H2K_KERNEL_NPAGES ?= 0 +H2K_TLB_SIZE ?= 128 +CFLAGS += -DH2K_TLB_SIZE=$(H2K_TLB_SIZE) LDFLAGS += -Wl,--defsym=__bootvm_entry_point=hexagon_pre_main -Wl,--defsym=__bootvm_entry=qdsp6_pre_main -Wl,--defsym=H2K_KERNEL_NPAGES=$(H2K_KERNEL_NPAGES) -Wl,--defsym=H2K_LOAD_ADDR=$(H2K_LINK_ADDR) -Wl,-e=start # -Wl,--defsym=__entry=$(H2K_LOAD_ADDR) diff --git a/scripts/testlist.v81 b/scripts/testlist.v81 index 63f4ea5ca..1fb57e9dd 100644 --- a/scripts/testlist.v81 +++ b/scripts/testlist.v81 @@ -56,7 +56,7 @@ ./kernel/traps/prio/test ./kernel/traps/tid/test ./kernel/traps/cputime/test -#./kernel/traps/tlb/test FIXME: needs to adapt to different kernel page size/count +./kernel/traps/tlb/test ./kernel/traps/waitcycles/test ./kernel/traps/info/test # ./kernel/time/timer/test_standalone # out for ARCHV > 60 because can't set timer regs