From 0b652d72783d7fa432e357659b2b2ef4a140fa8a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 28 Aug 2017 16:04:54 +0200 Subject: pkg/compiler: tolerate unsupported consts everywhere Currently unsupported consts in structs and resources break build. However, that can well happen for arch-specific devices (e.g. Android). Make this non-fatal as it used to be. --- sys/sys_arm.go | 11 +++++++++++ sys/sys_arm64.go | 11 +++++++++++ sys/test.txt | 9 +++++++++ 3 files changed, 31 insertions(+) (limited to 'sys') diff --git a/sys/sys_arm.go b/sys/sys_arm.go index ba643ccfb..72cce42ba 100644 --- a/sys/sys_arm.go +++ b/sys/sys_arm.go @@ -85,6 +85,7 @@ var resourceArray = []*ResourceDesc{ &ResourceDesc{Name: "sock_udp", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in", "sock_udp"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, &ResourceDesc{Name: "sock_udp6", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in6", "sock_udp6"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, &ResourceDesc{Name: "sock_unix", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_unix"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, + &ResourceDesc{Name: "syz_missing_const_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_missing_const_res"}, Values: []uint64{1075883694}}, &ResourceDesc{Name: "syz_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_res"}, Values: []uint64{0xffff}}, &ResourceDesc{Name: "tcp_seq_num", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"tcp_seq_num"}, Values: []uint64{0x42424242}}, &ResourceDesc{Name: "te_session_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"te_session_id"}, Values: []uint64{0}}, @@ -681,6 +682,7 @@ var structArray = []Type{ &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent2_struct_inner_inner", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent_struct", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_vma_struct", IsOptional: false}}, + &StructType{TypeCommon: TypeCommon{TypeName: "syz_missing_const_struct", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_0", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_1", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_2", IsOptional: false}}, @@ -19134,6 +19136,15 @@ var structFields = []struct { &VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "f0", ArgDir: DirOut, IsOptional: false}, RangeBegin: 0, RangeEnd: 0}, &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "f1", ArgDir: DirOut, IsOptional: false}, TypeSize: 8, BigEndian: false, BitfieldLen: 0}, Buf: "f0", ByteSize: 0}, }}, + {structKey{"syz_missing_const_struct", "", DirIn}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirIn, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, + {structKey{"syz_missing_const_struct", "", DirInOut}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, + {structKey{"syz_missing_const_struct", "", DirOut}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, {structKey{"syz_recur_0", "", DirIn}, []Type{ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", ArgDir: DirIn, IsOptional: true}, Type: getStruct(structKey{"syz_recur_0", "", DirIn})}, }}, diff --git a/sys/sys_arm64.go b/sys/sys_arm64.go index b81c7ede8..7f81b2c19 100644 --- a/sys/sys_arm64.go +++ b/sys/sys_arm64.go @@ -85,6 +85,7 @@ var resourceArray = []*ResourceDesc{ &ResourceDesc{Name: "sock_udp", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in", "sock_udp"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, &ResourceDesc{Name: "sock_udp6", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_in6", "sock_udp6"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, &ResourceDesc{Name: "sock_unix", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"fd", "sock", "sock_unix"}, Values: []uint64{0xffffffffffffffff, 18446744073709551516}}, + &ResourceDesc{Name: "syz_missing_const_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_missing_const_res"}, Values: []uint64{1075883694}}, &ResourceDesc{Name: "syz_res", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"syz_res"}, Values: []uint64{0xffff}}, &ResourceDesc{Name: "tcp_seq_num", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"tcp_seq_num"}, Values: []uint64{0x42424242}}, &ResourceDesc{Name: "te_session_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "resource-type", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}}, Kind: []string{"te_session_id"}, Values: []uint64{0}}, @@ -681,6 +682,7 @@ var structArray = []Type{ &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent2_struct_inner_inner", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_parent_struct", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_length_vma_struct", IsOptional: false}}, + &StructType{TypeCommon: TypeCommon{TypeName: "syz_missing_const_struct", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_0", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_1", IsOptional: false}}, &StructType{TypeCommon: TypeCommon{TypeName: "syz_recur_2", IsOptional: false}}, @@ -19134,6 +19136,15 @@ var structFields = []struct { &VmaType{TypeCommon: TypeCommon{TypeName: "vma", FldName: "f0", ArgDir: DirOut, IsOptional: false}, RangeBegin: 0, RangeEnd: 0}, &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "f1", ArgDir: DirOut, IsOptional: false}, TypeSize: 8, BigEndian: false, BitfieldLen: 0}, Buf: "f0", ByteSize: 0}, }}, + {structKey{"syz_missing_const_struct", "", DirIn}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirIn, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, + {structKey{"syz_missing_const_struct", "", DirInOut}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirInOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, + {structKey{"syz_missing_const_struct", "", DirOut}, []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a0", ArgDir: DirOut, IsOptional: false}, TypeSize: 4, BigEndian: false, BitfieldLen: 0}, Val: uint64(1075883694)}, + }}, {structKey{"syz_recur_0", "", DirIn}, []Type{ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", ArgDir: DirIn, IsOptional: true}, Type: getStruct(structKey{"syz_recur_0", "", DirIn})}, }}, diff --git a/sys/test.txt b/sys/test.txt index ded19ae0b..491196ab3 100644 --- a/sys/test.txt +++ b/sys/test.txt @@ -518,3 +518,12 @@ resource syz_res[int32]: 0xffff syz_test$res0() syz_res syz_test$res1(a0 syz_res) + +# KVM_ARM_VCPU_INIT const is not present on all arches. +# Ensure that it does not break build. + +resource syz_missing_const_res[int32]: KVM_ARM_VCPU_INIT + +syz_missing_const_struct { + a0 const[KVM_ARM_VCPU_INIT, int32] +} -- cgit mrf-deployment