[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 09/14] hvmloader: Check modules whereabouts in perform_tests
As perform_tests() is going to clear memory past 4MB, we check that the memory can be use or we skip the tests. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- Changes in V5: - also account for the pages table - fix coding style - also check modules cmdline and main cmdline and modlist_paddr - make use of check_overlap. Changes in v4: - move the check into the perform_test() function. - skip tests instead of using BUG. New in V3 --- tools/firmware/hvmloader/tests.c | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/firmware/hvmloader/tests.c b/tools/firmware/hvmloader/tests.c index fea3ad3..bf3aa01 100644 --- a/tools/firmware/hvmloader/tests.c +++ b/tools/firmware/hvmloader/tests.c @@ -20,6 +20,7 @@ */ #include "util.h" +#include "config.h" #define TEST_FAIL 0 #define TEST_PASS 1 @@ -189,6 +190,15 @@ static int shadow_gs_test(void) return (ebx == 2) ? TEST_PASS : TEST_FAIL; } +static bool check_test_overlap(uint64_t start, uint64_t size) +{ + if (start) + return check_overlap(start, size, + 4ul << 20, + (PT_START + 4 * PAGE_SIZE) - (4ul << 20)); + return false; +} + void perform_tests(void) { int i, passed, skipped; @@ -210,6 +220,49 @@ void perform_tests(void) return; } + /* Check that tests does not use memory where modules are stored */ + if ( check_test_overlap((uint32_t)hvm_start_info, sizeof(hvm_start_info)) ) + { + printf("Skipping tests due to memory used by hvm_start_info\n"); + return; + } + if ( check_test_overlap(hvm_start_info->modlist_paddr, + hvm_start_info->nr_modules * + sizeof(struct hvm_modlist_entry)) ) + { + printf("Skipping tests due to memory used by" + " hvm_start_info->modlist\n"); + return; + } + for ( i = 0; i < hvm_start_info->nr_modules; i++ ) + { + const struct hvm_modlist_entry *modlist = + (struct hvm_modlist_entry *)(uint32_t)hvm_start_info->modlist_paddr; + uint64_t cmdline_paddr = modlist[i].cmdline_paddr; + + if ( check_test_overlap(modlist[i].paddr, modlist[i].size) ) + { + printf("Skipping tests due to memory used by module[%d]\n", i); + return; + } + if ( cmdline_paddr && cmdline_paddr < UINT_MAX && + check_test_overlap(cmdline_paddr, + strlen((char*)(uint32_t)cmdline_paddr)) ) + { + printf("Skipping tests due to memory used by" + " module[%d]'s cmdline\n", i); + return; + } + } + if ( hvm_start_info->cmdline_paddr && + hvm_start_info->cmdline_paddr < UINT_MAX && + check_test_overlap(hvm_start_info->cmdline_paddr, + strlen((char*)(uint32_t)hvm_start_info->cmdline_paddr)) ) + { + printf("Skipping tests due to memory used by the hvm_start_info->cmdline\n"); + return; + } + passed = skipped = 0; for ( i = 0; tests[i].test; i++ ) { -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |