PageRenderTime 34ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/x86/mm/setup_nx.c

https://bitbucket.org/cresqo/cm7-p500-kernel
C | 60 lines | 46 code | 5 blank | 9 comment | 11 complexity | 4298b13fb2faa340ca2f2852561d7ff6 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  1. #include <linux/spinlock.h>
  2. #include <linux/errno.h>
  3. #include <linux/init.h>
  4. #include <asm/pgtable.h>
  5. #include <asm/proto.h>
  6. static int disable_nx __cpuinitdata;
  7. /*
  8. * noexec = on|off
  9. *
  10. * Control non-executable mappings for processes.
  11. *
  12. * on Enable
  13. * off Disable
  14. */
  15. static int __init noexec_setup(char *str)
  16. {
  17. if (!str)
  18. return -EINVAL;
  19. if (!strncmp(str, "on", 2)) {
  20. disable_nx = 0;
  21. } else if (!strncmp(str, "off", 3)) {
  22. disable_nx = 1;
  23. }
  24. x86_configure_nx();
  25. return 0;
  26. }
  27. early_param("noexec", noexec_setup);
  28. void __cpuinit x86_configure_nx(void)
  29. {
  30. if (cpu_has_nx && !disable_nx)
  31. __supported_pte_mask |= _PAGE_NX;
  32. else
  33. __supported_pte_mask &= ~_PAGE_NX;
  34. }
  35. void __init x86_report_nx(void)
  36. {
  37. if (!cpu_has_nx) {
  38. printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
  39. "missing in CPU or disabled in BIOS!\n");
  40. } else {
  41. #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
  42. if (disable_nx) {
  43. printk(KERN_INFO "NX (Execute Disable) protection: "
  44. "disabled by kernel command line option\n");
  45. } else {
  46. printk(KERN_INFO "NX (Execute Disable) protection: "
  47. "active\n");
  48. }
  49. #else
  50. /* 32bit non-PAE kernel, NX cannot be used */
  51. printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
  52. "cannot be enabled: non-PAE kernel!\n");
  53. #endif
  54. }
  55. }