Commit 34c9a7c5 authored by Alexei Starovoitov's avatar Alexei Starovoitov

Merge branch 'Add clang-based BTF_KIND_FLOAT tests'

Ilya Leoshkevich says:

====================

The two tests here did not make it into the main BTF_KIND_FLOAT series
because of dependency on LLVM.

v0: https://lore.kernel.org/bpf/20210226202256.116518-10-iii@linux.ibm.com/
v1 -> v0: Per Alexei's suggestion, document the required LLVM commit.

v1: https://lore.kernel.org/bpf/20210305170844.151594-1-iii@linux.ibm.com/
v1 -> v2: Per Andrii's suggestions, use double in
          core_reloc_size___diff_sz and non-pointer member in
          btf_dump_test_case_syntax.
====================
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents a0d73acc ccb0e23c
...@@ -170,3 +170,12 @@ failures: ...@@ -170,3 +170,12 @@ failures:
.. _2: https://reviews.llvm.org/D85174 .. _2: https://reviews.llvm.org/D85174
.. _3: https://reviews.llvm.org/D83878 .. _3: https://reviews.llvm.org/D83878
.. _4: https://reviews.llvm.org/D83242 .. _4: https://reviews.llvm.org/D83242
Floating-point tests and Clang version
======================================
Certain selftests, e.g. core_reloc, require support for the floating-point
types, which was introduced in `Clang 13`__. The older Clang versions will
either crash when compiling these tests, or generate an incorrect BTF.
__ https://reviews.llvm.org/D83289
...@@ -266,6 +266,7 @@ static int duration = 0; ...@@ -266,6 +266,7 @@ static int duration = 0;
.arr_elem_sz = sizeof(((type *)0)->arr_field[0]), \ .arr_elem_sz = sizeof(((type *)0)->arr_field[0]), \
.ptr_sz = 8, /* always 8-byte pointer for BPF */ \ .ptr_sz = 8, /* always 8-byte pointer for BPF */ \
.enum_sz = sizeof(((type *)0)->enum_field), \ .enum_sz = sizeof(((type *)0)->enum_field), \
.float_sz = sizeof(((type *)0)->float_field), \
} }
#define SIZE_CASE(name) { \ #define SIZE_CASE(name) { \
......
...@@ -205,6 +205,12 @@ struct struct_with_embedded_stuff { ...@@ -205,6 +205,12 @@ struct struct_with_embedded_stuff {
int t[11]; int t[11];
}; };
struct float_struct {
float f;
const double *d;
volatile long double *ld;
};
struct root_struct { struct root_struct {
enum e1 _1; enum e1 _1;
enum e2 _2; enum e2 _2;
...@@ -219,6 +225,7 @@ struct root_struct { ...@@ -219,6 +225,7 @@ struct root_struct {
union_fwd_t *_12; union_fwd_t *_12;
union_fwd_ptr_t _13; union_fwd_ptr_t _13;
struct struct_with_embedded_stuff _14; struct struct_with_embedded_stuff _14;
struct float_struct _15;
}; };
/* ------ END-EXPECTED-OUTPUT ------ */ /* ------ END-EXPECTED-OUTPUT ------ */
......
...@@ -807,6 +807,7 @@ struct core_reloc_size_output { ...@@ -807,6 +807,7 @@ struct core_reloc_size_output {
int arr_elem_sz; int arr_elem_sz;
int ptr_sz; int ptr_sz;
int enum_sz; int enum_sz;
int float_sz;
}; };
struct core_reloc_size { struct core_reloc_size {
...@@ -816,6 +817,7 @@ struct core_reloc_size { ...@@ -816,6 +817,7 @@ struct core_reloc_size {
int arr_field[4]; int arr_field[4];
void *ptr_field; void *ptr_field;
enum { VALUE = 123 } enum_field; enum { VALUE = 123 } enum_field;
float float_field;
}; };
struct core_reloc_size___diff_sz { struct core_reloc_size___diff_sz {
...@@ -825,6 +827,7 @@ struct core_reloc_size___diff_sz { ...@@ -825,6 +827,7 @@ struct core_reloc_size___diff_sz {
char arr_field[10]; char arr_field[10];
void *ptr_field; void *ptr_field;
enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field; enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field;
double float_field;
}; };
/* Error case of two candidates with the fields (int_field) at the same /* Error case of two candidates with the fields (int_field) at the same
...@@ -839,6 +842,7 @@ struct core_reloc_size___err_ambiguous1 { ...@@ -839,6 +842,7 @@ struct core_reloc_size___err_ambiguous1 {
int arr_field[4]; int arr_field[4];
void *ptr_field; void *ptr_field;
enum { VALUE___1 = 123 } enum_field; enum { VALUE___1 = 123 } enum_field;
float float_field;
}; };
struct core_reloc_size___err_ambiguous2 { struct core_reloc_size___err_ambiguous2 {
...@@ -850,6 +854,7 @@ struct core_reloc_size___err_ambiguous2 { ...@@ -850,6 +854,7 @@ struct core_reloc_size___err_ambiguous2 {
int arr_field[4]; int arr_field[4];
void *ptr_field; void *ptr_field;
enum { VALUE___2 = 123 } enum_field; enum { VALUE___2 = 123 } enum_field;
float float_field;
}; };
/* /*
......
...@@ -21,6 +21,7 @@ struct core_reloc_size_output { ...@@ -21,6 +21,7 @@ struct core_reloc_size_output {
int arr_elem_sz; int arr_elem_sz;
int ptr_sz; int ptr_sz;
int enum_sz; int enum_sz;
int float_sz;
}; };
struct core_reloc_size { struct core_reloc_size {
...@@ -30,6 +31,7 @@ struct core_reloc_size { ...@@ -30,6 +31,7 @@ struct core_reloc_size {
int arr_field[4]; int arr_field[4];
void *ptr_field; void *ptr_field;
enum { VALUE = 123 } enum_field; enum { VALUE = 123 } enum_field;
float float_field;
}; };
SEC("raw_tracepoint/sys_enter") SEC("raw_tracepoint/sys_enter")
...@@ -45,6 +47,7 @@ int test_core_size(void *ctx) ...@@ -45,6 +47,7 @@ int test_core_size(void *ctx)
out->arr_elem_sz = bpf_core_field_size(in->arr_field[0]); out->arr_elem_sz = bpf_core_field_size(in->arr_field[0]);
out->ptr_sz = bpf_core_field_size(in->ptr_field); out->ptr_sz = bpf_core_field_size(in->ptr_field);
out->enum_sz = bpf_core_field_size(in->enum_field); out->enum_sz = bpf_core_field_size(in->enum_field);
out->float_sz = bpf_core_field_size(in->float_field);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment