lkml.org 
[lkml]   [2012]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[tip:x86/trampoline] x86, realmode: Set permission for real mode pages
Commit-ID:  f156ffc439951b63cfa9f4d999a8d54267f13282
Gitweb: http://git.kernel.org/tip/f156ffc439951b63cfa9f4d999a8d54267f13282
Author: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
AuthorDate: Tue, 8 May 2012 21:22:30 +0300
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Tue, 8 May 2012 11:47:08 -0700

x86, realmode: Set permission for real mode pages

Set proper permissions for rodata, text and data, removing the
realmode trampoline area as a remaining RWX memory mapping in the
kernel.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
Link: http://lkml.kernel.org/r/1336501366-28617-8-git-send-email-jarkko.sakkinen@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/realmode.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/realmode.c b/arch/x86/kernel/realmode.c
index a465775..d85ac20 100644
--- a/arch/x86/kernel/realmode.c
+++ b/arch/x86/kernel/realmode.c
@@ -86,7 +86,21 @@ static int __init set_real_mode_permissions(void)
PAGE_ALIGN(real_mode_header.end) -
__pa(real_mode_base);

- set_memory_x((unsigned long) real_mode_base, all_size >> PAGE_SHIFT);
+ size_t ro_size =
+ PAGE_ALIGN(real_mode_header.ro_end) -
+ __pa(real_mode_base);
+
+ size_t text_size =
+ PAGE_ALIGN(real_mode_header.ro_end) -
+ real_mode_header.text_start;
+
+ unsigned long text_start =
+ (unsigned long) __va(real_mode_header.text_start);
+
+ set_memory_nx((unsigned long) real_mode_base, all_size >> PAGE_SHIFT);
+ set_memory_ro((unsigned long) real_mode_base, ro_size >> PAGE_SHIFT);
+ set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);
+
return 0;
}


\
 
 \ /
  Last update: 2012-05-09 00:41    [W:0.058 / U:1.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site