Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Alex Williamson wrote: On Mon, 2006-08-28 at 08:35 +0900, [EMAIL PROTECTED] wrote: In PV-on-HVM driver code, is_running_on_xen and HYPERVISOR_ioremap have to be used as valid feature. Thus we modified like this. Doesn't the below do what you need w/o breaking the CONFIG_XEN=n build? It's important to keep both builds working. Thanks, Thank you for suggestion. We modified linux-ia64.patch. I'll post it. And, We'll change PV-on-HVM implementation in xen side which uses same method of x86 code. Thanks, - Tsunehisa Doi Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 40f6fdb68fa9 linux-2.6-xen-sparse/include/asm-ia64/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sun Aug 27 10:25:39 2006 -0600 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Mon Aug 28 20:02:22 2006 +0900 @@ -315,7 +315,9 @@ static inline void exit_idle(void) {} }) #include linux/err.h +#ifdef CONFIG_XEN #include asm/xen/privop.h +#endif /* CONFIG_XEN */ static inline unsigned long __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size) diff -r 40f6fdb68fa9 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSun Aug 27 10:25:39 2006 -0600 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hMon Aug 28 20:02:22 2006 +0900 @@ -33,7 +33,7 @@ #ifndef __HYPERVISOR_H__ #define __HYPERVISOR_H__ -#ifndef CONFIG_XEN +#if !defined(CONFIG_XEN) !defined(CONFIG_VMX_GUEST) #define is_running_on_xen()(0) #define HYPERVISOR_ioremap(offset, size) (offset) #else @@ -41,7 +41,7 @@ extern int running_on_xen; #define is_running_on_xen()(running_on_xen) #endif -#ifdef CONFIG_XEN +#if defined(CONFIG_XEN) || defined(CONFIG_VMX_GUEST) #include linux/config.h #include linux/types.h #include linux/kernel.h @@ -59,10 +59,9 @@ extern shared_info_t *HYPERVISOR_shared_ extern shared_info_t *HYPERVISOR_shared_info; extern start_info_t *xen_start_info; -#define is_initial_xendomain() (xen_start_info-flags SIF_INITDOMAIN) - void force_evtchn_callback(void); +#ifndef CONFIG_VMX_GUEST /* Turn jiffies into Xen system time. XXX Implement me. */ #define jiffies_to_st(j) 0 @@ -145,10 +144,14 @@ int privcmd_mmap(struct file * file, str #define scrub_pages(_p,_n) ((void)0) #endif #definepte_mfn(_x) pte_pfn(_x) -#define __pte_ma(_x) ((pte_t) {(_x)}) #define phys_to_machine_mapping_valid(_x) (1) -#define pfn_pte_ma(_x,_y) __pte_ma(0) - + +#endif /* !CONFIG_VMX_GUEST */ + +#define __pte_ma(_x) ((pte_t) {(_x)})/* unmodified use */ +#define pfn_pte_ma(_x,_y) __pte_ma(0) /* unmodified use */ + +#ifndef CONFIG_VMX_GUEST int __xen_create_contiguous_region(unsigned long vstart, unsigned int order, unsigned int address_bits); static inline int xen_create_contiguous_region(unsigned long vstart, @@ -170,6 +173,8 @@ xen_destroy_contiguous_region(unsigned l __xen_destroy_contiguous_region(vstart, order); } +#endif /* !CONFIG_VMX_GUEST */ + // for netfront.c, netback.c #define MULTI_UVMFLAGS_INDEX 0 //XXX any value @@ -180,12 +185,29 @@ MULTI_update_va_mapping( { mcl-op = __HYPERVISOR_update_va_mapping; mcl-result = 0; +} + +static inline void +MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd, + void *uop, unsigned int count) +{ + mcl-op = __HYPERVISOR_grant_table_op; + mcl-args[0] = cmd; + mcl-args[1] = (unsigned long)uop; + mcl-args[2] = count; } // for debug asmlinkage int xprintk(const char *fmt, ...); #define xprintd(fmt, ...) xprintk(%s:%d fmt, __func__, __LINE__, \ ##__VA_ARGS__) -#endif /* CONFIG_XEN */ + +#endif /* CONFIG_XEN || CONFIG_VMX_GUEST */ + +#ifdef CONFIG_XEN_PRIVILEGED_GUEST +#define is_initial_xendomain() (xen_start_info-flags SIF_INITDOMAIN) +#else +#define is_initial_xendomain() 0 +#endif #endif /* __HYPERVISOR_H__ */ ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
All 3 ia64 patches from this thread are now applied. Thanks, Alex -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
On Sat, 2006-08-26 at 14:45 +0900, 土肥 実久 wrote: -/* Copy existing grant table shared into new page */ +/* Copy existing grant table new page */ if (o_grant_shared) { memcpy((void *)d-grant_table-shared, (void *)o_grant_shared, PAGE_SIZE * nr_frames); The existing comment seems to make more sense here. Should it be Copy existing grant table into new page? The patch below causes the kernel build to fail when CONFIG_XEN is not set. Why remove the CONFIG_XEN statement? Thanks, Alex diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:37:41 2006 +0900 @@ -315,7 +315,9 @@ static inline void exit_idle(void) {} }) #include linux/err.h +#ifdef CONFIG_XEN #include asm/xen/privop.h +#endif /* CONFIG_XEN */ static inline unsigned long __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size) diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:37:41 2006 +0900 @@ -33,15 +33,9 @@ #ifndef __HYPERVISOR_H__ #define __HYPERVISOR_H__ -#ifndef CONFIG_XEN -#define is_running_on_xen()(0) -#define HYPERVISOR_ioremap(offset, size) (offset) -#else extern int running_on_xen; #define is_running_on_xen()(running_on_xen) -#endif -#ifdef CONFIG_XEN -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Hi, You (alex.williamson) said: On Sat, 2006-08-26 at 14:45 +0900, $Be.d9(B wrote: -/* Copy existing grant table shared into new page */ +/* Copy existing grant table new page */ if (o_grant_shared) { memcpy((void *)d-grant_table-shared, (void *)o_grant_shared, PAGE_SIZE * nr_frames); The existing comment seems to make more sense here. Should it be Copy existing grant table into new page? Thank you. I'll modify it. The patch below causes the kernel build to fail when CONFIG_XEN is not set. Why remove the CONFIG_XEN statement? Thanks, diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:37:41 2006 +0900 @@ -315,7 +315,9 @@ static inline void exit_idle(void) {} }) #include linux/err.h +#ifdef CONFIG_XEN #include asm/xen/privop.h +#endif /* CONFIG_XEN */ static inline unsigned long __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size) diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:37:41 2006 +0900 @@ -33,15 +33,9 @@ #ifndef __HYPERVISOR_H__ #define __HYPERVISOR_H__ -#ifndef CONFIG_XEN -#define is_running_on_xen()(0) -#define HYPERVISOR_ioremap(offset, size) (offset) -#else extern int running_on_xen; #define is_running_on_xen()(running_on_xen) -#endif -#ifdef CONFIG_XEN In PV-on-HVM driver code, is_running_on_xen and HYPERVISOR_ioremap have to be used as valid feature. Thus we modified like this. Thanks, - Tsunehisa Doi ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
[EMAIL PROTECTED] wrote: You (alex.williamson) said: On Sat, 2006-08-26 at 14:45 +0900, 絎箙 wrote: -/* Copy existing grant table shared into new page */ +/* Copy existing grant table new page */ if (o_grant_shared) { memcpy((void *)d-grant_table-shared, (void *)o_grant_shared, PAGE_SIZE * nr_frames); The existing comment seems to make more sense here. Should it be Copy existing grant table into new page? Thank you. I'll modify it. I'll post new fix-comment.patch2. Thanks, - Tsunehisa Doi Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 3e0685ecfe64 xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Fri Aug 25 16:21:39 2006 -0600 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Mon Aug 28 09:08:38 2006 +0900 @@ -75,7 +75,7 @@ vmx_gnttab_setup_table(unsigned long fra o_grant_shared = (unsigned long)d-grant_table-shared; d-grant_table-shared = (struct grant_entry *)pgaddr; -/* Copy existing grant table shared into new page */ +/* Copy existing grant table info new page */ if (o_grant_shared) { memcpy((void *)d-grant_table-shared, (void *)o_grant_shared, PAGE_SIZE * nr_frames); ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
On Mon, 2006-08-28 at 08:35 +0900, [EMAIL PROTECTED] wrote: In PV-on-HVM driver code, is_running_on_xen and HYPERVISOR_ioremap have to be used as valid feature. Thus we modified like this. Doesn't the below do what you need w/o breaking the CONFIG_XEN=n build? It's important to keep both builds working. Thanks, Alex Signed-off-by: Alex Williamson [EMAIL PROTECTED] --- diff -r 3e0685ecfe64 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hFri Aug 25 16:21:39 2006 -0600 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSun Aug 27 19:50:59 2006 -0600 @@ -59,8 +59,6 @@ extern shared_info_t *HYPERVISOR_shared_ extern shared_info_t *HYPERVISOR_shared_info; extern start_info_t *xen_start_info; -#define is_initial_xendomain() (xen_start_info-flags SIF_INITDOMAIN) - void force_evtchn_callback(void); /* Turn jiffies into Xen system time. XXX Implement me. */ @@ -182,10 +180,26 @@ MULTI_update_va_mapping( mcl-result = 0; } +static inline void +MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd, + void *uop, unsigned int count) +{ + mcl-op = __HYPERVISOR_grant_table_op; + mcl-args[0] = cmd; + mcl-args[1] = (unsigned long)uop; + mcl-args[2] = count; +} + // for debug asmlinkage int xprintk(const char *fmt, ...); #define xprintd(fmt, ...) xprintk(%s:%d fmt, __func__, __LINE__, \ ##__VA_ARGS__) #endif /* CONFIG_XEN */ +#ifdef CONFIG_XEN_PRIVILEGED_GUEST +#define is_initial_xendomain() (xen_start_info-flags SIF_INITDOMAIN) +#else +#define is_initial_xendomain() 0 +#endif + #endif /* __HYPERVISOR_H__ */ ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Le Vendredi 25 Août 2006 01:47, [EMAIL PROTECTED] a écrit : Hi Tristan, Thank you for your comment. You (Tristan.Gingold) said: I will post patches of PV-on-HVM for IPF. We wrote the patch under this consideration: * Expand hvm_op hypercall + Introduce HVMOP_setup_shared_info_page - A page allocated on HVM-guest OS is swapped original shared_info page with this hypercall. - In x86 code, original shared_info page is used after pv-on-hvm setup with remapping feature in arch depend HYPERVISOR_memory_op. But, we can't implement same feature for IPF, thus we select to implement with this method. Can you explain why you can't reuse the HYPERVISOR_memory_op hcall ? It isn't clear for me. In x86 code (xen/arch/x86/mm.c), it uses only virtual space of page frame allocated by GuestOS, and remaps the vitual space to original share_info page frame. But, we can't find same method for IPF. Can you suggest us about the remapping method ? I simply wonder why did you create a new hypercall. You could have reuse the same hypercall, using a slighly different semantic. But it doesn't really matter. [...] +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Sorry I was not clear enough. This block appears in both function. I'd suggest to create a function to avoid duplicating code. Tristan. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Hi, You (Tristan.Gingold) said: I will post patches of PV-on-HVM for IPF. We wrote the patch under this consideration: * Expand hvm_op hypercall + Introduce HVMOP_setup_shared_info_page - A page allocated on HVM-guest OS is swapped original shared_info page with this hypercall. - In x86 code, original shared_info page is used after pv-on-hvm setup with remapping feature in arch depend HYPERVISOR_memory_op. But, we can't implement same feature for IPF, thus we select to implement with this method. Can you explain why you can't reuse the HYPERVISOR_memory_op hcall ? It isn't clear for me. In x86 code (xen/arch/x86/mm.c), it uses only virtual space of page frame allocated by GuestOS, and remaps the vitual space to original share_info page frame. But, we can't find same method for IPF. Can you suggest us about the remapping method ? I simply wonder why did you create a new hypercall. You could have reuse the same hypercall, using a slighly different semantic. But it doesn't really matter. I think that the functions which have diffect semantic should be called with the different names. +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Sorry I was not clear enough. This block appears in both function. I'd suggest to create a function to avoid duplicating code. Sorry, I had misunderstood your suggestion. I agree. I'll correct it. Thanks, -- Tsunehisa Doi ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
I'll post new xen-hyper.patch3 whitch was modified. Thanks, -- Tsunehisa Doi [EMAIL PROTECTED] wrote: +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Sorry I was not clear enough. This block appears in both function. I'd suggest to create a function to avoid duplicating code. Sorry, I had misunderstood your suggestion. I agree. I'll correct it. Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 3e54734e55f3 xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Wed Aug 23 13:26:46 2006 -0600 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Fri Aug 25 17:25:17 2006 +0900 @@ -2,6 +2,7 @@ /* * vmx_hyparcall.c: handling hypercall from domain * Copyright (c) 2005, Intel Corporation. + * Copyright (c) 2006, Fujitsu Limited. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,6 +18,8 @@ * Place - Suite 330, Boston, MA 02111-1307 USA. * * Xuefei Xu (Anthony Xu) ([EMAIL PROTECTED]) + * Tsunehisa Doi ([EMAIL PROTECTED]) + * Tomonari Horikoshi ([EMAIL PROTECTED]) */ #include xen/config.h @@ -34,6 +37,89 @@ #include public/version.h #include asm/dom_fw.h #include xen/domain.h +#include xen/compile.h +#include xen/event.h + +static void +vmx_free_pages(unsigned long pgaddr, int npg) +{ +for (; npg 0; npg--, pgaddr += PAGE_SIZE) { +/* If original page belongs to xen heap, then relinguish back + * to xen heap. Or else, leave to domain itself to decide. + */ + if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { + free_domheap_page(virt_to_page(pgaddr)); + free_xenheap_page((void *)pgaddr); + } + else { + put_page(virt_to_page(pgaddr)); + } +} +} + +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +unsigned long o_grant_shared, pgaddr; + +if ((nr_frames != NR_GRANT_FRAMES) || (frame_pa (PAGE_SIZE - 1))) { +return -EINVAL; +} + +pgaddr = domain_mpa_to_imva(d, frame_pa); +if (pgaddr == NULL) { +return -EFAULT; +} + +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)pgaddr; + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void *)d-grant_table-shared, +(void *)o_grant_shared, PAGE_SIZE * nr_frames); + vmx_free_pages(o_grant_shared, nr_frames); +} +else { +memset((void *)d-grant_table-shared, 0, PAGE_SIZE * nr_frames); +} +return 0; +} + +static int +vmx_setup_shared_info_page(unsigned long gpa) +{ +VCPU *vcpu = current; +struct domain *d = vcpu-domain; +unsigned long o_info, pgaddr; +struct vcpu *v; + +if (gpa (PAGE_SIZE - 1)) { +return -EINVAL; +} + +pgaddr = domain_mpa_to_imva(d, gpa); +if (pgaddr == NULL) { +return -EFAULT; +} + +o_info = (u64)d-shared_info; +d-shared_info= (shared_info_t *)pgaddr; + +/* Copy existing shared info into new page */ +if (o_info) { +memcpy((void*)d-shared_info, (void*)o_info, PAGE_SIZE); +for_each_vcpu(d, v) { +v-vcpu_info = d-shared_info-vcpu_info[v-vcpu_id]; +} + vmx_free_pages(o_info, 1); +} +else { +memset((void *)d-shared_info, 0, PAGE_SIZE); +} +return 0; +} long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) @@ -78,6 +164,25 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA break; } +case HVMOP_setup_gnttab_table: +case HVMOP_setup_shared_info_page: +{ +struct xen_hvm_setup a; + +if (copy_from_guest(a, arg, 1)) +return -EFAULT; + +switch (op) { +case HVMOP_setup_gnttab_table: +printk(vmx_gnttab_setup_table: frame_pa=%#lx, +nr_frame=%ld\n, a.arg1, a.arg2); +return vmx_gnttab_setup_table(a.arg1, a.arg2); +case HVMOP_setup_shared_info_page: +printk(vmx_setup_shared_info_page: gpa=0x%lx\n, a.arg1); +return vmx_setup_shared_info_page(a.arg1); +} +} + default: DPRINTK(Bad HVM op %ld.\n, op); rc = -ENOSYS; diff -r 3e54734e55f3 xen/include/public/arch-ia64.h --- a/xen/include/public/arch-ia64.hWed Aug 23 13:26:46 2006 -0600 +++ b/xen/include/public/arch-ia64.hFri
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Sorry, I didn't cleanup about indent. I'll repost new xen-hyper.patch4. Thanks, -- Tsunehisa Doi DOI Tsunehisa wrote: I'll post new xen-hyper.patch3 whitch was modified. Thanks, -- Tsunehisa Doi [EMAIL PROTECTED] wrote: +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Sorry I was not clear enough. This block appears in both function. I'd suggest to create a function to avoid duplicating code. Sorry, I had misunderstood your suggestion. I agree. I'll correct it. Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 3e54734e55f3 xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Wed Aug 23 13:26:46 2006 -0600 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Fri Aug 25 17:25:17 2006 +0900 @@ -2,6 +2,7 @@ /* * vmx_hyparcall.c: handling hypercall from domain * Copyright (c) 2005, Intel Corporation. + * Copyright (c) 2006, Fujitsu Limited. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,6 +18,8 @@ * Place - Suite 330, Boston, MA 02111-1307 USA. * * Xuefei Xu (Anthony Xu) ([EMAIL PROTECTED]) + * Tsunehisa Doi ([EMAIL PROTECTED]) + * Tomonari Horikoshi ([EMAIL PROTECTED]) */ #include xen/config.h @@ -34,6 +37,89 @@ #include public/version.h #include asm/dom_fw.h #include xen/domain.h +#include xen/compile.h +#include xen/event.h + +static void +vmx_free_pages(unsigned long pgaddr, int npg) +{ +for (; npg 0; npg--, pgaddr += PAGE_SIZE) { +/* If original page belongs to xen heap, then relinguish back + * to xen heap. Or else, leave to domain itself to decide. + */ +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} +} +} + +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +unsigned long o_grant_shared, pgaddr; + +if ((nr_frames != NR_GRANT_FRAMES) || (frame_pa (PAGE_SIZE - 1))) { +return -EINVAL; +} + +pgaddr = domain_mpa_to_imva(d, frame_pa); +if (pgaddr == NULL) { +return -EFAULT; +} + +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)pgaddr; + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void *)d-grant_table-shared, +(void *)o_grant_shared, PAGE_SIZE * nr_frames); +vmx_free_pages(o_grant_shared, nr_frames); +} +else { +memset((void *)d-grant_table-shared, 0, PAGE_SIZE * nr_frames); +} +return 0; +} + +static int +vmx_setup_shared_info_page(unsigned long gpa) +{ +VCPU *vcpu = current; +struct domain *d = vcpu-domain; +unsigned long o_info, pgaddr; +struct vcpu *v; + +if (gpa (PAGE_SIZE - 1)) { +return -EINVAL; +} + +pgaddr = domain_mpa_to_imva(d, gpa); +if (pgaddr == NULL) { +return -EFAULT; +} + +o_info = (u64)d-shared_info; +d-shared_info= (shared_info_t *)pgaddr; + +/* Copy existing shared info into new page */ +if (o_info) { +memcpy((void*)d-shared_info, (void*)o_info, PAGE_SIZE); +for_each_vcpu(d, v) { +v-vcpu_info = d-shared_info-vcpu_info[v-vcpu_id]; +} +vmx_free_pages(o_info, 1); +} +else { +memset((void *)d-shared_info, 0, PAGE_SIZE); +} +return 0; +} long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) @@ -78,6 +164,25 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA break; } +case HVMOP_setup_gnttab_table: +case HVMOP_setup_shared_info_page: +{ +struct xen_hvm_setup a; + +if (copy_from_guest(a, arg, 1)) +return -EFAULT; + +switch (op) { +case HVMOP_setup_gnttab_table: +printk(vmx_gnttab_setup_table: frame_pa=%#lx, +nr_frame=%ld\n, a.arg1, a.arg2); +return vmx_gnttab_setup_table(a.arg1, a.arg2); +case HVMOP_setup_shared_info_page: +printk(vmx_setup_shared_info_page: gpa=0x%lx\n, a.arg1); +
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Hi Alex, Alex Williamson wrote: On Fri, 2006-08-25 at 17:44 +0900, DOI Tsunehisa wrote: Sorry, I didn't cleanup about indent. I'll repost new xen-hyper.patch4. Applied. The other patches in the original set touch a lot of common files. I think it would be preferable to further split these into ia64 versus common code changes. The changes to common files need to be sent to xen-devel, the others here. Thanks, Thank you for your suggestion. I have splited these patches. I'll send the ia64 part patches with this message. Thanks, -- Tsunehisa Doi # HG changeset patch # User [EMAIL PROTECTED] # Node ID 25fd8c0ddea218c3b8c09e3c996d2784bbe6c488 # Parent 3e0685ecfe644253d64ab12e83acd81845c4b37d Fix comment of vmx_hypercall.c Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 3e0685ecfe64 -r 25fd8c0ddea2 xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Fri Aug 25 16:21:39 2006 -0600 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Sat Aug 26 13:30:46 2006 +0900 @@ -75,7 +75,7 @@ vmx_gnttab_setup_table(unsigned long fra o_grant_shared = (unsigned long)d-grant_table-shared; d-grant_table-shared = (struct grant_entry *)pgaddr; -/* Copy existing grant table shared into new page */ +/* Copy existing grant table new page */ if (o_grant_shared) { memcpy((void *)d-grant_table-shared, (void *)o_grant_shared, PAGE_SIZE * nr_frames); # HG changeset patch # User [EMAIL PROTECTED] # Node ID 153ba50864b7c11a61ecd1d0949858f94d935cb8 # Parent 25fd8c0ddea218c3b8c09e3c996d2784bbe6c488 Modify destroy code for PV-on-HVM on IPF Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 25fd8c0ddea2 -r 153ba50864b7 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.cSat Aug 26 13:30:46 2006 +0900 +++ b/xen/arch/ia64/xen/domain.cSat Aug 26 13:33:16 2006 +0900 @@ -400,8 +400,16 @@ void arch_domain_destroy(struct domain * void arch_domain_destroy(struct domain *d) { BUG_ON(d-arch.mm.pgd != NULL); - if (d-shared_info != NULL) - free_xenheap_pages(d-shared_info, get_order_from_shift(XSI_SHIFT)); + if (d-shared_info != NULL) { + /* If this domain is domVTi, the shared_info page may +* be replaced with domheap. Then the shared_info page +* frees in relinquish_mm(). +*/ + if (IS_XEN_HEAP_FRAME(virt_to_page(d-shared_info))) { + free_xenheap_pages(d-shared_info, + get_order_from_shift(XSI_SHIFT)); + } + } if (d-arch.shadow_bitmap != NULL) xfree(d-arch.shadow_bitmap); # HG changeset patch # User [EMAIL PROTECTED] # Node ID 9647400b50415a7ef26729016ca11c58e3e3c5a5 # Parent 153ba50864b7c11a61ecd1d0949858f94d935cb8 Modify linux code of IPF for PV-on-HVM on HPF Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Sat Aug 26 13:37:41 2006 +0900 @@ -315,7 +315,9 @@ static inline void exit_idle(void) {} }) #include linux/err.h +#ifdef CONFIG_XEN #include asm/xen/privop.h +#endif /* CONFIG_XEN */ static inline unsigned long __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size) diff -r 153ba50864b7 -r 9647400b5041 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:33:16 2006 +0900 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.hSat Aug 26 13:37:41 2006 +0900 @@ -33,15 +33,9 @@ #ifndef __HYPERVISOR_H__ #define __HYPERVISOR_H__ -#ifndef CONFIG_XEN -#define is_running_on_xen()(0) -#define HYPERVISOR_ioremap(offset, size) (offset) -#else extern int running_on_xen; #define is_running_on_xen()(running_on_xen) -#endif -#ifdef CONFIG_XEN #include linux/config.h #include linux/types.h #include linux/kernel.h @@ -59,7 +53,11 @@ extern shared_info_t *HYPERVISOR_shared_ extern shared_info_t *HYPERVISOR_shared_info; extern start_info_t *xen_start_info; +#ifdef CONFIG_XEN_PRIVILEGED_GUEST #define is_initial_xendomain() (xen_start_info-flags SIF_INITDOMAIN) +#else +#define is_initial_xendomain() 0 +#endif void force_evtchn_callback(void); @@ -182,10 +180,19 @@ MULTI_update_va_mapping( mcl-result = 0; } +static inline void +MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd, + void *uop, unsigned int count) +{ +mcl-op = __HYPERVISOR_grant_table_op; +mcl-args[0] = cmd; +mcl-args[1] = (unsigned long)uop; +
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Le Jeudi 24 Août 2006 15:14, DOI Tsunehisa a écrit : Hi all, Hi, I will post patches of PV-on-HVM for IPF. We wrote the patch under this consideration: * Expand hvm_op hypercall + Introduce HVMOP_setup_shared_info_page - A page allocated on HVM-guest OS is swapped original shared_info page with this hypercall. - In x86 code, original shared_info page is used after pv-on-hvm setup with remapping feature in arch depend HYPERVISOR_memory_op. But, we can't implement same feature for IPF, thus we select to implement with this method. Can you explain why you can't reuse the HYPERVISOR_memory_op hcall ? It isn't clear for me. About the patch: +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +int rc = 0, i; +unsigned long o_grant_shared, pgaddr; + +if (nr_frames != NR_GRANT_FRAMES) { +return -1; You'd better to return -EINVAL. +} +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)domain_mpa_to_imva(d, frame_pa); + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void*)d-grant_table-shared, +(void*)o_grant_shared, PAGE_SIZE * nr_frames); You should check the result of domain_mpa_to_imva, as it could fail. +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. Tristan. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Hi Tristan, Thank you for your comment. You (Tristan.Gingold) said: I will post patches of PV-on-HVM for IPF. We wrote the patch under this consideration: * Expand hvm_op hypercall + Introduce HVMOP_setup_shared_info_page - A page allocated on HVM-guest OS is swapped original shared_info page with this hypercall. - In x86 code, original shared_info page is used after pv-on-hvm setup with remapping feature in arch depend HYPERVISOR_memory_op. But, we can't implement same feature for IPF, thus we select to implement with this method. Can you explain why you can't reuse the HYPERVISOR_memory_op hcall ? It isn't clear for me. In x86 code (xen/arch/x86/mm.c), it uses only virtual space of page frame allocated by GuestOS, and remaps the vitual space to original share_info page frame. But, we can't find same method for IPF. Can you suggest us about the remapping method ? About the patch: +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +int rc = 0, i; +unsigned long o_grant_shared, pgaddr; + +if (nr_frames != NR_GRANT_FRAMES) { +return -1; You'd better to return -EINVAL. I agree. I'll correct it. +} +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)domain_mpa_to_imva(d, frame_pa); + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void*)d-grant_table-shared, +(void*)o_grant_shared, PAGE_SIZE * nr_frames); You should check the result of domain_mpa_to_imva, as it could fail. I agree. I'll try to correct it. It returns NULL if it fails, I think. Is it correct ? +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Thanks, -- Tsunehisa Doi ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
Re: [Xen-ia64-devel] PV-on-HVM driver for IPF
Hi, I'll post a new xen-hyper.patch2, whitch is modified about parameter checking. [EMAIL PROTECTED] wrote: Hi Tristan, Thank you for your comment. You (Tristan.Gingold) said: I will post patches of PV-on-HVM for IPF. We wrote the patch under this consideration: * Expand hvm_op hypercall + Introduce HVMOP_setup_shared_info_page - A page allocated on HVM-guest OS is swapped original shared_info page with this hypercall. - In x86 code, original shared_info page is used after pv-on-hvm setup with remapping feature in arch depend HYPERVISOR_memory_op. But, we can't implement same feature for IPF, thus we select to implement with this method. Can you explain why you can't reuse the HYPERVISOR_memory_op hcall ? It isn't clear for me. In x86 code (xen/arch/x86/mm.c), it uses only virtual space of page frame allocated by GuestOS, and remaps the vitual space to original share_info page frame. But, we can't find same method for IPF. Can you suggest us about the remapping method ? About the patch: +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +int rc = 0, i; +unsigned long o_grant_shared, pgaddr; + +if (nr_frames != NR_GRANT_FRAMES) { +return -1; You'd better to return -EINVAL. I agree. I'll correct it. +} +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)domain_mpa_to_imva(d, frame_pa); + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void*)d-grant_table-shared, +(void*)o_grant_shared, PAGE_SIZE * nr_frames); You should check the result of domain_mpa_to_imva, as it could fail. I agree. I'll try to correct it. It returns NULL if it fails, I think. Is it correct ? +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} May create a function to be called by gnttab_setup_table and setup_shared_info_page. I think that these function are for only VT-i domain, thus I used vmx_ prefix. What do you think about it ? Thanks, -- Tsunehisa Doi Signed-off-by: Tsunehisa Doi [EMAIL PROTECTED] Signed-off-by: Tomonari Horikoshi [EMAIL PROTECTED] diff -r 3e54734e55f3 xen/arch/ia64/vmx/vmx_hypercall.c --- a/xen/arch/ia64/vmx/vmx_hypercall.c Wed Aug 23 13:26:46 2006 -0600 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c Fri Aug 25 11:08:18 2006 +0900 @@ -2,6 +2,7 @@ /* * vmx_hyparcall.c: handling hypercall from domain * Copyright (c) 2005, Intel Corporation. + * Copyright (c) 2006, Fujitsu Limited. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,6 +18,8 @@ * Place - Suite 330, Boston, MA 02111-1307 USA. * * Xuefei Xu (Anthony Xu) ([EMAIL PROTECTED]) + * Tsunehisa Doi ([EMAIL PROTECTED]) + * Tomonari Horikoshi ([EMAIL PROTECTED]) */ #include xen/config.h @@ -34,6 +37,94 @@ #include public/version.h #include asm/dom_fw.h #include xen/domain.h +#include xen/compile.h +#include xen/event.h + +static int +vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames) +{ +struct domain *d = current-domain; +int rc = 0, i; +unsigned long o_grant_shared, pgaddr; + +if ((nr_frames != NR_GRANT_FRAMES) || (frame_pa (PAGE_SIZE - 1))) { +return -EINVAL; +} + +pgaddr = domain_mpa_to_imva(d, frame_pa); +if (pgaddr == NULL) { +return -EFAULT; +} + +o_grant_shared = (unsigned long)d-grant_table-shared; +d-grant_table-shared = (struct grant_entry *)pgaddr; + +/* Copy existing grant table shared into new page */ +if (o_grant_shared) { +memcpy((void*)d-grant_table-shared, +(void*)o_grant_shared, PAGE_SIZE * nr_frames); +/* If original page belongs to xen heap, then relinguish back + * to xen heap. Or else, leave to domain itself to decide. + */ +for (i = 0; i NR_GRANT_FRAMES; i++) { +pgaddr = o_grant_shared + PAGE_SIZE * i; +if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr { +free_domheap_page(virt_to_page(pgaddr)); +free_xenheap_page((void *)pgaddr); +} +else { +put_page(virt_to_page(pgaddr)); +} +} +} +else { +memset(d-grant_table-shared, 0, PAGE_SIZE * nr_frames); +} +return rc; +} + +static int +vmx_setup_shared_info_page(unsigned long gpa) +{ +VCPU *vcpu = current; +struct domain *d = vcpu-domain; +unsigned long o_info, pgaddr; +struct