How to print __u128_t in kernel?

Dongliang Mu mudongliangabcd at gmail.com
Sat Sep 18 09:35:33 EDT 2021


Hello everyone,

I encounter one object with __uint128_t type in the following code.
But I am not sure how to print the content of __uint128_t.

struct user_fpsimd_state {
__uint128_t vregs[32];
__u32 fpsr;
__u32 fpcr;
__u32 __reserved[2];
};

At first, I would like to use:
pr_alert("0x%lx %lx\n", i, (uint64_t)(fpreg.vregs[i] >> 64),
(uint64_t)(fpreg.vregs[i]));

However, gcc reports error with "-Werror" enabled:

In function ‘print_fpregs_in_coredump’:
error: iteration 32 invokes undefined behavior
[-Werror=aggressive-loop-optimizations]
   89 |   pr_alert("V%d 0x%lx %lx\n", i, (uint64_t)(fpreg.vregs[i] >> 64),

Any idea to eliminate this error?

--
My best regards to you.

     No System Is Safe!
     Dongliang Mu



More information about the Kernelnewbies mailing list