Re: [RFC v3 PATCH 6/7] Ksplice: Export symbols needed for Ksplice

From: Tim Abbott
Date: Mon Nov 24 2008 - 17:14:38 EST


On Sat, 22 Nov 2008, Christoph Hellwig wrote:

> On Fri, Nov 21, 2008 at 10:36:00PM -0500, Jeff Arnold wrote:
>> Ksplice uses init_mm to get access to the ranges of addresses
>> containing core kernel text and data. It seems that init_mm was
>> scheduled to be unexported entirely in 2.6.26, so move it to
>> EXPORT_SYMBOL_GPL (rather than back to EXPORT_SYMBOL).
>
> Umm, no. This is a very clear indicator that your code shouldn't be
> modular.

Well, it's easy to eliminate the use of init_mm in Ksplice by using a
slightly different check for whether to use virt_to_page or
vmalloc_to_page. Here is a patch:

Remove use of init_mm from Ksplice

Since the input to map_writable is guaranteed to be a core kernel
address or a module address, we can use __module_text_address and
__module_data_address to determine whether the address is in the core
kernel or a module, and thus whether to use virt_to_page or
vmalloc_to_page.

Signed-off-by: Tim Abbott <tabbott@xxxxxxx>
---
kernel/ksplice.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/ksplice.c b/kernel/ksplice.c
index 8a05123..d12a6db 100644
--- a/kernel/ksplice.c
+++ b/kernel/ksplice.c
@@ -949,11 +949,10 @@ static void *map_writable(void *addr, size_t len)
{
void *vaddr;
int nr_pages = 2;
- unsigned long laddr = (unsigned long)addr;
struct page *pages[2];

- if ((laddr >= init_mm.start_code && laddr < init_mm.end_code) ||
- (laddr >= init_mm.start_data && laddr < init_mm.end_data)) {
+ if (__module_text_address((unsigned long)addr) == NULL &&
+ __module_data_address((unsigned long)addr) == NULL) {
pages[0] = virt_to_page(addr);
WARN_ON(!PageReserved(pages[0]));
pages[1] = virt_to_page(addr + PAGE_SIZE);
--
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/