Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rv32: Question on interactions with SFENCE.VMA #38

Open
chyyuu opened this issue Dec 22, 2018 · 0 comments
Open

rv32: Question on interactions with SFENCE.VMA #38

chyyuu opened this issue Dec 22, 2018 · 0 comments

Comments

@chyyuu
Copy link
Owner

chyyuu commented Dec 22, 2018

In the current spec, from what I understand so far:

writes to ptes in memory need to be synchronized with sfence.vma
writes to pmp csrs need to be synchronized with sfence.vma
writes to the satp csr do not need to be synchronized with sfence.vma edit: to clarify, here, what I mean is that the very next instruction fetch following a write to satp that enable translation should be translated.

Alexandre Joannou和Andrew Waterman的互动:

对于当前指令集手册中关于SFENCE.VMA的部分可以做如下解读:

对内存中的PTEs进行写操作需用SFENCE.VMA进行同步;
对PMP CSRs进行写操作需用SFENCE.VMA进行同步;
对satp CSR进行写操作无需使用SFENCE.VMA进行同步(即,紧跟在使能转换的写satp操作后的那条指令的取指地址是会被转换的)。
对PMP CSRs进行写操作需显式的同步,而对satp的操作则不需要,暗示着某种微架构支持(可能是一种在大多数实现中的流水线阻塞)
从描述上来看,为什么对PMPs的操作描述相较于satp“没有那么严谨”?

Andrew Waterman 认为这是为了更容易使用缓存标签和TLB等机制来实现对PMPs的缓存,而satp本身则不被缓存。
一种相关的硬件行为描述如下:某些有效的PTEs已被缓存在系统中,此时更新PMP使那些PTEs无法再被访问。尽管如此,这些PTEs依然可以被命中,直到一个SFENCE.VMA指令(rs1=x0,rs2=x0)的执行。

Andrew Waterman 认为Alexandre Joannou描述的这种硬件行为是正确的。

riscv/riscv-isa-manual#204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant