Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/h2_reg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 29 additions & 22 deletions kernel/traps/tlb/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <cache.h>
#include <hw.h>
#include <tlbmisc.h>
#include <symbols.h>

void FAIL(const char *str)
{
Expand All @@ -39,24 +40,24 @@ 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;
while ((index = (int)H2K_tlb_tlbop(TLBOP_TLBALLOC,0,count | TLBCONST,&a)) >= 0) {
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) {
Expand All @@ -67,18 +68,18 @@ 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");
if (TH_tlb_read(i) != 0) FAIL("free1 tlbr");
}
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
Expand All @@ -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");
Expand All @@ -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();
Expand All @@ -136,4 +144,3 @@ int main()
puts("TEST PASSED\n");
return 0;
}

2 changes: 2 additions & 0 deletions scripts/Makefile.inc.test
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion scripts/testlist.v81
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading