powerpc: fix the allyesconfig build
Subsystems (5)
PATCH 1/1 powerpc: fix the allyesconfig build
There are 2 drivers that have arrays of packed structures that contain pointers that end up at unaligned offsets. These produce warnings in the PowerPC allyesconfig build like this:
WARNING: 148 bad relocationsc00000000e56510b R_PPC64_UADDR64 .rodata+0x0000000001c72378c00000000e565126 R_PPC64_UADDR64 .rodata+0x0000000001c723c0
They are not drivers that are used on PowerPC (I assume), so mark them to not be built on PPC64 when CONFIG_RELOCATABLE is enabled.
--- drivers/clk/renesas/Kconfig | 4 ++++ drivers/net/ethernet/hisilicon/Kconfig | 4 ++++ 2 files changed, 8 insertions(+)
It might be easiest to put this through the PowerPC (fixes?) tree, if people woulf just sned ACKs, please?
drivers/clk/renesas/Kconfig +4 -0
@@ -151,6 +151,10 @@ config CLK_R8A779A0 select CLK_RENESAS_CPG_MSSR config CLK_R9A06G032 + # PPC64 RELOCATABLE kernels cannot handle relocations to + # unaligned locations that are produced by the array of + # packed structures in this driver. + depends on !(PPC64 && RELOCATABLE) bool "Renesas R9A06G032 clock driver" help This is a driver for R9A06G032 clocks
drivers/net/ethernet/hisilicon/Kconfig +4 -0
@@ -102,6 +102,10 @@ config HNS3_HCLGE tristate "Hisilicon HNS3 HCLGE Acceleration Engine & Compatibility Layer Support" default m depends on PCI_MSI + # PPC64 RELOCATABLE kernels cannot handle relocations to + # unaligned locations that are produced by the array of + # packed structures in this driver. + depends on !(PPC64 && RELOCATABLE) help This selects the HNS3_HCLGE network acceleration engine & its hardware compatibility layer. The engine would be used in Hisilicon hip08 family of
Signature · 5 lines
2.29.2 -- Cheers, Stephen Rothwell
Jakub Kicinski
maintainerQuoted 10 lines · On Sat, 28 Nov 2020 12:28:19 +1100 Stephen Rothwell wrote:
There are 2 drivers that have arrays of packed structures that contain pointers that end up at unaligned offsets. These produce warnings in the PowerPC allyesconfig build like this:
WARNING: 148 bad relocations
c00000000e56510bR_PPC64_UADDR64.rodata+0x0000000001c72378c00000000e565126R_PPC64_UADDR64.rodata+0x0000000001c723c0They are not drivers that are used on PowerPC (I assume), so mark them to not be built on PPC64 when
CONFIG_RELOCATABLEis enabled.
😳😳
What's the offending structure in hisilicon? I'd rather have a look packing structs with pointers in 'em sounds questionable.
I only see these two:
$ git grep packed drivers/net/ethernet/hisilicon/
drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc {
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc {Quoted 14 lines · Jakub Kicinski
Quoted 10 lines · On Sat, 28 Nov 2020 12:28:19 +1100 Stephen Rothwell wrote:
There are 2 drivers that have arrays of packed structures that contain pointers that end up at unaligned offsets. These produce warnings in the PowerPC allyesconfig build like this:
WARNING: 148 bad relocations
c00000000e56510bR_PPC64_UADDR64.rodata+0x0000000001c72378c00000000e565126R_PPC64_UADDR64.rodata+0x0000000001c723c0They are not drivers that are used on PowerPC (I assume), so mark them to not be built on PPC64 when
CONFIG_RELOCATABLEis enabled.😳😳
Quoted 8 lines
What's the offending structure in hisilicon? I'd rather have a look packing structs with pointers in 'em sounds questionable.
I only see these two:
$ git grep packed drivers/net/ethernet/hisilicon/ drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc { drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc {
I assmue "struct __packed hnae_desc" is the offending structure, because flag_ipoffset field is defined as __le32 and is not 32 bit aligned.
struct __packed hnae_desc {
__le64 addr; //0
union {
struct { //64
union {
__le16 asid_bufnum_pid;
__le16 asid;
};
__le16 send_size; //92
union {
__le32 flag_ipoffset; //*108*
struct {
__u8 bn_pid;
__u8 ra_ri_cs_fe_vld;
__u8 ip_offset;
__u8 tse_vlan_snap_v6_sctp_nth;
};
};
__le16 mss;
__u8 l4_len;
__u8 reserved1;
__le16 paylen;
__u8 vmid;
__u8 qid;
__le32 reserved2[2];
} tx;
struct {
__le32 ipoff_bnum_pid_flag;
__le16 pkt_len;
__le16 size;
union {
__le32 vlan_pri_asid;
struct {
__le16 asid;
__le16 vlan_cfi_pri;
};
};
__le32 rss_hash;
__le32 reserved_1[2];
} rx;
};
};Quoted 2 lines
.
Hi Jakub,
Quoted 9 lines · On Fri, 27 Nov 2020 17:56:42 -0800 Jakub Kicinski <[email protected]> wrote:
What's the offending structure in hisilicon? I'd rather have a look packing structs with pointers in 'em sounds questionable.
I only see these two:
$ git grep packed drivers/net/ethernet/hisilicon/ drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc { drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc {
struct hclge_dbg_reg_type_info which is 28 bytes long due to the included struct struct hclge_dbg_reg_common_msg (which is 12 bytes long). They are surrounded by #pragma pack(1)/pack().
This forces the 2 pointers in each second array element of hclge_dbg_reg_info[] to be 4 byte aligned (where pointers are 8 bytes long on PPC64).
Signature · 2 lines
Cheers, Stephen Rothwell
Jakub Kicinski
maintainerQuoted 11 lines · On Sat, 28 Nov 2020 16:20:54 +1100 Stephen Rothwell wrote:
Quoted 9 lines · On Fri, 27 Nov 2020 17:56:42 -0800 Jakub Kicinski <[email protected]> wrote:
What's the offending structure in hisilicon? I'd rather have a look packing structs with pointers in 'em sounds questionable.
I only see these two:
$ git grep packed drivers/net/ethernet/hisilicon/ drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc { drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc {
Quoted 7 lines
struct
hclge_dbg_reg_type_infowhich is 28 bytes long due to the included struct structhclge_dbg_reg_common_msg(which is 12 bytes long). They are surrounded by #pragma pack(1)/pack().This forces the 2 pointers in each second array element of hclge_dbg_reg_info[] to be 4 byte aligned (where pointers are 8 bytes long on PPC64).
Ah! Thanks, I don't see a reason for these to be packed. Looks like an accident, there is no reason to pack anything past struct hclge_dbg_reg_common_msg AFAICT.
Huawei folks, would you mind sending a fix if the analysis is correct?
Quoted 20 lines · Jakub Kicinski
Quoted 11 lines · On Sat, 28 Nov 2020 16:20:54 +1100 Stephen Rothwell wrote:
Quoted 9 lines · On Fri, 27 Nov 2020 17:56:42 -0800 Jakub Kicinski <[email protected]> wrote:
What's the offending structure in hisilicon? I'd rather have a look packing structs with pointers in 'em sounds questionable.
I only see these two:
$ git grep packed drivers/net/ethernet/hisilicon/ drivers/net/ethernet/hisilicon/hns/hnae.h:struct __packed hnae_desc { drivers/net/ethernet/hisilicon/hns3/hns3_enet.h:struct __packed hns3_desc {Quoted 7 lines
struct
hclge_dbg_reg_type_infowhich is 28 bytes long due to the included struct structhclge_dbg_reg_common_msg(which is 12 bytes long). They are surrounded by #pragma pack(1)/pack().This forces the 2 pointers in each second array element of hclge_dbg_reg_info[] to be 4 byte aligned (where pointers are 8 bytes long on PPC64).
Quoted 5 lines
Ah! Thanks, I don't see a reason for these to be packed. Looks like an accident, there is no reason to pack anything past struct
hclge_dbg_reg_common_msgAFAICT.Huawei folks, would you mind sending a fix if the analysis is correct?
Yes, will send a patch to fix that. Thanks for the analysis.
Quoted 2 lines
.
Hi Stephen,
Quoted 11 lines · Stephen Rothwell
There are 2 drivers that have arrays of packed structures that contain pointers that end up at unaligned offsets. These produce warnings in the PowerPC allyesconfig build like this:
WARNING: 148 bad relocations
c00000000e56510bR_PPC64_UADDR64.rodata+0x0000000001c72378c00000000e565126R_PPC64_UADDR64.rodata+0x0000000001c723c0They are not drivers that are used on PowerPC (I assume), so mark them to not be built on PPC64 when
CONFIG_RELOCATABLEis enabled.
Quoted 11 lines
Cc Geert Uytterhoeven <[email protected]>Cc Michael Turquette <[email protected]>Cc Stephen Boyd <[email protected]>Cc Yisen Zhuang <[email protected]>Cc Salil Mehta <[email protected]>Cc David S. Miller <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Daniel Axtens <[email protected]>Cc Joel Stanley <[email protected]>Signed-off-by Stephen Rothwell <[email protected]>
Thanks for your patch!
drivers/clk/renesas/Kconfig config CLK_R8A779A0 · line 160
Quoted 13 lines
drivers/clk/renesas/Kconfig +4
-0@@ -151,6 +151,10 @@ config CLK_R8A779A0 select CLK_RENESAS_CPG_MSSR config CLK_R9A06G032 + # PPC64 RELOCATABLE kernels cannot handle relocations to + # unaligned locations that are produced by the array of + # packed structures in this driver. + depends on !(PPC64 && RELOCATABLE) bool "Renesas R9A06G032 clock driver" help This is a driver for R9A06G032 clocks
I prefer to fix this in the driver instead. The space saving by packing the structure is minimal.
I've sent a patch
https://lore.kernel.org/r/[email protected]
(when lore is back)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert,
Quoted 2 lines · On Mon, 30 Nov 2020 09:58:23 +0100 Geert Uytterhoeven <[email protected]>…
Thanks for your patch!
No worries, it has been a small irritant to me for quite a while.
Quoted 5 lines
I prefer to fix this in the driver instead. The space saving by packing the structure is minimal.
I've sent a patch
https://lore.kernel.org/r/[email protected]
(when lore is back)
Absolutely, thanks.
Signature · 2 lines
Cheers, Stephen Rothwell