vdso32-setup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * (C) Copyright 2002 Linus Torvalds
  3. * Portions based on the vdso-randomization code from exec-shield:
  4. * Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
  5. *
  6. * This file contains the needed initializations to support sysenter.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/smp.h>
  10. #include <linux/kernel.h>
  11. #include <linux/mm_types.h>
  12. #include <asm/cpufeature.h>
  13. #include <asm/processor.h>
  14. #include <asm/vdso.h>
  15. #ifdef CONFIG_COMPAT_VDSO
  16. #define VDSO_DEFAULT 0
  17. #else
  18. #define VDSO_DEFAULT 1
  19. #endif
  20. /*
  21. * Should the kernel map a VDSO page into processes and pass its
  22. * address down to glibc upon exec()?
  23. */
  24. unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
  25. static int __init vdso32_setup(char *s)
  26. {
  27. vdso32_enabled = simple_strtoul(s, NULL, 0);
  28. if (vdso32_enabled > 1)
  29. pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
  30. return 1;
  31. }
  32. /*
  33. * For consistency, the argument vdso32=[012] affects the 32-bit vDSO
  34. * behavior on both 64-bit and 32-bit kernels.
  35. * On 32-bit kernels, vdso=[012] means the same thing.
  36. */
  37. __setup("vdso32=", vdso32_setup);
  38. #ifdef CONFIG_X86_32
  39. __setup_param("vdso=", vdso_setup, vdso32_setup, 0);
  40. #endif
  41. #ifdef CONFIG_X86_64
  42. #define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SYSENTER32))
  43. #define vdso32_syscall() (boot_cpu_has(X86_FEATURE_SYSCALL32))
  44. #else /* CONFIG_X86_32 */
  45. #define vdso32_sysenter() (boot_cpu_has(X86_FEATURE_SEP))
  46. #define vdso32_syscall() (0)
  47. #endif /* CONFIG_X86_64 */
  48. #if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
  49. const struct vdso_image *selected_vdso32;
  50. #endif
  51. int __init sysenter_setup(void)
  52. {
  53. #ifdef CONFIG_COMPAT
  54. if (vdso32_syscall())
  55. selected_vdso32 = &vdso_image_32_syscall;
  56. else
  57. #endif
  58. if (vdso32_sysenter())
  59. selected_vdso32 = &vdso_image_32_sysenter;
  60. else
  61. selected_vdso32 = &vdso_image_32_int80;
  62. init_vdso_image(selected_vdso32);
  63. return 0;
  64. }
  65. #ifdef CONFIG_X86_64
  66. subsys_initcall(sysenter_setup);
  67. #ifdef CONFIG_SYSCTL
  68. /* Register vsyscall32 into the ABI table */
  69. #include <linux/sysctl.h>
  70. static struct ctl_table abi_table2[] = {
  71. {
  72. .procname = "vsyscall32",
  73. .data = &vdso32_enabled,
  74. .maxlen = sizeof(int),
  75. .mode = 0644,
  76. .proc_handler = proc_dointvec
  77. },
  78. {}
  79. };
  80. static struct ctl_table abi_root_table2[] = {
  81. {
  82. .procname = "abi",
  83. .mode = 0555,
  84. .child = abi_table2
  85. },
  86. {}
  87. };
  88. static __init int ia32_binfmt_init(void)
  89. {
  90. register_sysctl_table(abi_root_table2);
  91. return 0;
  92. }
  93. __initcall(ia32_binfmt_init);
  94. #endif /* CONFIG_SYSCTL */
  95. #endif /* CONFIG_X86_64 */