linux-4.4-rc8/arch/arm64/kernel/module.c:78: 32/64 bit problem ?

David Binderman dcb314 at hotmail.com
Mon Jan 4 00:25:30 PST 2016


Hello there,

[linux-4.4-rc8/arch/arm64/kernel/module.c:78] -> [linux-4.4-rc8/arch/arm64/kernel/module.c:88]: (warning) Shifting 32-bit value by 64 bits is undefined behaviour. See condition at line 88.

Source code is

    u64 imm_mask = (1 << len) - 1;
    s64 sval = do_reloc(op, place, val);

    switch (len) {
    case 16:
        *(s16 *)place = sval;
        break;
    case 32:
        *(s32 *)place = sval;
        break;
    case 64:

So it seems that len can be 64. Suggest new code

    u64 imm_mask = (1UL << len) - 1;
    s64 sval = do_reloc(op, place, val);

    switch (len) {
    case 16:
        *(s16 *)place = sval;
        break;
    case 32:
        *(s32 *)place = sval;
        break;
    case 64:

Regards

David Binderman

 		 	   		  


More information about the linux-arm-kernel mailing list