Skip to content

Commit 9136730

Browse files
Merge branch 'arm' of https://github.com/gwsystems/composite into arm
2 parents d955eea + c45bf91 commit 9136730

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

src/components/implementation/tests/micro_booter/mb_tests.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ test_captbl_expand(void)
853853

854854
/* FIXME: values are hard-coded */
855855
#define TEST_SMALL
856-
#define TEST_SUPERPAGE_FRAME 0x4A400000
857856
#define TEST_SUPERPAGE_VADDR 0x42000000
858857
#define TEST_SMALLPAGE_VADDR 0x408FF000
859858
#define TEST_SUPERDELEG_VADDR 0x42400000
@@ -865,10 +864,9 @@ void test_superpages(void)
865864
/* This will be used by the memory test */
866865
unsigned long *ptr_small = (unsigned long*)TEST_SMALLPAGE_VADDR;
867866
unsigned long *ptr_large = (unsigned long*)TEST_SUPERDELEG_VADDR;
867+
868868
/* Retype this to user */
869-
if (call_cap_op(BOOT_CAPTBL_SELF_UNTYPED_PT, CAPTBL_OP_MEM_RETYPE2USER, TEST_SUPERPAGE_FRAME, 0, 0, 0) != 0) BUG();
870-
/* Map a superpage to somewhere we want */
871-
if (call_cap_op(BOOT_CAPTBL_SELF_UNTYPED_PT, CAPTBL_OP_MEMACTIVATE, TEST_SUPERPAGE_FRAME, BOOT_CAPTBL_SELF_PT, (unsigned long)ptr, SUPER_PAGE_ORDER) !=0) BUG();
869+
cos_booter_allocn_super(&booter_info, (1 << SUPER_PAGE_ORDER), ptr);
872870

873871
/* Do some rw tests on this - write */
874872
PRINTC("Doing R/W tests on superpage....\n");
@@ -890,7 +888,19 @@ void test_superpages(void)
890888
for (i = 0; i < (1 << SUPER_PAGE_ORDER) / sizeof(unsigned long); i++) {
891889
if (ptr_large[i] != i) BUG();
892890
}
893-
PRINTC("Superpage test SUCCESS.\n");
891+
PRINTC("Initial superpage test SUCCESS.\n");
892+
893+
PRINTC("Doing expanded testing on ALL superpages...\n");
894+
ptr += (1 << SUPER_PAGE_ORDER);
895+
cos_booter_allocn_super(&booter_info, (EXTRA_SUPERPAGES - 1) * (1 << SUPER_PAGE_ORDER), ptr);
896+
897+
/* Do some rw tests on this - write */
898+
PRINTC("Doing R/W tests on superpage....\n");
899+
for (i = 0; i < 4 * (1 << SUPER_PAGE_ORDER) / sizeof(unsigned long); i++) ptr[i] = i;
900+
for (i = 0; i < 4 * (1 << SUPER_PAGE_ORDER) / sizeof(unsigned long); i++) {
901+
if (ptr[i] != i) BUG();
902+
}
903+
PRINTC("Expanded superpage test SUCCESS.\n");
894904
}
895905

896906
/* Executed in micro_booter environment */

src/components/include/cos_kernel_api.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ typedef capid_t hwcap_t;
5656

5757
/* Memory source information */
5858
struct cos_meminfo {
59-
vaddr_t untyped_ptr, umem_ptr, kmem_ptr;
60-
vaddr_t untyped_frontier, umem_frontier, kmem_frontier;
59+
vaddr_t untyped_ptr, umem_ptr, kmem_ptr, super_ptr;
60+
vaddr_t untyped_frontier, umem_frontier, kmem_frontier, super_frontier;
6161
pgtblcap_t pgtbl_cap;
6262
};
6363

@@ -120,6 +120,7 @@ asndcap_t cos_asnd_alloc(struct cos_compinfo *ci, arcvcap_t arcvcap, captblcap_t
120120

121121
void *cos_page_bump_alloc(struct cos_compinfo *ci);
122122
void *cos_page_bump_allocn(struct cos_compinfo *ci, size_t sz);
123+
void *cos_booter_allocn_super(struct cos_compinfo *ci, size_t sz, void* vaddr);
123124

124125
capid_t cos_cap_cpy(struct cos_compinfo *dstci, struct cos_compinfo *srcci, cap_t srcctype, capid_t srccap);
125126
int cos_cap_cpy_at(struct cos_compinfo *dstci, capid_t dstcap, struct cos_compinfo *srcci, capid_t srccap);

src/components/lib/cos_kernel_api.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@
1717
#define printd(...)
1818
#endif
1919

20+
/* RSK -- move this to proper location, probably consts.h
21+
* At this point I'm following runyu's lead but I don't think is
22+
* a good long term solution
23+
* */
24+
#define SUPER_PAGE_ORDER 22
25+
#define SUPER_PAGE_SIZE (1 << SUPER_PAGE_ORDER)
26+
2027
void
2128
cos_meminfo_init(struct cos_meminfo *mi, vaddr_t untyped_ptr, unsigned long untyped_sz, pgtblcap_t pgtbl_cap)
2229
{
2330
mi->untyped_ptr = mi->umem_ptr = mi->kmem_ptr = mi->umem_frontier = mi->kmem_frontier = untyped_ptr;
2431
mi->untyped_frontier = untyped_ptr + untyped_sz;
32+
mi->super_ptr = TEST_SUPERPAGE_FRAME;
33+
mi->super_frontier = mi->super_ptr + (EXTRA_SUPERPAGES * SUPER_PAGE_SIZE);
2534
mi->pgtbl_cap = pgtbl_cap;
2635
}
2736

@@ -743,6 +752,43 @@ cos_page_bump_allocn(struct cos_compinfo *ci, size_t sz)
743752
return (void *)__page_bump_alloc(ci, sz);
744753
}
745754

755+
static vaddr_t
756+
__superpage_bump_alloc(struct cos_compinfo *ci, vaddr_t addr)
757+
{
758+
vaddr_t ret = 0;
759+
vaddr_t * ptr, *frontier;
760+
761+
ptr = &ci->mi.super_ptr;
762+
frontier = &ci->mi.super_frontier;
763+
764+
ret = ps_faa(ptr, SUPER_PAGE_SIZE);
765+
766+
//TODO: RSK -- ensure checks make sense and are sufficient
767+
if (ret >= *frontier) return 0;
768+
769+
if (call_cap_op(BOOT_CAPTBL_SELF_UNTYPED_PT, CAPTBL_OP_MEM_RETYPE2USER, ret, 0, 0, 0)) return 0;
770+
if (call_cap_op(BOOT_CAPTBL_SELF_UNTYPED_PT, CAPTBL_OP_MEMACTIVATE, ret, BOOT_CAPTBL_SELF_PT, addr, 22)) return 0;
771+
772+
return ret;
773+
}
774+
775+
void *
776+
cos_booter_allocn_super(struct cos_compinfo *ci, size_t sz, void* vaddr)
777+
{
778+
int i;
779+
vaddr_t ret = 0;
780+
vaddr_t curr;
781+
782+
//TODO: check for valid booter component
783+
784+
assert (sz % SUPER_PAGE_SIZE == 0);
785+
for (curr = (vaddr_t)vaddr; curr < (vaddr_t)vaddr + sz; curr += SUPER_PAGE_SIZE) {
786+
ret = __superpage_bump_alloc(ci, curr);
787+
if (!ret) assert(0);
788+
}
789+
return vaddr;
790+
}
791+
746792
capid_t
747793
cos_cap_cpy(struct cos_compinfo *dstci, struct cos_compinfo *srcci, cap_t srcctype, capid_t srccap)
748794
{

src/kernel/include/shared/consts.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,7 @@ struct pt_regs {
140140
#define THDID_OFFSET 2
141141
#define INVTOKEN_OFFSET 3
142142

143+
/* Info on superpage mappings */
144+
#define TEST_SUPERPAGE_FRAME 0x4A400000
145+
143146
#endif

0 commit comments

Comments
 (0)