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

Added bus blocker to deny requests to dmInner when dmactive=0 #2205

Merged
merged 7 commits into from
Mar 28, 2020

Conversation

mwachs5
Copy link
Contributor

@mwachs5 mwachs5 commented Nov 25, 2019

Related issue:

Type of change: feature request

Impact:API modification

Development Phase: implementation

Release Notes

dmactive is now used to deny transactions (return error) that would pass across the DMI interface when dmactive=0. This is to prevent accesses to the interface when it may be in reset and/or have no running clock which might cause it to hang.

This will result in an error response and will prevent reading the DMSTATUS fields (e.g. version) before dmactive is set to 1.

This also changes the interface to make the TLError device more flexible to allow a reduced-size TLError device to be instantiated in the Debug Module.

This also changes the TLBusBypass to report its minLatency as the min of both the original and bypassed paths minLatency.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Nov 25, 2019

It occurs to me that the JTAG DTM has an assertion that error will never be returned. This code needs to be revisited before this PR can be merged (Note: I did that)

Copy link
Contributor

@terpstra terpstra left a comment

Choose a reason for hiding this comment

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

unsound

@@ -19,7 +19,8 @@ class TLZero(address: AddressSet, beatBytes: Int = 4)(implicit p: Parameters)
region = RegionType.UNCACHED,
executable = true,
mayDenyGet = false,
mayDenyPut = false),
mayDenyPut = false,
minLatency = 1),
Copy link
Contributor

Choose a reason for hiding this comment

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

That is a lie. The implementation clearly has minLatency=0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then it has always been lying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously DevNull device always reported that it had minLatency=1. So if this is actually 0 then it should report as 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the line I am referring to:

minLatency = 1))) // no bypass needed for this device

src/main/scala/devices/tilelink/DevNull.scala Show resolved Hide resolved
Copy link
Contributor

@ernie-sifive ernie-sifive left a comment

Choose a reason for hiding this comment

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

Other than minLatency, the rest looks good.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Nov 30, 2019

@terpstra can you please re-review how I handled passing the bufferError parameter and communicating the minLatency appropriately.

@ernie-sifive can you please review the change I made to turn assertion into cover property for the JTAG Debug Transport

Copy link
Contributor

@ernie-sifive ernie-sifive left a comment

Choose a reason for hiding this comment

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

The assert -> cover change looks good to me.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Dec 2, 2019

This is failing regressions because of unhandled errors. I am not sure what is not handling this, presumably OpenOCD?

Warn : Adapter driver 'remote_bitbang' did not declare which transports it allows; assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
Info : Initializing remote_bitbang driver
Info : Connecting to localhost:39085
Info : remote_bitbang driver initialized
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x0)
Error: fflush: Broken pipe
Error: read: count=-1, error=Broken pipe
Error: dmi_scan failed jtag scan
Error: failed read (NOP) at 0x11, status=2
Info : Listening on port 40231 for gdb connections
Error: Target not examined yet

@ernie-sifive
Copy link
Contributor

@mwachs5 The OpenOCD failure is from reading dmstatus before setting dmactive to 1. This was fixed many months ago in riscv-openocd. We need to update rocket-tools with the latest riscv-openocd. I tried to do a PR to do this but don't have permission for rocket-tools.

@aswaterman
Copy link
Member

@ernie-sifive It looks like the permissions for that repository were misconfigured (the intent was that people who have write access to this repo also have it over there). It should be fixed now.

@ernie-sifive
Copy link
Contributor

ernie-sifive commented Jan 4, 2020

@mwachs5 rocket-chip commit 177b5b8 fixes the OpenOCD issue. (Edit: Well, not really...the resulting tools are missing riscv-unknown-elf-objcopy).

There is another case of reading dmstatus while dmactive=0 that is not handling an error return and is also causing CI failures in rocket-chip. Once again I don't have permission to push a branch to the repo (@aswaterman?). In riscv-isa-sim/fesvr/dtm.cc, function dtm_t::resume:

if (running) {
  write(DMI_DMCONTROL, 0);
  // Read dmstatus to avoid back-to-back writes to dmcontrol.                                                                               
  read(DMI_STATUS);   
 }

I would propose changing the write to dmcontrol to write dmactive=1.

@mwachs5 You should also be aware that an assertion fires when the bus blocker error device responds. Something is still wrong with the minlatency settings in the blocker.

Assertion failed: 'A' and 'D' concurrent, despite minlatency 3 (connected at BusBypass.scala:32:12)
    at Monitor.scala:49 assert(cond, message)

@mwachs5
Copy link
Contributor Author

mwachs5 commented Jan 5, 2020 via email

@mwachs5
Copy link
Contributor Author

mwachs5 commented Jan 8, 2020

What needs riscv-unknown-elf-objcopy? This is required by riscv-tests/debug or the rest of rocket-chip code?

I can look into just building a specific commit of riscv-openocd instead of relying on the version in riscv-tools...

@ernie-sifive
Copy link
Contributor

objcopy is needed by sifive closed-source configs that refer to the riscv-tools under rocket-chip. My attempt at updating riscv-tools (chipsalliance/rocket-tools@7f46e7e) changed only openocd and only as far as the commit that fixed the dmstatus access with dmactive=0 (riscv-collab/riscv-openocd@906635c).

@mwachs5
Copy link
Contributor Author

mwachs5 commented Jan 12, 2020

@ernie-sifive do you still need help with the necessary fesvr change? Or are you just looking for my help (on this PR) for the minLatency issue?

@ernie-sifive
Copy link
Contributor

@mwachs5 I don't have permission to push branches to any of the rocket-tools submodules. I think the most expedient way to get this PR to pass CI tests is to branch riscv-openocd and riscv-fesvr from the commits currently pointed to by rocket-tools, make the necessary change to each, and then update rocket-tools to point to these branch commits.

@aswaterman
Copy link
Member

@ernie-sifive you don’t need write permissions to create pull requests. You can fork the repo to your own github account then make PRs back to the original.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 10, 2020

@aswaterman I attempted to do as suggested and just bump the riscv-openocd version and then add the fix to riscv-fesvr, but seems riscv/riscv-fesvr is locked down and can't be modified anymore due to being deprecated...? Am I understanding this correctly?

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 10, 2020

Attempting to move this forwards with riscv-software-src/riscv-isa-sim#392. I am still unclear why the lack of objcopy is a problem, since it seems like the current version of rocket-tools pointed to by rocket-chip also doesn't include objcopy.

This will require us to bump rocket-tools past the point where riscv-fesvr was merged with riscv-isa-sim. I don't know why that was not done before or what complications it will bring. @ernie-sifive it looks like you attempted to do this in your Debug reset PR

@aswaterman
Copy link
Member

aswaterman commented Feb 10, 2020 via email

@ernie-sifive
Copy link
Contributor

@mwachs5 Yes, I attempted this but was never able to achieve a consistent set of tools. The objcopy problem was seen in closed-source that depends on rocket-tools.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 11, 2020

I figured out that the minLatency issue is because TLBypassNode does not have the same behavior as TLXbar in its handling of min latency, it just grabs the parameters from the "real" (non bypassed) device vs combining information from the real vs bypassed device. At least for minLatency I am not sure why you would not want to take the actual minimum.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 11, 2020

This is still failing on tests loading with DTM with an assertion failure that dtm is not supposed to return error. Will look into it.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 13, 2020

This is working, but the version of rocket-tools is not passing its own regressions, so will need to resolve that before merging.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 14, 2020

The current version of rocket-tools is now passing its own regressions. This is ready to merge once more downstream testing is complete and once @terpstra removes his blocking review.

@@ -11,7 +11,8 @@ import freechips.rocketchip.diplomacy._
* continue to send traffic to it !!!
*/
class TLDeadlock(params: DevNullParams, beatBytes: Int = 4)(implicit p: Parameters)
extends DevNullDevice(params, beatBytes, new SimpleDevice("deadlock-device", Seq("sifive,deadlock0")))
extends DevNullDevice(params, minLatency = 1, // technically not true but we don't want to add extra logic to handle minLatency = 0
beatBytes, new SimpleDevice("deadlock-device", Seq("sifive,deadlock0")))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this comment. AFAICT, this device never responds. So minLatency=infinity would be more accurate. This device (TLDeadlock) also flagrantly violates the TL forward progress requirements, but I assume based on the name that this is intentional. What is this device for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know I assume you had created it? Maybe @hcook knows?

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 14, 2020

This is now failing due to missing pexpect. Not sure why this suddenly was a problem...

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 14, 2020

@richardxia i think the tool which required python-pexpect package to be installed in .travis is now python3. Does that mean I need to install a different pexpect package?

@richardxia
Copy link
Member

@richardxia i think the tool which required python-pexpect package to be installed in .travis is now python3. Does that mean I need to install a different pexpect package?

If you switched from Python 2 to Python 3, and if you installed the Python package pexpect via Ubuntu's official apt repository rather than from the Python Package Index, then yes, you need to install python3-pexpect, which is Ubuntu's packaging of Python 3's pexpect library.

Also, just for the record, I have never touched the Travis CI tests for rocket-chip ever (which you can confirm by checking the commit history of .travis.yml here :P), so I don't really know much about how they are configured, but if you want me to dig into them and figure out how they work, I'm happy to do so. Just wanted to make it clear here that I don't have any pre-existing expertise of rocket-chip's CI, only pre-existing expertise of the intersection of Travis CI, Ubuntu, and Python.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Feb 24, 2020

This is failing due to pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: riscv64-unknown-elf-gdb.. Something still off with my tools install.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Mar 6, 2020

hooray. this is finally passing. Will merge with squash-and-merge once some downstream tests pass

@mwachs5 mwachs5 force-pushed the add-dmactive-bus-blocker branch 3 times, most recently from 3b1a2a8 to 901b01b Compare March 16, 2020 04:32
ernie-sifive and others added 6 commits March 26, 2020 04:43
Reduce size of Bypass logic in debug modoule

Parameterize atomics and transferSize in TLBusBypassBase, set in dmOuterAsync

Bus Blocker: BriskBusBlocker is very similar to TLBusBlocker

DMI Bus Blocker: clean up API for error device buffering

Debug: reduce hardware added to TLError on APB interface

Update Zero.scala

Correct the minLatency for TLZero back to 1

Debug: fix rebase issue

Debug: revert unncessary whitespace change

Add optional buffering for C channel as well in error
BusBypass: correct removal of sync reset reliance
…mal and bypass device, otherwise you can get assertion failures when using the bypass path
regression: FESVR is now part of spike so don't build it

bump riscv-tools for FESVR DMACTIVE fix

Rocket-tools: remove prolematic space

rocket-tools: bumping to use latest-ish versions of tools and FSF GDB

rocket-tools: bump hash and build the FSF GDB, not riscv GDB

Regression: apparently need to have the binutils-gdb submodule even if we don't plan to comiple it

Travis: bump pexpect since gdbserver.py now uses Python3

Debug tests: now need to be python3 compatible

dmactive: bump riscv-tools hash

Debug regressions: need to add RISCV/bin to the path now apparently
@mwachs5 mwachs5 merged commit 73333fa into master Mar 28, 2020
@mwachs5 mwachs5 deleted the add-dmactive-bus-blocker branch June 9, 2020 15:34
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.

6 participants