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

Design for cbmem #642

Open
rmsyn opened this issue Dec 6, 2022 · 4 comments
Open

Design for cbmem #642

rmsyn opened this issue Dec 6, 2022 · 4 comments

Comments

@rmsyn
Copy link
Contributor

rmsyn commented Dec 6, 2022

cbmem is used throughout coreboot for managing memory regions in ramstage and romstage.

It looks like there are some pretty unsafe code patterns required by the design currently used in coreboot (e.g. https://github.com/coreboot/coreboot/blob/master/src/include/imd.h#L53-L59).

Would it make sense to rework the design with something like hashbrown::HashMap as the backing datastore?

Maybe it would require writing a custom allocator?

I looked through existing and previous mainboards, but didn't find any reference to cbmem. Is it even needed?

I'm also new to coreboot and oreboot, so maybe I've misunderstood something.

@orangecms
Copy link
Contributor

orangecms commented Dec 6, 2022

Hi, so far we don't have any need for something like cbmem.
On some platforms where there is no serial port available for debugging, one of the only ways to get a log would be memory. With the platforms (well, the only one) we currently support in oreboot, we can just look at the serial output.

Edit: added in oreboot for clarification

@rmsyn
Copy link
Contributor Author

rmsyn commented Dec 6, 2022

I traced a call into cbmem for google/octopus mainboard, so maybe just block out the debug calls that trace back to cbmem for now?

It looks like cbmem is also used for checking acpi_is_wakeup_s3 by romstage_handoff_is_resume in mainboards/google/octopus/ec.c

For now I can stub out the call to cbmem_find, and make a note about implementing it if other boards become supported that need it.

When/if cbmem is supported, maybe ringbuffer using const generics would be a good backing data structure?

@orangecms
Copy link
Contributor

Could you elaborate on the question or what you are trying to do?

Technically, besides debugging, cbmem can also be used to gain information on the platform. It is based on an in-memory data store and provides coreboot's log.

@rmsyn
Copy link
Contributor Author

rmsyn commented Dec 8, 2022

Could you elaborate on the question or what you are trying to do?

I'm working on support for the google/octopus/bobba mainboard (CB311-9H), and came across the cbmem stuff while porting over the code from coreboot. Basically, just looking at the code in the mainboard/google/octopus directory, and working backwards to pull in all the code needed.

cbmem is a pretty complex data store, with a couple layers of indirection, and heavy use of pointers + type conversion. So, I was hoping to get opinions on (re)design ideas to create a safer version of the same thing.

Like maybe using ringbuffer for the backing data structure, and (de)serializing stored data structures from/to u8 slices.

It may be a lot of work for nothing though, if the boards that use cbmem never get supported, or end up getting ripped out like in the [x86 cleanup] set of PRs. So, for now, I'm just stubbing out the calls.

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

No branches or pull requests

2 participants