From: Sabrina Dubroca <sdubroca@xxxxxxxxxx> redhat: rh_kabi: introduce RH_KABI_EXCLUDE_WITH_SIZE This macro is identical to RH_KABI_EXTEND_WITH_SIZE, but with a different intention. While RH_KABI_EXTEND_WITH_SIZE is meant to add new elements that may grow in the future to kABI-protected structures, RH_KABI_EXCLUDE_WITH_SIZE should be used to hide existing elements from kABI checksum computation, while allowing them to be extended in the future without silently breaking binary compatibility of any field that follows it. The size check guarantees that binary compatibility is preserved. Signed-off-by: Sabrina Dubroca <sdubroca@xxxxxxxxxx> diff --git a/include/linux/rh_kabi.h b/include/linux/rh_kabi.h index blahblah..blahblah 100644 --- a/include/linux/rh_kabi.h +++ b/include/linux/rh_kabi.h @@ -306,6 +306,21 @@ * of the size is not allowed and would constitute a silent kABI breakage. * Beware that the RH_KABI_EXCLUDE macro does not do any size checks. * + * RH_KABI_EXCLUDE_WITH_SIZE + * Like RH_KABI_EXCLUDE, this macro excludes the element from + * checksum generation. The same warnings as for RH_KABI_EXCLUDE + * apply: use RH_KABI_FORCE_CHANGE. + * + * This macro is intended to be used for elements embedded inside + * kABI-protected structures (struct, array). In contrast with + * RH_KABI_EXCLUDE, this macro reserves extra space, so that the + * embedded element can grow without changing the offsets of the + * fields that follow. The provided 'size' is the total space to be + * added in longs (i.e. it's 8 * 'size' bytes), including the size + * of the added element. It is automatically checked that the new + * element does not overflow the reserved space, now nor in the + * future. + * * RH_KABI_BROKEN_INSERT * RH_KABI_BROKEN_REMOVE * Insert a field to the middle of a struct / delete a field from a struct. @@ -477,6 +492,13 @@ #define RH_KABI_EXCLUDE(_elem) _RH_KABI_EXCLUDE(_elem); +#define RH_KABI_EXCLUDE_WITH_SIZE(_new, _size) \ + RH_KABI_EXCLUDE(union { \ + _new; \ + unsigned long RH_KABI_UNIQUE_ID[_size]; \ + __RH_KABI_CHECK_SIZE(_new, 8 * (_size)); \ + }) + #define RH_KABI_EXTEND_WITH_SIZE(_new, _size) \ RH_KABI_EXTEND(union { \ _new; \ -- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1619 _______________________________________________ kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure