diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-05-13 10:23:16 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-05-13 10:26:57 +0200 |
| commit | 000f08bb1864d570d5652d621e34f73ecf54626a (patch) | |
| tree | 6339f0fa251f334be5bcd8fa9414ad0ee5c7e7b2 /sys | |
| parent | aa8482aa8acbe261c9413fd4179e8163069b7605 (diff) | |
sys/linux: switch ppc64le to little-endian
make extract recently broke for powerpc on linux-next with:
include/uapi/linux/byteorder/big_endian.h:6:2: error: #error "Unsupported endianness, check your toolchain"
#error "Unsupported endianness, check your toolchain"
Turns out we always built ppc64le headers as big-endian.
First, kernel was configured as BE.
Then, we used gcc to build an executable program for host
and on x86 gcc does not define __LITTLE_ENDIAN__ so kernel
thought that the toolchain is BE too.
Configure kernel as LE and define __LITTLE_ENDIAN__.
This actually changes values of some consts,
but fortunately just few of them.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/linux/gen/ppc64le.go | 14 | ||||
| -rw-r--r-- | sys/linux/socket_packet_ppc64le.const | 2 | ||||
| -rw-r--r-- | sys/linux/vnet_ppc64le.const | 4 | ||||
| -rw-r--r-- | sys/syz-extract/fetch.go | 3 | ||||
| -rw-r--r-- | sys/syz-extract/linux.go | 20 | ||||
| -rw-r--r-- | sys/targets/targets.go | 10 |
6 files changed, 29 insertions, 24 deletions
diff --git a/sys/linux/gen/ppc64le.go b/sys/linux/gen/ppc64le.go index 440ffb107..cdda9f68d 100644 --- a/sys/linux/gen/ppc64le.go +++ b/sys/linux/gen/ppc64le.go @@ -6368,8 +6368,8 @@ var structDescs_ppc64le = []*KeyedStruct{ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "control", TypeSize: 1}, BitfieldOff: 5, BitfieldLen: 1, BitfieldMdl: true}}, &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "version", TypeSize: 1}, BitfieldOff: 6, BitfieldLen: 2}}, &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "proto_ctype", TypeSize: 1}}}, - &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "guehdr_flags", FldName: "flags", TypeSize: 2}}, Vals: []uint64{1}, BitMask: true}, - &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "priv", IsVarlen: true}, Type: &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "guehdr_prov_flags", TypeSize: 4}}, Vals: []uint64{2147483648}, BitMask: true}, Kind: 1, RangeEnd: 1}, + &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "guehdr_flags", FldName: "flags", TypeSize: 2}}, Vals: []uint64{256}, BitMask: true}, + &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "priv", IsVarlen: true}, Type: &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "guehdr_prov_flags", TypeSize: 4}}, Vals: []uint64{128}, BitMask: true}, Kind: 1, RangeEnd: 1}, }}}, {Key: StructKey{Name: "hashlimit_cfg1"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "hashlimit_cfg1", TypeSize: 32}, Fields: []Type{ &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "xt_hashlimit_modes", FldName: "mode", TypeSize: 4}}, Vals: []uint64{1, 2, 4, 8, 16, 32, 64}, BitMask: true}, @@ -41295,7 +41295,7 @@ var syscalls_ppc64le = []*Syscall{ {NR: 326, Name: "socket$packet", CallName: "socket", Args: []Type{ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "domain", TypeSize: 8}}, Val: 17}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "packet_socket_type", FldName: "type", TypeSize: 8}}, Vals: []uint64{3, 2}}, - &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "proto", TypeSize: 8}}, Val: 3}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "proto", TypeSize: 8}}, Val: 768}, }, Ret: &ResourceType{TypeCommon: TypeCommon{TypeName: "sock_packet", FldName: "ret", TypeSize: 4, ArgDir: 1}}}, {NR: 326, Name: "socket$pppoe", CallName: "socket", Args: []Type{ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "domain", TypeSize: 8}}, Val: 24}, @@ -43987,7 +43987,7 @@ var consts_ppc64le = []ConstValue{ {Name: "ETH_P_AARP", Value: 33011}, {Name: "ETH_P_AF_IUCV", Value: 64507}, {Name: "ETH_P_ALL", Value: 3}, - {Name: "ETH_P_ALL_BE", Value: 3}, + {Name: "ETH_P_ALL_BE", Value: 768}, {Name: "ETH_P_AOE", Value: 34978}, {Name: "ETH_P_ARCNET", Value: 26}, {Name: "ETH_P_ARP", Value: 2054}, @@ -44473,8 +44473,8 @@ var consts_ppc64le = []ConstValue{ {Name: "GIO_UNISCRNMAP", Value: 19305}, {Name: "GRND_NONBLOCK", Value: 1}, {Name: "GRND_RANDOM", Value: 2}, - {Name: "GUE_FLAG_PRIV", Value: 1}, - {Name: "GUE_PFLAG_REMCSUM", Value: 2147483648}, + {Name: "GUE_FLAG_PRIV", Value: 256}, + {Name: "GUE_PFLAG_REMCSUM", Value: 128}, {Name: "HASH_ALGO__LAST", Value: 20}, {Name: "HCIBLOCKADDR", Value: 2147764454}, {Name: "HCIDEVDOWN", Value: 2147764426}, @@ -50590,4 +50590,4 @@ var consts_ppc64le = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_ppc64le = "84345e4c9ab2df204d5e2216e1ee380880b1e68c" +const revision_ppc64le = "dd812ad5534b0a3035b3aecdae9fb6d47a6e2ffa" diff --git a/sys/linux/socket_packet_ppc64le.const b/sys/linux/socket_packet_ppc64le.const index 79f28f517..2de392a9e 100644 --- a/sys/linux/socket_packet_ppc64le.const +++ b/sys/linux/socket_packet_ppc64le.const @@ -4,7 +4,7 @@ ARPHRD_ETHER = 1 ETH_P_802_2 = 4 ETH_P_802_3 = 1 ETH_P_ALL = 3 -ETH_P_ALL_BE = 3 +ETH_P_ALL_BE = 768 ETH_P_ARCNET = 26 ETH_P_AX25 = 2 ETH_P_CAIF = 247 diff --git a/sys/linux/vnet_ppc64le.const b/sys/linux/vnet_ppc64le.const index d51f5c41d..b8e3d7fc5 100644 --- a/sys/linux/vnet_ppc64le.const +++ b/sys/linux/vnet_ppc64le.const @@ -174,8 +174,8 @@ ETH_P_WAN_PPP = 7 ETH_P_WCCP = 34878 ETH_P_X25 = 2053 ETH_P_XDSA = 248 -GUE_FLAG_PRIV = 1 -GUE_PFLAG_REMCSUM = 2147483648 +GUE_FLAG_PRIV = 256 +GUE_PFLAG_REMCSUM = 128 ICMPV6_ADDR_UNREACH = 3 ICMPV6_ADM_PROHIBITED = 1 ICMPV6_DEST_UNREACH = 1 diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go index a3c49c9b5..bb0c8b54b 100644 --- a/sys/syz-extract/fetch.go +++ b/sys/syz-extract/fetch.go @@ -58,7 +58,8 @@ func extract(info *compiler.ConstInfo, cc string, args []string, addSource strin } bin, out, err = compile(cc, args, data) if err != nil { - return nil, nil, fmt.Errorf("failed to run compiler: %v\n%v", err, string(out)) + return nil, nil, fmt.Errorf("failed to run compiler: %v %v\n%v\n%v", + cc, args, err, string(out)) } } defer os.Remove(bin) diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go index 45f8144ce..3ca100b73 100644 --- a/sys/syz-extract/linux.go +++ b/sys/syz-extract/linux.go @@ -82,17 +82,17 @@ func (*linux) prepareArch(arch *Arch) error { if err != nil { return fmt.Errorf("make defconfig failed: %v\n%s", err, out) } - // Without CONFIG_NETFILTER kernel does not build. - _, err = osutil.RunCmd(time.Minute, buildDir, "sed", "-i", - "s@# CONFIG_NETFILTER is not set@CONFIG_NETFILTER=y@g", ".config") + _, err = osutil.RunCmd(time.Minute, buildDir, filepath.Join(kernelDir, "scripts", "config"), + // powerpc arch is configured to be big-endian by default, but we want little-endian powerpc. + // Since all of our archs are little-endian for now, we just blindly switch it. + "-d", "CPU_BIG_ENDIAN", "-e", "CPU_LITTLE_ENDIAN", + // Without CONFIG_NETFILTER kernel does not build. + "-e", "NETFILTER", + // include/net/mptcp.h is the only header in kernel that guards some + // of the consts with own config, so we need to enable CONFIG_MPTCP. + "-e", "MPTCP") if err != nil { - return fmt.Errorf("sed .config failed: %v", err) - } - // include/net/mptcp.h is the only header in kernel that guards some of the consts with own config - _, err = osutil.RunCmd(time.Minute, buildDir, "sed", "-i", - "s@# CONFIG_MPTCP is not set@CONFIG_MPTCP=y@g", ".config") - if err != nil { - return fmt.Errorf("sed .config failed: %v", err) + return err } out, err = osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "olddefconfig")...) if err != nil { diff --git a/sys/targets/targets.go b/sys/targets/targets.go index da8c568fe..d9095e1c2 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -161,9 +161,13 @@ var List = map[string]map[string]*Target{ KernelHeaderArch: "arm", }, "ppc64le": { - PtrSize: 8, - PageSize: 4 << 10, - CFlags: []string{"-D__powerpc64__"}, + PtrSize: 8, + PageSize: 4 << 10, + CFlags: []string{ + "-D__powerpc64__", + "-D__LITTLE_ENDIAN__=1", + "-D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__", + }, CrossCFlags: []string{"-D__powerpc64__", "-static"}, CCompilerPrefix: "powerpc64le-linux-gnu-", KernelArch: "powerpc", |
