Hi Konrad, the followings are the patches that I am proposing for Linux 3.7. I am leaving out the bulk of the ARM patches for the moment. Stefano Stabellini (6): xen/events: fix unmask_evtchn for PV on HVM guests xen: missing includes xen: update xen_add_to_physmap interface xen: Introduce xen_pfn_t for pfn and mfn types xen: clear IRQ_NOAUTOEN and IRQ_NOREQUEST xen: allow privcmd for HVM guests arch/ia64/include/asm/xen/interface.h | 7 ++++++- arch/x86/include/asm/xen/interface.h | 7 +++++++ arch/x86/xen/mmu.c | 3 +++ drivers/tty/hvc/hvc_xen.c | 2 ++ drivers/xen/events.c | 18 +++++++++++++++--- drivers/xen/grant-table.c | 1 + drivers/xen/privcmd.c | 4 ---- drivers/xen/xenbus/xenbus_probe_frontend.c | 1 + include/xen/interface/grant_table.h | 4 ++-- include/xen/interface/memory.h | 9 ++++++--- include/xen/interface/platform.h | 4 ++-- include/xen/interface/xen.h | 7 +++---- include/xen/privcmd.h | 3 +-- 13 files changed, 49 insertions(+), 21 deletions(-) A git branch based on v3.6-rc2 is available here: git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git for_upstream_3.7 Cheers, Stefano
Stefano Stabellini
2012-Aug-22 16:20 UTC
[PATCH 1/6] xen/events: fix unmask_evtchn for PV on HVM guests
When unmask_evtchn is called, if we already have an event pending, we just set evtchn_pending_sel waiting for local_irq_enable to be called. That is because PV guests set the irq_enable pvops to xen_irq_enable_direct in xen_setup_vcpu_info_placement: xen_irq_enable_direct is implemented in assembly in arch/x86/xen/xen-asm.S and call xen_force_evtchn_callback if XEN_vcpu_info_pending is set. However HVM guests (and ARM guests) do not change or do not have the irq_enable pvop, so evtchn_unmask cannot work properly for them. Considering that having the pending_irq bit set when unmask_evtchn is called is not very common, and it is simpler to keep the native_irq_enable implementation for HVM guests (and ARM guests), the best thing to do is just use the EVTCHNOP_unmask hypercall (Xen re-injects pending events in response). Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- drivers/xen/events.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 7595581..36bf17d 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -373,11 +373,22 @@ static void unmask_evtchn(int port) { struct shared_info *s = HYPERVISOR_shared_info; unsigned int cpu = get_cpu(); + int do_hypercall = 0, evtchn_pending = 0; BUG_ON(!irqs_disabled()); - /* Slow path (hypercall) if this is a non-local port. */ - if (unlikely(cpu != cpu_from_evtchn(port))) { + if (unlikely((cpu != cpu_from_evtchn(port)))) + do_hypercall = 1; + else + evtchn_pending = sync_test_bit(port, &s->evtchn_pending[0]); + + if (unlikely(evtchn_pending && xen_hvm_domain())) + do_hypercall = 1; + + /* Slow path (hypercall) if this is a non-local port or if this is + * an hvm domain and an event is pending (hvm domains don''t have + * their own implementation of irq_enable). */ + if (do_hypercall) { struct evtchn_unmask unmask = { .port = port }; (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask); } else { @@ -390,7 +401,7 @@ static void unmask_evtchn(int port) * ''hw_resend_irq''. Just like a real IO-APIC we ''lose * the interrupt edge'' if the channel is masked. */ - if (sync_test_bit(port, &s->evtchn_pending[0]) && + if (evtchn_pending && !sync_test_and_set_bit(port / BITS_PER_LONG, &vcpu_info->evtchn_pending_sel)) vcpu_info->evtchn_upcall_pending = 1; -- 1.7.2.5
Changes in v3: - add missing pvclock-abi.h include to ia64 header files. Changes in v2: - remove pvclock hack; - remove include linux/types.h from xen/interface/xen.h. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- arch/ia64/include/asm/xen/interface.h | 2 ++ arch/x86/include/asm/xen/interface.h | 2 ++ drivers/tty/hvc/hvc_xen.c | 2 ++ drivers/xen/grant-table.c | 1 + drivers/xen/xenbus/xenbus_probe_frontend.c | 1 + include/xen/interface/xen.h | 1 - include/xen/privcmd.h | 1 + 7 files changed, 9 insertions(+), 1 deletions(-) diff --git a/arch/ia64/include/asm/xen/interface.h b/arch/ia64/include/asm/xen/interface.h index 09d5f7f..ee9cad6 100644 --- a/arch/ia64/include/asm/xen/interface.h +++ b/arch/ia64/include/asm/xen/interface.h @@ -265,6 +265,8 @@ typedef struct xen_callback xen_callback_t; #endif /* !__ASSEMBLY__ */ +#include <asm/pvclock-abi.h> + /* Size of the shared_info area (this is not related to page size). */ #define XSI_SHIFT 14 #define XSI_SIZE (1 << XSI_SHIFT) diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xen/interface.h index cbf0c9d..a93db16 100644 --- a/arch/x86/include/asm/xen/interface.h +++ b/arch/x86/include/asm/xen/interface.h @@ -121,6 +121,8 @@ struct arch_shared_info { #include "interface_64.h" #endif +#include <asm/pvclock-abi.h> + #ifndef __ASSEMBLY__ /* * The following is all CPU context. Note that the fpu_ctxt block is filled diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 1e456dc..2944ff8 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -21,6 +21,7 @@ #include <linux/console.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/irq.h> #include <linux/init.h> #include <linux/types.h> #include <linux/list.h> @@ -35,6 +36,7 @@ #include <xen/page.h> #include <xen/events.h> #include <xen/interface/io/console.h> +#include <xen/interface/sched.h> #include <xen/hvc-console.h> #include <xen/xenbus.h> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 0bfc1ef..1d0d95e 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -47,6 +47,7 @@ #include <xen/interface/memory.h> #include <xen/hvc-console.h> #include <asm/xen/hypercall.h> +#include <asm/xen/interface.h> #include <asm/pgtable.h> #include <asm/sync_bitops.h> diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c index a31b54d..3159a37 100644 --- a/drivers/xen/xenbus/xenbus_probe_frontend.c +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c @@ -21,6 +21,7 @@ #include <xen/xenbus.h> #include <xen/events.h> #include <xen/page.h> +#include <xen/xen.h> #include <xen/platform_pci.h> diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 0801468..6e75dea 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h @@ -10,7 +10,6 @@ #define __XEN_PUBLIC_XEN_H__ #include <asm/xen/interface.h> -#include <asm/pvclock-abi.h> /* * XEN "SYSTEM CALLS" (a.k.a. HYPERCALLS). diff --git a/include/xen/privcmd.h b/include/xen/privcmd.h index 17857fb..4d58881 100644 --- a/include/xen/privcmd.h +++ b/include/xen/privcmd.h @@ -35,6 +35,7 @@ #include <linux/types.h> #include <linux/compiler.h> +#include <xen/interface/xen.h> typedef unsigned long xen_pfn_t; -- 1.7.2.5
Stefano Stabellini
2012-Aug-22 16:20 UTC
[PATCH 3/6] xen: update xen_add_to_physmap interface
Update struct xen_add_to_physmap to be in sync with Xen''s version of the structure. The size field was introduced by: changeset: 24164:707d27fe03e7 user: Jean Guyader <jean.guyader@eu.citrix.com> date: Fri Nov 18 13:42:08 2011 +0000 summary: mm: New XENMEM space, XENMAPSPACE_gmfn_range According to the comment: "This new field .size is located in the 16 bits padding between .domid and .space in struct xen_add_to_physmap to stay compatible with older versions." Changes in v2: - remove erroneous comment in the commit message. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- include/xen/interface/memory.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index eac3ce1..8d4efc1 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -163,6 +163,9 @@ struct xen_add_to_physmap { /* Which domain to change the mapping for. */ domid_t domid; + /* Number of pages to go through for gmfn_range */ + uint16_t size; + /* Source mapping space. */ #define XENMAPSPACE_shared_info 0 /* shared info page */ #define XENMAPSPACE_grant_table 1 /* grant table page */ -- 1.7.2.5
Stefano Stabellini
2012-Aug-22 16:20 UTC
[PATCH 4/6] xen: Introduce xen_pfn_t for pfn and mfn types
All the original Xen headers have xen_pfn_t as mfn and pfn type, however when they have been imported in Linux, xen_pfn_t has been replaced with unsigned long. That might work for x86 and ia64 but it does not for arm. Bring back xen_pfn_t and let each architecture define xen_pfn_t as they see fit. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- arch/ia64/include/asm/xen/interface.h | 5 ++++- arch/x86/include/asm/xen/interface.h | 5 +++++ include/xen/interface/grant_table.h | 4 ++-- include/xen/interface/memory.h | 6 +++--- include/xen/interface/platform.h | 4 ++-- include/xen/interface/xen.h | 6 +++--- include/xen/privcmd.h | 2 -- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/ia64/include/asm/xen/interface.h b/arch/ia64/include/asm/xen/interface.h index ee9cad6..3d52a5b 100644 --- a/arch/ia64/include/asm/xen/interface.h +++ b/arch/ia64/include/asm/xen/interface.h @@ -67,6 +67,10 @@ #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0) #ifndef __ASSEMBLY__ +/* Explicitly size integers that represent pfns in the public interface + * with Xen so that we could have one ABI that works for 32 and 64 bit + * guests. */ +typedef unsigned long xen_pfn_t; /* Guest handles for primitive C types. */ __DEFINE_GUEST_HANDLE(uchar, unsigned char); __DEFINE_GUEST_HANDLE(uint, unsigned int); @@ -79,7 +83,6 @@ DEFINE_GUEST_HANDLE(void); DEFINE_GUEST_HANDLE(uint64_t); DEFINE_GUEST_HANDLE(uint32_t); -typedef unsigned long xen_pfn_t; DEFINE_GUEST_HANDLE(xen_pfn_t); #define PRI_xen_pfn "lx" #endif diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xen/interface.h index a93db16..555f94d 100644 --- a/arch/x86/include/asm/xen/interface.h +++ b/arch/x86/include/asm/xen/interface.h @@ -47,6 +47,10 @@ #endif #ifndef __ASSEMBLY__ +/* Explicitly size integers that represent pfns in the public interface + * with Xen so that on ARM we can have one ABI that works for 32 and 64 + * bit guests. */ +typedef unsigned long xen_pfn_t; /* Guest handles for primitive C types. */ __DEFINE_GUEST_HANDLE(uchar, unsigned char); __DEFINE_GUEST_HANDLE(uint, unsigned int); @@ -57,6 +61,7 @@ DEFINE_GUEST_HANDLE(long); DEFINE_GUEST_HANDLE(void); DEFINE_GUEST_HANDLE(uint64_t); DEFINE_GUEST_HANDLE(uint32_t); +DEFINE_GUEST_HANDLE(xen_pfn_t); #endif #ifndef HYPERVISOR_VIRT_START diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h index a17d844..7da811b 100644 --- a/include/xen/interface/grant_table.h +++ b/include/xen/interface/grant_table.h @@ -338,7 +338,7 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table); #define GNTTABOP_transfer 4 struct gnttab_transfer { /* IN parameters. */ - unsigned long mfn; + xen_pfn_t mfn; domid_t domid; grant_ref_t ref; /* OUT parameters. */ @@ -375,7 +375,7 @@ struct gnttab_copy { struct { union { grant_ref_t ref; - unsigned long gmfn; + xen_pfn_t gmfn; } u; domid_t domid; uint16_t offset; diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index 8d4efc1..d8e33a9 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -31,7 +31,7 @@ struct xen_memory_reservation { * OUT: GMFN bases of extents that were allocated * (NB. This command also updates the mach_to_phys translation table) */ - GUEST_HANDLE(ulong) extent_start; + GUEST_HANDLE(xen_pfn_t) extent_start; /* Number of extents, and size/alignment of each (2^extent_order pages). */ unsigned long nr_extents; @@ -130,7 +130,7 @@ struct xen_machphys_mfn_list { * any large discontiguities in the machine address space, 2MB gaps in * the machphys table will be represented by an MFN base of zero. */ - GUEST_HANDLE(ulong) extent_start; + GUEST_HANDLE(xen_pfn_t) extent_start; /* * Number of extents written to the above array. This will be smaller @@ -175,7 +175,7 @@ struct xen_add_to_physmap { unsigned long idx; /* GPFN where the source mapping page should appear. */ - unsigned long gpfn; + xen_pfn_t gpfn; }; DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap); diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h index 61fa661..a3275a8 100644 --- a/include/xen/interface/platform.h +++ b/include/xen/interface/platform.h @@ -54,7 +54,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t); #define XENPF_add_memtype 31 struct xenpf_add_memtype { /* IN variables. */ - unsigned long mfn; + xen_pfn_t mfn; uint64_t nr_mfns; uint32_t type; /* OUT variables. */ @@ -84,7 +84,7 @@ struct xenpf_read_memtype { /* IN variables. */ uint32_t reg; /* OUT variables. */ - unsigned long mfn; + xen_pfn_t mfn; uint64_t nr_mfns; uint32_t type; }; diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 6e75dea..1e0df6b 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h @@ -189,7 +189,7 @@ struct mmuext_op { unsigned int cmd; union { /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */ - unsigned long mfn; + xen_pfn_t mfn; /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */ unsigned long linear_addr; } arg1; @@ -429,11 +429,11 @@ struct start_info { unsigned long nr_pages; /* Total pages allocated to this domain. */ unsigned long shared_info; /* MACHINE address of shared info struct. */ uint32_t flags; /* SIF_xxx flags. */ - unsigned long store_mfn; /* MACHINE page number of shared page. */ + xen_pfn_t store_mfn; /* MACHINE page number of shared page. */ uint32_t store_evtchn; /* Event channel for store communication. */ union { struct { - unsigned long mfn; /* MACHINE page number of console page. */ + xen_pfn_t mfn; /* MACHINE page number of console page. */ uint32_t evtchn; /* Event channel for console page. */ } domU; struct { diff --git a/include/xen/privcmd.h b/include/xen/privcmd.h index 4d58881..45c1aa1 100644 --- a/include/xen/privcmd.h +++ b/include/xen/privcmd.h @@ -37,8 +37,6 @@ #include <linux/compiler.h> #include <xen/interface/xen.h> -typedef unsigned long xen_pfn_t; - struct privcmd_hypercall { __u64 op; __u64 arg[5]; -- 1.7.2.5
Stefano Stabellini
2012-Aug-22 16:20 UTC
[PATCH 5/6] xen: clear IRQ_NOAUTOEN and IRQ_NOREQUEST
Reset the IRQ_NOAUTOEN and IRQ_NOREQUEST flags that are enabled by default on ARM. If IRQ_NOAUTOEN is set, __setup_irq doesn''t call irq_startup, that is responsible for calling irq_unmask at startup time. As a result event channels remain masked. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- drivers/xen/events.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 36bf17d..c60d162 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -842,6 +842,7 @@ int bind_evtchn_to_irq(unsigned int evtchn) struct irq_info *info = info_for_irq(irq); WARN_ON(info == NULL || info->type != IRQT_EVTCHN); } + irq_clear_status_flags(irq, IRQ_NOREQUEST|IRQ_NOAUTOEN); out: mutex_unlock(&irq_mapping_update_lock); -- 1.7.2.5
This patch removes the "return -ENOSYS" for auto_translated_physmap guests from privcmd_mmap, thus it allows ARM guests to issue privcmd mmap calls. However privcmd mmap calls are still going to fail for HVM and hybrid guests on x86 because the xen_remap_domain_mfn_range implementation is currently PV only. Changes in v2: - better commit message; - return -EINVAL from xen_remap_domain_mfn_range if auto_translated_physmap. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- arch/x86/xen/mmu.c | 3 +++ drivers/xen/privcmd.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index b65a761..2a1ee7b 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -2337,6 +2337,9 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma, unsigned long range; int err = 0; + if (xen_feature(XENFEAT_auto_translated_physmap)) + return -EINVAL; + prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP); BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_RESERVED | VM_IO)) =diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index ccee0f1..85226cb 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -380,10 +380,6 @@ static struct vm_operations_struct privcmd_vm_ops = { static int privcmd_mmap(struct file *file, struct vm_area_struct *vma) { - /* Unsupported for auto-translate guests. */ - if (xen_feature(XENFEAT_auto_translated_physmap)) - return -ENOSYS; - /* DONTCOPY is essential for Xen because copy_page_range doesn''t know * how to recreate these mappings */ vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP; -- 1.7.2.5
On Wed, Aug 22, 2012 at 05:19:18PM +0100, Stefano Stabellini wrote:> Hi Konrad, > the followings are the patches that I am proposing for Linux 3.7. > I am leaving out the bulk of the ARM patches for the moment.applied. going to test it overnight.> > > Stefano Stabellini (6): > xen/events: fix unmask_evtchn for PV on HVM guests > xen: missing includes > xen: update xen_add_to_physmap interface > xen: Introduce xen_pfn_t for pfn and mfn types > xen: clear IRQ_NOAUTOEN and IRQ_NOREQUEST > xen: allow privcmd for HVM guests > > arch/ia64/include/asm/xen/interface.h | 7 ++++++- > arch/x86/include/asm/xen/interface.h | 7 +++++++ > arch/x86/xen/mmu.c | 3 +++ > drivers/tty/hvc/hvc_xen.c | 2 ++ > drivers/xen/events.c | 18 +++++++++++++++--- > drivers/xen/grant-table.c | 1 + > drivers/xen/privcmd.c | 4 ---- > drivers/xen/xenbus/xenbus_probe_frontend.c | 1 + > include/xen/interface/grant_table.h | 4 ++-- > include/xen/interface/memory.h | 9 ++++++--- > include/xen/interface/platform.h | 4 ++-- > include/xen/interface/xen.h | 7 +++---- > include/xen/privcmd.h | 3 +-- > 13 files changed, 49 insertions(+), 21 deletions(-) > > > A git branch based on v3.6-rc2 is available here: > > git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git for_upstream_3.7 > > Cheers, > > Stefano