ANDROID: GKI: Add reservation and use macros for non-LTS backports

With KMI freeze, we reserve padding in structs to be exclusively used
for LTS updates that would otherwise break the KMI. These fields are
reserved via the ANDROID_KABI_RESERVE() macro that adds a u64 field to
the struct. The ANDROID_KABI_USE() macro is used when the field is
needed for an LTS patch backport.

Since those macros are not usable for general use such as backporting
upstream features, two new macros are added for this purpose:
ANDROID_BACKPORT_RESERVE()
ANDROID_BACKPORT_USE()

Patches that change a ANDROID_BACKPORT_RESERVE() to
ANDROID_BACKPORT_USE() must get the approval of the engineer who added
the reservation.

Bug: 417480479
Change-Id: Iddaf324e1793c33fa171f87376c2c3e7d8473959
Signed-off-by: T.J. Mercier <tjmercier@google.com>
This commit is contained in:
T.J. Mercier
2025-05-13 17:29:58 +00:00
committed by Giuliano Procida
parent e1cdedc5db
commit 42cfdfb46c

View File

@@ -79,12 +79,18 @@
/*
* ANDROID_KABI_RESERVE
* Reserve some "padding" in a structure for potential future use.
* Reserve some "padding" in a structure for use by LTS backports.
* This normally placed at the end of a structure.
* number: the "number" of the padding variable in the structure. Start with
* 1 and go up.
*
*
* ANDROID_BACKPORT_RESERVE
* Similar to ANDROID_KABI_RESERVE, but this is for planned feature backports
* (not for LTS).
*/
#define ANDROID_KABI_RESERVE(number) u64 __kabi_reserved##number
#define ANDROID_KABI_RESERVE(number) u64 __kabi_reserved##number
#define ANDROID_BACKPORT_RESERVE(number) u64 __kabi_reserved_backport##number
/*
* Macros to use _after_ the ABI is frozen
@@ -150,5 +156,13 @@
#define ANDROID_KABI_USE2(number, _new1, _new2) \
_ANDROID_KABI_REPLACE(ANDROID_KABI_RESERVE(number), struct{ _new1; _new2; })
/*
* ANDROID_BACKPORT_USE(number, _new)
* Use a previous padding entry that was defined with ANDROID_BACKPORT_RESERVE
* number: the previous "number" of the padding variable
* _new: the variable to use now instead of the padding variable
*/
#define ANDROID_BACKPORT_USE(number, _new) \
_ANDROID_KABI_REPLACE(ANDROID_BACKPORT_RESERVE(number), _new)
#endif /* _ANDROID_KABI_H */