2 new revisions:
Revision: 8dbde40dab7c
Branch: default
Author: Scott Levy <
sll...@sandia.gov>
Date: Tue Jan 28 19:01:34 2014 UTC
Log: BUGFIX: smartmap_loader was not properly embedding smartmap_test
ELF i...
http://code.google.com/p/kitten/source/detail?r=8dbde40dab7c
Revision: ccaf6475832f
Branch: default
Author: Kevin Pedretti <
ktp...@sandia.gov>
Date: Wed Jan 29 00:18:42 2014 UTC
Log: BUGFIX: Prevent 32-bit integer overflows when doing math on
pte->base_...
http://code.google.com/p/kitten/source/detail?r=ccaf6475832f
==============================================================================
Revision: 8dbde40dab7c
Branch: default
Author: Scott Levy <
sll...@sandia.gov>
Date: Tue Jan 28 19:01:34 2014 UTC
Log: BUGFIX: smartmap_loader was not properly embedding smartmap_test
ELF image.
Also fix build so running 'make' from user/smartmap directory works.
http://code.google.com/p/kitten/source/detail?r=8dbde40dab7c
Modified:
/user/Makefile.header
/user/smartmap/loader.c
=======================================
--- /user/Makefile.header Thu Aug 22 11:54:44 2013 UTC
+++ /user/Makefile.header Tue Jan 28 19:01:34 2014 UTC
@@ -13,6 +13,11 @@
srctree=matchnothing
endif
+# Default build tools
+ifndef OBJCOPY
+OBJCOPY = $(CROSS_COMPILE)objcopy
+endif
+
# Make sure 'all' is the default target by putting it first.
# The real 'all' target is defined in Makefile.footer
.PHONY:all
=======================================
--- /user/smartmap/loader.c Fri Aug 5 00:30:05 2011 UTC
+++ /user/smartmap/loader.c Tue Jan 28 19:01:34 2014 UTC
@@ -8,13 +8,13 @@
/* The linker sets this up to point to the embedded smartmap_app ELF image
*/
-int _binary_loader_rawdata_start __attribute__ ((weak));
+extern int _binary_smartmap_loader_rawdata_start __attribute__ ((weak));
int
main(int argc, char *argv[], char *envp[])
{
- volatile vaddr_t elf_image = (vaddr_t) &_binary_loader_rawdata_start;
+ volatile vaddr_t elf_image = (vaddr_t)
&_binary_smartmap_loader_rawdata_start;
start_state_t *start_state;
cpu_set_t cpuset;
int num_ranks=0;
==============================================================================
Revision: ccaf6475832f
Branch: default
Author: Kevin Pedretti <
ktp...@sandia.gov>
Date: Wed Jan 29 00:18:42 2014 UTC
Log: BUGFIX: Prevent 32-bit integer overflows when doing math on
pte->base_paddr bitfields.
This could cause odd behavior on systems with > 4 GB memory.
Thanks to Jiannan Ouyang <
jiannan...@gmail.com> for finding this bug.
http://code.google.com/p/kitten/source/detail?r=ccaf6475832f
Modified:
/arch/x86_64/mm/aspace.c
/include/arch-x86_64/page_table.h
=======================================
--- /arch/x86_64/mm/aspace.c Mon Oct 21 22:42:09 2013 UTC
+++ /arch/x86_64/mm/aspace.c Wed Jan 29 00:18:42 2014 UTC
@@ -55,19 +55,19 @@
continue;
/* Walk and then free the Page Upper Directory */
- pud = __va(pgd[i].base_paddr << 12);
+ pud = __va(xpte_paddr(&pgd[i]));
for (j = 0; j < 512; j++) {
if (!pud[j].present || pud[j].pagesize)
continue;
/* Walk and then free the Page Middle Directory */
- pmd = __va(pud[j].base_paddr << 12);
+ pmd = __va(xpte_paddr(&pud[j]));
for (k = 0; k < 512; k++) {
if (!pmd[k].present || pmd[k].pagesize)
continue;
/* Free the last level Page Table Directory */
- ptd = __va(pmd[k].base_paddr << 12);
+ ptd = __va(xpte_paddr(&pmd[k]));
kmem_free_pages(ptd, 0);
}
kmem_free_pages(pmd, 0);
@@ -157,7 +157,7 @@
return NULL;
/* Traverse the Page Upper Directory */
- pud = __va(pge->base_paddr << 12);
+ pud = __va(xpte_paddr(pge));
pue = &pud[pud_index];
if (pagesz == VM_PAGE_1GB)
return pue;
@@ -167,7 +167,7 @@
panic("BUG: Can't follow PUD entry, pagesize bit set.");
/* Traverse the Page Middle Directory */
- pmd = __va(pue->base_paddr << 12);
+ pmd = __va(xpte_paddr(pue));
pme = &pmd[pmd_index];
if (pagesz == VM_PAGE_2MB)
return pme;
@@ -177,7 +177,7 @@
panic("BUG: Can't follow PMD entry, pagesize bit set.");
/* Traverse the Page Table Entry Directory */
- ptd = __va(pme->base_paddr << 12);
+ ptd = __va(xpte_paddr(pme));
pte = &ptd[ptd_index];
return pte;
}
@@ -245,7 +245,7 @@
return;
/* Traverse the Page Upper Directory */
- pud = __va(pge->base_paddr << 12);
+ pud = __va(xpte_paddr(pge));
pue = &pud[pud_index];
if (!pue->present) {
return;
@@ -262,7 +262,7 @@
}
/* Traverse the Page Middle Directory */
- pmd = __va(pue->base_paddr << 12);
+ pmd = __va(xpte_paddr(pue));
pme = &pmd[pmd_index];
if (!pme->present) {
return;
@@ -283,7 +283,7 @@
}
/* Traverse the Page Table Entry Directory */
- ptd = __va(pme->base_paddr << 12);
+ ptd = __va(xpte_paddr(pme));
pte = &ptd[ptd_index];
if (!pte->present) {
return;
@@ -475,34 +475,31 @@
return -ENOENT;
/* Traverse the Page Upper Directory */
- pud = __va(pge->base_paddr << 12);
+ pud = __va(xpte_paddr(pge));
pue = &pud[pud_index];
if (!pue->present)
return -ENOENT;
if (pue->pagesize) {
- result = (((xpte_1GB_t *)pue)->base_paddr << 30)
- | (vaddr & 0x3FFFFFFF);
+ result = xpte_1GB_paddr((xpte_1GB_t *)pue) | (vaddr & 0x3FFFFFFF);
goto out;
}
/* Traverse the Page Middle Directory */
- pmd = __va(pue->base_paddr << 12);
+ pmd = __va(xpte_paddr(pue));
pme = &pmd[pmd_index];
if (!pme->present)
return -ENOENT;
if (pme->pagesize) {
- result = (((xpte_2MB_t *)pme)->base_paddr << 21)
- | (vaddr & 0x1FFFFF);
+ result = xpte_2MB_paddr((xpte_2MB_t *)pme) | (vaddr & 0x1FFFFF);
goto out;
}
/* Traverse the Page Table Entry Directory */
- ptd = __va(pme->base_paddr << 12);
+ ptd = __va(xpte_paddr(pme));
pte = &ptd[ptd_index];
if (!pte->present)
return -ENOENT;
- result = (((xpte_4KB_t *)pte)->base_paddr << 12)
- | (vaddr & 0xFFF);
+ result = xpte_4KB_paddr((xpte_4KB_t *)pte) | (vaddr & 0xFFF);
out:
if (paddr)
=======================================
--- /include/arch-x86_64/page_table.h Mon Dec 17 04:17:38 2007 UTC
+++ /include/arch-x86_64/page_table.h Wed Jan 29 00:18:42 2014 UTC
@@ -72,5 +72,17 @@
os_bits_2 :11, /* Available for us! */
no_exec :1; /* Is the page executable? */
} xpte_1GB_t;
+
+/*
+ * These functions return the base_paddr field in the input pte as a
paddr_t.
+ * These functions should always be used rather than trying to use
+ * pte->base_addr directly, since the default type of C bitfields is
+ * typically 32-bit integer, leading to hard to debug integer overflows
+ * when working with 64-bit unsigned addresses.
+ */
+static inline paddr_t xpte_paddr(xpte_t *pte) { return
((paddr_t)(pte->base_paddr)) << 12; }
+static inline paddr_t xpte_4KB_paddr(xpte_4KB_t *pte) { return
((paddr_t)(pte->base_paddr)) << 12; }
+static inline paddr_t xpte_2MB_paddr(xpte_2MB_t *pte) { return
((paddr_t)(pte->base_paddr)) << 21; }
+static inline paddr_t xpte_1GB_paddr(xpte_1GB_t *pte) { return
((paddr_t)(pte->base_paddr)) << 30; }
#endif