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 generate(self, **kwargs): # Process the options specified in the fctrl file # Will set: _requested_fault_type # _page_fault_level # _iter_count - number of instructions to generate self._processFctrlOptions() # Generate some no-ops before making changes to the paging choices self._genDummyInstructions() # Modify the paging choices based on the options parsed from the fctrl file page_fault_mod = PageFaultModifier( self.genThread, self.getGlobalState("AppRegisterWidth")) if not self._requested_fault_type in page_fault_mod.getValidFaultTypes( ): self.error("'PageFaultType' of {} is an unsupported type.").format( self._requested_fault_type) else: if self._page_fault_level == None: page_fault_mod.apply(**{"Type": self._requested_fault_type}) else: page_fault_mod.apply( **{ "Type": self._requested_fault_type, "Level": [self._page_fault_level] }) # Generate the faulting instructions for _ in range(self._iter_count): instr_id = self.genInstruction(self.choice(self._mInstrList)) instr_obj = self.queryInstructionRecord(instr_id) # Write exception count info into the gen.log self._displayExceptionInfo(instr_obj) # Write the page translation info into the gen.log ls_target_addr = instr_obj["LSTarget"] page_obj = self.getPageInfo(ls_target_addr, "VA", 0) displayPageInfo(self, page_obj) # Restore the paging choices to values before the page_fault_mod.apply page_fault_mod.revert() # Some no-ops after the paging choices were restored self._genDummyInstructions()