With CONFIG_CC_OPTIMIZE_FOR_SIZE, objtool reports: drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: i915_gem_execbuffer2_ioctl()+0x5b7: call to gen8_canonical_addr() with UACCESS enabled This means i915_gem_execbuffer2_ioctl() is calling gen8_canonical_addr() from the user_access_begin/end critical region (i.e, with SMAP disabled). While it's probably harmless in this case, in general we like to avoid extra function calls in SMAP-disabled regions because it can open up inadvertent security holes. Fix the warning by changing the sign extension helpers to __always_inline. This convinces GCC to inline gen8_canonical_addr(). The sign extension functions are trivial anyway, so it makes sense to always inline them. With my test optimize-for-size-based config, this actually shrinks the text size of i915_gem_execbuffer.o by 45 bytes -- and no change for vmlinux.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -162,7 +162,7 @@ static inline __u8 ror8(__u8 word, unsigned int shift) · 161 unmodified lines | |||
| 162 | * | 162 | * |
| 163 | * This is safe to use for 16- and 8-bit types as well. | 163 | * This is safe to use for 16- and 8-bit types as well. |
| 164 | */ | 164 | */ |
| 165 | static inline __s32 sign_extend32(__u32 value, int index) | 165 | static __always_inline __s32 sign_extend32(__u32 value, int index) |
| 166 | { | 166 | { |
| 167 | __u8 shift = 31 - index; | 167 | __u8 shift = 31 - index; |
| 168 | return (__s32)(value << shift) >> shift; | 168 | return (__s32)(value << shift) >> shift; |
| @@ -173,7 +173,7 @@ static inline __s32 sign_extend32(__u32 value, int index) · 4 unmodified lines | |||
| 173 | * @value: value to sign extend | 173 | * @value: value to sign extend |
| 174 | * @index: 0 based bit index (0<=index<64) to sign bit | 174 | * @index: 0 based bit index (0<=index<64) to sign bit |
| 175 | */ | 175 | */ |
| 176 | static inline __s64 sign_extend64(__u64 value, int index) | 176 | static __always_inline __s64 sign_extend64(__u64 value, int index) |
| 177 | { | 177 | { |
| 178 | __u8 shift = 63 - index; | 178 | __u8 shift = 63 - index; |
| 179 | return (__s64)(value << shift) >> shift; | 179 | return (__s64)(value << shift) >> shift; |