Commit Graph

5 Commits

Author SHA1 Message Date
David Chisnall
dec65d1b4a Make MetaCommon state public.
C++ has no way of exposing it only to things that are backend
implementations.  Eventually this class should be made purely part of
the CHERI back end.
2022-03-28 09:52:49 +01:00
Nathaniel Wesley Filardo
7940fee00c Refactor MetaEntry remote_and_sizeclass
Introduce a class that we can use to more completely separate the frontend
encoding details from the backend.
2022-03-21 23:21:24 +00:00
Nathaniel Wesley Filardo
772e46f878 Additional commentary and more verbose names 2022-03-21 23:21:24 +00:00
Nathaniel Wesley Filardo
b5a66131bd Move BACKEND_MARKER to backend/metatypes
And rename it to REMOTE_BACKEND_MARKER to scope it a bit.
2022-03-21 23:21:24 +00:00
Nathaniel Wesley Filardo
9d97a38806 Move MetaEntry and MetaCommon to backend
These are almost entirely backend concerns, so move their definitions over
there.  Use C++ friend classes to ensure that MetaCommon structures are opaque
to frontend code (at least, at compile time, and neglecting the rest of C++).
(These structures contain high-authority pointers and so should be as closely
guarded as we can make them.)

The bits that leak out are

- the encoding of RemoteAllocator* and sizeclass_t into the uinptr_t within a
  MetaEntry.  This, however, is almost entirely a frontend concern, so detach
  the method definitions from the class and leave those in mem/metaslab.h for
  the moment.

- the size of metadata structures pointed to by the MetaEntry meta field.
  Rather than use sizeof(Metaslab) (and assert that sizeof(ChunkRecord) is
  smaller), instead, define PAGEMAP_METADATA_STRUCT_SIZE once and assert that
  all records fit.  Additionally, add an assertion that Metaslab is exactly this
  size, not for semantic reasons, but because we expect it to be true.

The bits that leak in are

- the need to zero memory corresponding to a chunk.  Rather than having an
  escape hatch that reveals the MetaCommon.chunk, move the zeroing call into a
  small wrapper method within the MetaCommon class itself.

- the need to get the address of a chunk.  We want to assert that we've got the
  right chunk on occasion (well, at least once so far) and so add a class method
  to expose the address_t view of the chunk pointer without exposing the pointer
  itself.
2022-03-21 23:21:24 +00:00