Initial cut at assembly hybrid / purecap unification. - #2606
Conversation
arichardson
left a comment
There was a problem hiding this comment.
Not managed to review everything in detail but this cleanup is great 👍
| sb a4, 0(a1) /* Store byte in dest */ | ||
| addi a1, a1, 1 | ||
| #endif | ||
| CLB a4, 0(CAP(a0)) /* Load byte from src */ |
There was a problem hiding this comment.
Can we use a plain lb here? Or does the compiler not accept that yet?
There was a problem hiding this comment.
And the same for the other ones
There was a problem hiding this comment.
Good point, will check.
There was a problem hiding this comment.
So, it appears that aliasing lb to lb.cap is much more involved than anticipated. I think I will leave these definitions here.
Another ways of doing this would be to always mode switch and avoid using .cap instructions at all, but mode switching is more involved in ISAv9 than RVY and I'm worried about perturbation to the hybrid kernel syscall performance measurement.
There was a problem hiding this comment.
Ah did not realize this needed to be hybrid compatible
There was a problem hiding this comment.
Yeah, it is a bit annoying. At some point all this will become simpler, hopefully.
|
I think for the purposes of this patch I 'd like to split the ASM unification refactor from the RVY-specific bits, which is admittedly not straightforward because we rely on some of the compiler aliases that make assumptions about the RVY instruction mnemonics. In the RVY branch I have macros for all the capability instructions. One of the reasons for splitting the patches is that those macros should be relatively easy to revert and replace with compiler aliases once we have the frozen mnemonics. Another thing I'd like to do here is to pretend that |
fb8b664 to
09b28bc
Compare
09b28bc to
d1dd6e8
Compare
d1dd6e8 to
480d75a
Compare
bcc3863 to
34a0120
Compare
brooksdavis
left a comment
There was a problem hiding this comment.
A couple comments before I get on a flight without wifi. I've made it up do "cheri riscv: Implement MODESW macros"
34a0120 to
2675da5
Compare
arichardson
left a comment
There was a problem hiding this comment.
This is great but we will need to use something like ADD_PTR for RVY compatibility
| csetaddr CAP(t1), CAP(t1), t0 | ||
| li t0, 1 | ||
| csetflags CAP(t1), CAP(t1), t0 | ||
| cspecialw stcc, ct1 |
There was a problem hiding this comment.
Could write to ct0 and then share the set_stvec between modes?
There was a problem hiding this comment.
Trying to see if I can simplify this with some LLVM support, which we would need to replace cspecialrw with csrrrw
2675da5 to
7ab8cfb
Compare
|
The CSR story is still a bit sad here, as I can't easily use |
285c65f to
822d3be
Compare
822d3be to
2fec88b
Compare
Rely on compiler menmonic aliases.
Unify copyin/out assembly for hybrid and purecap. Use the new machine/asm.h macros and rely on complier mnemonic aliases.
Unify support.S assembly for hybrid and purecap. Rely on asm.h macros and compiler mnemonic aliases. Partial patch, no csr registers yet.
Unify locore assembly for hybrid and purecap. This reduces the amount of ifdefs and relies on both asm.h definitions and compilier mnemonic aliases.
Unify context switch assembly hybrid and purecap. Rely on asm.h and compiler mnemonic aliases.
Unify hybrid and purecap assembly for exception handling. Rely on compiler mnemonic aliases and asm.h macros.
Unify bus space assembly for hybrid and purecap.
| #define ADD_CAP yadd | ||
| #define ADDI_CAP yaddi | ||
| /* Note: xcheri */ | ||
| #define MODESW_CAP(tmp, tmp1) \ |
There was a problem hiding this comment.
Maybe should distinguish between modesw that are always enabled and those that only exist when building for hybrid. Most of them really exist only for hybrid.
Update assembly in libc, libsys and rtld.
These are used to abstract away switching between hybrid and purecap encodings in the hybrid kernel. This patch facilitates migration to cheri-rv64y.
2fec88b to
5d562e9
Compare
Move towards a unified assembly implementation that relies more heavily on compiler aliases and asm.h definitions to abstract away ISAv9-specific bits.
NOTE: requires compiler patches for
tail->ctail[Cheri] [RISCV] Add alias for ctail instruction. llvm-project#813llyandlgyfor LLA_PTR and LA_PTR macros [CHERI-RISC-V] Add aliases for lly and lgy to llc and lgc. llvm-project#825