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

More RISC-V CHERI PTE bits #117

Merged
merged 12 commits into from
Jul 20, 2021
Merged

Conversation

nwf
Copy link
Member

@nwf nwf commented Jul 2, 2020

As per the ongoing Sail work at CTSRD-CHERI/sail-cheri-riscv#18.

@nwf nwf requested review from jrtc27, arichardson and bsdjhb July 2, 2020 19:32
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

Looks good to me

target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_bits.h Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
@nwf nwf force-pushed the riscv-cheri-pte-more branch from 17aef50 to 354ea58 Compare July 3, 2020 21:59
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
return TRANSLATE_CHERI_FAIL;
#endif
} else {
/* if necessary, set accessed and dirty bits. */
target_ulong updated_pte = pte | PTE_A |
(access_type == MMU_DATA_STORE ? PTE_D : 0);

#if defined(TARGET_CHERI) && !defined(TARGET_RISCV32)
if (access_type == MMU_DATA_CAP_STORE) {
/* (SCM and not SC) transitions to (SC and not SCM) */
Copy link
Contributor

Choose a reason for hiding this comment

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

So I don't see a check for both bits being set. If that is reserved, we should be checking that above and returning some other fault instead? (What fault is defined for invalid settings of PTE bits?)

Similarly for invalid combinations of the load cap bits.

Copy link
Member

Choose a reason for hiding this comment

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

Invalid setting of PTE bits is normally the page fault corresponding to the instruction type. I don't know if that means we'd want a page fault or a capability page fault if the CHERI-specific bits were the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm. x86 has a special code for reserved bits being set (but it also uses a single PF# vector). I suspect we want to raise the relevant CHERI fault which would happen here by just returning TRANSLATION_FAIL_CHERI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I added checks that raise the existing TRANSLATE_FAIL code; if anyone feels strongly that this should be TRANSLATE_CHERI_FAIL, I'll flip to that.

@nwf nwf force-pushed the riscv-cheri-pte-more branch from 354ea58 to 10f7fe3 Compare July 7, 2020 23:36
target/mips/cp0_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_bits.h Outdated Show resolved Hide resolved
target/riscv/cpu_bits.h Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/csr.c Outdated Show resolved Hide resolved
target/riscv/monitor.c Outdated Show resolved Hide resolved
@nwf nwf force-pushed the riscv-cheri-pte-more branch from 6587776 to 318d800 Compare October 22, 2020 15:09
@nwf nwf requested a review from jrtc27 October 22, 2020 15:09
@nwf nwf force-pushed the riscv-cheri-pte-more branch from 318d800 to 9cafb77 Compare December 3, 2020 13:34
@nwf
Copy link
Member Author

nwf commented Dec 3, 2020

Rebasing. Assuming Jenkins doesn't find any problems and nobody screams, I'll merge.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

Sorry about the conflict.

}

/* Take the GCLG bits from the store and update state bits */
env->mccsr = set_field(env->mccsr, gclgmask, get_field(val, gclgmask));
Copy link
Member

Choose a reason for hiding this comment

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

Do we need another bit somewhere determining whether S-mode is allowed to write?

Copy link
Member

Choose a reason for hiding this comment

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

No, they're like [ms]status.SIE. But they should really have S prefixes on all of them to make that clear.

@arichardson
Copy link
Member

Test failure is my fault. Will fix shortly.

@nwf nwf force-pushed the riscv-cheri-pte-more branch from 9cafb77 to e148b2b Compare December 3, 2020 14:18
@nwf
Copy link
Member Author

nwf commented Dec 3, 2020

Renamed the fields as @jrtc27 suggested.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

I haven't been following the discussion regarding these bits closely. QEMU code looks good.
Will defer functional review to @jrtc27 / @bsdjhb

@arichardson arichardson requested a review from bsdjhb February 25, 2021 12:27
@nwf nwf force-pushed the riscv-cheri-pte-more branch from e148b2b to cbd9b41 Compare April 26, 2021 15:24
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
target/riscv/csr.c Outdated Show resolved Hide resolved
@nwf nwf force-pushed the riscv-cheri-pte-more branch from ee68c8e to c8f3eeb Compare May 5, 2021 22:47
@nwf nwf requested a review from jrtc27 May 5, 2021 22:48
@nwf nwf mentioned this pull request Jun 17, 2021
@nwf nwf force-pushed the riscv-cheri-pte-more branch 2 times, most recently from d91b0d7 to 8a37b8e Compare July 7, 2021 13:37
More obviously parallels the existing W/R bits.
@nwf nwf force-pushed the riscv-cheri-pte-more branch from 8a37b8e to 7c1abfb Compare July 9, 2021 16:43
@nwf nwf requested a review from arichardson July 9, 2021 16:43
@nwf
Copy link
Member Author

nwf commented Jul 12, 2021

@jrtc27: Are there still changes you want me to make?

target/riscv/cpu_helper.c Outdated Show resolved Hide resolved
@@ -1333,12 +1333,8 @@ static int write_pmpaddr(CPURISCVState *env, int csrno, target_ulong val)
#endif

#ifdef TARGET_CHERI

// See Capability Control and Status Registers (CCSRs) in CHERI ISA spec
Copy link
Member

Choose a reason for hiding this comment

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

Hm, either this comment should be grouped with the one below (which should also not have a blank line after it) or it should move to where XCCSR_* are defined

Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved it to the XCCSR_* definitions and pruned the second comment.

target/riscv/csr.c Outdated Show resolved Hide resolved
target/riscv/csr.c Show resolved Hide resolved
nwf-msr and others added 11 commits July 12, 2021 14:03
While here, guard the use of all the upper metadata bits with
`!defined(TARGET_RISCV32)`
Don't yet let the hypervisor play the load-side trap game, but it's
fairly apparent how we might go about it.
This makes [ms]ccsr writable, but only the GCLG bits are updated.

Co-Authored-By: Jessica Clarke <[email protected]>
When raising a MMU exception, we were zeroing out the CLG bits from CP0
EntryHi, which was, understandably, making software sad.

Fixes 7c74ddc
and f0feea1
These are `#if 0`-ed out, but has proven useful in testing, as our FPGA cores
trap rather than atomically update the PTE.
Thanks to @jrtc27 for pointing out its omission.
@nwf nwf force-pushed the riscv-cheri-pte-more branch from 7c1abfb to e9dbce2 Compare July 12, 2021 15:38
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

@jrtc27 can we merge this?

@arichardson arichardson requested a review from jrtc27 July 20, 2021 08:38
@arichardson arichardson merged commit 1ca3bd0 into CTSRD-CHERI:dev Jul 20, 2021
@nwf nwf deleted the riscv-cheri-pte-more branch November 16, 2021 18:30
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