~ubuntu-branches/debian/jessie/grub/jessie

« back to all changes in this revision

Viewing changes to debian/patches/mprotect.patch

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-03-17 13:34:14 UTC
  • Revision ID: james.westby@ubuntu.com-20110317133414-cawa48d482iuqqb9
Tags: 0.97-65
* Fix grub/migrate_from_legacy title to not end with a full stop.
* Fix update-grub(8) groff typo (".bar" instead of ".br").
* Adjust doc-base file to account for renaming of grub.info to
  grub-legacy.info.
* Compare -trunk kernels earlier than numeric ABIs (thanks, Aaron M. Ucko
  and Andreas Beckmann; closes: #570318).
* Convert from home-grown patch system to quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: b/grub/asmstub.c
 
2
===================================================================
 
3
--- a/grub/asmstub.c
 
4
+++ b/grub/asmstub.c
 
5
@@ -42,6 +42,12 @@
 
6
 #include <sys/time.h>
 
7
 #include <termios.h>
 
8
 #include <signal.h>
 
9
+#include <sys/mman.h>
 
10
+
 
11
+#include <limits.h>
 
12
+#ifndef PAGESIZE
 
13
+#define PAGESIZE 4096
 
14
+#endif
 
15
 
 
16
 #ifdef __linux__
 
17
 # include <sys/ioctl.h>                /* ioctl */
 
18
@@ -148,6 +154,22 @@
 
19
   assert (grub_scratch_mem == 0);
 
20
   scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15);
 
21
   assert (scratch);
 
22
+
 
23
+  {
 
24
+    char *p;
 
25
+    int ret;
 
26
+
 
27
+    /* Align to a multiple of PAGESIZE, assumed to be a power of two. */
 
28
+    p = (char *) (((long) scratch) & ~(PAGESIZE - 1));
 
29
+
 
30
+    /* The simulated stack needs to be executable, since GCC uses stack
 
31
+     * trampolines to implement nested functions.
 
32
+     */
 
33
+    ret = mprotect (p, 0x100000 + EXTENDED_MEMSIZE + 15,
 
34
+                   PROT_READ | PROT_WRITE | PROT_EXEC);
 
35
+    assert (ret == 0);
 
36
+  }
 
37
+
 
38
   grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4);
 
39
 
 
40
   /* FIXME: simulate the memory holes using mprot, if available. */