Commit Graph

11399 Commits

Author SHA1 Message Date
Tim Newsome 8f81655256
Merge pull request #864 from riscv/prototypes
target/riscv: Remove unnecessary prototypes.
2023-06-12 09:00:22 -07:00
Tim Newsome 166b68c1b0 target/riscv: Remove unnecessary prototypes.
These functions used to exist but don't anymore. (Pointed out in #863)

Change-Id: Iac6b5edd320bdff7628a788861e332f956dcd93d
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-06-09 15:13:44 -07:00
Tim Newsome 973c72887c
Merge pull request #860 from riscv/examine_state
target/riscv: set_dcsr_ebreak() while target->state is still changed
2023-06-08 09:10:55 -07:00
Tim Newsome c8d6ffa6f0
Merge pull request #858 from MarekVCodasip/register-cache-invalidate
Add register cache flushing and invalidation to protobuf execution.
2023-06-08 09:04:54 -07:00
Tim Newsome ad89d570e7 target/riscv: set_dcsr_ebreak() while target->state is still changed
Otherwise it fails.

Fixes #859.

Change-Id: Ib59e6d840316b881481a9b1e01f9d546e73bf932
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-06-07 09:49:58 -07:00
Marek Vrbka 711ac4f0f0 target/riscv: add register cache flushing and invalidation to protobuf execution.
Previously, progbuf execution did not flush or invalidate the register cache which could lead to incorrect behavior. This patch fixes it as well as refactors few sore points in the code related to it.

Change-Id: I353b931ca70a1828d4a9cc512aead00441730875
Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com>
2023-06-07 09:41:30 +02:00
Tim Newsome e0dd44a53c
Merge pull request #856 from riscv/select_hart
target/riscv: Select hart in update_dcsr()
2023-06-06 08:56:05 -07:00
Tim Newsome 0ab2ebd191 target/riscv: Select hart in update_dcsr()
Otherwise we may end up modifying DCSR of a different hart than
intended.

Change-Id: I39bde21a1444623ed150f2b3d504b9318b9d6191
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-06-05 09:39:14 -07:00
Tim Newsome 5a9654d272
Merge pull request #854 from en-sc/en-sc/fix-regacc-running
target/riscv: fix register access on running target
2023-06-02 08:25:07 -07:00
Evgeniy Naydanov 3a29542056 target/riscv: fix register access on running target
Register access on running target should fail if mstatus needs to be
modified.

Change-Id: Iec8e8d514ef2f5ca42606a5534cce55aaaa99180
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-31 22:22:53 +03:00
Tim Newsome 58b6a5eabf
Merge pull request #851 from riscv/power_dance
target/riscv: Handle harts powering down and coming back up.
2023-05-30 12:51:24 -07:00
Tim Newsome f0898155d1 target/riscv: Set dcsr.ebreak* during examine()
This way if you connect to a running target, before it's hit a breakpoint,
then when it does hit the breakpoint OpenOCD will catch it.

Change-Id: I6f1e5f169fa385f46759015786e664693c3872e4
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-26 13:01:47 -07:00
Tim Newsome 21433e83ee target: poll() failure does not mean the target halted.
Poll failure just means poll failed. It's safer to assume the target is
still running, because then if it is running and subsequently halts we can
relay this to gdb correctly. We can't do the other way around, because once
gdb thinks the target has halted, it can't deal with it spontaneously
running.

Change-Id: Idb56137f1d6baa9afc1b0e55e4a48f407b8ebe83
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-26 13:00:13 -07:00
Tim Newsome 82ed02f92a target/riscv: Always clear progbuf cache in examine().
When a DM was powered down, we end up in examine() again, and clearly if
the DM was powered down we need to invalidate that cache.

Change-Id: I5eb6a289939f313e06c09cac22245db083026aa3
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-26 13:00:13 -07:00
Tim Newsome 1c5cf8023c target/riscv: Reset DTM when it reports an error.
The error state is sticky, so this has to be done to recover.

Change-Id: I589f3cdab0f2351fd25f89951830cbc16c39bd93
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-26 13:00:13 -07:00
Tim Newsome c8e7e3535c
Merge pull request #842 from en-sc/en-sc/optimize-access
target:riscv: optimize register accesses
2023-05-25 09:34:49 -07:00
Evgeniy Naydanov 5a29a7399f target/riscv: refactor register accesses
Change-Id: I45731d501f6261c4142c70afacf3fbbe42cf2806
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-23 20:20:19 +03:00
Evgeniy Naydanov c822dc8194 target/riscv: improve register caching (prep_*, cleanup_*)
Introduce riscv_write_register to prep_for_register/vector_access and
cleanup_after_register/vector_access.

Change-Id: I77a0a06ac6f12eceec309f0aff94aa77bd56ff55
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-22 11:55:37 +03:00
Evgeniy Naydanov 8f3a617dc7 target/riscv: improve register caching (riscv_write_register)
This commit introduces a new function, which can be used to reduce number
of register accesses.

Change-Id: I125809726eb7797b11121175c3ad66bedb66dd0d
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-22 11:55:37 +03:00
Evgeniy Naydanov 7a181e8bbc target/riscv: use `riscv_reg_t` and `enum gbb_regno` consistently
Change-Id: Ia476251e835fa5fd129ae6b679c6049c5c60c716
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-22 11:55:37 +03:00
Evgeniy Naydanov 919a98a05b target/riscv: fix register cache flushing
Since writing a register can make some GPRs dirty (e.g. S0, S1), registers
should be flushed in reverse order, so GPRs are flushed last.

Change-Id: Ice352a4df4ae064619c0f9905db634a7b57e4711
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2023-05-22 11:55:37 +03:00
Jan Matyas 431deec8c9
Multiple improvements to Spike smoke-test workflow (#809)
* Multiple improvements to Spike smoke-test workflow

These changes have been made:

- use checkout action v3 (not v2) - silences a Github warning
- cache dependencies to speed-up the process (Spike + toolchain)
- reorder actions so that cached items are handled first
- move dependencies to /opt/riscv for easier caching
- archive logs from the tests (downloadable artifact)
- more descriptive names for some steps
- changed 'apt' to 'apt-get' to supress a warning

Change-Id: I5b8e9200c5d8cbaa3116bac565e009089bb6b36b
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>

* Split cache for spike and toolchain

Change-Id: I423c4ba28e44ec5126786897135fb245e164c664
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>

* Split cache for spike and toolchain - fix cache keys

Change-Id: I907bdb52f402b17a7829ea1d06cd395518de4cd3
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>

* Empty commit to re-trigger the CI

Change-Id: I749d44d8f0dde09ce5adf6e2e1ab5a5324f4018f
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>

---------

Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Co-authored-by: Jan Matyas <jan.matyas@codasip.com>
2023-05-18 14:15:54 -07:00
Tim Newsome 461eb65e21
Merge pull request #847 from riscv/data1_cache
target/riscv: Comment that data1 might change.
2023-05-18 10:56:00 -07:00
Tim Newsome be5187d0a8 target/riscv: Comment that data1 might change.
In case in the future I have the same idea of optimizing progbuf writes
again.

Change-Id: Ie383487691cceeff75e2c22f4c85fc1fe4873937
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-17 09:46:23 -07:00
Tim Newsome 0a38258f71
Merge pull request #848 from riscv/removed-unused-func-set-frontend-running
gdb_server: Removed unused function gdb_set_frontend_state_running
2023-05-16 09:28:14 -07:00
Tim Newsome d78d991191
Merge pull request #850 from riscv/cleanup-in-target-c
Minor cleanup in target.c
2023-05-16 09:27:57 -07:00
Tim Newsome 15bd33cc20
Merge pull request #844 from riscv/from_upstream
Merge 228fe7 from upstream
2023-05-15 08:17:31 -07:00
Jan Matyas bd275ef483 Minor cleanup in target.c
Small cleanup in target.c to get rid of few upstream differences:

- removed a pointless check for `reg->exists` - already checked
  few lines above
- unify one log message with what's in upstream

Change-Id: I3fd761157382670611fa90de84e2dfc90192f473
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
2023-05-15 15:09:55 +02:00
Jan Matyas 528970c47a gdb_server: Removed unused function gdb_set_frontend_state_running
Non-functional change: unused function removed that does not exist
in the OpenOCD upstream, either.

Change-Id: Ibeab5b41a24183673cc02ca919b2f7285309e6f4
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
2023-05-15 12:38:02 +02:00
Tim Newsome e02c83e401
Merge pull request #846 from riscv/cleanup
target/riscv: Remove non-functional code in riscv_program_exec().
2023-05-11 10:27:46 -07:00
Tim Newsome 57d20e4d96 target/riscv: Remove non-functional code in riscv_program_exec().
Addresses #845.

Change-Id: If4eee383f92946669a84f92e52a3ac3600707525
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-05-10 16:58:09 -07:00
Tim Newsome da44fb5407 Merge commit '228fe7300c7df7aa05ba2c0bc19edde6d0156401' into from_upstream
Conflicts:
	doc/openocd.texi
	src/jtag/aice/aice_pipe.c
	src/jtag/aice/aice_usb.c
	src/rtos/FreeRTOS.c
	src/rtos/hwthread.c
	src/rtos/rtos_standard_stackings.c
	src/target/riscv/riscv.c

Change-Id: I0c6228c499d60274325be895fbcd8007ed1699bc
2023-05-04 14:38:10 -07:00
Tim Newsome 80d529cad3
Merge pull request #843 from riscv/hypervisor_translate
target/riscv: Support hypervisor address translation
2023-05-04 09:52:54 -07:00
Tim Newsome 880fa0a8da target/riscv: Support VS-stage and G-stage address translation.
These are used in hypervisor mode.

Change-Id: I5f773816f73c83b4ae57727fbc3b36b65b6185eb
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-04-28 14:48:49 -07:00
Tim Newsome fc52bfefc8
Merge pull request #840 from aap-sc/aap-sc/resume_on_bp
fix bp handling during resume
2023-04-28 09:13:58 -07:00
Tim Newsome 70380dda80
Merge pull request #841 from aap-sc/aap-sc/error_handling_fixup
target/riscv: respect error code from dm013_select_target in select_prepped_harts
2023-04-27 09:04:41 -07:00
Parshintsev Anatoly 152ef1a936 fix bp handling during resume
Depending client parameters OpenOCD resume command can do step+resume
to avoid triggering a pending breakpoint

Change-Id: Ib7ae544e1a1f13843584f4c1c87db17851642b89
Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
2023-04-27 10:06:08 +03:00
Tim Newsome d4429f62e4 target/riscv: Refactor to create riscv_effective_privilege_mode()
Change-Id: I65bba63a7bde746b0069133f8a42529d1d857d3e
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-04-25 10:58:24 -07:00
Tim Newsome 5da1e086b6 target/riscv: Move some code from riscv_address_translate() to riscv_virt2phys()
Also minor code cleanups, and better debug messages.

Change-Id: Iffc9951c8b38da2e3516926108b93db91883680e
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-04-25 10:35:12 -07:00
Tim Newsome 85f44fc37f Comment pte_shift
Change-Id: I48ad7637ff37898ca2df0f48501cf2c72fa1e722
2023-04-25 09:34:27 -07:00
Tim Newsome f2c2ebbcd0 target/riscv: Add constants for vsatp, hgatp
Change-Id: I130a8f7a7abc294bbdf60e7e0ce0bccb72bf920a
Signed-off-by: Tim Newsome <tim@sifive.com>
2023-04-25 09:30:27 -07:00
Parshintsev Anatoly 7ca8350d3a target/riscv: respect error code from dm013_select_target in select_prepped_harts
Change-Id: I3099589521538590e366d60629e49cfc74e2d0c6
Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
2023-04-24 21:15:56 +03:00
Tim Newsome 4d274298b2
workflow: Run checkpatch against diff with riscv (#822)
* workflow: Run checkpatch against pull request only

Instead of arbitrarily picking 20 changes.

Change-Id: I5ec488aa4faa0b06056aa91d0432cda1674967b7
Signed-off-by: Tim Newsome <tim@sifive.com>

* Display FETCH_HEAD in the log

Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com>
Signed-off-by: Tim Newsome <tim@sifive.com>

---------

Signed-off-by: Tim Newsome <tim@sifive.com>
Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com>
2023-04-13 08:38:59 -07:00
Tim Newsome 92dd9eed71
Preserve artifact of Linux build, too. (#828)
* Preserve artifact of Linux build, too.

That can be handy to e-mail to people who don't have a build setup.

Change-Id: I7b7e2d6f0033edf71f53211168f74b80ada64b97
Signed-off-by: Tim Newsome <tim@sifive.com>

* workflow: Run Linux build on Ubuntu 20.04, which is LTS.

This makes the binaries more useful.

Change-Id: I0cf6df68f03c4161222baa222c466fe0004ea769
Signed-off-by: Tim Newsome <tim@sifive.com>

* Use checkoutv3

Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com>
Signed-off-by: Tim Newsome <tim@sifive.com>

---------

Signed-off-by: Tim Newsome <tim@sifive.com>
Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com>
2023-04-12 08:41:47 -07:00
Tim Newsome c454db3eee
Merge pull request #835 from en-sc/en-sc/fix-err-resume
target/riscv: Handle error code in resume_prep
2023-04-11 09:54:47 -07:00
Tim Newsome da229508aa
Merge pull request #833 from zqb-all/read_log128
target/riscv: support log memory access128 for read
2023-04-11 09:53:48 -07:00
Evgeniy Naydanov 08df077083 target/riscv: Handle error code in resume_prep
If hart can't change pc (e.g. it is running), resume command should
fail.

Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Change-Id: I14627366d574d806ea16262b7d305d8161f8bcc2
2023-04-10 17:19:20 +03:00
Mark Zhuang aa7344225b target/riscv: support log memory access128 for read
Change-Id: I9235150fa00c03a1d75d0b44a7500758daa56e2b
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
2023-04-10 09:48:48 +08:00
Tim Newsome 0c76e263e3
Merge pull request #823 from panciyan/riscv
target/riscv: leaf PTE check PTE_W missing
2023-04-07 10:05:57 -07:00
Tim Newsome 15bb3e23b8
Merge pull request #821 from en-sc/en-sc/fix-reset-mharts
target/riscv: simplify reset for rtos harts
2023-04-06 09:54:15 -07:00