2
1

0005-Use-a-local-copy-of-copy_xregs_to_kernel.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From eb703737be5c91c1a0817351db8ec152c523c85d Mon Sep 17 00:00:00 2001
  2. From: Alberto Milone <alberto.milone@canonical.com>
  3. Date: Thu, 17 Sep 2015 15:49:46 +0200
  4. Subject: [PATCH] Use a local copy of copy_xregs_to_kernel
  5. This is needed for Linux 4.2.
  6. Thanks to Tim Gardner for the patch.
  7. Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
  8. ---
  9. common/lib/modules/fglrx/build_mod/firegl_public.c | 44 +++++++++++++++++++++-
  10. 1 file changed, 43 insertions(+), 1 deletion(-)
  11. diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
  12. index 4c1f9a5..bb67bba 100755
  13. --- a/common/lib/modules/fglrx/build_mod/firegl_public.c
  14. +++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
  15. @@ -6443,6 +6443,48 @@ int ATI_API_CALL kcl_sscanf(const char * buf, const char * fmt, ...)
  16. return i;
  17. }
  18. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
  19. +/*
  20. + * Save processor xstate to xsave area.
  21. + */
  22. +static void _copy_xregs_to_kernel(struct xregs_state *xstate)
  23. +{
  24. + u64 mask = -1;
  25. + u32 lmask = mask;
  26. + u32 hmask = mask >> 32;
  27. + int err = 0;
  28. +
  29. + /*WARN_ON(!alternatives_patched);*/
  30. +
  31. + /*
  32. + * If xsaves is enabled, xsaves replaces xsaveopt because
  33. + * it supports compact format and supervisor states in addition to
  34. + * modified optimization in xsaveopt.
  35. + *
  36. + * Otherwise, if xsaveopt is enabled, xsaveopt replaces xsave
  37. + * because xsaveopt supports modified optimization which is not
  38. + * supported by xsave.
  39. + *
  40. + * If none of xsaves and xsaveopt is enabled, use xsave.
  41. + */
  42. + alternative_input_2(
  43. + "1:"XSAVE,
  44. + XSAVEOPT,
  45. + X86_FEATURE_XSAVEOPT,
  46. + XSAVES,
  47. + X86_FEATURE_XSAVES,
  48. + [xstate] "D" (xstate), "a" (lmask), "d" (hmask) :
  49. + "memory");
  50. + asm volatile("2:\n\t"
  51. + xstate_fault(err)
  52. + : "0" (err)
  53. + : "memory");
  54. +
  55. + /* We should never fault when copying to a kernel buffer: */
  56. + WARN_ON_FPU(err);
  57. +}
  58. +#endif
  59. +
  60. /** \brief Generate UUID
  61. * \param buf pointer to the generated UUID
  62. * \return None
  63. @@ -6462,7 +6504,7 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
  64. fpu_xsave(fpu);
  65. if (!(fpu->state->xsave.xsave_hdr.xstate_bv & XSTATE_FP))
  66. #else
  67. - copy_xregs_to_kernel(&fpu->state.xsave);
  68. + _copy_xregs_to_kernel(&fpu->state.xsave);
  69. if (!(fpu->state.xsave.header.xfeatures & XSTATE_FP))
  70. #endif
  71. return 1;
  72. --
  73. 2.8.1