This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Behaviour of cheri_pcc_get() on Linux hybrid-cap and Morello Compartments Demo

Hi

I have been porting the Morello compartments demo to Debian linux, cross-compiling with g++ and link with LLVM lld.

I have noticed this attempts to use cheri_pcc_get() to build a capability with same bounds/permissions/tag/flag as the PCC, however in Linux hybrid-cap for me this will only read the address part.

Is this the expected behaviour of cheri_pcc_get() in hybrid?

This built-in is being compiled to ADRP <reg> by the gcc compiler.  According to the Morello architecture reference, in hybrid then ADRP will only read the offset or value which would seem to make sense.  A quick check with clang suggests the builtin is being compiled in the same way.

So, this would mean that one of the following is true:

  1. My understanding of cheri_pcc_get() is wrong and/or for some reason things are different on Linux hybrid than Android (which the demo was targetting)
  2. The gcc and clang compilers are not generating the correct assembly for the builtin on Morello
  3. The Morello compartments demo doesn't work

What say you?

Thanks
Pete
(P.S: The port was made to work by using cheri_ddc_get() since that also covers the whole memory range, although that seems a bit of a cludge)

Parents
  • There aren't many ways to read the full PCC from hybrid (or rather A64). For me, clang compiles cheri_pcc_get() to something like this:

        ADR x8, #0
    CVTP c0, x8

    Registers will vary, of course. I've not updated my clang for a month or so (18d3bd9b) and I've not tried g++.

    My first guess would be that the toolchains are wrong, but it's weird for them _both_ to be wrong. Have you reproduced this in a standalone example, to rule out any complication from the compartments demo build system or similar?

Reply
  • There aren't many ways to read the full PCC from hybrid (or rather A64). For me, clang compiles cheri_pcc_get() to something like this:

        ADR x8, #0
    CVTP c0, x8

    Registers will vary, of course. I've not updated my clang for a month or so (18d3bd9b) and I've not tried g++.

    My first guess would be that the toolchains are wrong, but it's weird for them _both_ to be wrong. Have you reproduced this in a standalone example, to rule out any complication from the compartments demo build system or similar?

Children