diff options
Diffstat (limited to 'mprotect.patch')
-rw-r--r-- | mprotect.patch | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mprotect.patch b/mprotect.patch new file mode 100644 index 000000000000..7d3e2ee3ae70 --- /dev/null +++ b/mprotect.patch @@ -0,0 +1,40 @@ +Index: b/grub/asmstub.c +=================================================================== +--- a/grub/asmstub.c ++++ b/grub/asmstub.c +@@ -42,6 +42,12 @@ + #include <sys/time.h> + #include <termios.h> + #include <signal.h> ++#include <sys/mman.h> ++ ++#include <limits.h> ++#ifndef PAGESIZE ++#define PAGESIZE 4096 ++#endif + + #ifdef __linux__ + # include <sys/ioctl.h> /* ioctl */ +@@ -148,6 +154,22 @@ + assert (grub_scratch_mem == 0); + scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15); + assert (scratch); ++ ++ { ++ char *p; ++ int ret; ++ ++ /* Align to a multiple of PAGESIZE, assumed to be a power of two. */ ++ p = (char *) (((long) scratch) & ~(PAGESIZE - 1)); ++ ++ /* The simulated stack needs to be executable, since GCC uses stack ++ * trampolines to implement nested functions. ++ */ ++ ret = mprotect (p, 0x100000 + EXTENDED_MEMSIZE + 15, ++ PROT_READ | PROT_WRITE | PROT_EXEC); ++ assert (ret == 0); ++ } ++ + grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4); + + /* FIXME: simulate the memory holes using mprot, if available. */ |