def generate(self, **kwargs): page_fault_mod = PageFaultModifier( self.genThread, self.getGlobalState("AppRegisterWidth") ) page_fault_mod.apply(**{"All": 1}) # The PageFaultModifier alters the page size choices, so we need to # set the desired values after applying the page fault modifications choices_mod = ChoicesModifier(self.genThread) satp_info = self.getRegisterInfo("satp", self.getRegisterIndex("satp")) if satp_info["Width"] == 32: choices_mod.modifyPagingChoices( "Page size#4K granule#S#stage 1", {"4K": 1, "4M": 10} ) else: choices_mod.modifyPagingChoices( "Page size#4K granule#S#stage 1", {"4K": 1, "2M": 10, "1G": 10, "512G": 10}, ) choices_mod.commitSet() instruction_list = ("JAL##RISCV", "JALR##RISCV") for _ in range(RandomUtils.random32(2, 5)): self.genInstruction(self.choice(instruction_list)) page_fault_mod.revert() if self.queryExceptionRecordsCount(1) != 0: self.error("Unexpected instruction access fault.")
def gen_thread_initialization(gen_thread): # when satp csr width is 32 bits then Sv32 is only paging mode possible... satp_info = gen_thread.getRegisterInfo("satp", gen_thread.getRegisterIndex("satp")) rv32 = satp_info["Width"] == 32 choices_mod = ChoicesModifier(gen_thread) if rv32: # Sv32 only choices... choices_mod.modifyPagingChoices("Page size#4K granule#S#stage 1", { "4K": 10, "4M": 10 }) else: # Sv48 otherwise... choices_mod.modifyPagingChoices( "Page size#4K granule#S#stage 1", { "4K": 10, "2M": 10, "1G": 0, "512G": 0 }, ) choices_mod.commitSet()
def gen_thread_initialization(gen_thread): satp_info = gen_thread.getRegisterInfo("satp", gen_thread.getRegisterIndex("satp")) rv32 = satp_info["Width"] == 32 choices_mod = ChoicesModifier(gen_thread) # Make the pages small, so it is easy to generate a mapping that crosses # page boundaries if rv32: choices_mod.modifyPagingChoices("Page size#4K granule#S#stage 1", { "4K": 25, "4M": 25 }) else: choices_mod.modifyPagingChoices( "Page size#4K granule#S#stage 1", { "4K": 25, "2M": 25, "1G": 25, "512G": 25 }, ) choices_mod.commitSet()
def gen_thread_initialization(gen_thread): choices_mod = ChoicesModifier(gen_thread) # Make the pages small, so it is easy to generate a mapping that crosses # page boundaries choices_mod.modifyPagingChoices('Page size#4K granule#S#stage 1', {'4K': 25, '2M': 25, '1G': 25, '512G': 25}) choices_mod.commitSet()
def gen_thread_initialization(gen_thread): choices_mod = ChoicesModifier(gen_thread) # Increase the likelihood of using GPRs x10, x11, x12 and x13 by # increasing the weighting. The default weighting in the operand_choices.xml # file is 10 for each GPR. choices_mod.modifyPagingChoices("Page size#4K granule#S#stage 1", { "4K": 10, "2M": 10, "1G": 0, "512G": 0 }) choices_mod.commitSet()
def _generateSystemCallParameters(self): params = {} function = self.choice(("SwitchPrivilegeLevel", None)) if function is not None: params["Function"] = function priv_level = self.choice(("U", "S", "M", 0, 1, 3, "Random", None)) if priv_level is not None: params["PrivilegeLevel"] = priv_level target_addr = self._generateTargetAddress(priv_level) if target_addr is not None: params["TargetAddr"] = target_addr # Don't skip validation if no target address is specified skip_addr_validation = self.choice((0, 1, None)) if (skip_addr_validation is not None) and ( ("TargetAddr" in params) or (skip_addr_validation != 1)): params["SkipAddrValidation"] = skip_addr_validation if RandomUtils.random32(0, 4) == 4: choices_mod = ChoicesModifier(self.genThread) choices_mod.modifyPagingChoices( "Page Allocation Scheme", { "RandomFreeAlloc": 0, "FlatMapAlloc": 10 }, ) params["AddrChoicesModID"] = choices_mod.registerSet() # for param_name in ('InterruptMask', 'SUM', 'MXR', 'MPRV'): for param_name in ("InterruptMask", ): param_val = self.choice((0, 1, "Same", "Flip", "Random", None)) if param_val is not None: params[param_name] = param_val return params
def _generateSystemCallParameters(self): params = {} function = self.choice(('SwitchPrivilegeLevel', None)) if function is not None: params['Function'] = function priv_level = self.choice(('U', 'S', 'M', 0, 1, 3, 'Random', None)) if priv_level is not None: params['PrivilegeLevel'] = priv_level target_addr = self._generateTargetAddress(priv_level) if (target_addr is not None): params['TargetAddr'] = target_addr skip_addr_validation = self.choice((0, 1, None)) if skip_addr_validation is not None: # Don't skip validation if no target address is specified if ('TargetAddr' in params) or (skip_addr_validation != 1): params['SkipAddrValidation'] = skip_addr_validation if RandomUtils.random32(0, 4) == 4: choices_mod = ChoicesModifier(self.genThread) choices_mod.modifyPagingChoices('Page Allocation Scheme', { 'RandomFreeAlloc': 0, 'FlatMapAlloc': 10 }) params['AddrChoicesModID'] = choices_mod.registerSet() # TODO(Noah): Add testing for SUM, MXR and MPRV when support for changing those fields is # established. #for param_name in ('InterruptMask', 'SUM', 'MXR', 'MPRV'): for param_name in ('InterruptMask', ): param_val = self.choice((0, 1, 'Same', 'Flip', 'Random', None)) if param_val is not None: params[param_name] = param_val return params