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

Drive protection user bits on TL #2383

Merged
merged 2 commits into from
Mar 31, 2020
Merged

Drive protection user bits on TL #2383

merged 2 commits into from
Mar 31, 2020

Conversation

jsmithsf
Copy link
Contributor

@jsmithsf jsmithsf commented Mar 30, 2020

Related issue:

Type of change: other enhancement
Drive some relevant AMBA protection field information from Rocket.

Impact: API modification
When Rocket is configured to not use virtual memory, it will drive extra information on the TL user bits that can be converted into the AMBA protection fields.

Development Phase: implementation

Release Notes

The instruction vs data, cacheable vs. non-cacheable, and privileged vs. non-privileged information should be driven now.

Now we will mark an access as privileged if the core is in machine mode, or if the access is to a cacheable region.

@jsmithsf jsmithsf requested a review from aswaterman March 30, 2020 11:12
@jsmithsf jsmithsf requested review from hcook and terpstra March 31, 2020 17:27
@jsmithsf
Copy link
Contributor Author

The changes are pretty minor, just looking for an approval from someone

tl_out_a.bits.user.lift(AMBAProt).foreach { x =>
val user_bit_cacheable = edge.manager.supportsAcquireTFast(access_address, a_size)

x.privileged := s2_req.dprv === PRV.M || user_bit_cacheable
Copy link
Contributor

Choose a reason for hiding this comment

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

so all cacheable accesses are also by definition privileged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The relevant point from the AMBA spec is that if a master cannot generate accurate protection information, it is recommended that we mark the transaction as privileged. Because caches like the L2 can merge requests from multiple different privilege modes, we can't accurately provide the protection information.

tl_out.a.bits.user.lift(AMBAProt).foreach { x =>
val user_bit_cacheable = edge_out.manager.supportsAcquireTFast(refill_paddr, lgCacheBlockBytes.U)

x.privileged := io.privileged || user_bit_cacheable // privileged if machine mode or memory port
Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see the comment here. so we are assuming everythign cacheable is going to memory port? If not this comment is a bit misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, currently we are assuming any cacheable thing is going to the memory port. During a short discussion that I had with @hcook he mentioned that it's possible this may change in the future if we add other types of ports.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems it should be the opposite for safety, i.e. if you cannot figure out the exact privilege level, you should assume the lowest level of privilege.

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 understand ARM's reasoning behind their decision, but we are making this change to be more compatible with ARM behavior. So I think for that reason we should follow the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused. Since we cache everything on fetch, why is privileged not just tied to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@terpstra, @aswaterman posed a similar question but was unsure.

@mwachs5 mwachs5 requested a review from daveparry March 31, 2020 17:58
@mwachs5
Copy link
Contributor

mwachs5 commented Mar 31, 2020

If @daveparry can review i can rubber stamp (assuming his review is not strong enough)

x.fetch := false.B
x.secure := true.B
x.bufferable := false.B
x.modifiable := false.B
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether bufferable/modifiable should be !user_bit_cacheable ?

tl_out.a.bits.user.lift(AMBAProt).foreach { x =>
val user_bit_cacheable = edge_out.manager.supportsAcquireTFast(refill_paddr, lgCacheBlockBytes.U)

x.privileged := io.privileged || user_bit_cacheable // privileged if machine mode or memory port
Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused. Since we cache everything on fetch, why is privileged not just tied to true?

@jsmithsf jsmithsf merged commit 468befd into master Mar 31, 2020
@michael-etzkorn michael-etzkorn deleted the amba_prot branch May 14, 2022 21:21
@DecodeTheEncoded
Copy link

DecodeTheEncoded commented May 17, 2023

@jsmithsf Hi, Thanks for your work. I am rookie to rocketchip, and want to understand why AMBAProtField is needed when virtual memory is disabled.

  val masterNode = TLClientNode(Seq(TLMasterPortParameters.v1(
    clients = Seq(TLMasterParameters.v1(
      sourceId = IdRange(0, 1 + icacheParams.prefetch.toInt), // 0=refill, 1=hint
      name = s"Core ${staticIdForMetadataUseOnly} ICache")),
    requestFields = useVM.option(Seq()).getOrElse(Seq(AMBAProtField())))))

I am working on a chipyard configuration(rv32imac without os support), and when I port the deign to vcu118 fpga prototyping, the firrtl will complain some amba signal is not initialized.
I do some debugging, and found the problem is icache masterNode will have amba related userbits if useVM is false, through diplomacy negotiation, these requestFields will go downsteam and reach an end of fpga signal while there is no corresponding amba signal. So, I want to know why you add this in the first place. Thanks

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.

5 participants