: PVH basic and hader file changes
Subsystems (3)
PATCH 1/8 : PVH basic and hader file changes
--- arch/x86/include/asm/xen/interface.h | 8 +++++++- arch/x86/include/asm/xen/page.h | 3 +++ arch/x86/xen/irq.c | 5 ++++- arch/x86/xen/p2m.c | 2 +- drivers/xen/cpu_hotplug.c | 4 +++- drivers/xen/events.c | 12 ++++++++---- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 6 +++++- include/xen/interface/memory.h | 27 +++++++++++++++++++++++++++ include/xen/interface/physdev.h | 10 ++++++++++ 10 files changed, 69 insertions(+), 10 deletions(-)
arch/x86/include/asm/xen/interface.h +7 -1
@@ -136,7 +136,13 @@ struct vcpu_guest_context {struct cpu_user_regs user_regs;/* User-level CPU registers */ struct trap_info trap_ctxt[256 ];/* Virtual IDT */ unsigned long ldt_base, ldt_ents;/* LDT (linear address, # ents) */ -unsigned long gdt_frames[16 ], gdt_ents;/* GDT (machine frames, # ents) */ +union { +struct { +/* PV: GDT (machine frames, # ents).*/ +unsigned long gdt_frames[16 ], gdt_ents; + }; +unsigned long gdtaddr, gdtsz;/* PVH: GDTR addr and size */ + };unsigned long kernel_ss, kernel_sp;/* Virtual TSS (only SS1/SP1) */ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ unsigned long ctrlreg[8 ];/* CR0-CR7 (control registers) */
arch/x86/include/asm/xen/page.h +3 -0
@@ -158,6 +158,9 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)static inline unsigned long mfn_to_local_pfn (unsigned long mfn) {unsigned long pfn =mfn_to_pfn (mfn); + +if (xen_feature (XENFEAT_auto_translated_physmap)) +return mfn;if (get_phys_to_machine (pfn) != mfn)return -1 ;/* force !pfn_valid() */ return pfn;
arch/x86/xen/irq.c +4 -1
@@ -5,6 +5,7 @@#include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/vcpu.h> +#include <xen/features.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h>
@@ -128,6 +129,8 @@ static const struct pv_irq_ops xen_irq_ops __initconst = {void __init xen_init_irq_ops (void ) { - pv_irq_ops = xen_irq_ops; +/* For PVH we use default pv_irq_ops settings */ +if (!xen_feature (XENFEAT_hvm_callback_vector)) + pv_irq_ops = xen_irq_ops; x86_init.irqs.intr_init = xen_init_IRQ; }
arch/x86/xen/p2m.c +1 -1
@@ -626,7 +626,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) {unsigned topidx, mididx, idx; -if (unlikely (xen_feature (XENFEAT_auto_translated_physmap))) { +if (xen_feature (XENFEAT_auto_translated_physmap)) {BUG_ON (pfn != mfn && mfn !=INVALID_P2M_ENTRY );return true; }
drivers/xen/cpu_hotplug.c +3 -1
@@ -2,6 +2,7 @@#include <xen/xen.h> #include <xen/xenbus.h> +#include <xen/features.h> #include <asm/xen/hypervisor.h> #include <asm/cpu.h>
@@ -100,7 +101,8 @@ static int __init setup_vcpu_hotplug_event(void)static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; -if (!xen_pv_domain ()) +/* PVH TBD/FIXME: future work */ +if (!xen_pv_domain () ||xen_feature (XENFEAT_auto_translated_physmap))return -ENODEV ;register_xenstore_notifier (&xsn_cpu);
drivers/xen/events.c +8 -4
@@ -1755,7 +1755,7 @@ int xen_set_callback_via(uint64_t via) }EXPORT_SYMBOL_GPL (xen_set_callback_via); -#ifdef CONFIG_XEN_PVHVM +/* Vector callbacks are better than PCI interrupts to receive event * channel notifications because we can receive vector callbacks on any * vcpu and we don't need PCI support or APIC interactions. */
@@ -1779,9 +1779,6 @@ void xen_callback_vector(void)alloc_intr_gate (XEN_HVM_EVTCHN_CALLBACK , xen_hvm_callback_vector); } } -#else -void xen_callback_vector (void ) {} -#endif void __init xen_init_IRQ (void ) {
@@ -1814,6 +1811,13 @@ void __init xen_init_IRQ(void)if (xen_initial_domain ())pci_xen_initial_domain (); +if (xen_feature (XENFEAT_hvm_callback_vector)) { +xen_callback_vector (); +return ; + } + +/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */ + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
drivers/xen/xenbus/xenbus_client.c +1 -1
@@ -743,7 +743,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {void __init xenbus_ring_ops_init (void ) { -if (xen_pv_domain ()) +if (xen_pv_domain () && !xen_feature (XENFEAT_auto_translated_physmap)) ring_ops = &ring_ops_pv;else ring_ops = &ring_ops_hvm;
drivers/xen/xenbus/xenbus_probe.c +5 -1
@@ -749,7 +749,11 @@ static int __init xenbus_init(void)if (err) goto out_error; } - xen_store_interface =mfn_to_virt (xen_store_mfn); +if (xen_feature (XENFEAT_auto_translated_physmap)) +/* mfn is actually a pfn */ + xen_store_interface =__va (xen_store_mfn<<PAGE_SHIFT ); +else + xen_store_interface =mfn_to_virt (xen_store_mfn); }/* Initialize the interface to xenstore. */
include/xen/interface/memory.h +27 -0
@@ -163,11 +163,22 @@ struct xen_add_to_physmap {/* Which domain to change the mapping for. */ domid_t domid; +union { +/* Number of pages to go through for gmfn_range */ +uint16_t size; +/* IFF XENMAPSPACE_gmfn_foreign */ +domid_t foreign_domid; + } u;/* Source mapping space. */ #define XENMAPSPACE_shared_info 0/* shared info page */ #define XENMAPSPACE_grant_table 1/* grant table page */ +#define XENMAPSPACE_gmfn 2/* GMFN */ +#define XENMAPSPACE_gmfn_range 3/* GMFN range */ +#define XENMAPSPACE_gmfn_foreign 4/* GMFN from another guest */ unsigned int space; +#define XENMAPIDX_grant_table_status 0x80000000 +/* Index into source mapping space. */ unsigned long idx;
@@ -234,4 +245,20 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);* during a driver critical region. */ extern spinlock_t xen_reservation_lock; + +/* +* Unmaps the page appearing at a particular GPFN from the specified guest's +* pseudophysical address space. +* arg == addr of xen_remove_from_physmap_t. +*/ +#define XENMEM_remove_from_physmap 15 +struct xen_remove_from_physmap { +/* Which domain to change the mapping for. */ +domid_t domid; + +/* GPFN of the current mapping of the page. */ +unsigned long gpfn; +}; +DEFINE_GUEST_HANDLE_STRUCT (xen_remove_from_physmap); +#endif /* __XEN_PUBLIC_MEMORY_H__ */
include/xen/interface/physdev.h +10 -0
@@ -258,6 +258,16 @@ struct physdev_pci_device {uint8_t devfn; }; +#define PHYSDEVOP_pvh_map_iomem 29 +struct physdev_map_iomem { +/* IN */ +uint64_t first_gfn; +uint64_t first_mfn; +uint32_t nr_mfns; +uint32_t add_mapping;/* 1 == add mapping; 0 == unmap */ + +}; +/* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is **
Signature · 1 line
1.7.2.3
Quoted 22 lines · Mukesh Rathor
--- arch/x86/include/asm/xen/interface.h | 8 +++++++- arch/x86/include/asm/xen/page.h | 3 +++ arch/x86/xen/irq.c | 5 ++++- arch/x86/xen/p2m.c | 2 +- drivers/xen/cpu_hotplug.c | 4 +++- drivers/xen/events.c | 12 ++++++++---- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 6 +++++- include/xen/interface/memory.h | 27 +++++++++++++++++++++++++++ include/xen/interface/physdev.h | 10 ++++++++++ 10 files changed, 69 insertions(+), 10 deletions(-)arch/x86/include/asm/xen/interface.h +0
-1@@ -136,7 +136,13 @@ struct vcpu_guest_context {struct cpu_user_regs user_regs;/* User-level CPU registers */ struct trap_info trap_ctxt[256 ];/* Virtual IDT */ unsigned long ldt_base, ldt_ents;/* LDT (linear address, # ents) */ -unsigned long gdt_frames[16 ], gdt_ents;/* GDT (machine frames, # ents) */
arch/x86/include/asm/xen/interface.h struct vcpu_guest_context { · line 148
Quoted 10 lines
arch/x86/include/asm/xen/interface.h +7
-0+union { +struct { +/* PV: GDT (machine frames, # ents).*/ +unsigned long gdt_frames[16 ], gdt_ents; + }; +unsigned long gdtaddr, gdtsz;/* PVH: GDTR addr and size */ + };unsigned long kernel_ss, kernel_sp;/* Virtual TSS (only SS1/SP1) */ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ unsigned long ctrlreg[8 ];/* CR0-CR7 (control registers) */
I think I'll be fully able to understand what these are for only after I read the Xen side patches...
Quoted 62 lines
arch/x86/include/asm/xen/page.h +3
-0@@ -158,6 +158,9 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)static inline unsigned long mfn_to_local_pfn (unsigned long mfn) {unsigned long pfn =mfn_to_pfn (mfn); + +if (xen_feature (XENFEAT_auto_translated_physmap)) +return mfn;if (get_phys_to_machine (pfn) != mfn)return -1 ;/* force !pfn_valid() */ return pfn;arch/x86/xen/irq.c +4
-1@@ -5,6 +5,7 @@#include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/vcpu.h> +#include <xen/features.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -128,6 +129,8 @@ static const struct pv_irq_ops xen_irq_ops __initconst = {void __init xen_init_irq_ops (void ) { - pv_irq_ops = xen_irq_ops; +/* For PVH we use default pv_irq_ops settings */ +if (!xen_feature (XENFEAT_hvm_callback_vector)) + pv_irq_ops = xen_irq_ops; x86_init.irqs.intr_init = xen_init_IRQ; }arch/x86/xen/p2m.c +1
-1@@ -626,7 +626,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) {unsigned topidx, mididx, idx; -if (unlikely (xen_feature (XENFEAT_auto_translated_physmap))) { +if (xen_feature (XENFEAT_auto_translated_physmap)) {BUG_ON (pfn != mfn && mfn !=INVALID_P2M_ENTRY );return true; }drivers/xen/cpu_hotplug.c +1
-0@@ -2,6 +2,7 @@#include <xen/xen.h> #include <xen/xenbus.h> +#include <xen/features.h> #include <asm/xen/hypervisor.h> #include <asm/cpu.h>
drivers/xen/cpu_hotplug.c static int __init setup_vcpu_hotplug_event(void) · line 106
Quoted 7 lines
drivers/xen/cpu_hotplug.c +2
-1@@ -100,7 +101,8 @@ static int __init setup_vcpu_hotplug_event(void)static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; -if (!xen_pv_domain ()) +/* PVH TBD/FIXME: future work */ +if (!xen_pv_domain () ||xen_feature (XENFEAT_auto_translated_physmap))return -ENODEV ;
Didn't we say that a PVH domain is actually a pv guest? In that case shouldn't the test
if (!xen_pv_domain())
be sufficient?
Quoted 56 lines
drivers/xen/cpu_hotplug.c +0
-0register_xenstore_notifier (&xsn_cpu);drivers/xen/events.c +8
-4@@ -1755,7 +1755,7 @@ int xen_set_callback_via(uint64_t via) }EXPORT_SYMBOL_GPL (xen_set_callback_via); -#ifdef CONFIG_XEN_PVHVM +/* Vector callbacks are better than PCI interrupts to receive event * channel notifications because we can receive vector callbacks on any * vcpu and we don't need PCI support or APIC interactions. */ @@ -1779,9 +1779,6 @@ void xen_callback_vector(void)alloc_intr_gate (XEN_HVM_EVTCHN_CALLBACK , xen_hvm_callback_vector); } } -#else -void xen_callback_vector (void ) {} -#endif void __init xen_init_IRQ (void ) {@@ -1814,6 +1811,13 @@ void __init xen_init_IRQ(void)if (xen_initial_domain ())pci_xen_initial_domain (); +if (xen_feature (XENFEAT_hvm_callback_vector)) { +xen_callback_vector (); +return ; + } + +/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */ + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);drivers/xen/xenbus/xenbus_client.c +1
-1@@ -743,7 +743,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {void __init xenbus_ring_ops_init (void ) { -if (xen_pv_domain ()) +if (xen_pv_domain () && !xen_feature (XENFEAT_auto_translated_physmap)) ring_ops = &ring_ops_pv;else ring_ops = &ring_ops_hvm;drivers/xen/xenbus/xenbus_probe.c +0
-0
drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 752
Quoted 5 lines
drivers/xen/xenbus/xenbus_probe.c +1
-1@@ -749,7 +749,11 @@ static int __init xenbus_init(void)if (err) goto out_error; } - xen_store_interface =mfn_to_virt (xen_store_mfn); +if (xen_feature (XENFEAT_auto_translated_physmap))
small code style issue here
drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 757
Quoted 5 lines
drivers/xen/xenbus/xenbus_probe.c +4
-0+/* mfn is actually a pfn */ + xen_store_interface =__va (xen_store_mfn<<PAGE_SHIFT ); + else + xen_store_interface =mfn_to_virt (xen_store_mfn); }
I think that mfn_to_virt should work for PVH too: mfn_to_virt is:
(__va(mfn_to_pfn(m) << PAGE_SHIFT))
and mfn_to_pfn just return mfn when XENFEAT_auto_translated_physmap is set
Quoted 14 lines · Stefano Stabellini
Quoted 14 lines
arch/x86/include/asm/xen/interface.h +5
-1@@ -136,7 +136,13 @@ struct vcpu_guest_context {struct cpu_user_regs user_regs;/* User-level CPU registers */ struct trap_info trap_ctxt[256 ];/* Virtual IDT */ unsigned long ldt_base, ldt_ents;/* LDT (linear address, # ents) */ -unsigned long gdt_frames[16 ], gdt_ents;/* GDT (machine frames, # ents) */ +union { +struct { +/* PV: GDT (machine frames, # ents).*/ +unsigned long gdt_frames[16 ], gdt_ents; + };
Quoted 8 lines
arch/x86/include/asm/xen/interface.h struct vcpu_guest_context { · line 148
Quoted 5 lines
arch/x86/include/asm/xen/interface.h +2
-0+unsigned long gdtaddr, gdtsz;/* PVH: GDTR addr and size */ + };unsigned long kernel_ss, kernel_sp;/* Virtual TSS (only SS1/SP1) */ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ unsigned long ctrlreg[8 ];/* CR0-CR7 (control registers) */ I think I'll be fully able to understand what these are for only after I read the Xen side patches...
Also won't this cause gdtaddr and gdtsz to share the same storage, since they are immediately inside a union -- I suspect that isn't what was wanted!
Quoted 33 lines · On Mon, 24 Sep 2012 12:26:57 +0100 Stefano Stabellini…
Quoted 32 lines · Mukesh Rathor
--- arch/x86/include/asm/xen/interface.h | 8 +++++++- arch/x86/include/asm/xen/page.h | 3 +++ arch/x86/xen/irq.c | 5 ++++- arch/x86/xen/p2m.c | 2 +- drivers/xen/cpu_hotplug.c | 4 +++- drivers/xen/events.c | 12 ++++++++---- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 6 +++++- include/xen/interface/memory.h | 27+++++++++++++++++++++++++++
include/xen/interface/physdev.h
| 10 ++++++++++ 10 files changed, 69 insertions(+), 10
deletions(-)(quoted diff) +0
-0
b/arch/x86/include/asm/xen/interface.hindex cbf0c9d..1d22131 100644arch/x86/include/asm/xen/interface.h +0
-0@@ -136,7 +136,13 @@ struct vcpu_guest_context {struct cpu_user_regs user_regs;/* User-level CPU registers */ struct
trap_infotrap_ctxt[256]; /* Virtual
IDT */ unsigned longldt_base,ldt_ents; /*
LDT (linear address, # ents) */
- unsigned long gdt_frames[16],gdt_ents; /* GDT (machine
frames, # ents) */arch/x86/include/asm/xen/interface.h +6
-0+union { +struct { +/* PV: GDT (machine frames, # ents).*/ +unsigned long gdt_frames[16 ], gdt_ents; + }; +unsigned long gdtaddr, gdtsz;/* PVH: GDTR addr and size */
Quoted 8 lines
Quoted 5 lines
+ };
unsigned longkernel_ss,kernel_sp; /* Virtual TSS (only
SS1/SP1) */ /* NB. User pagetable on x86/64 is placed in
ctrlreg[1]. */ unsigned long ctrlreg[8]; /* CR0-CR7
(control registers) */I think I'll be fully able to understand what these are for only after I read the Xen side patches...
When we are bringup up smp vcpu, we just need to send down gdtaddr and gdt size for vcpu context. You had suggested doing it during the code review, remember :). I had originally in xen. Anyways, earlier I was just using gdt_frames[0] for addr and gdt_ents for size. But Ian suggested I change it to union.
Quoted 19 lines
Quoted 8 lines
#include <
xen/xenbus.h>arch/x86/include/asm/xen/interface.h +1
-0+#include <xen/features.h> #include <asm/xen/hypervisor.h> #include <asm/cpu.h> arch/x86/include/asm/xen/interface.h static int __init setup_vcpu_hotplug_event(void) · line 106
Quoted 7 lines
arch/x86/include/asm/xen/interface.h +2
-1@@ -100,7 +101,8 @@ static int __init setup_vcpu_hotplug_event(void)static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; -if (!xen_pv_domain ()) +/* PVH TBD/FIXME: future work */ +if (!xen_pv_domain () ||xen_feature (XENFEAT_auto_translated_physmap))return -ENODEV ;Didn't we say that a PVH domain is actually a pv guest? In that case shouldn't the test
Quoted 3 lines
if (!xen_pv_domain())
be sufficient?
No, for HVM and PVH, we want to return -ENODEV.
Quoted 45 lines
Quoted 41 lines
arch/x86/include/asm/xen/interface.h +0
-0register_xenstore_notifier (&xsn_cpu);drivers/xen/events.c +1
-1@@ -1755,7 +1755,7 @@ int xen_set_callback_via(uint64_t via) }EXPORT_SYMBOL_GPL (xen_set_callback_via); -#ifdef CONFIG_XEN_PVHVM +/* Vector callbacks are better than PCI interrupts to receive event * channel notifications because we can receive vector callbacks on any
* vcpu and we don't need PCI support or APIC interactions. */drivers/xen/events.c +6
-3@@ -1779,9 +1779,6 @@ void xen_callback_vector(void)alloc_intr_gate (XEN_HVM_EVTCHN_CALLBACK , xen_hvm_callback_vector); } } -#else -void xen_callback_vector (void ) {} -#endif void __init xen_init_IRQ (void ) {@@ -1814,6 +1811,13 @@ void __init xen_init_IRQ(void)if (xen_initial_domain ())pci_xen_initial_domain (); +if (xen_feature (XENFEAT_hvm_callback_vector)) { +xen_callback_vector (); +return ; + } + +/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */ +
pirq_eoi_map= (void__va(xen_store_mfn<<PAGE_SHIFT);drivers/xen/events.c +2
-0+else + xen_store_interface =Quoted 1 line
mfn_to_virt(xen_store_mfn); }I think that
mfn_to_virtshould work for PVH too:mfn_to_virtis:
Quoted 4 lines
(
__va(mfn_to_pfn(m) << PAGE_SHIFT))and
mfn_to_pfnjust return mfn whenXENFEAT_auto_translated_physmapis set
You are right. Testing it out.
NB typo in the subject line.
Quoted 1 line · Mukesh Rathor
drivers/xen/xenbus/xenbus_client.c | 2 +-
I needed this fixup to build on ARM after this patch:
8<----------------------------------------------
Quoted 1 line
From
f4d7d3ea58d1cb673632d8e65fc40a4c84a1d213Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 26 Sep 2012 14:35:39 +0100
Subject: [PATCH] xenbus: include features header.
Fixes:drivers/xen/xenbus/xenbus_probe.c: In function 'xenbus_init':drivers/xen/xenbus/xenbus_probe.c:760:3: error: implicit declaration of function 'xen_feature' [-Werror=implicit-function-declaration] drivers/xen/xenbus/xenbus_probe.c:760:19: error: 'XENFEAT_auto_translated_physmap' undeclared (first use in this function) drivers/xen/xenbus/xenbus_probe.c:760:19: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
--- drivers/xen/xenbus/xenbus_probe.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/xen/xenbus/xenbus_probe.c +1 -0
@@ -56,6 +56,7 @@#include <xen/xenbus.h> #include <xen/events.h> #include <xen/page.h> +#include <xen/features.h> #include <xen/hvm.h>
Signature · 1 line
1.7.2.5
Quoted 24 lines · Mukesh Rathor
drivers/xen/events.c +1
-1@@ -1755,7 +1755,7 @@ int xen_set_callback_via(uint64_t via) }EXPORT_SYMBOL_GPL (xen_set_callback_via); -#ifdef CONFIG_XEN_PVHVM +/* Vector callbacks are better than PCI interrupts to receive event * channel notifications because we can receive vector callbacks on any
* vcpu and we don't need PCI support or APIC interactions. */drivers/xen/events.c +0
-3@@ -1779,9 +1779,6 @@ void xen_callback_vector(void)alloc_intr_gate (XEN_HVM_EVTCHN_CALLBACK , xen_hvm_callback_vector); } } -#else -void xen_callback_vector (void ) {} -#endif void __init xen_init_IRQ (void )
Quoted 1 line
{
This breaks on ARM because this like XEN_HVM_EVTCHN_CALLBACK, which are inside this ifdef, are actually X86 specific.
I suspect that xen_callback_vector needs to be moved in to an arch specific file so that we can supply a suitably different implementation on ARM -- Stefano what do you think?
Ian.
Quoted 5 lines
include/xen/interface/memory.h +0
-0
include/xen/interface/memory.h struct xen_add_to_physmap { · line 172
Quoted 10 lines
include/xen/interface/memory.h +6
-0@@ -163,11 +163,22 @@ struct xen_add_to_physmap {/* Which domain to change the mapping for. */ domid_t domid; +union { +/* Number of pages to go through for gmfn_range */ +uint16_t size; +/* IFF XENMAPSPACE_gmfn_foreign */ +domid_t foreign_domid; + } u;/* Source mapping space. */
So found out why it crashed on PVHVM. If you rebase your patch on top of b58aaa4b0b3506c094308342d746f600468c63d9
Author: Stefano Stabellini <[email protected]> Date: Mon Aug 6 15:27:24 2012 +0100
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 <[email protected]>
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.
the merge ends up looking like this:
@ -166,11 +166,22 @@ struct xen_add_to_physmap {
/* Number of pages to go through for gmfn_range */
uint16_t size;+ union {
+ /* Number of pages to go through for gmfn_range */
+ uint16_t size;
+ /* IFF XENMAPSPACE_gmfn_foreign */
+ domid_t foreign_domid;
+ } u;
Grrrr..
Quoted 158 lines · Mukesh Rathor
--- arch/x86/include/asm/xen/interface.h | 8 +++++++- arch/x86/include/asm/xen/page.h | 3 +++ arch/x86/xen/irq.c | 5 ++++- arch/x86/xen/p2m.c | 2 +- drivers/xen/cpu_hotplug.c | 4 +++- drivers/xen/events.c | 12 ++++++++---- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 6 +++++- include/xen/interface/memory.h | 27 +++++++++++++++++++++++++++ include/xen/interface/physdev.h | 10 ++++++++++ 10 files changed, 69 insertions(+), 10 deletions(-)arch/x86/include/asm/xen/interface.h +7
-1@@ -136,7 +136,13 @@ struct vcpu_guest_context {struct cpu_user_regs user_regs;/* User-level CPU registers */ struct trap_info trap_ctxt[256 ];/* Virtual IDT */ unsigned long ldt_base, ldt_ents;/* LDT (linear address, # ents) */ -unsigned long gdt_frames[16 ], gdt_ents;/* GDT (machine frames, # ents) */ +union { +struct { +/* PV: GDT (machine frames, # ents).*/ +unsigned long gdt_frames[16 ], gdt_ents; + }; +unsigned long gdtaddr, gdtsz;/* PVH: GDTR addr and size */ + };unsigned long kernel_ss, kernel_sp;/* Virtual TSS (only SS1/SP1) */ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ unsigned long ctrlreg[8 ];/* CR0-CR7 (control registers) */ arch/x86/include/asm/xen/page.h +3
-0@@ -158,6 +158,9 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)static inline unsigned long mfn_to_local_pfn (unsigned long mfn) {unsigned long pfn =mfn_to_pfn (mfn); + +if (xen_feature (XENFEAT_auto_translated_physmap)) +return mfn;if (get_phys_to_machine (pfn) != mfn)return -1 ;/* force !pfn_valid() */ return pfn;arch/x86/xen/irq.c +4
-1@@ -5,6 +5,7 @@#include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/vcpu.h> +#include <xen/features.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -128,6 +129,8 @@ static const struct pv_irq_ops xen_irq_ops __initconst = {void __init xen_init_irq_ops (void ) { - pv_irq_ops = xen_irq_ops; +/* For PVH we use default pv_irq_ops settings */ +if (!xen_feature (XENFEAT_hvm_callback_vector)) + pv_irq_ops = xen_irq_ops; x86_init.irqs.intr_init = xen_init_IRQ; }arch/x86/xen/p2m.c +1
-1@@ -626,7 +626,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) {unsigned topidx, mididx, idx; -if (unlikely (xen_feature (XENFEAT_auto_translated_physmap))) { +if (xen_feature (XENFEAT_auto_translated_physmap)) {BUG_ON (pfn != mfn && mfn !=INVALID_P2M_ENTRY );return true; }drivers/xen/cpu_hotplug.c +3
-1@@ -2,6 +2,7 @@#include <xen/xen.h> #include <xen/xenbus.h> +#include <xen/features.h> #include <asm/xen/hypervisor.h> #include <asm/cpu.h> @@ -100,7 +101,8 @@ static int __init setup_vcpu_hotplug_event(void)static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; -if (!xen_pv_domain ()) +/* PVH TBD/FIXME: future work */ +if (!xen_pv_domain () ||xen_feature (XENFEAT_auto_translated_physmap))return -ENODEV ;register_xenstore_notifier (&xsn_cpu);drivers/xen/events.c +8
-4@@ -1755,7 +1755,7 @@ int xen_set_callback_via(uint64_t via) }EXPORT_SYMBOL_GPL (xen_set_callback_via); -#ifdef CONFIG_XEN_PVHVM +/* Vector callbacks are better than PCI interrupts to receive event * channel notifications because we can receive vector callbacks on any * vcpu and we don't need PCI support or APIC interactions. */ @@ -1779,9 +1779,6 @@ void xen_callback_vector(void)alloc_intr_gate (XEN_HVM_EVTCHN_CALLBACK , xen_hvm_callback_vector); } } -#else -void xen_callback_vector (void ) {} -#endif void __init xen_init_IRQ (void ) {@@ -1814,6 +1811,13 @@ void __init xen_init_IRQ(void)if (xen_initial_domain ())pci_xen_initial_domain (); +if (xen_feature (XENFEAT_hvm_callback_vector)) { +xen_callback_vector (); +return ; + } + +/* PVH: TBD/FIXME: debug and fix eio map to work with pvh */ + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);drivers/xen/xenbus/xenbus_client.c +1
-1@@ -743,7 +743,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {void __init xenbus_ring_ops_init (void ) { -if (xen_pv_domain ()) +if (xen_pv_domain () && !xen_feature (XENFEAT_auto_translated_physmap)) ring_ops = &ring_ops_pv;else ring_ops = &ring_ops_hvm;drivers/xen/xenbus/xenbus_probe.c +0
-0
drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 752
Quoted 5 lines
drivers/xen/xenbus/xenbus_probe.c +1
-1@@ -749,7 +749,11 @@ static int __init xenbus_init(void)if (err) goto out_error; } - xen_store_interface =mfn_to_virt (xen_store_mfn); +if (xen_feature (XENFEAT_auto_translated_physmap))
code style: spaces vs tabs
Quoted 12 lines
drivers/xen/xenbus/xenbus_probe.c +4
-0+/* mfn is actually a pfn */ + xen_store_interface =__va (xen_store_mfn<<PAGE_SHIFT ); + else + xen_store_interface =mfn_to_virt (xen_store_mfn); }/* Initialize the interface to xenstore. */ include/xen/interface/memory.h +0
-0
include/xen/interface/memory.h struct xen_add_to_physmap { · line 171
Quoted 9 lines
include/xen/interface/memory.h +6
-0@@ -163,11 +163,22 @@ struct xen_add_to_physmap {/* Which domain to change the mapping for. */ domid_t domid; +union { +/* Number of pages to go through for gmfn_range */ +uint16_t size; +/* IFF XENMAPSPACE_gmfn_foreign */ +domid_t foreign_domid; + } u;
code style: mixed spaces and tabs
Quoted 58 lines
include/xen/interface/memory.h +21
-0/* Source mapping space. */ #define XENMAPSPACE_shared_info 0/* shared info page */ #define XENMAPSPACE_grant_table 1/* grant table page */ +#define XENMAPSPACE_gmfn 2/* GMFN */ +#define XENMAPSPACE_gmfn_range 3/* GMFN range */ +#define XENMAPSPACE_gmfn_foreign 4/* GMFN from another guest */ unsigned int space; +#define XENMAPIDX_grant_table_status 0x80000000 +/* Index into source mapping space. */ unsigned long idx;@@ -234,4 +245,20 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);* during a driver critical region. */ extern spinlock_t xen_reservation_lock; + +/* +* Unmaps the page appearing at a particular GPFN from the specified guest's +* pseudophysical address space. +* arg == addr of xen_remove_from_physmap_t. +*/ +#define XENMEM_remove_from_physmap 15 +struct xen_remove_from_physmap { +/* Which domain to change the mapping for. */ +domid_t domid; + +/* GPFN of the current mapping of the page. */ +unsigned long gpfn; +}; +DEFINE_GUEST_HANDLE_STRUCT (xen_remove_from_physmap); +#endif /* __XEN_PUBLIC_MEMORY_H__ */ include/xen/interface/physdev.h +10
-0@@ -258,6 +258,16 @@ struct physdev_pci_device {uint8_t devfn; }; +#define PHYSDEVOP_pvh_map_iomem 29 +struct physdev_map_iomem { +/* IN */ +uint64_t first_gfn; +uint64_t first_mfn; +uint32_t nr_mfns; +uint32_t add_mapping;/* 1 == add mapping; 0 == unmap */ + +}; +/* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is ** Signature · 1 line
1.7.2.3
The title says ' hader' - it should say 'header'.
Also there is a missing description of what it does, and how this works. For an example check out:
f4cec35b0d4b90d96e3770a3d1e68ea882e7a7c8
(which added the 1-1 P2M notion), or:357a3cfb147ee8e97c6f9cdc51e9a33aa56f7d99
(for the > 128gb support).
It needs to be verbose with lots of details.
Quoted 13 lines · Stefano Stabellini
Quoted 12 lines · Mukesh Rathor
--- arch/x86/include/asm/xen/interface.h | 8 +++++++- arch/x86/include/asm/xen/page.h | 3 +++ arch/x86/xen/irq.c | 5 ++++- arch/x86/xen/p2m.c | 2 +- drivers/xen/cpu_hotplug.c | 4 +++- drivers/xen/events.c | 12 ++++++++---- drivers/xen/xenbus/xenbus_client.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 6 +++++- include/xen/interface/memory.h | 27 +++++++++++++++++++++++++++ include/xen/interface/physdev.h | 10 ++++++++++ 10 files changed, 69 insertions(+), 10 deletions(-)
Quoted 11 lines · Mukesh Rathor
(quoted diff) +3
-0@@ -234,4 +245,20 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map); * during a driver critical region. */ extern spinlock_t xen_reservation_lock; + +/* + * Unmaps the page appearing at a particular GPFN from the specifiedguest's
+ * pseudophysical address space.
+ * arg == addr ofxen_remove_from_physmap_t.
+ */
Review
Quoted 9 lines
(quoted diff) +9
-0+#define XENMEM_remove_from_physmap 15 +struct xen_remove_from_physmap { + /* Which domain to change the mapping for. */ + domid_t domid; + + /* GPFN of the current mapping of the page. */ + unsigned long gpfn; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);
I needed this fixup in a tree with both the ARM and PVH stuff:
8<------------------------------------
Quoted 1 line
From
d56a302734180171855e0ee07571ac0cee69b3e5Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Thu, 4 Oct 2012 10:45:52 +0100
Subject: [PATCH] xen: use xen_pft_t in struct xen_remove_from_physmap
4a6c2b4 "PVH basic and hader file changes" and bd3f79b "xen: Introduce xen_pfn_t for pfn and mfn types" passed like ships in the night.
--- include/xen/interface/memory.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/xen/interface/memory.h +1 -1
@@ -258,7 +258,7 @@ struct xen_remove_from_physmap {domid_t domid;/* GPFN of the current mapping of the page. */ -unsigned long gpfn; +xen_pfn_t gpfn; };DEFINE_GUEST_HANDLE_STRUCT (xen_remove_from_physmap);
Signature · 1 line
1.7.2.5
Quoted 26 lines · Ian Campbell
Quoted 11 lines · Mukesh Rathor
(quoted diff) +3
-0@@ -234,4 +245,20 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map); * during a driver critical region. */ extern spinlock_t xen_reservation_lock; + +/* + * Unmaps the page appearing at a particular GPFN from the specifiedguest's
+ * pseudophysical address space.
+ * arg == addr ofxen_remove_from_physmap_t.
+ */Review
Quoted 9 lines
(quoted diff) +9
-0+#define XENMEM_remove_from_physmap 15 +struct xen_remove_from_physmap { + /* Which domain to change the mapping for. */ + domid_t domid; + + /* GPFN of the current mapping of the page. */ + unsigned long gpfn; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);I needed this fixup in a tree with both the ARM and PVH stuff:
8<------------------------------------
Quoted 7 lines
Quoted 1 line
From
d56a302734180171855e0ee07571ac0cee69b3e5Mon Sep 17 00:00:00 2001From: Ian Campbell <[email protected]>
Date: Thu, 4 Oct 2012 10:45:52 +0100
Subject: [PATCH] xen: usexen_pft_tin structxen_remove_from_physmap4a6c2b4 "PVH basic and hader file changes" and bd3f79b "xen: Introduce
xen_pfn_tfor pfn and mfn types" passed like ships in the night.
.. and at least they did not collide with each other :-)
Quoted 31 lines
Signed-off-by Ian Campbell <[email protected]>--- include/xen/interface/memory.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)include/xen/interface/memory.h +1
-2@@ -258,7 +258,7 @@ struct xen_remove_from_physmap {domid_t domid;/* GPFN of the current mapping of the page. */ -unsigned long gpfn; +xen_pfn_t gpfn; };DEFINE_GUEST_HANDLE_STRUCT (xen_remove_from_physmap); --1.7.2.5
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel