aboutsummaryrefslogtreecommitdiff
path: root/riscv/mmu.h
AgeCommit message (Collapse)AuthorFilesLines
2022-10-14In triggers, use optional<data> instead of {has_data, data}Andrew Waterman1-1/+1
2022-10-06Don't use reexecution as the means to implement trigger-afterAndrew Waterman1-0/+3
The scheme was based on the notion that memory accesses are idempotent up until the point the trigger would've been hit, which isn't true in the case of side-effecting loads and data-value triggers. Instead, check the trigger on the next instruction fetch. To keep the perf overhead minimal, perform this check on the I$ refill path, and ensure that path is taken by flushing the I$.
2022-10-06DRY in checking triggersAndrew Waterman1-16/+1
2022-10-06Move uncommon-case fetch functionality into fetch_slow_pathAndrew Waterman1-17/+1
2022-10-06Move all uncommon-case store functionality into store_slow_pathAndrew Waterman1-57/+11
As a side effect, misaligned stores now behave the same as aligned stores with respect to triggers: only the first byte is checked.
2022-10-06Move all uncommon-case load functionality into load_slow_pathAndrew Waterman1-55/+9
As a side effect, misaligned loads now behave the same as aligned loads with respect to triggers: only the first byte is checked.
2022-10-05Merge pull request #1105 from YenHaoChen/pr-trigger-priorityAndrew Waterman1-6/+22
Fix trigger priority
2022-10-04Suppress most unused-variable warningsAndrew Waterman1-3/+3
2022-10-04Suppress most unused variable warningsAndrew Waterman1-2/+2
2022-09-30Fix priority of mcontrol trigger store address/data beforeYenHaoChen1-0/+7
The spec defines that the mcontrol store address/data has a higher priority over page fault and address misalignment (Debug spec, Table 5.2). Thus, the trigger checking should be before the translation and alignment checking. The previous implementation checks the trigger after the translation and alignment, resulting in incorrect priority. For instance, when page fault and trigger occur on the same instruction, the previous implementation will choose to raise the page fault, which contradicts the priority requirement. This commit moves the trigger checking before the misaligned checking and translation. The trigger will fire on the instruction instead of the page fault in the above case.
2022-09-30Fix priority of mcontrol trigger load address beforeYenHaoChen1-0/+5
The spec defines the mcontrol load address has a higher priority over page fault and address misaligned (Debug spec, Table 5.2). Thus, the trigger checking should be before the translation and alignment checking. The previous implementation checks the trigger after the translation and alignment, resulting in incorrect priority. For instance, when page fault and trigger occur on the same instruction, the previous implementation will choose to raise the page fault, which contradicts the priority requirement. This commit adds an address-only trigger checking before the misaligned checking and translation. The trigger will fire on the instruction instead of the page fault in the above case.
2022-09-30Fix priority of mcontrol trigger execute address beforeYenHaoChen1-2/+6
The spec defines the mcontrol execute address has a higher priority over page fault (Debug spec, Table 5.2). Thus, the trigger checking should be before the translation. The previous implementation checks the trigger after the translation, resulting in incorrect priority. For instance, when page fault and trigger occur on the same instruction, the previous implementation will choose to raise the page fault, which contradicts the priority requirement. This commit adds an address-only trigger checking before the translation. The trigger will fire on the instruction instead of the page fault in the above case.
2022-09-30Add has_data argument to trigger checking functionsYenHaoChen1-5/+5
The mcontrol trigger can select either address or data for checking. The The selection decides the priority of the trigger. For instance, the address trigger has a higher priority over the page fault, and the page fault has a higher priority over the data trigger. The previous implementation only has the checking functions for data trigger, which results in incorrect priority of address trigger. This commit adds a has_data argument to indicate address trigger and the priority of the trigger.
2022-09-16Fix trigger never fire on executing an instruction on plugin devices (#1084)YenHaoChen1-7/+5
The trigger matching only checks on TLB hit (after refill_tlb()). However, instructions on plugin devices will never be filled into the TLB; thus, triggers cannot fire when executing instructions on the plugin devices. The PR removes the if-condition of TLB hit for trigger checking. Co-authored-by: Howard Yen-Hao Chen <yhchen@andestech.com>
2022-08-23Constantize variablesScott Johnson1-2/+2
Because it's always better to do so where possible.
2022-08-23Separate variables that contain two different thingsScott Johnson1-2/+2
No reason to use a variable misleadingly named 'paddr' to hold the virtual address.
2022-07-18Fix load/store performance under clangAndrew Waterman1-2/+2
Hopefully for the last time :-)
2022-07-18Fix totally-broken misaligned HSVScott Johnson1-1/+5
It was accessing memory using the current privilege mode instead of the expected guest privilege. Once #872 is fixed, I suspect we can greatly simplify this.
2022-07-18Fix totally-broken misaligned HLV/HLVXScott Johnson1-1/+6
They were accessing memory using the current privilege mode instead of the expected guest privilege. Once #872 is fixed, I suspect we can greatly simplify this.
2022-07-18Remove no-longer-necessary typecastScott Johnson1-1/+1
It was previously necessary because we were shifting left before assigning to a reg_t, but that changed in the previous commit.
2022-07-15Split up misaligned store into several stepsScott Johnson1-2/+5
Since the last step is about to get much more complex
2022-07-15Split up misaligned load into several stepsScott Johnson1-2/+5
Since the middle step is about to get much more complex
2022-06-06Zero-extend instructions when fetching them from memoryAndrew Waterman1-4/+4
...since we no longer rely on their being sign-extended.
2022-04-21Pass acutally_store from store_func to misaligned_storeRyan Buchner1-1/+1
In future, someone may expect this functionality.
2022-04-21Add actually_store tag to misaligned_store functionRyan Buchner1-2/+2
Is passed along to the contained store_func.
2022-04-21Modify store_func to throw fault if misaligned and require_alignment=trueRyan Buchner1-2/+4
2022-04-21Set require alignment to true on the 'fake' store in amo_func.Ryan Buchner1-1/+1
2022-04-21Add require_alignment tag to store_funcRyan Buchner1-1/+1
Will be used similarly as in load_func.
2022-04-13Adjust indentation in store_slow_path and store_funcRyan Buchner1-9/+9
Didn't want to make change in previous commit to isolate the change.
2022-04-13Skip storing in store_func if actually_store is false, add a fake store at ↵Ryan Buchner1-1/+6
start of AMO. This includes skipping store in store_slow_path. Is okay to skip the mmio_store part too, since the access_fault for mmio_failure will be caught on the actual store. The ordering for the mmio_access fault is irrelevant since it will occur after the TW faults, and load faults are converted to store faults. Will catch any faults from the access but won't perform a store. Since store permissions can only be granted if read permissions exist, any store faults will occur before or at the same time as a load fault. Thus this store permissions check is sufficient for properly catching the faults in an Amo access TW.
2022-04-12Add actually_store tag to store_func and store_slow_pathRyan Buchner1-3/+3
Will be used to check store attributes without actually performing the store. Needed to AMO bug fix.
2022-04-11Merge pull request #944 from riscv-software-src/triggersScott Johnson1-25/+15
Refactor trigger code
2022-04-05Move trigger match logic into triggers.ccTim Newsome1-8/+10
2022-04-05module_t::trigger_match -> memory_access_matchTim Newsome1-2/+2
2022-04-05trigger_matched_t -> triggers::matched_tTim Newsome1-18/+5
2022-04-05Give triggers::module_t its own processor_t*Tim Newsome1-2/+2
2022-04-05Move trigger_match() into triggers.Tim Newsome1-2/+2
2022-03-30Replace state.mcontrol with TM.triggers.Tim Newsome1-1/+1
Created a new triggers::module_t to hold the structure. Also make sure mcontrol_t instances are properly initialized.
2022-03-30trigger_operation_t -> triggers::operation_tTim Newsome1-7/+8
2022-03-30Implement Sv57 and Sv57x4 translation modesAndrew Waterman1-0/+1
2022-01-30add instructions function for cmoliweiwei1-14/+36
prefetch.* are hints and share the encoding of ORI with rd = 0. so it can share the implementation of ORI and execute as no-ops
2022-01-29add blocksz parameter to specify the cache block size for CBO operationsliweiwei1-0/+6
2021-09-08Make pmp_ok return type boolScott Johnson1-1/+1
Since that's what it was returning anyway.
2021-07-21Fix hypervisor MXR and SUMAndrew Waterman1-2/+2
When V=1, vsstatus.MXR applies to the first stage of translation, and mstatus.MXR applies to both. mstatus.SUM doesn't apply when V=1, but vsstatus.SUM does.
2021-07-21Fix HLVX permissions checkAndrew Waterman1-5/+5
It should require X permissions, rather than (R || X).
2021-07-21Simplify (and possibly fix) handling of HLV/HSV TLB accessesAndrew Waterman1-12/+4
The previous scheme flushed the TLB before and after HLV/HSV. I think this was slightly wrong in the case of a debug trigger match: because the TLB gets refilled before the trigger exception gets thrown, we might not have reached the second TLB flush, so the entry could linger. Instead of flushing, simply don't access the TLB and don't refill the TLB for these instructions. Other than the trigger exception case, the effect is the same: we'll perform a full table walk and we won't cache the result.
2021-07-17ext-h: handle mis-aligned exception for guest worldChih-Min Chao1-16/+20
It has been discussed that mis-aligned exception needs to update mstata.GVA ref: https://github.com/riscv/riscv-isa-manual/issues/673 Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
2021-06-12Revert the redundant check for lr instruction (#728)sven1-4/+1
Co-authored-by: zhongchengyong <zhongcy93@gmail.com>
2021-05-25Add alignment check for lr instruction (#713)sven1-1/+4
Co-authored-by: zhongcy <zhongcy93@gmail.com>
2021-03-02Fix AMO guest page fault as store guest fault (#663)francis40961-0/+3