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

target/riscv: move the dcsr modification out of program buffer #1190

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from

Conversation

lz-bro
Copy link
Contributor

@lz-bro lz-bro commented Dec 24, 2024

When riscv virt2phys_mode is hw, reduce the use of unnecessary program buffers. See #1188 for the original issue.

@lz-bro lz-bro force-pushed the enable-hardware-translation branch from 83bd140 to 46e3fe5 Compare December 24, 2024 07:29
if (register_read_direct(target, &dcsr, GDB_REGNO_DCSR) != ERROR_OK)
return ERROR_FAIL;

/* dcsr.mprven <- 0 */
Copy link
Collaborator

@aap-sc aap-sc Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you set the filed to zero unconditionally ? should not we preserve the original value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

riscv_program_load_mprv() set the dcsr.mprven to zero unconditionally, and I followed its logic. If I set riscv virt2phys_mode back to sw, dcsr.mprven should set to zero?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not we preserve the original value?

Strictly speaking, I don't think we should -- dcsr value is managed by the debugger exclusively. Though either approach should work just fine.

Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lz-bro, thank you for the patch!

Please take a look at my suggestions.

src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
@en-sc en-sc linked an issue Dec 25, 2024 that may be closed by this pull request
@lz-bro lz-bro force-pushed the enable-hardware-translation branch 2 times, most recently from 67516c3 to af1b33a Compare December 25, 2024 12:59
en-sc
en-sc previously approved these changes Dec 25, 2024
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Only a minor nitpick.

src/target/riscv/riscv-013.c Outdated Show resolved Hide resolved
en-sc
en-sc previously approved these changes Dec 25, 2024
when riscv virt2phys_mode is hw, reduce the use of
unnecessary program buffers.
@lz-bro lz-bro force-pushed the enable-hardware-translation branch from 5c47203 to 1390357 Compare December 27, 2024 06:36
@lz-bro lz-bro requested a review from en-sc December 27, 2024 06:39
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, great catch!

LGTM

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.

How to enable hardware translation when progbufsize too small
3 participants