[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH v2 2/3] x86/uaccess: replace __{get,put}_user_bad() with STATIC_ASSERT_UNREACHABLE()
On 15/02/24 09:10, Jan Beulich wrote: On 14.02.2024 17:11, Federico Serafini wrote:I did some tries with example programs and the assembler error always points to file and line of the most enclosing function that caused the failure. If I am not missing something, using __FILE__ and __LINE__ does not add any information. Therefore, if the new macro is used within the body of other macros, then the resulting assembler error will point to the source of the problem (e.g., the site of a bogus call to put_guest()). In my opinion, converting put_guest() &Co. to inline functions is not convenient: the assembler error will point to the most enclosing function that would be put_unsafe_size(), instead of pointing to the source of the problem.The assembler error will point to where the inline function was expanded, sure. __FILE__ / __LINE__ ought to point to that inline function (where the macro was used) then, though? This is what I get: federico@Dell:~$ cat m.c #define STRINGIFY(arg) #arg #define STATIC_ASSERT_UNREACHABLE(file, line) \ asm(".error \"static assertion failed: " file ": " STRINGIFY(line) "\"") static inline __attribute__((always_inline)) void g(int x) { switch(x) { case 0: STATIC_ASSERT_UNREACHABLE(__FILE__, __LINE__); } } static inline __attribute__((always_inline)) void f(int x) { g(x); } int main(void) { f(0); return 0; } federico@Dell:~$ gcc -O3 m.c m.c: Assembler messages: m.c:8: Error: static assertion failed: m.c: 8 Note that the linker behaves differently: federico@Dell:~$ cat m.c extern void __put_user_bad(void); static inline __attribute__((always_inline)) void g(int x) { switch(x) { case 0: __put_user_bad(); } } static inline __attribute__((always_inline)) void f(int x) { g(x); } int main(void) { f(0); return 0; } federico@Dell:~$ gcc -O3 m.c /usr/bin/ld: /tmp/ccv9KHJD.o: in function `main': m.c:(.text.startup+0x9): undefined reference to `__put_user_bad' collect2: error: ld returned 1 exit status -- Federico Serafini, M.Sc. Software Engineer, BUGSENG (http://bugseng.com)
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |