Re: [PATCH v3 3/8] x86/virt/tdx: Prepare to support reading other global metadata fields

From: Dan Williams
Date: Fri Sep 06 2024 - 17:34:21 EST


Kai Huang wrote:
> Future changes will need to read more metadata fields with different
> element sizes. To make the code short, extend the helper to take a
> 'void *' buffer and the buffer size so it can work with all element
> sizes.

The whole point was to have compile time type safety for global struct
member and the read routine. So, no, using 'void *' is a step backwards.

Take some inspiration from build_mmio_read() and just have a macro that
takes the size as an argument to the macro, not the runtime routine. The
macro statically selects the right routine to call and does not need to
grow a size parameter itself.