Advertisement
Guest User

linux 4.9.24 rol/ror patch

a guest
Apr 26th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. --- include/linux/bitops.h.orig 2017-04-22 10:20:37.284090151 -0500
  2. +++ include/linux/bitops.h 2017-04-22 10:20:43.468090276 -0500
  3. @@ -77,7 +77,12 @@ static __always_inline unsigned long __i
  4. */
  5. static inline __u64 rol64(__u64 word, unsigned int shift)
  6. {
  7. +#if defined(CONFIG_X86_64) || defined(CONFIG_X86)
  8. + __asm__ __volatile__ ("rolq %%cl, %%rax;" : "=a" (word) : "a" (word), "c" (shift) : );
  9. + return word;
  10. +#else
  11. return (word << shift) | (word >> (64 - shift));
  12. +#endif /* defined(CONFIG_X86_64) || defined(CONFIG_X86) */
  13. }
  14.  
  15. /**
  16. @@ -87,7 +92,12 @@ static inline __u64 rol64(__u64 word, un
  17. */
  18. static inline __u64 ror64(__u64 word, unsigned int shift)
  19. {
  20. +#if defined(CONFIG_X86_64) || defined(CONFIG_X86)
  21. + __asm__ __volatile__ ("rorq %%cl, %%rax;" : "=a" (word) : "a" (word), "c" (shift) : );
  22. + return word;
  23. +#else
  24. return (word >> shift) | (word << (64 - shift));
  25. +#endif /* defined(CONFIG_X86_64) || defined(CONFIG_X86) */
  26. }
  27.  
  28. /**
  29. @@ -97,7 +107,12 @@ static inline __u64 ror64(__u64 word, un
  30. */
  31. static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
  32. {
  33. +#if defined(CONFIG_X86_64) || defined(CONFIG_X86)
  34. + __asm__ __volatile__ ("rol %%cl, %%eax;" : "=a" (word) : "a" (word), "c" (shift) : );
  35. + return word;
  36. +#else
  37. return (word << shift) | (word >> ((-shift) & 31));
  38. +#endif /* defined(CONFIG_X86_64) || defined(CONFIG_X86) */
  39. }
  40.  
  41. /**
  42. @@ -107,7 +122,12 @@ static inline __u32 __intentional_overfl
  43. */
  44. static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
  45. {
  46. +#if defined(CONFIG_X86_64) || defined(CONFIG_X86)
  47. + __asm__ __volatile__ ("ror %%cl, %%eax;" : "=a" (word) : "a" (word), "c" (shift) : );
  48. + return word;
  49. +#else
  50. return (word >> shift) | (word << (32 - shift));
  51. +#endif /* defined(CONFIG_X86_64) || defined(CONFIG_X86) */
  52. }
  53.  
  54. /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement