From 6a4a1c75ed3fe289b1711fe66ce1a6acf2434221 Mon Sep 17 00:00:00 2001 From: Manjunath Govindashetty Date: Tue, 10 Nov 2015 02:45:46 -0800 Subject: [PATCH] KABI PADDING FOR ORACLE SPECIFIC FUTURE EXTENSIONS Orabug 21903851 Padding added before ABI freeze to allow future extensions while preserving ABI on interface structures scsi_disk ,queue_limits,block_device_operations, sk_buff,user_namespace,ip_tunnel,net,sock,scsi_cmnd ,scsi_device Reviwed-by: Martin Petersen Signed-off-by: Manjunath Govindashetty --- drivers/scsi/sd.h | 10 +++ include/linux/blk_types.h | 2 +- include/linux/blkdev.h | 15 +++++ include/linux/mm_types.h | 7 ++ include/linux/skbuff.h | 9 +++ include/linux/uek_kabi.h | 118 +++++++++++++++++++++++++++++++++ include/linux/user_namespace.h | 8 +++ include/net/ip_tunnels.h | 8 +++ include/net/net_namespace.h | 13 ++++ include/net/sock.h | 9 +++ include/scsi/scsi_cmnd.h | 8 +++ include/scsi/scsi_device.h | 8 +++ 12 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 include/linux/uek_kabi.h diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 63ba5ca7f9a16..6932b6da98479 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -1,6 +1,8 @@ #ifndef _SCSI_DISK_H #define _SCSI_DISK_H +#include + /* * More than enough for everybody ;) The huge number of majors * is a leftover from 16bit dev_t days, we don't really need that @@ -93,6 +95,14 @@ struct scsi_disk { unsigned lbpvpd : 1; unsigned ws10 : 1; unsigned ws16 : 1; + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index b7299febc4b4a..d92357eeed07a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -6,6 +6,7 @@ #define __LINUX_BLK_TYPES_H #include +#include struct bio_set; struct bio; @@ -97,7 +98,6 @@ struct bio { struct bio_vec *bi_io_vec; /* the actual vec list */ struct bio_set *bi_pool; - /* * We can inline a number of vecs at the end of the bio, to avoid * double allocations for a small number of bio_vecs. This member diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 5d93a6645e886..d22c8ad2c1a15 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -307,6 +308,14 @@ struct queue_limits { unsigned char cluster; unsigned char discard_zeroes_data; unsigned char raid_partial_stripes_expensive; + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; struct request_queue { @@ -1613,6 +1622,12 @@ struct block_device_operations { int (*getgeo)(struct block_device *, struct hd_geometry *); /* this callback is with swap_lock and sometimes page table lock held */ void (*swap_slot_free_notify) (struct block_device *, unsigned long); + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + int (*uek_reserved1) (struct block_device *, unsigned long); struct module *owner; }; diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 8d37e26a1007c..f41302bfd50df 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1,6 +1,7 @@ #ifndef _LINUX_MM_TYPES_H #define _LINUX_MM_TYPES_H +#include #include #include #include @@ -313,6 +314,12 @@ struct vm_area_struct { #ifdef CONFIG_NUMA struct mempolicy *vm_policy; /* NUMA policy for the VMA */ #endif + /* Oracle inc use only + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; struct core_thread { diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f15154a879c71..fcd05bcfba541 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -34,6 +34,7 @@ #include #include #include +#include #include /* A. Checksumming of received packets by device. @@ -607,6 +608,7 @@ struct sk_buff { __u8 csum_valid:1; __u8 csum_complete_sw:1; __u8 csum_level:2; + __u8 csum_pad:1; __u8 csum_bad:1; #ifdef CONFIG_IPV6_NDISC_NODETYPE @@ -675,6 +677,13 @@ struct sk_buff { *data; unsigned int truesize; atomic_t users; + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; #ifdef __KERNEL__ diff --git a/include/linux/uek_kabi.h b/include/linux/uek_kabi.h new file mode 100644 index 0000000000000..32a4c7f317060 --- /dev/null +++ b/include/linux/uek_kabi.h @@ -0,0 +1,118 @@ + /* + * uek_abi.h - Oracle kabi abstraction header + * + * (C) 2015 Oracle, Inc. All rights reserved. + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + + #ifndef _LINUX_UEK_KABI_H + #define _LINUX_UEK_KABI_H + + #include + + /* + * The UEK_KABI_REPLACE* macros attempt to add the ability to use the '_new' + * element while preserving size alignment and kabi agreement with the '_orig' + * element. + * + * The #ifdef __GENKSYMS__ preserves the kabi agreement, while the anonymous + * union structure preserves the size alignment (assuming the '_new' element is + * not bigger than the '_orig' element). + * + * UEK_KABI_REPLACE - simple replacement of _orig with a union of _orig and _new + * UEK_KABI_DEPRECATE - mark the element as deprecated and make it unusable + * by modules while preserving KABI checksums + * + * UEK_KABI_EXTEND - simple macro for adding a new element to a struct while + * preserving the kabi agreement (by wrapping with GENKSYMS). + * UEK_KABI_FILL_HOLE - simple macro for filling a hole in a struct while + * preserving the kabi agreement (by wrapping with GENKSYMS). + * UEK_KABI_RENAME - simple macro for renaming an element without changing its type + * while preserving thi kabi agreement (by wrapping with GENKSYMS). + * This macro can be used in bitfields, for example. + * NOTE: does not include the final ';' + * UEK_KABI_REPLACE_UNSAFE - unsafe version of UEK_KABI_REPLACE. Only use for typedefs. + * + * NOTE NOTE NOTE + * Don't use ';' after these macros as it messes up the kabi checker by + * changing what the resulting token string looks like. + * Instead let this macro add the ';' so it can be properly hidden from + * the kabi checker (mainly for UEK_KABI_EXTEND, but applied to all macros for + * uniformity). + * NOTE NOTE NOTE + */ + #ifdef __GENKSYMS__ + + # define _UEK_KABI_REPLACE(_orig, _new) _orig + # define _UEK_KABI_REPLACE_UNSAFE(_orig, _new) _orig + # define _UEK_KABI_DEPRECATE(_type, _orig) _type _orig + + # define UEK_KABI_EXTEND(_new) + # define UEK_KABI_FILL_HOLE(_new) + # define UEK_KABI_RENAME(_orig, _new) _orig + + #else + + #if IS_BUILTIN(CONFIG_UEK_KABI_SIZE_ALIGN_CHECKS) + #define __UEK_KABI_CHECK_SIZE_ALIGN(_orig, _new) \ + union { \ + _Static_assert(sizeof(struct{_new;}) <= sizeof(struct{_orig;}), \ + "kabi sizeof test panic"); \ + _Static_assert(__alignof__(struct{_new;}) <= __alignof__(struct{_orig;}), \ + "kabi alignof test panic"); \ + } + #else + #define __UEK_KABI_CHECK_SIZE_ALIGN(_orig, _new) + #endif + + # define _UEK_KABI_REPLACE(_orig, _new) \ + union { \ + _new; \ + struct { \ + _orig; \ + } __UNIQUE_ID(uek_kabi_hide); \ + __UEK_KABI_CHECK_SIZE_ALIGN(_orig, _new); \ + } + + #define _UEK_KABI_REPLACE_UNSAFE(_orig, _new) _new + + #define _UEK_KABI_DEPRECATE(_type, _orig) _type uek_reserved_##_orig + + #define UEK_KABI_EXTEND(_new) _new; + + /* Warning, only use if a hole exists for _all_ arches. Use pahole to verify */ + #define UEK_KABI_FILL_HOLE(_new) _new; + #define UEK_KABI_RENAME(_orig, _new) _new + + #endif /* __GENKSYMS__ */ + + /* colon added wrappers for the UEK_KABI_REPLACE macros */ + #define UEK_KABI_REPLACE(_orig, _new) _UEK_KABI_REPLACE(_orig, _new); + #define UEK_KABI_REPLACE_UNSAFE(_orig, _new) _UEK_KABI_REPLACE_UNSAFE(_orig, _new); + #define UEK_KABI_DEPRECATE(_type, _orig) _UEK_KABI_DEPRECATE(_type, _orig); + + /* + * Standardization on Oracle inc reserved names. These wrappers leverage + * those common names making it easier to read and find in the code. + */ + #define _UEK_KABI_RESERVED(n) unsigned long uek_reserved##n + #define _UEK_KABI_RESERVED_P(n) void (*uek_reserved##n)(void) + #define UEK_KABI_RESERVED(n) _UEK_KABI_RESERVED(n); + #define UEK_KABI_RESERVED_P(n) _UEK_KABI_RESERVED_P(n); + + /* + * Simple wrappers to replace standard Oracle inc reserved elements. + */ + #define UEK_KABI_USE(n, _new) UEK_KABI_REPLACE(_UEK_KABI_RESERVED(n), _new) + #define UEK_KABI_USE_P(n, _new) UEK_KABI_REPLACE(_UEK_KABI_RESERVED_P(n), _new) + + /* + * Macros for breaking up a reserved element into two smaller chunks using an + * anonymous struct inside an anonymous union. + */ + #define UEK_KABI_USE2(n, _new1, _new2) UEK_KABI_REPLACE(_UEK_KABI_RESERVED(n), struct{ _new1; _new2; }) + #define UEK_KABI_USE2_P(n, _new1, _new2) UEK_KABI_REPLACE(_UEK_KABI_RESERVED_P(n), struct{ _new1; _new2;}) + + #endif /* _LINUX_UEK_KABI_H */ diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 8297e5b341d86..78d1148ca6b6b 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -6,6 +6,7 @@ #include #include #include +#include #define UID_GID_MAP_MAX_EXTENTS 5 @@ -39,6 +40,13 @@ struct user_namespace { struct key *persistent_keyring_register; struct rw_semaphore persistent_keyring_register_sem; #endif + /* Oracle use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserve ABI. + */ + UEK_KABI_EXTEND(bool may_mount_sysfs) + UEK_KABI_EXTEND(bool may_mount_proc) }; extern struct user_namespace init_user_ns; diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index d8214cb88bbcf..95ceb532447cf 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,13 @@ struct ip_tunnel { unsigned int prl_count; /* # of entries in PRL */ int ip_tnl_net_id; struct gro_cells gro_cells; + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; #define TUNNEL_CSUM __cpu_to_be16(0x01) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index f733656404de0..ee2e43512b3d5 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -28,6 +28,7 @@ #include #include #include +#include struct user_namespace; struct proc_dir_entry; @@ -133,6 +134,18 @@ struct net { #endif struct sock *diag_nlsk; atomic_t fnhe_genid; + /* Oracle use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_EXTEND(int sysctl_ip_no_pmtu_disc) + UEK_KABI_EXTEND(int sysctl_ip_fwd_use_pmtu) + /* upstream has this as part of netns_ipv4 */ + UEK_KABI_EXTEND(struct local_ports ipv4_sysctl_local_ports) + UEK_KABI_EXTEND(spinlock_t nsid_lock) + /* upstream has this as part of netns_ipv4 */ + UEK_KABI_EXTEND(struct sock * __percpu *ipv4_tcp_sk) }; #include diff --git a/include/net/sock.h b/include/net/sock.h index 3a4898ec8c67c..6f91ef2f02e2d 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -438,6 +439,14 @@ struct sock { int (*sk_backlog_rcv)(struct sock *sk, struct sk_buff *skb); void (*sk_destruct)(struct sock *sk); + /* Oracle specific + * padding inserted before ABI freeze to + * allow extending the structure while preserving ABI. Feel free + * to replace reserved slots with required structure field + * additions of your backport. + */ + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) }; #define __sk_user_data(sk) ((*((void __rcu **)&(sk)->sk_user_data))) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 9fc1aecfc8136..25cd82e585ca2 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -138,6 +139,13 @@ struct scsi_cmnd { int flags; /* Command flags */ unsigned char tag; /* SCSI-II queued command tag */ + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_RESERVED(3) + UEK_KABI_RESERVED(4) }; /* diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index a4c9336811d17..58ec58ee03430 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -7,6 +7,7 @@ #include #include #include +#include struct device; struct request_queue; @@ -197,6 +198,13 @@ struct scsi_device { struct scsi_dh_data *scsi_dh_data; enum scsi_device_state sdev_state; + /* Oracle inc use only + * + * The following padding has been inserted before ABI freeze to + * allow extending the structure while preserving ABI. + */ + UEK_KABI_RESERVED(1) + UEK_KABI_RESERVED(2) unsigned long sdev_data[0]; } __attribute__((aligned(sizeof(unsigned long)))); -- 2.50.1