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

Miscellaneous fixes and improvements for RISC-V #7043

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gagachang
Copy link
Contributor

  • Commit "core: riscv: Set exception return PC into XEPC for entering user mode"
    removes redundant usage of "ra" register.
  • Commit "core: riscv: Fix misconfiguration of XSCRATCH when XRET to kernel mode"
    fixes the value of XSCRATCH when XRET to kernel mode.
  • Commit "core: riscv: Use sp as base register of load instructions"
    uses "sp" as base register for load instructions to reduce the code size.

Instead of setting exception return PC into "ra" register and assign it
to XEPC, we should directly set exception return PC into "XEPC" CSR to
improve code redability.

Signed-off-by: Alvin Chang <[email protected]>
Reviewed-by: Yu Chien Peter Lin <[email protected]>
When the program wants to XRET to kernel mode, the value of XSCRATCH
must be cleared to zero.

Signed-off-by: Alvin Chang <[email protected]>
Reviewed-by: Yu Chien Peter Lin <[email protected]>
Use sp as base register of load instructions can reduce code size if RVC
extension is enabled to generate 16-bit instructions. The following code
shows the difference after applying this commit.

Before:
    f10009da:	0d053d83          	ld	s11,208(a0)
    f10009de:	0c853d03          	ld	s10,200(a0)
    f10009e2:	0c053c83          	ld	s9,192(a0)
    f10009e6:	0b853c03          	ld	s8,184(a0)
    f10009ea:	0b053b83          	ld	s7,176(a0)
    f10009ee:	0a853b03          	ld	s6,168(a0)
    f10009f2:	0a053a83          	ld	s5,160(a0)
    f10009f6:	09853a03          	ld	s4,152(a0)
    f10009fa:	09053983          	ld	s3,144(a0)
    f10009fe:	08853903          	ld	s2,136(a0)

After:
    f10009a6:	6dce                	ld	s11,208(sp)
    f10009a8:	6d2e                	ld	s10,200(sp)
    f10009aa:	6c8e                	ld	s9,192(sp)
    f10009ac:	7c6a                	ld	s8,184(sp)
    f10009ae:	7bca                	ld	s7,176(sp)
    f10009b0:	7b2a                	ld	s6,168(sp)
    f10009b2:	7a8a                	ld	s5,160(sp)
    f10009b4:	6a6a                	ld	s4,152(sp)
    f10009b6:	69ca                	ld	s3,144(sp)
    f10009b8:	692a                	ld	s2,136(sp)

Signed-off-by: Alvin Chang <[email protected]>
Reviewed-by: Yu Chien Peter Lin <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant