From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] Add MSR Bitmap support in VMX Date: Thu, 02 Aug 2007 15:39:46 +0300 Message-ID: <46B1D092.7070609@qumranet.com> References: <37E52D09333DE2469A03574C88DBF40F048ED2@pdsmsx414.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040600010502050206060306" Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: "He, Qing" , Rusty Russell Return-path: In-Reply-To: <37E52D09333DE2469A03574C88DBF40F048ED2-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org This is a multi-part message in MIME format. --------------040600010502050206060306 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit 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 --------------040600010502050206060306 Content-Type: text/x-patch; name="module_to_page.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="module_to_page.patch" 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 #include #include +#include #include @@ -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) --------------040600010502050206060306 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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/ --------------040600010502050206060306 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --------------040600010502050206060306--