oxidecomputer / amd-apcb

AMD Generic Encapsulated Software Architecture Platform Security Processor Configuration Block manipulation library
Mozilla Public License 2.0
13 stars 1 forks source link

serde: Deny unknown fields. #50

Closed daym closed 2 years ago

daym commented 2 years ago

Fixes https://github.com/oxidecomputer/amd-apcb/issues/27.

daym commented 2 years ago

Indeed, it would be better. Adding...

daym commented 2 years ago

There are serde attributes commented out for struct Parameter; these should be deleted, or if the derivations are actually needed, is this restriction needed there too?

The macro make_accessors!, which is used on struct Parameter, automatically takes care of it nowadays--so none of those manual serde attributes need to be specified. I've thus now cleared out the commented-out attributes.

Some not-that-necessary background: The on-disk-Parameters in the apcb are actually stored like this (in sequence): key1, key2, key3, ..., keyN, value1, value2, value3, ..., valueN. Needless to say, that isn't user-friendly, so struct Parameter is used to pretend to the user that they are (key1, value1), (key2, value2), ..., (keyN, valueN), with Parameter being (key1, value1) or similar.

Likewise, struct SlinkConfig, struct CustomSerdeRdimmDdr4Voltages, struct CustomSerdeUdimmDdr4Voltages, struct CustomSerdeLrdimmDdr4Voltages, struct CustomSerdeErrorOutControlBeepCode, struct CustomSerdeDdrPostPackageRepairElement, and maybe others I missed?

Ok, added all it to all the relevant structs and enums now, and added a test.

Also tested it using amd-host-image-builder--result: bitwise identical img before and afterwards.