He, Qing wrote:
>>
>> hmm.  While there's nothing wrong with the patch, there is a simpler way
>> to do this:
>>
>>    static unsigned long vmx_msr_bitmap[PAGE_SIZE / sizeof(unsigned
>> long)] __aligned(PAGE_SIZE);
>>
>> now there's no need to allocate, error-check, free, or kmap the memory.
>> The io bitmaps can receive similar treatment.
>>     
>
> Well, though not so important, kmapping do have a tiny advantage, it uses 
> less virtual space if HIGHMEM is used. This makes sense when 1G limited 
> kernel space is used, although it's highly unlikely to be a real problem.
>
>   

Starting a virtual machine consumes about 4MB of low memory for the
shadow mmu (more for the memory map and for various slabs), so 4K is not
an issue.

However, I do see an issue with my proposal. To get the physical address
of the page, we need to use vmalloc_to_page(). But that won't work if
kvm is built into the kernel (and thus uses large pages for data).

Rusty, what say you to a 'struct page *module_to_page(void *kaddr)'
which does the right thing? Attached an implementation.


-- 
error compiling committee.c: too many arguments to function

diff --git a/include/linux/module.h b/include/linux/module.h
index b6a646c..c520a3a 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -16,6 +16,7 @@
 #include <linux/kobject.h>
 #include <linux/moduleparam.h>
 #include <asm/local.h>
+#include <asm/page.h>
 
 #include <asm/module.h>
 
@@ -371,6 +372,7 @@ static inline int module_is_live(struct module *mod)
 struct module *module_text_address(unsigned long addr);
 struct module *__module_text_address(unsigned long addr);
 int is_module_address(unsigned long addr);
+struct page *module_to_page(void *kaddr);
 
 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
    symnum out of range. */
@@ -498,6 +500,11 @@ static inline int is_module_address(unsigned long addr)
 	return 0;
 }
 
+static inline struct page *module_to_page(void *kaddr)
+{
+	return virt_to_page(kaddr);
+}
+
 /* Get/put a kernel symbol (calls should be symmetric) */
 #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
 #define symbol_put(x) do { } while(0)
diff --git a/kernel/module.c b/kernel/module.c
index 33c04ad..4618792 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2347,6 +2347,16 @@ int is_module_address(unsigned long addr)
 	return 0;
 }
 
+/*
+ * Convert a virtual address, possibly in a module, to a struct page.
+ */
+struct page *module_to_page(void *kaddr)
+{
+	if (is_module_address((unsigned long)kaddr))
+		return vmalloc_to_page(kaddr);
+	else
+		return virt_to_page(kaddr);
+}
 
 /* Is this a valid kernel address? */
 struct module *__module_text_address(unsigned long addr)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to