File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -133,4 +133,45 @@ int mixed_mem_type(void *ctx)
133
133
return * p ;
134
134
}
135
135
136
+ __attribute__((__aligned__ (8 )))
137
+ u8 global [] = {
138
+ 0x11 , 0x22 , 0x33 , 0x44 ,
139
+ 0x55 , 0x66 , 0x77 , 0x88 ,
140
+ 0x99
141
+ };
142
+
143
+ __always_inline
144
+ static u64 combine (void * p )
145
+ {
146
+ u64 acc ;
147
+
148
+ acc = 0 ;
149
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
150
+ acc |= (* (u64 * )p >> 56 ) << 24 ;
151
+ acc |= (* (u32 * )p >> 24 ) << 16 ;
152
+ acc |= (* (u16 * )p >> 8 ) << 8 ;
153
+ acc |= * (u8 * )p ;
154
+ #else
155
+ acc |= (* (u64 * )p & 0xff ) << 24 ;
156
+ acc |= (* (u32 * )p & 0xff ) << 16 ;
157
+ acc |= (* (u16 * )p & 0xff ) << 8 ;
158
+ acc |= * (u8 * )p ;
159
+ #endif
160
+ return acc ;
161
+ }
162
+
163
+ SEC ("socket" )
164
+ __retval (0x88442211 )
165
+ int diff_size_access (void * ctx )
166
+ {
167
+ return combine (bpf_rdonly_cast (& global , 0 ));
168
+ }
169
+
170
+ SEC ("socket" )
171
+ __retval (0x99553322 )
172
+ int misaligned_access (void * ctx )
173
+ {
174
+ return combine (bpf_rdonly_cast (& global , 0 ) + 1 );
175
+ }
176
+
136
177
char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments