Hello Community,
In the RISC-V specification, it is not explicitly stated whether BBM (Break-Before-Make) is mandated when updating a page table entry.
Consider the following case where a superpage is being split:
```
...
Is it necessary to invalidate (i.e., clear the entry) and flush the TLB before calling write_pte()?
If not, what part of the RISC-V specification permits skipping BBM in this scenario?
For example, Arm mandates to do BBM: https://developer.arm.com/documentation/ka006181/latest/
Thanks in advance.
2025-07-23T02:14:52-07:00, Oleksii Kurochko <oleksii....@gmail.com>:
> *Hello Community,*
>
> In the RISC-V specification, it is not explicitly stated whether BBM
> (Break-Before-Make) is mandated when updating a page table entry.
>
> Consider the following case where a superpage is being split:
>
> ```
>
> ...
> if ( !split_superpage(&split_pte, level, target, offsets) )
> {
> /* Handle failure to split the superpage */
> ...
> }
>
> ------> /* Should BBM be used here? */
> write_pte(entry, split_pte);
> ...
> ```
>
> Is it necessary to invalidate (i.e., clear the entry) and flush the TLB
> before calling write_pte()?
I don't think so. Software just cannot predict which translation entry
is going to be used until a sfence.vma.
(I think it's better to only flush afterwards, because the TLB might
cache invalid entries, and software shouldn't get anything from
flushing twice.)
> If not, what part of the RISC-V specification permits skipping BBM in this
> scenario?
There is somewhat relevant non-normative text in the NAPOT chapter:
If any inconsistencies do exist, then the effect is the same as when
SFENCE.VMA is used incorrectly: one of the translations will be
chosen, but the choice is unpredictable.
Hope that helps.