From: Čestmír Kalina <[email protected]>

kabi: introduce RH_KABI_USE_AUX_PTR

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2024595
Upstream Status: RHEL only

commit 194de3042cda2e21a14b504965b4c463b47de73c
Author: Jiri Benc <[email protected]>
Date: Wed, 1 Apr 2020 13:04:15 -0400

    It's hard to predict the number of changes required in a struct. We do our
    best by reserving fields by RH_KABI_RESERVE but sometimes they run out. If
    that's going to happen, the last two reserved fields can be changed into
    an aux struct mechanism. Introduce a macro that does that.

    Example: there's this struct:

    struct foo {
            ...
            RH_KABI_USE(1, int a)
            RH_KABI_USE(2, int b)
            RH_KABI_RESERVE(3)
            RH_KABI_RESERVE(4)
    };

    and a need to add field 'int c', while we expect further additions. It can
    be now done in this way:

    struct foo_rh {
            int c;
    };

    struct foo {
            ...
            RH_KABI_USE(1, int a)
            RH_KABI_USE(2, int b)
            RH_KABI_USE_AUX_PTR(3, 4, foo)
    };

    RH-Signed-off-by: Jiri Benc <[email protected]>

Signed-off-by: Čestmír Kalina <[email protected]>
Signed-off-by: Prarit Bhargava <[email protected]>

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
@@ -388,6 +388,15 @@
 #define RH_KABI_AUX_EMBED(_struct)                                     \
        _RH_KABI_AUX_EMBED(_struct);
 
+/*
+ * If there is a post-kABI freeze need of RH_KABI_AUX_PTR and there are
+ * still two reserved fields available, they can be converted by
+ * RH_KABI_USE_AUX_PTR.
+ */
+#define RH_KABI_USE_AUX_PTR(n1, n2, _struct)                           \
+       RH_KABI_USE(n1, n2,                                             \
+                    struct { RH_KABI_AUX_PTR(_struct) })
+
 /*
  * RH_KABI_AUX_SET_SIZE calculates and sets the size of the extended struct and
  * stores it in the size_rh field for structs that are dynamically allocated.

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1530
_______________________________________________
kernel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
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/[email protected]
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to