Skip to contentSkip to conversation

backport requests for 4.x-testing

DISCUSSION Applied Jan Beulich 10 participants 53 messages Mar 6, 2012 – Apr 4, 2012 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

For 4.0 and 4.1:
24155 (x86/IO-APIC: refine EOI-ing of migrating level interrupts) 24190 (x86/mm: change return code for log-dirty disabling)
24201 (x86: small fixes to pcpu platform op handling)
24282 (x86/mm: Don't lose track of the log dirty bitmap)
24389 (x86, amd: Disable GartTlbWlkErr when BIOS forgets it)
24417 (x86/emulator: workaround for AMD erratum 573)
24535 (x86/vMSI: miscellaneous fixes)
24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

For 4.1:
23853+23955 (pv cpuid emulation for xsave)
23908 (p2m: query/modify p2mt with p2m_lock held)
24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

24157 (x86/xsave: provide guests with finit-like environment) 24357 (tools/firmware: remove "_PS0/3" Method)
24448 (x86/passthrough: don't leak guest IRQs)
24517 (Move IOMMU faults handling into softirq for VT-d)
24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi) 24701 (Fix error recovery path in __gnttab_map_grant_ref)
24883 (x86/mm: Don't check for invalid bits in non-present PTEs) 24950 (Grant table: fix a bug when grant copying a previous grant mapped page)

For 4.0 (already in 4.1)
24168 (x86/vioapic: clear remote IRR when switching RTE to edge triggered mode) 24193 (Trivial fix for rc val in hap track dirty vram)
24344+24345 (tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone) 24358 (KEXEC: fix kexec_get_range_compat to fail vocally)
24690 (x86: avoid deadlock after a PCI SERR NMI)
24742 (gnttab: miscellaneous fixes)

Especially some of the 4.0 ones may be non-trivial backports - already backported version can be provided.

Thanks, Jan

#1 lore raw
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

I will take a look and report back on ones that need non-trivial porting effort.

-- Keir

Quoted 45 lines

For 4.0 and 4.1:
24155 (x86/IO-APIC: refine EOI-ing of migrating level interrupts) 24190 (x86/mm: change return code for log-dirty disabling) 24201 (x86: small fixes to pcpu platform op handling)
24282 (x86/mm: Don't lose track of the log dirty bitmap) 24389 (x86, amd: Disable GartTlbWlkErr when BIOS forgets it) 24417 (x86/emulator: workaround for AMD erratum 573)
24535 (x86/vMSI: miscellaneous fixes)
24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

For 4.1:
23853+23955 (pv cpuid emulation for xsave)
23908 (p2m: query/modify p2mt with p2m_lock held)
24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

24157 (x86/xsave: provide guests with finit-like environment) 24357 (tools/firmware: remove "_PS0/3" Method)
24448 (x86/passthrough: don't leak guest IRQs)
24517 (Move IOMMU faults handling into softirq for VT-d)
24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi) 24701 (Fix error recovery path in __gnttab_map_grant_ref)
24883 (x86/mm: Don't check for invalid bits in non-present PTEs) 24950 (Grant table: fix a bug when grant copying a previous grant mapped page)

For 4.0 (already in 4.1)
24168 (x86/vioapic: clear remote IRR when switching RTE to edge triggered mode)
24193 (Trivial fix for rc val in hap track dirty vram) 24344+24345 (tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone)
24358 (KEXEC: fix kexec_get_range_compat to fail vocally)
24690 (x86: avoid deadlock after a PCI SERR NMI)
24742 (gnttab: miscellaneous fixes)

Especially some of the 4.0 ones may be non-trivial backports - already backported version can be provided.

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Jan Beulich
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions. These are all patches which we have cherry picked for XenServer.

The changesets with *'s are not a clean backport, and I can provide patches against Xen-4.1.x for them.

Quoted 11 lines

For 4.0 and 4.1:
24155 (x86/IO-APIC: refine EOI-ing of migrating level interrupts) 24190 (x86/mm: change return code for log-dirty disabling)
24201 (x86: small fixes to pcpu platform op handling)
24282 (x86/mm: Don't lose track of the log dirty bitmap)
24389 (x86, amd: Disable GartTlbWlkErr when BIOS forgets it)
24417 (x86/emulator: workaround for AMD erratum 573)
24535 (x86/vMSI: miscellaneous fixes)
24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

For 4.1:

23554 (shadow: adjust early heuristics)
23610 (x86: consolidate cpu_core_id and phys_proc_id) 23611 (AMD: core-pair detection)
23795* (x86: ICH10 Quirks) - We have just had to backport this for a customer escalation on xen-3.x, if it would be accepted there 23811* (UART: dont write spurious char)

Quoted 2 lines

23853+23955 (pv cpuid emulation for xsave)
23908 (p2m: query/modify p2mt with p2m_lock held)

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes)

Quoted 3 lines

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

24157 (x86/xsave: provide guests with finit-like environment)

24320 (ocaml: release global lock during some hypercalls)

Quoted 1 line

24357 (tools/firmware: remove "_PS0/3" Method)

24414 (oxenstored: install configuration file)

Quoted 1 line

24448 (x86/passthrough: don't leak guest IRQs)

(I can provide a backported version of 24448 if required)

Quoted 1 line

24517 (Move IOMMU faults handling into softirq for VT-d)

24518 (sched_credit: performance improvement)

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

24542, 24543, 24570, 24571 (xenoprof fixes)

Quoted 1 line

24701 (Fix error recovery path in __gnttab_map_grant_ref)

24709 (libxc: replace malloc with alloca on hot path) 24832 (libxc: remove tests of alloca() return value) 24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Quoted 21 lines

24883 (x86/mm: Don't check for invalid bits in non-present PTEs) 24950 (Grant table: fix a bug when grant copying a previous grant mapped page)

For 4.0 (already in 4.1)
24168 (x86/vioapic: clear remote IRR when switching RTE to edge triggered mode) 24193 (Trivial fix for rc val in hap track dirty vram)
24344+24345 (tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone) 24358 (KEXEC: fix kexec_get_range_compat to fail vocally)
24690 (x86: avoid deadlock after a PCI SERR NMI)
24742 (gnttab: miscellaneous fixes)

Especially some of the 4.0 ones may be non-trivial backports - already backported version can be provided.

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
#3 lore raw

I would like to nominate 2 patches to be backported to Xen 4.1:
24458 (libxl: print out vifname in create dryrun.) 24459 (libxl: write vifname in xenstore if set.)

Thanks,
Roderick Colenbrander

Quoted 76 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions.  These are all patches which we have cherry picked for XenServer.

The changesets with *'s are not a clean backport, and I can provide patches against Xen-4.1.x for them.

Quoted 11 lines

For 4.0 and 4.1:
24155 (x86/IO-APIC: refine EOI-ing of migrating level interrupts) 24190 (x86/mm: change return code for log-dirty disabling)
24201 (x86: small fixes to pcpu platform op handling)
24282 (x86/mm: Don't lose track of the log dirty bitmap)
24389 (x86, amd: Disable GartTlbWlkErr when BIOS forgets it)
24417 (x86/emulator: workaround for AMD erratum 573)
24535 (x86/vMSI: miscellaneous fixes)
24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

For 4.1:

23554 (shadow: adjust early heuristics)
23610 (x86: consolidate cpu_core_id and phys_proc_id) 23611 (AMD: core-pair detection)
23795* (x86: ICH10 Quirks) - We have just had to backport this for a customer escalation on xen-3.x, if it would be accepted there 23811* (UART: dont write spurious char)

Quoted 2 lines

23853+23955 (pv cpuid emulation for xsave)
23908 (p2m: query/modify p2mt with p2m_lock held)

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes)

Quoted 3 lines

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring 23900 [kzalloc])
24157 (x86/xsave: provide guests with finit-like environment)

24320 (ocaml: release global lock during some hypercalls)

Quoted 1 line

24357 (tools/firmware: remove "_PS0/3" Method)

24414 (oxenstored: install configuration file)

Quoted 1 line

24448 (x86/passthrough: don't leak guest IRQs)

(I can provide a backported version of 24448 if required)

Quoted 1 line

24517 (Move IOMMU faults handling into softirq for VT-d)

24518 (sched_credit: performance improvement)

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

24542, 24543, 24570, 24571 (xenoprof fixes)

Quoted 1 line

24701 (Fix error recovery path in __gnttab_map_grant_ref)

24709 (libxc: replace malloc with alloca on hot path) 24832 (libxc: remove tests of alloca() return value) 24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Quoted 14 lines

24883 (x86/mm: Don't check for invalid bits in non-present PTEs) 24950 (Grant table: fix a bug when grant copying a previous grant mapped page)

For 4.0 (already in 4.1)
24168 (x86/vioapic: clear remote IRR when switching RTE to edge triggered mode) 24193 (Trivial fix for rc val in hap track dirty vram)
24344+24345 (tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone) 24358 (KEXEC: fix kexec_get_range_compat to fail vocally)
24690 (x86: avoid deadlock after a PCI SERR NMI)
24742 (gnttab: miscellaneous fixes)

Especially some of the 4.0 ones may be non-trivial backports - already backported version can be provided.

Quoted 7 lines

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

--
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 3 lines · Roderick Colenbrander

I would like to nominate 2 patches to be backported to Xen 4.1:
24458 (libxl: print out vifname in create dryrun.) 24459 (libxl: write vifname in xenstore if set.)

These need to be Acked or backported by a toolstack maintainer.

-- Keir

Quoted 90 lines

Thanks,
Roderick Colenbrander

Quoted 76 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions.  These are all patches which we have cherry picked for XenServer.

The changesets with *'s are not a clean backport, and I can provide patches against Xen-4.1.x for them.

Quoted 11 lines

For 4.0 and 4.1:
24155 (x86/IO-APIC: refine EOI-ing of migrating level interrupts) 24190 (x86/mm: change return code for log-dirty disabling) 24201 (x86: small fixes to pcpu platform op handling)
24282 (x86/mm: Don't lose track of the log dirty bitmap) 24389 (x86, amd: Disable GartTlbWlkErr when BIOS forgets it) 24417 (x86/emulator: workaround for AMD erratum 573)
24535 (x86/vMSI: miscellaneous fixes)
24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

Quoted 1 line

For 4.1:

23554 (shadow: adjust early heuristics)
23610 (x86: consolidate cpu_core_id and phys_proc_id) 23611 (AMD: core-pair detection)
23795* (x86: ICH10 Quirks) - We have just had to backport this for a customer escalation on xen-3.x, if it would be accepted there 23811* (UART: dont write spurious char)

Quoted 2 lines

23853+23955 (pv cpuid emulation for xsave)
23908 (p2m: query/modify p2mt with p2m_lock held)

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes)

Quoted 3 lines

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring 23900 [kzalloc])
24157 (x86/xsave: provide guests with finit-like environment)

24320 (ocaml: release global lock during some hypercalls)

Quoted 1 line

24357 (tools/firmware: remove "_PS0/3" Method)

24414 (oxenstored: install configuration file)

Quoted 1 line

24448 (x86/passthrough: don't leak guest IRQs)

(I can provide a backported version of 24448 if required)

Quoted 1 line

24517 (Move IOMMU faults handling into softirq for VT-d)

24518 (sched_credit: performance improvement)

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

24542, 24543, 24570, 24571 (xenoprof fixes)

Quoted 1 line

24701 (Fix error recovery path in __gnttab_map_grant_ref)

24709 (libxc: replace malloc with alloca on hot path) 24832 (libxc: remove tests of alloca() return value) 24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Quoted 17 lines

24883 (x86/mm: Don't check for invalid bits in non-present PTEs) 24950 (Grant table: fix a bug when grant copying a previous grant mapped page)

For 4.0 (already in 4.1)
24168 (x86/vioapic: clear remote IRR when switching RTE to edge triggered mode)
24193 (Trivial fix for rc val in hap track dirty vram) 24344+24345 (tools/x86_64: Fix cpuid() inline asm to not clobber stack's red zone)
24358 (KEXEC: fix kexec_get_range_compat to fail vocally)
24690 (x86: avoid deadlock after a PCI SERR NMI)
24742 (gnttab: miscellaneous fixes)

Especially some of the 4.0 ones may be non-trivial backports - already backported version can be provided.

Quoted 7 lines

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

--
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
In reply to Roderick Colenbrander

Roderick Colenbrander writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 3 lines

I would like to nominate 2 patches to be backported to Xen 4.1:
24458 (libxl: print out vifname in create dryrun.) 24459 (libxl: write vifname in xenstore if set.)

I have backported 24458. 24459 looks fine to be for a backport but doesn't apply cleanly to 4.1. Would you care to provide a backported version ?

Thanks,
Ian.

Acked-by Ian Campbell
#6 lore raw
Quoted 8 lines · Ian Jackson

Roderick Colenbrander writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 3 lines

I would like to nominate 2 patches to be backported to Xen 4.1:
24458 (libxl: print out vifname in create dryrun.) 24459 (libxl: write vifname in xenstore if set.)

I have backported 24458.  24459 looks fine to be for a backport but doesn't apply cleanly to 4.1.  Would you care to provide a backported version ?

Sorry, just feel bored and here is the backport version which I not sure whether is it right :p Mind to check? Thanks.

libxl: write vifname in xenstore if set.

Simple fix to enable user to specify vif names.

Acked-by Ian Campbell <ian.campbell.com>

xen-unstable changeset: 24459:caf9753d4cc1

tools/libxl/libxl.c 2012-03-14 01:15:27.000000000 +0800 renamed from tools/libxl/libxl.c 2012-03-14 00:49:03.000000000 +0800 +4 -0
diff -urN a/tools/libxl/libxl.c b/tools/libxl/libxl.c
@@ -1229,6 +1229,10 @@
     flexarray_append(back, libxl__sprintf(&gc, "%d", 1));
     flexarray_append(back, "script");
     flexarray_append(back, nic->script);
+    if (nic->ifname) {
+       flexarray_append(back, "vifname");
+       flexarray_append(back, nic->ifname);
+    }
     flexarray_append(back, "mac");
     flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                                  nic->mac[0],

nic->mac[1], nic->mac[2],

Quoted 3 lines

Thanks,
Ian.

Thanks.

Kindest regards,
Giam Teck Choon

#9 lore raw

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 1 line

Sorry, one more cs 24593 ?

That one looks reasonable. Done.

Ian.

#11 lore raw
In reply to Teck Choon Giam

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 8 lines

libxl: write vifname in xenstore if set.

Simple fix to enable user to specify vif names.

Acked-by Ian Campbell <ian.campbell.com>

xen-unstable changeset: 24459:caf9753d4cc1

Thanks, this looks good but I really ought to ask you for your signoff. See http://wiki.xen.org/wiki/Submitting_Xen_Patches

Ian.

Acked-by Ian Campbell
#12 lore raw
Quoted 10 lines · Ian Jackson

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 8 lines

libxl: write vifname in xenstore if set.

Simple fix to enable user to specify vif names.

Acked-by Ian Campbell <ian.campbell.com>

xen-unstable changeset: 24459:caf9753d4cc1

Quoted 4 lines

Thanks, this looks good but I really ought to ask you for your signoff.  See http://wiki.xen.org/wiki/Submitting_Xen_Patches

Ian.

Sorry, attached is the backport patch. I added new lines to follow the original changeset in unstable.

For your review please.

Thanks.

Kindest regards,
Giam Teck Choon

libxl: write vifname in xenstore if set.

Simple fix to enable user to specify vif names.

Acked-by Ian Campbell <ian.campbell.com>

xen-unstable changeset: 24459:caf9753d4cc1

tools/libxl/libxl.c 2012-03-14 01:34:28.000000000 +0800 renamed from tools/libxl/libxl.c 2012-03-14 00:49:03.000000000 +0800 +6 -0
diff -urN a/tools/libxl/libxl.c b/tools/libxl/libxl.c
@@ -1229,6 +1229,12 @@
     flexarray_append(back, libxl__sprintf(&gc, "%d", 1));
     flexarray_append(back, "script");
     flexarray_append(back, nic->script);
+
+    if (nic->ifname) {
+       flexarray_append(back, "vifname");
+       flexarray_append(back, nic->ifname);
+    }
+
     flexarray_append(back, "mac");
     flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                                  nic->mac[0], nic->mac[1], nic->mac[2],

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

libxl: write vifname in xenstore if set.

Simple fix to enable user to specify vif names.

xen-unstable changeset: 24459:caf9753d4cc1

---
 tools/libxl/libxl.c |    6 ++++++
 1 file changed, 6 insertions(+)
tools/libxl/libxl.c +0 -0
index 902f282..19ef6a0 100644
@@ -1229,6 +1229,12 @@ int libxl_device_nic_add(libxl_ctx *ctx,

uint32_t domid, libxl_device_nic *nic)

     flexarray_append(back, libxl__sprintf(&gc, "%d", 1));
     flexarray_append(back, "script");
     flexarray_append(back, nic->script);

+
+ if (nic->ifname) {
+ flexarray_append(back, "vifname");
+ flexarray_append(back, nic->ifname);
+ }
+

     flexarray_append(back, "mac");
     flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                                  nic->mac[0],

nic->mac[1], nic->mac[2],

#15 lore raw
In reply to Andrew Cooper
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions. These are all patches which we have cherry picked for XenServer.

All applied except as follows:

Quoted 3 lines

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes) 24320 (ocaml: release global lock during some hypercalls) 24414 (oxenstored: install configuration file)

These need to be Acked or backported by a toolstack maintainer.

Quoted 1 line

24542, 24543, 24570, 24571 (xenoprof fixes)

These changesets do not relate to xenoprof??

Quoted 1 line

24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Too hard to backport. Please provide your backported version.

-- Keir

#16 lore raw
Quoted 9 lines · Keir Fraser
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions. These are all patches which we have cherry picked for XenServer.

All applied except as follows:

Quoted 7 lines
Quoted 3 lines

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes) 24320 (ocaml: release global lock during some hypercalls) 24414 (oxenstored: install configuration file)

These need to be Acked or backported by a toolstack maintainer.

Quoted 1 line

24542, 24543, 24570, 24571 (xenoprof fixes)

These changesets do not relate to xenoprof??

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

The numbers were in fact 24536,24537,24564,24565.

Quoted 2 lines
Quoted 1 line

24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Too hard to backport. Please provide your backported version.

Attached.

Quoted 3 lines

-- Keir

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com

# HG changeset patch
# User Andrew Cooper <[email protected]>
# Date 1329991127 0
# Node ID 9bf3ec036bef2b67338bf5685423e26de69bd031
# Parent c0412e6399fdc5048b4eeefa6a45822890309c72
IO-APIC: Prevent using EOI broadcast suppression if user specified ioapic_ack=new on the command line.

Currently, if EOI broadcast suppression is advertised on the BSP LAPIC, Xen will discard any user specified option regarding IO-APIC ack mode.

This patch introduces a check which prevents EOI Broadcast suppression from forcing the IO-APIC ack mode to old if the user has explicitly asked for the new ack mode on the command line.

xen/arch/x86/apic.c +9 -3
diff -r c0412e6399fd xen/arch/x86/apic.c
@@ -437,9 +437,15 @@ int __init verify_local_APIC(void)
      */
     if ( reg0 & APIC_LVR_DIRECTED_EOI )
     {
-        ioapic_ack_new = 0;
-        directed_eoi_enabled = 1;
-        printk("Enabled directed EOI with ioapic_ack_old on!\n");
+        if ( ioapic_ack_new == 1 && ioapic_ack_forced == 1 )
+            printk("Not enabling directed EOI because ioapic_ack_new has been "
+                   "forced on the command line\n");
+        else
+        {
+            ioapic_ack_new = 0;
+            directed_eoi_enabled = 1;
+            printk("Enabled directed EOI with ioapic_ack_old on!\n");
+        }
     }
 
     /*
xen/arch/x86/io_apic.c +7 -0
diff -r c0412e6399fd xen/arch/x86/io_apic.c
@@ -44,6 +44,7 @@ static struct { int pin, apic; } ioapic_
 static DEFINE_SPINLOCK(ioapic_lock);
 
 bool_t __read_mostly skip_ioapic_setup;
+bool_t __read_mostly ioapic_ack_forced = 0;
 
 #ifndef sis_apic_bug
 /*
@@ -1664,9 +1665,15 @@ int __read_mostly ioapic_ack_new = 1;
 static void setup_ioapic_ack(char *s)
 {
     if ( !strcmp(s, "old") )
+    {
         ioapic_ack_new = 0;
+        ioapic_ack_forced = 1;
+    }
     else if ( !strcmp(s, "new") )
+    {
         ioapic_ack_new = 1;
+        ioapic_ack_forced = 1;
+    }
     else
         printk("Unknown ioapic_ack value specified: '%s'\n", s);
 }
xen/include/asm-x86/io_apic.h +1 -0
diff -r c0412e6399fd xen/include/asm-x86/io_apic.h
@@ -179,6 +179,7 @@ static inline void io_apic_modify(unsign
 
 /* 1 if "noapic" boot option passed */
 extern bool_t skip_ioapic_setup;
+extern bool_t ioapic_ack_forced;
 
 #ifdef CONFIG_ACPI_BOOT
 extern int io_apic_get_unique_id (int ioapic, int apic_id);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#17 lore raw
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Keir Fraser
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

May I add the following suggestions. These are all patches which we have cherry picked for XenServer.

All applied except as follows:

Quoted 3 lines

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes) 24320 (ocaml: release global lock during some hypercalls) 24414 (oxenstored: install configuration file)

These need to be Acked or backported by a toolstack maintainer.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

24542, 24543, 24570, 24571 (xenoprof fixes)

These changesets do not relate to xenoprof??

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

The numbers were in fact 24536,24537,24564,24565.

Applied.

Quoted 4 lines
Quoted 2 lines
Quoted 1 line

24870* (IOAPIC: prevent directed EOI support trashing io_ack mode)

Too hard to backport. Please provide your backported version.

Attached.

And applied.

-- Keir

Quoted 3 lines
Quoted 3 lines

-- Keir

#18 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 4 lines · Andrew Cooper

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

The numbers were in fact 24536,24537,24564,24565.

Applied.

Hmm, if you apply 24537, then you should also pull in 24971 (perhaps once it made it through the stage tests).

Jan

#19 lore raw
Quoted 11 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 4 lines · Andrew Cooper

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

The numbers were in fact 24536,24537,24564,24565.

Applied.

Hmm, if you apply 24537, then you should also pull in 24971 (perhaps once it made it through the stage tests).

Jan

Yes - I had my eye on that patch. I will pull it through after it passes the tests.

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
#20 lore raw
In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper
Quoted 3 lines · Keir Fraser
Quoted 1 line · Andrew Cooper

24542, 24543, 24570, 24571 (xenoprof fixes)

These changesets do not relate to xenoprof??

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

These rev numbers are not globally meaningful, you need to use the node hash if you want to reliably refer to particular changesets.

#21 lore raw
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Andrew Cooper
Quoted 3 lines · Keir Fraser
Quoted 1 line · Andrew Cooper

24542, 24543, 24570, 24571 (xenoprof fixes)

These changesets do not relate to xenoprof??

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

These rev numbers are not globally meaningful, you need to use the node hash if you want to reliably refer to particular changesets.

The node hashes were correct, which is how I verified the patches after the error was noticed. I just naively assumed that the patches in the "explicitly from xen-unstable.hg" section would have the correct rev numbers as well.

I have checked all other patches and am now fairly happy that they are correct, and shall be more vigilant as new patches are being added.

Signature · 2 lines
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
#22 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 4 lines
Quoted 2 lines

So they are not. It appears that there was an off-by-6 numbering error in our patch queue for these patches. Apologies for that.

These rev numbers are not globally meaningful, you need to use the node hash if you want to reliably refer to particular changesets.

Quoted 7 lines

The node hashes were correct, which is how I verified the patches after the error was noticed. I just naively assumed that the patches in the "explicitly from xen-unstable.hg" section would have the correct rev numbers as well.

I have checked all other patches and am now fairly happy that they are correct, and shall be more vigilant as new patches are being added.

I certainly prefer changeset numbers, with reference to xenbits.xen.org master tree, when dealing with lists of patches. Just seem easier for me to deal with. They just need to be correct is all!

-- Keir

#23 lore raw
In reply to Keir Fraser

Keir Fraser writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 6 lines · Andrew Cooper
Quoted 3 lines

23936*,23937,23938*,23939,23940,23941 (Various ocaml fixes) 24320 (ocaml: release global lock during some hypercalls) 24414 (oxenstored: install configuration file)

These need to be Acked or backported by a toolstack maintainer.

Thanks, Keir.

Andrew, how did you construct this list of proposed backports ? It seems to be rather a mixed bag.

I'm certainly very reluctant to throw something like
23936:cdb34816a40a tools/ocaml: Rename the ocaml libraries
into a supposedly stable tree!

Ian.

#24 lore raw
In reply to Andrew Cooper
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only) 23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate. 24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

which I've back-ported to 4.1 (please see attachments)

# HG changeset patch
# Parent 476b0d68e7d5405babc1182da3b345b1e4cc1bca
libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)

The later retrieves the E820 as seen by the hypervisor (completely unchanged) and the second call sets the E820 for the specified guest.

[backport of c/s 23412]
tools/libxc/xc_domain.c +52 -25
diff -r 476b0d68e7d5 tools/libxc/xc_domain.c
@@ -478,37 +478,64 @@ int xc_domain_pin_memory_cacheattr(xc_in
 }
 
 #if defined(__i386__) || defined(__x86_64__)
-#include "xc_e820.h"
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries)
+{
+    int rc;
+    struct xen_foreign_memory_map fmap = {
+        .domid = domid,
+        .map = { .nr_entries = nr_entries }
+    };
+    DECLARE_HYPERCALL_BOUNCE(entries, nr_entries * sizeof(struct e820entry),
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( !entries || xc_hypercall_bounce_pre(xch, entries) )
+        return -1;
+
+    set_xen_guest_handle(fmap.map.buffer, entries);
+
+    rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap));
+
+    xc_hypercall_bounce_post(xch, entries);
+
+    return rc;
+}
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries)
+{
+    int rc;
+    struct xen_memory_map memmap = {
+        .nr_entries = max_entries
+    };
+    DECLARE_HYPERCALL_BOUNCE(entries, sizeof(struct e820entry) * max_entries,
+                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( !entries || xc_hypercall_bounce_pre(xch, entries) || max_entries <= 1)
+        return -1;
+
+
+    set_xen_guest_handle(memmap.buffer, entries);
+
+    rc = do_memory_op(xch, XENMEM_machine_memory_map, &memmap, sizeof(memmap));
+
+    xc_hypercall_bounce_post(xch, entries);
+
+    return rc ? rc : memmap.nr_entries;
+}
 int xc_domain_set_memmap_limit(xc_interface *xch,
                                uint32_t domid,
                                unsigned long map_limitkb)
 {
-    int rc;
-    struct xen_foreign_memory_map fmap = {
-        .domid = domid,
-        .map = { .nr_entries = 1 }
-    };
-    DECLARE_HYPERCALL_BUFFER(struct e820entry, e820);
+    struct e820entry e820;
 
-    e820 = xc_hypercall_buffer_alloc(xch, e820, sizeof(*e820));
+    e820.addr = 0;
+    e820.size = (uint64_t)map_limitkb << 10;
+    e820.type = E820_RAM;
 
-    if ( e820 == NULL )
-    {
-        PERROR("Could not allocate memory for xc_domain_set_memmap_limit hypercall");
-        return -1;
-    }
-
-    e820->addr = 0;
-    e820->size = (uint64_t)map_limitkb << 10;
-    e820->type = E820_RAM;
-
-    set_xen_guest_handle(fmap.map.buffer, e820);
-
-    rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap));
-
-    xc_hypercall_buffer_free(xch, e820);
-
-    return rc;
+    return xc_domain_set_memory_map(xch, domid, &e820, 1);
 }
 #else
 int xc_domain_set_memmap_limit(xc_interface *xch,
tools/libxc/xc_e820.h +3 -0
diff -r 476b0d68e7d5 tools/libxc/xc_e820.h
@@ -26,6 +26,9 @@
 #define E820_RESERVED     2
 #define E820_ACPI         3
 #define E820_NVS          4
+#define E820_UNUSABLE     5
+
+#define E820MAX           (128)
 
 struct e820entry {
     uint64_t addr;
tools/libxc/xenctrl.h +11 -0
diff -r 476b0d68e7d5 tools/libxc/xenctrl.h
@@ -966,6 +966,17 @@ int xc_domain_set_memmap_limit(xc_interf
                                uint32_t domid,
                                unsigned long map_limitkb);
 
+#if defined(__i386__) || defined(__x86_64__)
+#include "xc_e820.h"
+int xc_domain_set_memory_map(xc_interface *xch,
+                               uint32_t domid,
+                               struct e820entry entries[],
+                               uint32_t nr_entries);
+
+int xc_get_machine_memory_map(xc_interface *xch,
+                              struct e820entry entries[],
+                              uint32_t max_entries);
+#endif
 int xc_domain_set_time_offset(xc_interface *xch,
                               uint32_t domid,
                               int32_t time_offset_seconds);

# HG changeset patch
# Parent 5d31bd0eb8d040c0b44fe2a3b737fd752a607e74
libxc: Squash xc_e820.h (and delete) into xenctrl.h

.. as there is no need to keep that internal header file anymore. We export two functions xc_domain_[set|get]_memory_map which depend on the 'struct e820entry' defined in 'xc_e820.h'.

We move the contents of the 'xc_e820.h' to the 'xenctrl.h' fixing compiler errors when applications outside the Xen tree are trying to compile against the libraries.

[backport of c/s 23632]
tools/libxc/xc_core_x86.c +1 -1
diff -r 5d31bd0eb8d0 tools/libxc/xc_core_x86.c
@@ -20,7 +20,7 @@
 
 #include "xg_private.h"
 #include "xc_core.h"
-#include "xc_e820.h"
+#include <xen/hvm/e820.h>
 
 #define GET_FIELD(_p, _f) ((dinfo->guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f))
 
tools/libxc/xc_domain_save.c +0 -1
diff -r 5d31bd0eb8d0 tools/libxc/xc_domain_save.c
@@ -32,7 +32,6 @@
 #include "xg_save_restore.h"
 
 #include <xen/hvm/params.h>
-#include "xc_e820.h"
 
 /*
 ** Default values for important tuning parameters. Can override by passing
tools/libxc/xc_e820.h deleted +0 -39
diff -r 5d31bd0eb8d0 tools/libxc/xc_e820.h
@@ -1,39 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XC_E820_H__
-#define __XC_E820_H__
-
-#include <xen/hvm/e820.h>
-
-/*
- * PC BIOS standard E820 types and structure.
- */
-#define E820_RAM          1
-#define E820_RESERVED     2
-#define E820_ACPI         3
-#define E820_NVS          4
-#define E820_UNUSABLE     5
-
-#define E820MAX           (128)
-
-struct e820entry {
-    uint64_t addr;
-    uint64_t size;
-    uint32_t type;
-} __attribute__((packed));
-
-#endif /* __XC_E820_H__ */
tools/libxc/xenctrl.h +16 -1
diff -r 5d31bd0eb8d0 tools/libxc/xenctrl.h
@@ -967,7 +967,22 @@ int xc_domain_set_memmap_limit(xc_interf
                                unsigned long map_limitkb);
 
 #if defined(__i386__) || defined(__x86_64__)
-#include "xc_e820.h"
+/*
+ * PC BIOS standard E820 types and structure.
+ */
+#define E820_RAM          1
+#define E820_RESERVED     2
+#define E820_ACPI         3
+#define E820_NVS          4
+#define E820_UNUSABLE     5
+
+#define E820MAX           (128)
+
+struct e820entry {
+    uint64_t addr;
+    uint64_t size;
+    uint32_t type;
+} __attribute__((packed));
 int xc_domain_set_memory_map(xc_interface *xch,
                                uint32_t domid,
                                struct e820entry entries[],

# HG changeset patch
# User Keir Fraser <[email protected]>
# Date 1302707426 -3600
# Node ID 3f00c5faa12aed4d0993391f71b7f12cf92f0208 # Parent eb3b40bf0ba21ca518fdc0b4f86cd49228bbb853
x86: make the pv-only e820 array be dynamic.

During creation of the PV domain we allocate the E820 structure to have the amount of E820 entries on the machine, plus the number three.

This will allow the tool stack to fill the E820 with more than three entries. Specifically the use cases is , where the toolstack retrieves the E820, sanitizes it, and then sets it for the PV guest (for PCI passthrough), this dynamic number of E820 is just right.

[backport of c/s 23225]
xen/arch/x86/domain.c +4 -0
diff -r eb3b40bf0ba2 xen/arch/x86/domain.c
@@ -557,6 +557,8 @@ int arch_domain_create(struct domain *d,
         /* 32-bit PV guest by default only if Xen is not 64-bit. */
         d->arch.is_32bit_pv = d->arch.has_32bit_shinfo =
             (CONFIG_PAGING_LEVELS != 4);
+
+        spin_lock_init(&d->arch.e820_lock);
     }
 
     memset(d->arch.cpuids, 0, sizeof(d->arch.cpuids));
@@ -603,6 +605,8 @@ void arch_domain_destroy(struct domain *
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
+    else
+        xfree(d->arch.e820);
 
     vmce_destroy_msr(d);
     pci_release_devices(d);
xen/arch/x86/mm.c +36 -8

80 lines not on this page · raw message

xen/include/asm-x86/domain.h +2 -1
diff -r eb3b40bf0ba2 xen/include/asm-x86/domain.h
@@ -270,7 +270,8 @@ struct arch_domain
     unsigned long pirq_eoi_map_mfn;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
-    struct e820entry e820[3];
+    spinlock_t e820_lock;
+    struct e820entry *e820;
     unsigned int nr_e820;
 
     /* Maximum physical-address bitwidth supported by this guest. */

# HG changeset patch
# Parent 37cd883a764874bd5dfc8cfd6fbe82af1920a77e
libxl: Add support for passing in the host's E820 for PCI passthrough

The code that populates E820 is unconditionally triggered by the guest configuration having "pci=['<BDF>,..']", being a PV guest, and if b_info->u.pv.e820_host is set.

The code do_domain_create calls the libxl__e820_alloc when it notices that the guest is PV, has at least one PCI devices, and has the e820_host flag set.

libxl__e820_alloc calls the xc_get_machine_memory_map to retrieve the systems E820. Then the E820 is sanitized to weed out E820 entries below 16MB, and as well remove any E820_RAM or E820_UNUSED regions as the guest does not need to know about them. The guest only needs the E820_ACPI, E820_NVS, E820_RESERVED to get an idea of where the PCI I/O space is. Mostly.. The Linux kernel assumes that any gap in the E820 is considered PCI I/O space which means that if we pass in the guest 2GB, and the E820_ACPI, and its friend start at 3GB, the gap between 2GB and 3GB will be considered as PCI I/O space. To guard against that we also create an E820_UNUSABLE between the region of 'target_kb' (called ram_end in the code) up to the first E820_[ACPI,NVS,RESERVED] region. Lastly, the xc_domain_set_memory_map is called to install the new E820.

When tested with another PV guest (NetBSD 5.1) the modified E820 gave it no trouble. The code has also been tested with older "classic" Xen Linux and with the newer "pvops" with success (SLES11, RHEL5, Ubuntu Lucid, Debian Squeeze, 2.6.37, 2.6.38, 2.6.39).

Memory that is slack or for balloon (so 'maxmem' in guest configuration) is put behind the machine E820. Which in most cases is after the 4GB.

The reason for doing the fetching of the E820 using the hypercall in the toolstack (instead of the guest doing it) is that when a guest would do a hypercall to 'XENMEM_machine_memory_map' it would retrieve an E820 with I/O range caps added in. Meaning that the region after 4GB up to end of possible memory would be marked as unusable and the kernel would not have any space to allocate a balloon region.

[backport of c/s 23426]
tools/libxl/libxl.idl +1 -0
diff -r 37cd883a7648 tools/libxl/libxl.idl
@@ -117,6 +117,7 @@ libxl_domain_build_info = Struct("domain
                                         ("cmdline", string),
                                         ("ramdisk", libxl_file_reference),
                                         ("features", string, True),
+                                        ("e820_host", bool, False, "Use host's E820 for PCI passthrough."),
                                         ])),
                  ])),
     ],
tools/libxl/libxl_create.c +8 -0
diff -r 37cd883a7648 tools/libxl/libxl_create.c
@@ -540,6 +540,14 @@ static int do_domain_create(libxl_ctx *c
     for (i = 0; i < d_config->num_pcidevs; i++)
         libxl__device_pci_add(ctx, domid, &d_config->pcidevs[i], 1);
 
+    if (!d_config->c_info.hvm && d_config->b_info.u.pv.e820_host) {
+        int rc;
+        rc = libxl__e820_alloc(ctx, domid, d_config);
+        if (rc)
+            LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
+                      "Failed while collecting E820 with: %d (errno:%d)\n",
+                      rc, errno);
+    }
     if ( cb && (d_config->c_info.hvm || d_config->b_info.u.pv.bootloader )) {
         if ( (*cb)(ctx, domid, priv) )
             goto error_out;
tools/libxl/libxl_internal.h +1 -0
diff -r 37cd883a7648 tools/libxl/libxl_internal.h
@@ -330,4 +330,5 @@ _hidden int libxl__error_set(libxl_ctx *
 _hidden int libxl__file_reference_map(libxl_file_reference *f);
 _hidden int libxl__file_reference_unmap(libxl_file_reference *f);
 
+_hidden int libxl__e820_alloc(libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config);
 #endif
tools/libxl/libxl_pci.c +164 -0

167 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +3 -0
diff -r 37cd883a7648 tools/libxl/xl_cmdimpl.c
@@ -371,6 +371,7 @@ static void printf_info(int domid,
         printf("\t\t\t(kernel %s)\n", b_info->kernel.path);
         printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline);
         printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path);
+        printf("\t\t\t(e820_host %d)\n", b_info->u.pv.e820_host);
         printf("\t\t)\n");
     }
     printf("\t)\n");
@@ -1025,6 +1026,8 @@ skip_vfb:
             if (!libxl_device_pci_parse_bdf(&ctx, pcidev, buf))
                 d_config->num_pcidevs++;
         }
+        if (d_config->num_pcidevs && !c_info->hvm)
+            b_info->u.pv.e820_host = true;
     }
 
     switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) {

# HG changeset patch
# Parent 615d58973988e505c4cff62a338225152ceaa052
libxl: Add 'e820_host' option to config file.

.. which will be removed once the auto-ballooning of guests
with PCI devices works. During testing of the patches which provide a host E820 in a PV guest, certain inconsistencies were found with guests. When launching a RHEL5 or SLES11 PV guest with 4GB and a PCI device, the kernel would report 4GB, but have 1.5G "used". What happend was that the P2M that fall within the E820 I/O holes would never be used and was just wasted. The mechanism to go around this is to shrink the size of the guest before launch (say memory=2048, maxmem=4096) and then balloon back to 4096M after start. For PVOPS type kernels it would detect the E820 I/O holes and deflate by the correct amount but would not inflate back to 4GB. Manually inflating makes it work.

The fix in the future for guests where the memory amount flows over the PCI hole, is to launch the guest with decreased amount right up to the cusp of where the E820 PCI hole starts. Also increase the 'maxmem' by the delta and then when the guest has launched, balloon up to the delta number.

This will require some careful surgery so for right now this parameter will guard against unsuspecting users seeing their PV guests memory "vanish."

[backport of c/s 23428]
tools/libxl/xl_cmdimpl.c +10 -0
diff -r 615d58973988 tools/libxl/xl_cmdimpl.c
@@ -1010,6 +1010,16 @@ skip_vfb:
     if (!xlu_cfg_get_long (config, "pci_power_mgmt", &l))
         pci_power_mgmt = l;
 
+    /* To be reworked (automatically enabled) once the auto ballooning
+     * after guest starts is done (with PCI devices passed in). */
+    if (!xlu_cfg_get_long (config, "e820_host", &l)) {
+        if (c_info->hvm)
+          fprintf(stderr, "Can't do e820_host in HVM mode!");
+        else {
+          if (l)
+            b_info->u.pv.e820_host = true;
+        }
+    }
     if (!xlu_cfg_get_list (config, "pci", &pcis, 0, 0)) {
         int i;
         d_config->num_pcidevs = 0;

# HG changeset patch
# Parent d825fb0ba571f9f15c7fe1bb19c85c3568c0bb6f
libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.

Most machines after the RAM regions in the e802 have a couple of E820_RESERVED, with E820_ACPI and E820_NVS. On some Intel machines, the E820 looks like swiss cheese:

(XEN) Initial Xen-e820 RAM map:

(XEN)  0000000000000000 - 000000000009d000 (usable)
(XEN)  000000000009d000 - 00000000000a0000 (reserved)
(XEN)  00000000000e0000 - 0000000000100000 (reserved)
(XEN)  0000000000100000 - 000000009cf66000 (usable)
(XEN)  000000009cf66000 - 000000009d102000 (ACPI NVS)
(XEN)  000000009d102000 - 000000009f6bd000 (usable)  <--
(XEN)  000000009f6bd000 - 000000009f6bf000 (reserved)
(XEN)  000000009f6bf000 - 000000009f714000 (usable)  <--
(XEN)  000000009f714000 - 000000009f7bf000 (ACPI NVS)
(XEN)  000000009f7bf000 - 000000009f7e0000 (usable)  <--
(XEN)  000000009f7e0000 - 000000009f7ff000 (ACPI data)
(XEN)  000000009f7ff000 - 000000009f800000 (usable)  <--
(XEN)  000000009f800000 - 00000000a0000000 (reserved)
(XEN)  00000000a0000000 - 00000000b0000000 (reserved)
(XEN)  00000000fc000000 - 00000000fd000000 (reserved)
(XEN)  00000000ffe00000 - 0000000100000000 (reserved)
(XEN)  0000000100000000 - 0000000160000000 (usable)

Which means we have to pay attention to the E820_RAM that are between the E820_[ACPI,NVS,RESERVED]. If we remove those E820_RAM (b/c the amount of memory passed to the guest is less that where those E820 regions reside) from the E820, the Linux kernel interprets those "gaps" as PCI I/O space. This is what we are currently doing.

This can be disastrous if we pass in an Intel IGD card which tries to use the first available PCI I/O space - and ends up using the MFNs which are actually RAM instead of being the PCI I/O space.

To make this work, we convert all E820_RAM that are above the 'target_kb' (those that overlap the 'target_kb'
are truncated appropriately) to be E820_UNUSABLE. We also limit this alternation up to 4GB. This means that an E820 for a guest from this (target_kb=1024, maxmem=2048):

[    0.000000] Set 405658 page(s) to 1-1 mapping.
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  Xen: 0000000000000000 - 00000000000a0000 (usable)
[    0.000000]  Xen: 00000000000a0000 - 0000000000100000 (reserved)
[    0.000000]  Xen: 0000000000100000 - 0000000040000000 (usable)
[    0.000000]  Xen: 0000000040000000 - 000000009cf66000 (unusable)
[    0.000000]  Xen: 000000009cf66000 - 000000009d102000 (ACPI NVS)
[    0.000000]  Xen: 000000009f6bd000 - 000000009f6bf000 (reserved)
[    0.000000]  Xen: 000000009f714000 - 000000009f7bf000 (ACPI NVS)
[    0.000000]  Xen: 000000009f7e0000 - 000000009f7ff000 (ACPI data)
[    0.000000]  Xen: 000000009f800000 - 00000000b0000000 (reserved)
[    0.000000]  Xen: 00000000fc000000 - 00000000fd000000 (reserved)
[    0.000000]  Xen: 00000000fec00000 - 00000000fec01000 (reserved)
[    0.000000]  Xen: 00000000fee00000 - 00000000fee01000 (reserved)
[    0.000000]  Xen: 00000000ffe00000 - 0000000100000000 (reserved)
[    0.000000]  Xen: 0000000100000000 - 0000000140800000 (usable)

Will look as so:

[    0.000000] Set 395880 page(s) to 1-1 mapping.
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  Xen: 0000000000000000 - 00000000000a0000 (usable)
[    0.000000]  Xen: 00000000000a0000 - 0000000000100000 (reserved)
[    0.000000]  Xen: 0000000000100000 - 0000000040000000 (usable)
[    0.000000]  Xen: 0000000040000000 - 000000009cf66000 (unusable)
[    0.000000]  Xen: 000000009cf66000 - 000000009d102000 (ACPI NVS)
[    0.000000]  Xen: 000000009d102000 - 000000009f6bd000 (unusable)
[    0.000000]  Xen: 000000009f6bd000 - 000000009f6bf000 (reserved)
[    0.000000]  Xen: 000000009f6bf000 - 000000009f714000 (unusable)
[    0.000000]  Xen: 000000009f714000 - 000000009f7bf000 (ACPI NVS)
[    0.000000]  Xen: 000000009f7bf000 - 000000009f7e0000 (unusable)
[    0.000000]  Xen: 000000009f7e0000 - 000000009f7ff000 (ACPI data)
[    0.000000]  Xen: 000000009f7ff000 - 000000009f800000 (unusable)
[    0.000000]  Xen: 000000009f800000 - 00000000b0000000 (reserved)
[    0.000000]  Xen: 00000000fc000000 - 00000000fd000000 (reserved)
[    0.000000]  Xen: 00000000fec00000 - 00000000fec01000 (reserved)
[    0.000000]  Xen: 00000000fee00000 - 00000000fee01000 (reserved)
[    0.000000]  Xen: 00000000ffe00000 - 0000000100000000 (reserved)
[    0.000000]  Xen: 0000000100000000 - 0000000140800000 (usable)
[backport of c/s 23427]
tools/libxl/libxl_pci.c +85 -8

106 lines not on this page · raw message

# HG changeset patch
# User Zhenzhong Duan <[email protected]>
# Date 1319818821 -3600
# Node ID c4ed56a102dc3a66dc4dda6ed1584cb6531074a2 # Parent 2e16d8e6a965be8f62c99c6e456988cfa72b7e1d x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

pvhvm running with more than 32 vcpus and pv_irq/pv_time enabled need vcpu placement to work, or else it will softlockup.

xen/arch/x86/hvm/hvm.c +2 -0
diff -r 2e16d8e6a965 -r c4ed56a102dc xen/arch/x86/hvm/hvm.c
@@ -2794,6 +2794,7 @@ static long hvm_vcpu_op(
     case VCPUOP_stop_periodic_timer:
     case VCPUOP_set_singleshot_timer:
     case VCPUOP_stop_singleshot_timer:
+    case VCPUOP_register_vcpu_info:
         rc = do_vcpu_op(cmd, vcpuid, arg);
         break;
     default:
@@ -2869,6 +2870,7 @@ static long hvm_vcpu_op_compat32(
     case VCPUOP_stop_periodic_timer:
     case VCPUOP_set_singleshot_timer:
     case VCPUOP_stop_singleshot_timer:
+    case VCPUOP_register_vcpu_info:
         rc = compat_vcpu_op(cmd, vcpuid, arg);
         break;
     default:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#25 lore raw
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

Quoted 11 lines

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)
23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.
24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

-- Keir

Quoted 2 lines

which I've back-ported to 4.1 (please see attachments)

#26 lore raw
Quoted 19 lines · Keir Fraser
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

Quoted 11 lines

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)
23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.
24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and stuck for couple minutes with high load average and lastly crash the server. Please consider to revert these two commits as I am not sure which one is responsible for such crash.

# top -c

top - 19:30:54 up 6 min, 4 users, load average: 9.16, 4.34, 1.76

Tasks: 134 total,   4 running, 130 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 98.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.6%st
Mem:    355216k total,   179132k used,   176084k free,    14580k buffers
Swap:  2120568k total,        0k used,  2120568k free,    43896k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2856 root 20 0 31832 1416 1008 R 99.0 0.4 5:52.98 xl create
/etc/xen/example-hvm-domU.cfg

    1 root      20   0 19368 1512 1220 S  0.0  0.4   0:00.35

/sbin/init

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 12 lines

 -- Keir

Quoted 2 lines

which I've back-ported to 4.1 (please see attachments)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#27 lore raw
Quoted 20 lines · Teck Choon Giam
Quoted 19 lines · Keir Fraser
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)
23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.
24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

Quoted 8 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and stuck for couple minutes with high load average and lastly crash the server.  Please consider to revert these two commits as I am not sure which one is responsible for such crash.

Sorry, I shall be more clear about steps to reproduce:

xl list is fine as long I didn't start any domU after reboot.

If I xl create hvmdomU.cfg then it will overload the server and xl list will stuck as well... meaning once you issue the first xl create hvmdomU.cfg (starting first domU using xl) then xl list will stuck as well. Last known working changeset for xen-4.1-testing is 23269:d67e4d12723f.

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 34 lines
# top -c

top - 19:30:54 up 6 min,  4 users,  load average: 9.16, 4.34, 1.76
Tasks: 134 total,   4 running, 130 sleeping,   0 stopped,   0 zombie Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 98.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.6%st
Mem:    355216k total,   179132k used,   176084k free,    14580k buffers
Swap:  2120568k total,        0k used,  2120568k free,    43896k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 2856 root      20   0 31832 1416 1008 R 99.0  0.4   5:52.98 xl create /etc/xen/example-hvm-domU.cfg
   1 root      20   0 19368 1512 1220 S  0.0  0.4   0:00.35 /sbin/init

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 12 lines

 -- Keir

Quoted 2 lines

which I've back-ported to 4.1 (please see attachments)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#28 lore raw
In reply to Teck Choon Giam
Quoted 20 lines · Teck Choon Giam
Quoted 19 lines · Keir Fraser
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)
23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.
24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Hey Teck,

Thanks for reporting!

Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

Quoted 3 lines

stuck for couple minutes with high load average and lastly crash the server. Please consider to revert these two commits as I am not sure which one is responsible for such crash.

Hm, let me try seeing which one is the culprit. I think it is 23225 as it is suppose to go along the other tool one, but lets double check.

Quoted 33 lines
# top -c

top - 19:30:54 up 6 min, 4 users, load average: 9.16, 4.34, 1.76

Tasks: 134 total,   4 running, 130 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 98.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.6%st
Mem:    355216k total,   179132k used,   176084k free,    14580k buffers
Swap:  2120568k total,        0k used,  2120568k free,    43896k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2856 root 20 0 31832 1416 1008 R 99.0 0.4 5:52.98 xl create
/etc/xen/example-hvm-domU.cfg

    1 root      20   0 19368 1512 1220 S  0.0  0.4   0:00.35

/sbin/init

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 12 lines

 -- Keir

Quoted 2 lines

which I've back-ported to 4.1 (please see attachments)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#29 lore raw
Quoted 24 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Teck Choon Giam
Quoted 19 lines · Keir Fraser
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only)
23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.
24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Quoted 8 lines

Hey Teck,

Thanks for reporting!

Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

After a reboot with no domU running, xl list is fine but if I start a hvm domU will be stuck and caused high load then open another ssh terminal to issue xl list will stuck as well.

Quoted 6 lines
Quoted 3 lines

stuck for couple minutes with high load average and lastly crash the server.  Please consider to revert these two commits as I am not sure which one is responsible for such crash.

Hm, let me try seeing which one is the culprit. I think it is 23225 as it is suppose to go along the other tool one, but lets double check.

I actually tested with the list of patches you posted previously as well and same issue.

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 34 lines
Quoted 34 lines
# top -c

top - 19:30:54 up 6 min,  4 users,  load average: 9.16, 4.34, 1.76
Tasks: 134 total,   4 running, 130 sleeping,   0 stopped,   0 zombie Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 98.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.6%st
Mem:    355216k total,   179132k used,   176084k free,    14580k buffers
Swap:  2120568k total,        0k used,  2120568k free,    43896k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 2856 root      20   0 31832 1416 1008 R 99.0  0.4   5:52.98 xl create /etc/xen/example-hvm-domU.cfg
    1 root      20   0 19368 1512 1220 S  0.0  0.4   0:00.35 /sbin/init

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 12 lines

 -- Keir

Quoted 2 lines

which I've back-ported to 4.1 (please see attachments)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#30 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Hey Teck,

Thanks for reporting!

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

After a reboot with no domU running, xl list is fine but if I start a hvm domU will be stuck and caused high load then open another ssh terminal to issue xl list will stuck as well.

This fix fixes it for me:

xen/arch/x86/domain.c +3 -3
diff -r 13741fd6253b xen/arch/x86/domain.c
@@ -558,9 +558,9 @@ int arch_domain_create(struct domain *d,
         d->arch.is_32bit_pv = d->arch.has_32bit_shinfo =
             (CONFIG_PAGING_LEVELS != 4);
 
-        spin_lock_init(&d->arch.e820_lock);
     }
 
+    spin_lock_init(&d->arch.e820_lock);
     memset(d->arch.cpuids, 0, sizeof(d->arch.cpuids));
     for ( i = 0; i < MAX_CPUID_INPUT; i++ )
     {
@@ -605,8 +605,8 @@ void arch_domain_destroy(struct domain *
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
-    else
-        xfree(d->arch.e820);
+
+    xfree(d->arch.e820);
 
     vmce_destroy_msr(d);
     free_domain_pirqs(d);

The issue is that upstream we have two 'domain structs' - one for PV and one for HVM. In 4.1 it is just 'arch_domain' and the calls to create the guests are going through the same interface (at least using xl, with xm they are seperate). And I only initialized the spinlock in the PV case, but not in the HVM case. This fix to the backport resolves the problem.

Keir, please apply this to my botched back-port of 23225.

#31 lore raw
Quoted 45 lines · Konrad Rzeszutek Wilk
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Hey Teck,

Thanks for reporting!

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

After a reboot with no domU running, xl list is fine but if I start a hvm domU will be stuck and caused high load then open another ssh terminal to issue xl list will stuck as well.

This fix fixes it for me:

diff -r 13741fd6253b xen/arch/x86/domain.c

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +0 -0
@@ -558,9 +558,9 @@ int arch_domain_create(struct domain *d,

        d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = (CONFIG_PAGING_LEVELS != 4);

-        spin_lock_init(&d->arch.e820_lock);
    }

+    spin_lock_init(&d->arch.e820_lock); memset(d->arch.cpuids, 0, sizeof(d->arch.cpuids)); for ( i = 0; i < MAX_CPUID_INPUT; i++ )
    {

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +2 -2
@@ -605,8 +605,8 @@ void arch_domain_destroy(struct domain *
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
-    else
-        xfree(d->arch.e820);
+
+    xfree(d->arch.e820);
 
     vmce_destroy_msr(d);
     free_domain_pirqs(d);
Quoted 5 lines

The issue is that upstream we have two 'domain structs' - one for PV and one for HVM. In 4.1 it is just 'arch_domain' and the calls to create the guests are going through the same interface (at least using xl, with xm they are seperate). And I only initialized the spinlock in the PV case, but not in the HVM case. This fix to the backport resolves the problem.

Thanks for your fast and prompt fix ;)

I am compiling with the fix patch you provided on top of xen-4.1-testing changeset 23271:13741fd6253b. Will test and report back if you are interested ;)

Kindest regards,
Giam Teck Choon

Quoted 2 lines

Keir, please apply this to my botched back-port of  23225.

#32 lore raw
Quoted 55 lines · Teck Choon Giam
Quoted 45 lines · Konrad Rzeszutek Wilk
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Hey Teck,

Thanks for reporting!

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

After a reboot with no domU running, xl list is fine but if I start a hvm domU will be stuck and caused high load then open another ssh terminal to issue xl list will stuck as well.

This fix fixes it for me:

diff -r 13741fd6253b xen/arch/x86/domain.c

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +0 -0
@@ -558,9 +558,9 @@ int arch_domain_create(struct domain *d,

        d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = (CONFIG_PAGING_LEVELS != 4);

-        spin_lock_init(&d->arch.e820_lock);
    }

+    spin_lock_init(&d->arch.e820_lock); memset(d->arch.cpuids, 0, sizeof(d->arch.cpuids)); for ( i = 0; i < MAX_CPUID_INPUT; i++ )
    {

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +2 -2
@@ -605,8 +605,8 @@ void arch_domain_destroy(struct domain *
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
-    else
-        xfree(d->arch.e820);
+
+    xfree(d->arch.e820);
 
     vmce_destroy_msr(d);
     free_domain_pirqs(d);
Quoted 5 lines

The issue is that upstream we have two 'domain structs' - one for PV and one for HVM. In 4.1 it is just 'arch_domain' and the calls to create the guests are going through the same interface (at least using xl, with xm they are seperate). And I only initialized the spinlock in the PV case, but not in the HVM case. This fix to the backport resolves the problem.

Thanks for your fast and prompt fix ;)

Quoted 3 lines

I am compiling with the fix patch you provided on top of xen-4.1-testing changeset 23271:13741fd6253b. Will test and report back if you are interested ;)

Yes please! If you find other issues, please report them immediately! Thanks again for doing this.

#33 lore raw
Quoted 56 lines · Konrad Rzeszutek Wilk
Quoted 55 lines · Teck Choon Giam
Quoted 45 lines · Konrad Rzeszutek Wilk
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Applied 23225 and 24013. The other, toolstack-related, patches I will leave for a tools maintainer to ack or apply.

Hey Teck,

Thanks for reporting!

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

With the two backport patches committed in xen-4.1-testing (changeset 23271:13741fd6253b), xl list or xl create domU will cause 100% CPU and

xl list?

After a reboot with no domU running, xl list is fine but if I start a hvm domU will be stuck and caused high load then open another ssh terminal to issue xl list will stuck as well.

This fix fixes it for me:

diff -r 13741fd6253b xen/arch/x86/domain.c

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +0 -0
@@ -558,9 +558,9 @@ int arch_domain_create(struct domain *d,

        d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = (CONFIG_PAGING_LEVELS != 4);

-        spin_lock_init(&d->arch.e820_lock);
    }

+    spin_lock_init(&d->arch.e820_lock); memset(d->arch.cpuids, 0, sizeof(d->arch.cpuids)); for ( i = 0; i < MAX_CPUID_INPUT; i++ )
    {

xen/arch/x86/domain.c     Thu Mar 29 11:44:54 2012 -0400 renamed from xen/arch/x86/domain.c     Thu Mar 29 10:20:58 2012 +0100 +2 -2
@@ -605,8 +605,8 @@ void arch_domain_destroy(struct domain *
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
-    else
-        xfree(d->arch.e820);
+
+    xfree(d->arch.e820);
 
     vmce_destroy_msr(d);
     free_domain_pirqs(d);
Quoted 5 lines

The issue is that upstream we have two 'domain structs' - one for PV and one for HVM. In 4.1 it is just 'arch_domain' and the calls to create the guests are going through the same interface (at least using xl, with xm they are seperate). And I only initialized the spinlock in the PV case, but not in the HVM case. This fix to the backport resolves the problem.

Thanks for your fast and prompt fix ;)

Quoted 6 lines
Quoted 3 lines

I am compiling with the fix patch you provided on top of xen-4.1-testing changeset 23271:13741fd6253b.  Will test and report back if you are interested ;)

Yes please! If you find other issues, please report them immediately! Thanks again for doing this.

Thanks and it works!

#34 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich

For a (hopefully soon) upcoming 4.1.3 and 4.0.4, may I ask to consider the following changesets from -unstable for backporting:

Quoted 9 lines

And also these:
24140 tools: xend: tolerate empty state/*.xml
23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only) 23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23225 x86: make the pv-only e820 array be dynamic.
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate. 24013 x86,hvm: enable VCPUOP_register_vcpu_info op in hvm hypercall

What about:

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

backport appended.

---

linux/xen: support pirq_eoi_map

The pirq_eoi_map is a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We use PHYSDEVOP_pirq_eoi_gmfn_v2 to map the bitmap, then if we succeed we use pirq_eoi_map to check whether pirqs need eoi.

Changes in v2:

- explicitly use PHYSDEVOP_pirq_eoi_gmfn_v2 rather than PHYSDEVOP_pirq_eoi_gmfn;

- introduce pirq_check_eoi_map, a function to check if a pirq needs an eoi using the map;

-rename pirq_needs_eoi into pirq_needs_eoi_flag;

- introduce a function pointer called pirq_needs_eoi that is going to be set to the right implementation depending on the availability of PHYSDEVOP_pirq_eoi_gmfn_v2.

---
 drivers/xen/events.c            |   26 +++++++++++++++++++++++---
 include/xen/interface/physdev.h |   21 +++++++++++++++++++++
 2 files changed, 44 insertions(+), 3 deletions(-)
drivers/xen/events.c +23 -3
index 6e075cd..cc5fc40 100644
@@ -37,6 +37,7 @@
 #include <asm/idle.h>
 #include <asm/io_apic.h>
 #include <asm/sync_bitops.h>
+#include <asm/xen/page.h>
 #include <asm/xen/pci.h>
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -108,6 +109,8 @@ struct irq_info {
 #define PIRQ_SHAREABLE	(1 << 1)
 
 static int *evtchn_to_irq;
+static unsigned long *pirq_eoi_map;
+static bool (*pirq_needs_eoi)(unsigned irq);
 
 static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG],
 		      cpu_evtchn_mask);
@@ -268,10 +271,14 @@ static unsigned int cpu_from_evtchn(unsigned int evtchn)
 	return ret;
 }
 
-static bool pirq_needs_eoi(unsigned irq)
+static bool pirq_check_eoi_map(unsigned irq)
 {
-	struct irq_info *info = info_for_irq(irq);
+	return test_bit(irq, pirq_eoi_map);
+}
 
+static bool pirq_needs_eoi_flag(unsigned irq)
+{
+	struct irq_info *info = info_for_irq(irq);
 	BUG_ON(info->type != IRQT_PIRQ);
 
 	return info->u.pirq.flags & PIRQ_NEEDS_EOI;
@@ -1693,7 +1700,7 @@ void xen_callback_vector(void) {}
 
 void __init xen_init_IRQ(void)
 {
-	int i;
+	int i, rc;
 
 	evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq),
 				    GFP_KERNEL);
@@ -1707,6 +1714,8 @@ void __init xen_init_IRQ(void)
 	for (i = 0; i < NR_EVENT_CHANNELS; i++)
 		mask_evtchn(i);
 
+	pirq_needs_eoi = pirq_needs_eoi_flag;
+
 	if (xen_hvm_domain()) {
 		xen_callback_vector();
 		native_init_IRQ();
@@ -1714,8 +1723,19 @@ void __init xen_init_IRQ(void)
 		 * __acpi_register_gsi can point at the right function */
 		pci_xen_hvm_init();
 	} else {
+		struct physdev_pirq_eoi_gmfn eoi_gmfn;
+
 		irq_ctx_init(smp_processor_id());
 		if (xen_initial_domain())
 			pci_xen_initial_domain();
+
+		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);
+		if (rc != 0) {
+			free_page((unsigned long) pirq_eoi_map);
+			pirq_eoi_map = NULL;
+		} else
+			pirq_needs_eoi = pirq_check_eoi_map;
 	}
 }
include/xen/interface/physdev.h +21 -0
index c1080d9..1775722 100644
@@ -39,6 +39,27 @@ struct physdev_eoi {
 };
 
 /*
+ * Register a shared page for the hypervisor to indicate whether the guest
+ * must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly
+ * once the guest used this function in that the associated event channel
+ * will automatically get unmasked. The page registered is used as a bit
+ * array indexed by Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v1       17
+/*
+ * Register a shared page for the hypervisor to indicate whether the
+ * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
+ * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
+ * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
+ * Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v2       28
+struct physdev_pirq_eoi_gmfn {
+    /* IN */
+    unsigned long gmfn;
+};
+
+/*
  * Query the status of an IRQ line.
  * @arg == pointer to physdev_irq_status_query structure.
  */
Signature · 1 line
1.7.2.5
#35 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Stefano Stabellini <[email protected]> 03/29/12 1:54 PM >>>

What about:

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

backport appended.

---

linux/xen: support pirq_eoi_map

As the title says, this is a Linux patch that you provided, yet talk is about Xen backports here.

Jan

#36 lore raw
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Stefano Stabellini <[email protected]> 03/29/12 1:54 PM >>>

What about:

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

Quoted 8 lines
Quoted 5 lines

backport appended.

---

linux/xen: support pirq_eoi_map

As the title says, this is a Linux patch that you provided, yet talk is about Xen backports here.

Oops, I have appended the wrong patch. Now I am appending the right one.

Please note that the patch bumps __XEN_LATEST_INTERFACE_VERSION__ but it is not a requirement to get Linux kernels to work correctly with it. I would welcome opinions on whether we would need to backport that change too or not.

---

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. In order to improve the interface this patch:

- renames PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1;

- introduces PHYSDEVOP_pirq_eoi_gmfn_v2, that is like PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't modify the behaviour of another hypercall;

- bump __XEN_LATEST_INTERFACE_VERSION__;

- #define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1 or PHYSDEVOP_pirq_eoi_gmfn_v2 depending on the __XEN_INTERFACE_VERSION.

---
 xen/arch/ia64/xen/domain.c      |    1 +
 xen/arch/ia64/xen/hypercall.c   |    7 +++++--
 xen/arch/x86/domain.c           |    1 +
 xen/arch/x86/physdev.c          |    7 +++++--
 xen/include/asm-ia64/domain.h   |    3 +++
 xen/include/asm-x86/domain.h    |    3 +++
 xen/include/public/physdev.h    |   16 +++++++++++++++-
 xen/include/public/xen-compat.h |    2 +-
 8 files changed, 34 insertions(+), 6 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
index 271a744..7dd96bf 100644
@@ -1729,6 +1729,7 @@ int domain_relinquish_resources(struct domain *d)
 		if (d->arch.pirq_eoi_map != NULL) {
 			put_page(virt_to_page(d->arch.pirq_eoi_map));
 			d->arch.pirq_eoi_map = NULL;
+			d->arch.auto_unmask = 0;
 		}
 
 		/* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +5 -2
index 6ea15c2..22b06ec 100644
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq)
 {
 	if ( pirq < 0 || pirq >= NR_IRQS )
 		return -EINVAL;
-	if ( d->arch.pirq_eoi_map )
+	if ( d->arch.auto_unmask ) {
 		evtchn_unmask(d->pirq_to_evtchn[pirq]);
 	return pirq_guest_eoi(d, pirq);
 }
@@ -504,7 +504,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v1:
+    case PHYSDEVOP_pirq_eoi_gmfn_v2: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -527,6 +528,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         }
 
         current->domain->arch.pirq_eoi_map = mfn_to_virt(mfn);
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            current->domain->arch.auto_unmask = 1;
         ret = 0;
         break;
     }
xen/arch/x86/domain.c +1 -0
index d432eb8..8472e30 100644
@@ -1935,6 +1935,7 @@ int domain_relinquish_resources(struct domain *d)
             unmap_domain_page_global(d->arch.pirq_eoi_map);
             put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn));
             d->arch.pirq_eoi_map = NULL;
+            d->arch.auto_unmask = 0;
         }
 
         d->arch.relmem = RELMEM_xen;
xen/arch/x86/physdev.c +5 -2
index 3454c03..53c2461 100644
@@ -264,7 +264,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         ret = -EINVAL;
         if ( eoi.irq >= v->domain->nr_pirqs )
             break;
-        if ( v->domain->arch.pirq_eoi_map )
+        if ( v->domain->arch.auto_unmask )
             evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]);
         if ( !is_hvm_domain(v->domain) ||
              domain_pirq_to_emuirq(v->domain, eoi.irq) == IRQ_PT )
@@ -274,7 +274,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v2:
+    case PHYSDEVOP_pirq_eoi_gmfn_v1: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -304,6 +305,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
             ret = -ENOSPC;
             break;
         }
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            v->domain->arch.auto_unmask = 1;
 
         ret = 0;
         break;
xen/include/asm-ia64/domain.h +3 -0
index 14064ce..fc7b34f 100644
@@ -182,6 +182,9 @@ struct arch_domain {
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Address of efi_runtime_services_t (placed in domain memory)  */
     void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
index 8056559..75f2540 100644
@@ -268,6 +268,9 @@ struct arch_domain
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
     struct e820entry e820[3];
xen/include/public/physdev.h +15 -1
index 82602ca..2e0ee53 100644
@@ -49,7 +49,15 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
  * will automatically get unmasked. The page registered is used as a bit
  * array indexed by Xen's PIRQ value.
  */
-#define PHYSDEVOP_pirq_eoi_gmfn         17
+#define PHYSDEVOP_pirq_eoi_gmfn_v1       17
+/*
+ * Register a shared page for the hypervisor to indicate whether the
+ * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
+ * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
+ * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
+ * Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v2       28
 struct physdev_pirq_eoi_gmfn {
     /* IN */
     xen_pfn_t gmfn;
@@ -276,6 +284,12 @@ DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
 
+#if __XEN_INTERFACE_VERSION < 0x00040200
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
+#else
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2
+#endif
+
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
 /*
xen/include/public/xen-compat.h +1 -1
index 2e38003..d8c55bf 100644
@@ -27,7 +27,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x0003020a
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040200
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */
Signature · 1 line
1.7.2.5
#37 lore raw
Quoted 15 lines · Stefano Stabellini
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Stefano Stabellini <[email protected]> 03/29/12 1:54 PM >>>

What about:

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

Quoted 8 lines
Quoted 5 lines

backport appended.

---

linux/xen: support pirq_eoi_map

As the title says, this is a Linux patch that you provided, yet talk is about Xen backports here.

Quoted 6 lines

Oops, I have appended the wrong patch. Now I am appending the right one.

Please note that the patch bumps __XEN_LATEST_INTERFACE_VERSION__ but it is not a requirement to get Linux kernels to work correctly with it. I would welcome opinions on whether we would need to backport that change too or not.

Let's not. Please re-spin the patch to unconditionally define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1, and don't touch __XEN_LATEST_INTERFACE_VERSION__.

Thanks,
Keir

Quoted 194 lines

---

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. In order to improve the interface this patch:

- renames PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1;

- introduces PHYSDEVOP_pirq_eoi_gmfn_v2, that is like PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't modify the behaviour of another hypercall;

- bump __XEN_LATEST_INTERFACE_VERSION__;

- #define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1 or PHYSDEVOP_pirq_eoi_gmfn_v2 depending on the __XEN_INTERFACE_VERSION.

---
 xen/arch/ia64/xen/domain.c      |    1 +
 xen/arch/ia64/xen/hypercall.c   |    7 +++++--
 xen/arch/x86/domain.c           |    1 +
 xen/arch/x86/physdev.c          |    7 +++++--
 xen/include/asm-ia64/domain.h   |    3 +++
 xen/include/asm-x86/domain.h    |    3 +++
 xen/include/public/physdev.h    |   16 +++++++++++++++-
 xen/include/public/xen-compat.h |    2 +-
 8 files changed, 34 insertions(+), 6 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
index 271a744..7dd96bf 100644
@@ -1729,6 +1729,7 @@ int domain_relinquish_resources(struct domain *d)
 if (d->arch.pirq_eoi_map != NULL) {
 put_page(virt_to_page(d->arch.pirq_eoi_map));
 d->arch.pirq_eoi_map = NULL;
+   d->arch.auto_unmask = 0;
 }
 
 /* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +5 -2
index 6ea15c2..22b06ec 100644
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq)
 {
 if ( pirq < 0 || pirq >= NR_IRQS )
 return -EINVAL;
- if ( d->arch.pirq_eoi_map )
+ if ( d->arch.auto_unmask ) {
 evtchn_unmask(d->pirq_to_evtchn[pirq]);
 return pirq_guest_eoi(d, pirq);
 }
@@ -504,7 +504,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v1:
+    case PHYSDEVOP_pirq_eoi_gmfn_v2: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -527,6 +528,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         }
 
         current->domain->arch.pirq_eoi_map = mfn_to_virt(mfn);
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            current->domain->arch.auto_unmask = 1;
         ret = 0;
         break;
     }
xen/arch/x86/domain.c +1 -0
index d432eb8..8472e30 100644
@@ -1935,6 +1935,7 @@ int domain_relinquish_resources(struct domain *d)
             unmap_domain_page_global(d->arch.pirq_eoi_map);
             put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn));
             d->arch.pirq_eoi_map = NULL;
+            d->arch.auto_unmask = 0;
         }
 
         d->arch.relmem = RELMEM_xen;
xen/arch/x86/physdev.c +5 -2
index 3454c03..53c2461 100644
@@ -264,7 +264,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         ret = -EINVAL;
         if ( eoi.irq >= v->domain->nr_pirqs )
             break;
-        if ( v->domain->arch.pirq_eoi_map )
+        if ( v->domain->arch.auto_unmask )
             evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]);
         if ( !is_hvm_domain(v->domain) ||
              domain_pirq_to_emuirq(v->domain, eoi.irq) == IRQ_PT )
@@ -274,7 +274,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v2:
+    case PHYSDEVOP_pirq_eoi_gmfn_v1: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -304,6 +305,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
             ret = -ENOSPC;
             break;
         }
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            v->domain->arch.auto_unmask = 1;
 
         ret = 0;
         break;
xen/include/asm-ia64/domain.h +3 -0
index 14064ce..fc7b34f 100644
@@ -182,6 +182,9 @@ struct arch_domain {
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Address of efi_runtime_services_t (placed in domain memory)  */
     void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
index 8056559..75f2540 100644
@@ -268,6 +268,9 @@ struct arch_domain
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
     struct e820entry e820[3];
xen/include/public/physdev.h +15 -1
index 82602ca..2e0ee53 100644
@@ -49,7 +49,15 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
  * will automatically get unmasked. The page registered is used as a bit
  * array indexed by Xen's PIRQ value.
  */
-#define PHYSDEVOP_pirq_eoi_gmfn         17
+#define PHYSDEVOP_pirq_eoi_gmfn_v1       17
+/*
+ * Register a shared page for the hypervisor to indicate whether the
+ * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
+ * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
+ * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
+ * Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v2       28
 struct physdev_pirq_eoi_gmfn {
     /* IN */
     xen_pfn_t gmfn;
@@ -276,6 +284,12 @@ DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
 
+#if __XEN_INTERFACE_VERSION < 0x00040200
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
+#else
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2
+#endif
+
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
 /*
xen/include/public/xen-compat.h +1 -1
index 2e38003..d8c55bf 100644
@@ -27,7 +27,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x0003020a
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040200
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */
#38 lore raw
Quoted 20 lines · Keir Fraser
Quoted 17 lines · Stefano Stabellini
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Stefano Stabellini <[email protected]> 03/29/12 1:54 PM >>>

What about:

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

Quoted 8 lines
Quoted 5 lines

backport appended.

---

linux/xen: support pirq_eoi_map

As the title says, this is a Linux patch that you provided, yet talk is about Xen backports here.

Oops, I have appended the wrong patch. Now I am appending the right one.

Quoted 8 lines
Quoted 4 lines

Please note that the patch bumps __XEN_LATEST_INTERFACE_VERSION__ but it is not a requirement to get Linux kernels to work correctly with it. I would welcome opinions on whether we would need to backport that change too or not.

Let's not. Please re-spin the patch to unconditionally define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1, and don't touch __XEN_LATEST_INTERFACE_VERSION__.

Agreed, below and attached the updated patch.

---

xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. In order to improve the interface this patch:

- renames PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1;

- introduces PHYSDEVOP_pirq_eoi_gmfn_v2, that is like PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't modify the behaviour of another hypercall;

- #define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1.

---
 xen/arch/ia64/xen/domain.c    |    1 +
 xen/arch/ia64/xen/hypercall.c |    7 +++++--
 xen/arch/x86/domain.c         |    1 +
 xen/arch/x86/physdev.c        |    7 +++++--
 xen/include/asm-ia64/domain.h |    3 +++
 xen/include/asm-x86/domain.h  |    3 +++
 xen/include/public/physdev.h  |   12 +++++++++++-
 7 files changed, 29 insertions(+), 5 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
index 271a744..7dd96bf 100644
@@ -1729,6 +1729,7 @@ int domain_relinquish_resources(struct domain *d)
 		if (d->arch.pirq_eoi_map != NULL) {
 			put_page(virt_to_page(d->arch.pirq_eoi_map));
 			d->arch.pirq_eoi_map = NULL;
+			d->arch.auto_unmask = 0;
 		}
 
 		/* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +5 -2
index 6ea15c2..22b06ec 100644
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq)
 {
 	if ( pirq < 0 || pirq >= NR_IRQS )
 		return -EINVAL;
-	if ( d->arch.pirq_eoi_map )
+	if ( d->arch.auto_unmask ) {
 		evtchn_unmask(d->pirq_to_evtchn[pirq]);
 	return pirq_guest_eoi(d, pirq);
 }
@@ -504,7 +504,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v1:
+    case PHYSDEVOP_pirq_eoi_gmfn_v2: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -527,6 +528,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         }
 
         current->domain->arch.pirq_eoi_map = mfn_to_virt(mfn);
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            current->domain->arch.auto_unmask = 1;
         ret = 0;
         break;
     }
xen/arch/x86/domain.c +1 -0
index d432eb8..8472e30 100644
@@ -1935,6 +1935,7 @@ int domain_relinquish_resources(struct domain *d)
             unmap_domain_page_global(d->arch.pirq_eoi_map);
             put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn));
             d->arch.pirq_eoi_map = NULL;
+            d->arch.auto_unmask = 0;
         }
 
         d->arch.relmem = RELMEM_xen;
xen/arch/x86/physdev.c +5 -2
index 3454c03..53c2461 100644
@@ -264,7 +264,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         ret = -EINVAL;
         if ( eoi.irq >= v->domain->nr_pirqs )
             break;
-        if ( v->domain->arch.pirq_eoi_map )
+        if ( v->domain->arch.auto_unmask )
             evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]);
         if ( !is_hvm_domain(v->domain) ||
              domain_pirq_to_emuirq(v->domain, eoi.irq) == IRQ_PT )
@@ -274,7 +274,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v2:
+    case PHYSDEVOP_pirq_eoi_gmfn_v1: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -304,6 +305,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
             ret = -ENOSPC;
             break;
         }
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            v->domain->arch.auto_unmask = 1;
 
         ret = 0;
         break;
xen/include/asm-ia64/domain.h +3 -0
index 14064ce..fc7b34f 100644
@@ -182,6 +182,9 @@ struct arch_domain {
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Address of efi_runtime_services_t (placed in domain memory)  */
     void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
index 8056559..75f2540 100644
@@ -268,6 +268,9 @@ struct arch_domain
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
     struct e820entry e820[3];
xen/include/public/physdev.h +11 -1
index 82602ca..6f792ee 100644
@@ -49,7 +49,15 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
  * will automatically get unmasked. The page registered is used as a bit
  * array indexed by Xen's PIRQ value.
  */
-#define PHYSDEVOP_pirq_eoi_gmfn         17
+#define PHYSDEVOP_pirq_eoi_gmfn_v1       17
+/*
+ * Register a shared page for the hypervisor to indicate whether the
+ * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
+ * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
+ * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
+ * Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v2       28
 struct physdev_pirq_eoi_gmfn {
     /* IN */
     xen_pfn_t gmfn;
@@ -276,6 +284,8 @@ DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
 
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
+
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
 /*
Signature · 1 line
1.7.2.5

From 783c980463c6b70725796f4706385fdf332fc4f8 Mon Sep 17 00:00:00 2001
From: Stefano Stabellini <[email protected]>
Date: Thu, 29 Mar 2012 11:37:04 +0000
Subject: [PATCH] xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2

PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. In order to improve the interface this patch:

- renames PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1;

- introduces PHYSDEVOP_pirq_eoi_gmfn_v2, that is like PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't modify the behaviour of another hypercall;

- #define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1.

---
 xen/arch/ia64/xen/domain.c    |    1 +
 xen/arch/ia64/xen/hypercall.c |    7 +++++--
 xen/arch/x86/domain.c         |    1 +
 xen/arch/x86/physdev.c        |    7 +++++--
 xen/include/asm-ia64/domain.h |    3 +++
 xen/include/asm-x86/domain.h  |    3 +++
 xen/include/public/physdev.h  |   12 +++++++++++-
 7 files changed, 29 insertions(+), 5 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
index 271a744..7dd96bf 100644
@@ -1729,6 +1729,7 @@ int domain_relinquish_resources(struct domain *d)
 		if (d->arch.pirq_eoi_map != NULL) {
 			put_page(virt_to_page(d->arch.pirq_eoi_map));
 			d->arch.pirq_eoi_map = NULL;
+			d->arch.auto_unmask = 0;
 		}
 
 		/* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +5 -2
index 6ea15c2..22b06ec 100644
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq)
 {
 	if ( pirq < 0 || pirq >= NR_IRQS )
 		return -EINVAL;
-	if ( d->arch.pirq_eoi_map )
+	if ( d->arch.auto_unmask ) {
 		evtchn_unmask(d->pirq_to_evtchn[pirq]);
 	return pirq_guest_eoi(d, pirq);
 }
@@ -504,7 +504,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v1:
+    case PHYSDEVOP_pirq_eoi_gmfn_v2: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -527,6 +528,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         }
 
         current->domain->arch.pirq_eoi_map = mfn_to_virt(mfn);
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            current->domain->arch.auto_unmask = 1;
         ret = 0;
         break;
     }
xen/arch/x86/domain.c +1 -0
index d432eb8..8472e30 100644
@@ -1935,6 +1935,7 @@ int domain_relinquish_resources(struct domain *d)
             unmap_domain_page_global(d->arch.pirq_eoi_map);
             put_page_and_type(mfn_to_page(d->arch.pirq_eoi_map_mfn));
             d->arch.pirq_eoi_map = NULL;
+            d->arch.auto_unmask = 0;
         }
 
         d->arch.relmem = RELMEM_xen;
xen/arch/x86/physdev.c +5 -2
index 3454c03..53c2461 100644
@@ -264,7 +264,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         ret = -EINVAL;
         if ( eoi.irq >= v->domain->nr_pirqs )
             break;
-        if ( v->domain->arch.pirq_eoi_map )
+        if ( v->domain->arch.auto_unmask )
             evtchn_unmask(v->domain->pirq_to_evtchn[eoi.irq]);
         if ( !is_hvm_domain(v->domain) ||
              domain_pirq_to_emuirq(v->domain, eoi.irq) == IRQ_PT )
@@ -274,7 +274,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
-    case PHYSDEVOP_pirq_eoi_gmfn: {
+    case PHYSDEVOP_pirq_eoi_gmfn_v2:
+    case PHYSDEVOP_pirq_eoi_gmfn_v1: {
         struct physdev_pirq_eoi_gmfn info;
         unsigned long mfn;
 
@@ -304,6 +305,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
             ret = -ENOSPC;
             break;
         }
+        if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 )
+            v->domain->arch.auto_unmask = 1;
 
         ret = 0;
         break;
xen/include/asm-ia64/domain.h +3 -0
index 14064ce..fc7b34f 100644
@@ -182,6 +182,9 @@ struct arch_domain {
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Address of efi_runtime_services_t (placed in domain memory)  */
     void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
index 8056559..75f2540 100644
@@ -268,6 +268,9 @@ struct arch_domain
     /* Shared page for notifying that explicit PIRQ EOI is required. */
     unsigned long *pirq_eoi_map;
     unsigned long pirq_eoi_map_mfn;
+    /* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically
+     * unmask the event channel */
+    bool_t auto_unmask;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
     struct e820entry e820[3];
xen/include/public/physdev.h +11 -1
index 82602ca..6f792ee 100644
@@ -49,7 +49,15 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
  * will automatically get unmasked. The page registered is used as a bit
  * array indexed by Xen's PIRQ value.
  */
-#define PHYSDEVOP_pirq_eoi_gmfn         17
+#define PHYSDEVOP_pirq_eoi_gmfn_v1       17
+/*
+ * Register a shared page for the hypervisor to indicate whether the
+ * guest must issue PHYSDEVOP_eoi. This hypercall is very similar to
+ * PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of
+ * PHYSDEVOP_eoi. The page registered is used as a bit array indexed by
+ * Xen's PIRQ value.
+ */
+#define PHYSDEVOP_pirq_eoi_gmfn_v2       28
 struct physdev_pirq_eoi_gmfn {
     /* IN */
     xen_pfn_t gmfn;
@@ -276,6 +284,8 @@ DEFINE_XEN_GUEST_HANDLE(physdev_get_free_pirq_t);
 #define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi
 #define PHYSDEVOP_IRQ_SHARED             XENIRQSTAT_shared
 
+#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1
+
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
 /*
Signature · 1 line
1.7.2.5

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#39 lore raw
In reply to Konrad Rzeszutek Wilk

Konrad Rzeszutek Wilk writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 2 lines

And also these:
24140 tools: xend: tolerate empty state/*.xml

I have backported this.

Quoted 5 lines

23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only) 23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.

I'm not really convinced that these are appropriate for backporting to a supposedly stable tree.

Thanks,
Ian.

#40 lore raw
Quoted 6 lines · Ian Jackson

Konrad Rzeszutek Wilk writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 2 lines

And also these:
24140 tools: xend: tolerate empty state/*.xml

I have backported this.

Quoted 8 lines
Quoted 5 lines

23412 libxc: xc_domain_set_memory_map, xc_get_machine_memory_map (x86, amd64 only) 23632 libxc: Squash xc_e820.h (and delete) into xenctrl.h
23426 libxl: Add support for passing in the host's E820 for PCI passthrough 23428 libxl: Add 'e820_host' option to config file.
23427 libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate.

I'm not really convinced that these are appropriate for backporting to a supposedly stable tree.

What about the changeset 25131:6f81f4d79fde? It won't be able to apply cleanly in xen-4.1-testing though and I can provide the backport version for review if you give an OK?

Thanks.

Kindest regards,
Giam Teck Choon

#41 lore raw

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

I'm not really convinced that these are appropriate for backporting to a supposedly stable tree.

What about the changeset 25131:6f81f4d79fde? It won't be able to apply cleanly in xen-4.1-testing though and I can provide the backport version for review if you give an OK?

I would be happy to consider a backport of 25131, yes. You'll have to do some work as 4.1 doesn't have libxl_defbool_*.

Thanks,
Ian.

#42 lore raw
Quoted 11 lines · Ian Jackson

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

I'm not really convinced that these are appropriate for backporting to a supposedly stable tree.

What about the changeset 25131:6f81f4d79fde?  It won't be able to apply cleanly in xen-4.1-testing though and I can provide the backport version for review if you give an OK?

I would be happy to consider a backport of 25131, yes.  You'll have to do some work as 4.1 doesn't have libxl_defbool_*.

Not just libxl_defbool_* but also couple others :p

Anyway, here is my backport which I have tested and worked as described in http://lists.xen.org/archives/html/xen-devel/2012-03/msg01452.html
For your review and comments please.

libxl: support for "rtc_timeoffset" and "localtime"

Implement "rtc_timeoffset" and "localtime" options compatible as xm.

rtc_timeoffset is the offset between host time and guest time. localtime means to specify whether the emulted RTC appears as UTC or is offset by the host.

xen-unstable changeset: 25131:6f81f4d79fde

---
 tools/libxl/libxl.idl    |    2 ++
 tools/libxl/libxl_dom.c  |    3 +++
 tools/libxl/xl_cmdimpl.c |   13 +++++++++++++
 3 files changed, 18 insertions(+), 0 deletions(-)
tools/libxl/libxl.idl +2 -0
index 377417a..3193506 100644
@@ -94,6 +94,8 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("target_memkb",    uint32),
     ("video_memkb",     uint32),
     ("shadow_memkb",    uint32),
+    ("rtc_timeoffset",  uint32),
+    ("localtime",       bool),
     ("disable_migrate", bool),
     ("kernel",          libxl_file_reference),
     ("cpuid",           libxl_cpuid_policy_list),
tools/libxl/libxl_dom.c +3 -0
index c702cf7..7ab78db 100644
@@ -76,6 +76,9 @@ int libxl__build_pre(libxl_ctx *ctx, uint32_t domid,
     if ( info->disable_migrate )
         xc_domain_disable_migrate(ctx->xch, domid);
 
+    if (info->rtc_timeoffset)
+        xc_domain_set_time_offset(ctx->xch, domid, info->rtc_timeoffset);
+
     if (info->hvm) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
tools/libxl/xl_cmdimpl.c +0 -0
index 2dbced7..74545a5 100644
@@ -737,6 +737,19 @@ static void parse_config_data(const char

*configfile_filename_report,

     if (!xlu_cfg_get_long(config, "tsc_mode", &l))
         b_info->tsc_mode = l;

+ b_info->rtc_timeoffset = !xlu_cfg_get_long(config,
"rtc_timeoffset", &l) ? l : 0;
+
+ b_info->localtime = !xlu_cfg_get_long(config, "localtime", &l) ? l : 0;
+ if (b_info->localtime) {
+ time_t t;
+ struct tm *tm;
+
+ t = time(NULL);
+ tm = localtime(&t);
+
+ b_info->rtc_timeoffset += tm->tm_gmtoff;
+ }
+

     if (!xlu_cfg_get_long (config, "videoram", &l))
         b_info->video_memkb = l * 1024;
Quoted 3 lines

Thanks,
Ian.

Thanks.

Kindest regards,
Giam Teck Choon

#43 lore raw
Quoted 70 lines · Teck Choon Giam
Quoted 11 lines · Ian Jackson

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 7 lines · Ian Jackson
Quoted 2 lines

I'm not really convinced that these are appropriate for backporting to a supposedly stable tree.

What about the changeset 25131:6f81f4d79fde?  It won't be able to apply cleanly in xen-4.1-testing though and I can provide the backport version for review if you give an OK?

I would be happy to consider a backport of 25131, yes.  You'll have to do some work as 4.1 doesn't have libxl_defbool_*.

Not just libxl_defbool_* but also couple others :p

Anyway, here is my backport which I have tested and worked as described in http://lists.xen.org/archives/html/xen-devel/2012-03/msg01452.html
For your review and comments please.

libxl: support for "rtc_timeoffset" and "localtime"

Implement "rtc_timeoffset" and "localtime" options compatible as xm.

rtc_timeoffset is the offset between host time and guest time. localtime means to specify whether the emulted RTC appears as UTC or is offset by the host.

xen-unstable changeset: 25131:6f81f4d79fde

---
 tools/libxl/libxl.idl    |    2 ++
 tools/libxl/libxl_dom.c  |    3 +++
 tools/libxl/xl_cmdimpl.c |   13 +++++++++++++

 3 files changed, 18 insertions(+), 0 deletions(-)
tools/libxl/libxl.idl +2 -0
index 377417a..3193506 100644
@@ -94,6 +94,8 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("target_memkb",    uint32),
     ("video_memkb",     uint32),
     ("shadow_memkb",    uint32),
+    ("rtc_timeoffset",  uint32),
+    ("localtime",       bool),
     ("disable_migrate", bool),
     ("kernel",          libxl_file_reference),
     ("cpuid",           libxl_cpuid_policy_list),
tools/libxl/libxl_dom.c +3 -0
index c702cf7..7ab78db 100644
@@ -76,6 +76,9 @@ int libxl__build_pre(libxl_ctx *ctx, uint32_t domid,
     if ( info->disable_migrate )
         xc_domain_disable_migrate(ctx->xch, domid);
 
+    if (info->rtc_timeoffset)
+        xc_domain_set_time_offset(ctx->xch, domid, info->rtc_timeoffset);
+
     if (info->hvm) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
tools/libxl/xl_cmdimpl.c +0 -0
index 2dbced7..74545a5 100644

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 742

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -737,6 +737,19 @@ static void parse_config_data(const char
 *configfile_filename_report,
     if (!xlu_cfg_get_long(config, "tsc_mode", &l))
         b_info->tsc_mode = l;
 
+    b_info->rtc_timeoffset = !xlu_cfg_get_long(config,
 "rtc_timeoffset", &l) ? l : 0;

Ops... forgot about coding style... need to be within 80 column... I will roll out another patch to fix this after your review. Sorry :(

Thanks.

Kindest regards,
Giam Teck Choon

Quoted 25 lines
tools/libxl/xl_cmdimpl.c +12 -0
+
+    b_info->localtime = !xlu_cfg_get_long(config, "localtime", &l) ? l : 0;
+    if (b_info->localtime) {
+        time_t t;
+        struct tm *tm;
+
+        t = time(NULL);
+        tm = localtime(&t);
+
+        b_info->rtc_timeoffset += tm->tm_gmtoff;
+    }
+
     if (!xlu_cfg_get_long (config, "videoram", &l))

        b_info->video_memkb = l * 1024;

Quoted 3 lines

Thanks,
Ian.

Thanks.

Kindest regards,
Giam Teck Choon

Acked-by
#44 lore raw

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 1 line

On Wed, Apr 4, 2012 at 3:50 AM, Teck Choon Giam <[email protected]> wrot> > For your review and comments please.

...

Quoted 1 line
Quoted 1 line

libxl: support for "rtc_timeoffset" and "localtime"

Thanks, looks good to me.

Unfortunately...

Quoted 2 lines
Quoted 2 lines

+    b_info->rtc_timeoffset = !xlu_cfg_get_long(config, "rtc_timeoffset", &l) ? l : 0;

Your email program wrapped it.

Quoted 2 lines

Ops... forgot about coding style... need to be within 80 column... I will roll out another patch to fix this after your review. Sorry :(

I think if you fix the coding style you will avoid the bug in your email program. Alternatively, include the patch as an attachment too.

Ian.

#45 lore raw
Quoted 13 lines · Ian Jackson

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 1 line

On Wed, Apr 4, 2012 at 3:50 AM, Teck Choon Giam <[email protected]> wrot> > For your review and comments please.

...

Quoted 1 line
Quoted 1 line

libxl: support for "rtc_timeoffset" and "localtime"

Thanks, looks good to me.

Unfortunately...

Quoted 2 lines
Quoted 2 lines

+    b_info->rtc_timeoffset = !xlu_cfg_get_long(config, "rtc_timeoffset", &l) ? l : 0;

Quoted 7 lines

Your email program wrapped it.

Quoted 2 lines

Ops... forgot about coding style... need to be within 80 column... I will roll out another patch to fix this after your review.  Sorry :(

I think if you fix the coding style you will avoid the bug in your email program.  Alternatively, include the patch as an attachment too.

Yes, I know gmail wrapped it as it is longer than 80 in length. Attached is the fix patch.

Quoted 2 lines

Ian.

Thanks Ian for taking time to review ;)

Kindest regards,
Giam Teck Choon

libxl: support for "rtc_timeoffset" and "localtime"

Implement "rtc_timeoffset" and "localtime" options compatible as xm.

rtc_timeoffset is the offset between host time and guest time. localtime means to specify whether the emulted RTC appears as UTC or is offset by the host.

xen-unstable changeset: 25131:6f81f4d79fde

---
 tools/libxl/libxl.idl    |    2 ++
 tools/libxl/libxl_dom.c  |    3 +++
 tools/libxl/xl_cmdimpl.c |   14 ++++++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)
tools/libxl/libxl.idl +2 -0
index 377417a..3193506 100644
@@ -94,6 +94,8 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("target_memkb",    uint32),
     ("video_memkb",     uint32),
     ("shadow_memkb",    uint32),
+    ("rtc_timeoffset",  uint32),
+    ("localtime",       bool),
     ("disable_migrate", bool),
     ("kernel",          libxl_file_reference),
     ("cpuid",           libxl_cpuid_policy_list),
tools/libxl/libxl_dom.c +3 -0
index c702cf7..7ab78db 100644
@@ -76,6 +76,9 @@ int libxl__build_pre(libxl_ctx *ctx, uint32_t domid,
     if ( info->disable_migrate )
         xc_domain_disable_migrate(ctx->xch, domid);
 
+    if (info->rtc_timeoffset)
+        xc_domain_set_time_offset(ctx->xch, domid, info->rtc_timeoffset);
+
     if (info->hvm) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
tools/libxl/xl_cmdimpl.c +14 -0
index 2dbced7..6bace41 100644
@@ -737,6 +737,20 @@ static void parse_config_data(const char *configfile_filename_report,
     if (!xlu_cfg_get_long(config, "tsc_mode", &l))
         b_info->tsc_mode = l;
 
+    b_info->rtc_timeoffset = !xlu_cfg_get_long(config, "rtc_timeoffset", &l)
+        ? l : 0;
+
+    b_info->localtime = !xlu_cfg_get_long(config, "localtime", &l) ? l : 0;
+    if (b_info->localtime) {
+        time_t t;
+        struct tm *tm;
+
+        t = time(NULL);
+        tm = localtime(&t);
+
+        b_info->rtc_timeoffset += tm->tm_gmtoff;
+    }
+
     if (!xlu_cfg_get_long (config, "videoram", &l))
         b_info->video_memkb = l * 1024;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#46 lore raw

Teck Choon Giam writes ("Re: [Xen-devel] backport requests for 4.x-testing"):

Quoted 6 lines · Ian Jackson
Quoted 2 lines

I think if you fix the coding style you will avoid the bug in your email program.  Alternatively, include the patch as an attachment too.

Yes, I know gmail wrapped it as it is longer than 80 in length. Attached is the fix patch.

Thanks, applied.

Ian.

Applied
#47 lore raw
In reply to Jan Beulich

All applied, except:

Quoted 1 line · Jan Beulich

24535 (x86/vMSI: miscellaneous fixes)

Applied to 4.1, but does not easily apply to 4.0. You'll need to provide a patch against 4.0-testing.

Quoted 2 lines

24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

This one applied, but I see a bug in the original xen-unstable patch. In XEN_DOMCTL_assign_device you break on d->is_dying, but do not put_domain(d). You should go fix that in xen-unstable.

Quoted 2 lines

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

Doesn't easily apply. Need a patch against 4.1-testing.

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

Depends on other xen-unstable patches which refactor AMD IOMMU event handling. You'd need to provide a manual backport of this for 4.1-testing.

Quoted 1 line

24690 (x86: avoid deadlock after a PCI SERR NMI)

There is no PCI SERR NMI handling in 4.0-testing. It would also need backporting.

-- Keir

#48 lore raw
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Keir Fraser

All applied, except:

Thanks. Let's wait for the simple ones to get through the stage test first before throwing in such that are more involved.

Quoted 7 lines · Jan Beulich
Quoted 2 lines

24535 (x86/vMSI: miscellaneous fixes)

Applied to 4.1, but does not easily apply to 4.0. You'll need to provide a patch against 4.0-testing.

Quoted 6 lines
Quoted 2 lines

24888 (passthrough: release assigned PCI devices earlier during domain shutdown)

This one applied, but I see a bug in the original xen-unstable patch. In XEN_DOMCTL_assign_device you break on d->is_dying, but do not put_domain(d). You should go fix that in xen-unstable.

24983:f234e34ea28f

Quoted 7 lines
Quoted 2 lines

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

Doesn't easily apply. Need a patch against 4.1-testing.

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

Quoted 7 lines

Depends on other xen-unstable patches which refactor AMD IOMMU event handling. You'd need to provide a manual backport of this for 4.1-testing.

Quoted 1 line

24690 (x86: avoid deadlock after a PCI SERR NMI)

There is no PCI SERR NMI handling in 4.0-testing. It would also need backporting.

Oh, sorry, I overlooked that this requires 22949 as prerequisite. But then again maybe we might just leave it as-is in 4.0 (and have distros that care, like ours, continue to carry the patches themselves - after all when providing the list I didn't pick everything we backported anyway, just those that I considered more of a fix than an enhancement).

Jan

author Acked-by Keir Fraser Acked-by Andrew Cooper
#49 lore raw
In reply to Keir Fraser
Quoted 10 lines
Quoted 3 lines
Quoted 1 line · Keir Fraser

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])

Doesn't easily apply. Need a patch against 4.1-testing.

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

Depends on other xen-unstable patches which refactor AMD IOMMU event handling. You'd need to provide a manual backport of this for 4.1-testing.

All attached.

Jan

# HG changeset patch
# User Dario Faggioli <[email protected]> # Date 1327054832 0
# Node ID 028230eb2359f33da48b3b7f85173a1b49b9c7d6 # Parent d600a3d7faeeee3cf947bf1658b873e966fc0f16
iommu: Move IOMMU faults handling into softirq for AMD-Vi.

Dealing with interrupts from AMD-Vi IOMMU(s) is deferred to a softirq-tasklet, raised by the actual IRQ handler. To avoid more interrupts being generated (because of further faults), they must be masked in the IOMMU within the low level IRQ handler and enabled back in the tasklet body. Notice that this may cause the log to overflow, but none of the existing entry will be overwritten.

xen/drivers/passthrough/amd/iommu_init.c +54 -14
@@ -33,6 +33,8 @@ static int nr_amd_iommus;
 static long amd_iommu_cmd_buffer_entries = IOMMU_CMD_BUFFER_DEFAULT_ENTRIES;
 static long amd_iommu_event_log_entries = IOMMU_EVENT_LOG_DEFAULT_ENTRIES;
 
+static struct tasklet amd_iommu_irq_tasklet;
+
 unsigned short ivrs_bdf_entries;
 struct ivrs_mappings *ivrs_mappings;
 struct list_head amd_iommu_head;
@@ -517,34 +519,70 @@ static void parse_event_log_entry(u32 en
     }
 }
 
+static void do_amd_iommu_irq(unsigned long data)
+{
+    struct amd_iommu *iommu;
+
+    if ( !iommu_found() )
+    {
+        AMD_IOMMU_DEBUG("no device found, something must be very wrong!\n");
+        return;
+   }
+
+    /*
+     * No matter from where the interrupt came from, check all the
+     * IOMMUs present in the system. This allows for having just one
+     * tasklet (instead of one per each IOMMUs).
+     */
+    for_each_amd_iommu ( iommu )
+    {
+        u32 entry;
+        unsigned long flags;
+        int of;
+
+        spin_lock_irqsave(&iommu->lock, flags);
+        amd_iommu_read_event_log(iommu);
+
+        /* check event overflow */
+        entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
+        of = get_field_from_reg_u32(entry,
+                                   IOMMU_STATUS_EVENT_OVERFLOW_MASK,
+                                   IOMMU_STATUS_EVENT_OVERFLOW_SHIFT);
+
+        /* reset event log if event overflow */
+        if ( of )
+            amd_iommu_reset_event_log(iommu);
+
+        /* reset interrupt status bit */
+        entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
+        set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry,
+                             IOMMU_STATUS_EVENT_LOG_INT_MASK,
+                             IOMMU_STATUS_EVENT_LOG_INT_SHIFT, &entry);
+        writel(entry, iommu->mmio_base+IOMMU_STATUS_MMIO_OFFSET);
+        spin_unlock_irqrestore(&iommu->lock, flags);
+    }
+}
+
 static void amd_iommu_page_fault(int irq, void *dev_id,
                              struct cpu_user_regs *regs)
 {
     u32 entry;
     unsigned long flags;
-    int of;
     struct amd_iommu *iommu = dev_id;
 
     spin_lock_irqsave(&iommu->lock, flags);
-    amd_iommu_read_event_log(iommu);
 
-    /*check event overflow */
+    /* Silence interrupts from both event logging */
     entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
-    of = get_field_from_reg_u32(entry,
-                               IOMMU_STATUS_EVENT_OVERFLOW_MASK,
-                               IOMMU_STATUS_EVENT_OVERFLOW_SHIFT);
-
-    /* reset event log if event overflow */
-    if ( of )
-        amd_iommu_reset_event_log(iommu);
-
-    /* reset interrupt status bit */
-    entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
-    set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry,
+    set_field_in_reg_u32(IOMMU_CONTROL_DISABLED, entry,
                          IOMMU_STATUS_EVENT_LOG_INT_MASK,
                          IOMMU_STATUS_EVENT_LOG_INT_SHIFT, &entry);
     writel(entry, iommu->mmio_base+IOMMU_STATUS_MMIO_OFFSET);
+
     spin_unlock_irqrestore(&iommu->lock, flags);
+
+    /* It is the tasklet that will clear the logs and re-enable interrupts */
+    tasklet_schedule(&amd_iommu_irq_tasklet);
 }
 
 static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
@@ -689,6 +727,8 @@ static int __init amd_iommu_init_one(str
     printk("AMD-Vi: IOMMU %d Enabled.\n", nr_amd_iommus );
     nr_amd_iommus++;
 
+    softirq_tasklet_init(&amd_iommu_irq_tasklet, do_amd_iommu_irq, 0);
+
     return 0;
 
 error_out:

# HG changeset patch
# User Jan Beulich <[email protected]>
# Date 1317730526 -7200
# Node ID e09ebf7a31f55bb26c3cce7695a435ed20adf05b # Parent a99d75671a911f9c0d5d11e0fe88a0a65863cb44 introduce xzalloc() & Co

Rather than having to match a call to one of the xmalloc() flavors with a subsequent memset(), introduce a zeroing variant of each of those flavors.

xen/common/xmalloc_tlsf.c +7 -0
@@ -585,6 +585,13 @@ void *_xmalloc(unsigned long size, unsig
     return p;
 }
 
+void *_xzalloc(unsigned long size, unsigned long align)
+{
+    void *p = _xmalloc(size, align);
+
+    return p ? memset(p, 0, size) : p;
+}
+
 void xfree(void *p)
 {
     struct bhdr *b;
xen/include/acpi/platform/aclinux.h +1 -4
@@ -77,10 +77,7 @@
 #define acpi_thread_id struct vcpu *
 
 #define ACPI_ALLOCATE(a)	xmalloc_bytes(a)
-#define ACPI_ALLOCATE_ZEROED(a)	({              \
-    void *p = xmalloc_bytes(a);                 \
-    if ( p ) memset(p, 0, a);                   \
-    p; })
+#define ACPI_ALLOCATE_ZEROED(a)	xzalloc_bytes(a)
 #define ACPI_FREE(a)		xfree(a)
 
 #endif				/* __ACLINUX_H__ */
xen/include/xen/xmalloc.h +16 -1
@@ -8,19 +8,25 @@
 
 /* Allocate space for typed object. */
 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+#define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type)))
 
 /* Allocate space for array of typed objects. */
 #define xmalloc_array(_type, _num) \
     ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
+#define xzalloc_array(_type, _num) \
+    ((_type *)_xzalloc_array(sizeof(_type), __alignof__(_type), _num))
 
 /* Allocate untyped storage. */
-#define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES))
+#define xmalloc_bytes(_bytes) _xmalloc(_bytes, SMP_CACHE_BYTES)
+#define xzalloc_bytes(_bytes) _xzalloc(_bytes, SMP_CACHE_BYTES)
 
 /* Free any of the above. */
 extern void xfree(void *);
 
 /* Underlying functions */
 extern void *_xmalloc(unsigned long size, unsigned long align);
+extern void *_xzalloc(unsigned long size, unsigned long align);
+
 static inline void *_xmalloc_array(
     unsigned long size, unsigned long align, unsigned long num)
 {
@@ -30,6 +36,15 @@ static inline void *_xmalloc_array(
  	return _xmalloc(size * num, align);
 }
 
+static inline void *_xzalloc_array(
+    unsigned long size, unsigned long align, unsigned long num)
+{
+    /* Check for overflow. */
+    if (size && num > UINT_MAX / size)
+        return NULL;
+    return _xzalloc(size * num, align);
+}
+
 /*
  * Pooled allocator interface.
  */

# HG changeset patch
# User Jan Beulich <[email protected]>
# Date 1321604484 -3600
# Node ID f29b5bd6e25fd78409baa5461914c67065f7579f # Parent 0d50e704834fb53c6c86b8b0badd19d88e73c4ed x86/IRQ: prevent vector sharing within IO-APICs

Following the prevention of vector sharing for MSIs, this change enforces the same within IO-APICs: Pin based interrupts use the IO-APIC as their identifying device under the AMD IOMMU (and just like for MSIs, only the identifying device is used to remap interrupts here, with no regard to an interrupt's destination).

Additionally, LAPIC initiated EOIs (for level triggered interrupts) too use only the vector for identifying which interrupts to end. While this generally causes no significant problem (at worst an interrupt would be re-raised without a new interrupt event actually having occurred), it still seems better to avoid the situation.

For this second aspect, a distinction is being made between the traditional and the directed-EOI cases: In the former, vectors should not be shared throughout all IO-APICs in the system, while in the latter case only individual IO-APICs need to be contrained (or, if the firmware indicates so, sub- groups of them having the same GSI appear at multiple pins).

xen/arch/x86/io_apic.c +53 -2

96 lines not on this page · raw message

xen/arch/x86/irq.c +5 -0
@@ -403,6 +403,11 @@ static vmask_t *irq_get_used_vector_mask
             }
         }
     }
+    else if ( IO_APIC_IRQ(irq) &&
+              opt_irq_vector_map != OPT_IRQ_VECTOR_MAP_NONE )
+    {
+        ret = io_apic_get_used_vector_map(irq);
+    }
 
     return ret;
 }
xen/include/asm-x86/irq.h +1 -0
@@ -113,6 +113,7 @@ void setup_IO_APIC(void);
 void disable_IO_APIC(void);
 void print_IO_APIC(void);
 void setup_ioapic_dest(void);
+vmask_t *io_apic_get_used_vector_map(unsigned int irq);
 
 extern unsigned long io_apic_irqs;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#50 lore raw
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 3 lines
Quoted 1 line · Keir Fraser

24156 (x86/IRQ: prevent vector sharing within IO-APICs, requiring

            23900 [kzalloc])
Quoted 8 lines
Quoted 6 lines

Doesn't easily apply. Need a patch against 4.1-testing.

Quoted 1 line

24527 (iommu: Move IOMMU faults handling into softirq for AMD-Vi)

Depends on other xen-unstable patches which refactor AMD IOMMU event handling. You'd need to provide a manual backport of this for 4.1-testing.

All attached.

And all now applied.

-- Keir

Quoted 2 lines

Jan

#51 lore raw
In reply to Keir Fraser
Quoted 5 lines
Quoted 2 lines
Quoted 1 line · Keir Fraser

24535 (x86/vMSI: miscellaneous fixes)

Applied to 4.1, but does not easily apply to 4.0. You'll need to provide a patch against 4.0-testing.

Here you go.

Jan

# HG changeset patch
# User Jan Beulich <[email protected]>
# Date 1327311317 0
# Node ID fb81b807c1540eb5797b3daa4bddff99363b20ef # Parent eca719b621a1201528bfec25fb1786ec21c0c9d3 x86/vMSI: miscellaneous fixes

This addresses a number of problems in msixtbl_{read,write}():
- address alignment was not checked, allowing for memory corruption in the hypervisor (write case) or returning of hypervisor private data to the guest (read case)
- the interrupt mask bit was permitted to be written by the guest (while Xen's interrupt flow control routines need to control it)
- MAX_MSIX_TABLE_{ENTRIES,PAGES} were pointlessly defined to plain numbers (making it unobvious why they have these values, and making the latter non-portable)
- MAX_MSIX_TABLE_PAGES was also off by one (failing to account for a non-zero table offset); this was also affecting host MSI-X code
- struct msixtbl_entry's table_flags[] was one element larger than necessary due to improper open-coding of BITS_TO_LONGS()
- msixtbl_read() unconditionally accessed the physical table, even though the data was only needed in a quarter of all cases
- various calculations were done unnecessarily for both of the rather distinct code paths in msixtbl_read()

Additionally it is unclear on what basis MAX_MSIX_ACC_ENTRIES was chosen to be 3.

xen/arch/x86/hvm/vmsi.c +24 -14
@@ -157,7 +157,7 @@ struct msixtbl_entry
     struct pci_dev *pdev;
     unsigned long gtable;       /* gpa of msix table */
     unsigned long table_len;
-    unsigned long table_flags[MAX_MSIX_TABLE_ENTRIES / BITS_PER_LONG + 1];
+    unsigned long table_flags[BITS_TO_LONGS(MAX_MSIX_TABLE_ENTRIES)];
 
     struct rcu_head rcu;
 };
@@ -179,17 +179,14 @@ static struct msixtbl_entry *msixtbl_fin
 static void __iomem *msixtbl_addr_to_virt(
     struct msixtbl_entry *entry, unsigned long addr)
 {
-    int idx, nr_page;
+    unsigned int idx, nr_page;
 
-    if ( !entry )
+    if ( !entry || !entry->pdev )
         return NULL;
 
     nr_page = (addr >> PAGE_SHIFT) -
               (entry->gtable >> PAGE_SHIFT);
 
-    if ( !entry->pdev )
-        return NULL;
-
     idx = entry->pdev->msix_table_idx[nr_page];
     if ( !idx )
         return NULL;
@@ -207,10 +204,10 @@ static int msixtbl_read(
     void *virt;
     int r = X86EMUL_UNHANDLEABLE;
 
-    rcu_read_lock();
+    if ( len != 4 || (address & 3) )
+        return r;
 
-    if ( len != 4 )
-        goto out;
+    rcu_read_lock();
 
     offset = address & (PCI_MSIX_ENTRY_SIZE - 1);
     if ( offset != PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET)
@@ -235,13 +232,13 @@ static int msixtbl_write(struct vcpu *v,
     unsigned long offset;
     struct msixtbl_entry *entry;
     void *virt;
-    int nr_entry;
+    unsigned int nr_entry;
     int r = X86EMUL_UNHANDLEABLE;
 
-    rcu_read_lock();
+    if ( len != 4 || (address & 3) )
+        return r;
 
-    if ( len != 4 )
-        goto out;
+    rcu_read_lock();
 
     entry = msixtbl_find_entry(v, address);
     nr_entry = (address - entry->gtable) / PCI_MSIX_ENTRY_SIZE;
@@ -261,9 +258,22 @@ static int msixtbl_write(struct vcpu *v,
     if ( !virt )
         goto out;
 
+    /* Do not allow the mask bit to be changed. */
+#if 0 /* XXX
+       * As the mask bit is the only defined bit in the word, and as the
+       * host MSI-X code doesn't preserve the other bits anyway, doing
+       * this is pointless. So for now just discard the write (also
+       * saving us from having to determine the matching irq_desc).
+       */
+    spin_lock_irqsave(&desc->lock, flags);
+    orig = readl(virt);
+    val &= ~PCI_MSIX_VECTOR_BITMASK;
+    val |= orig & PCI_MSIX_VECTOR_BITMASK;
     writel(val, virt);
-    r = X86EMUL_OKAY;
+    spin_unlock_irqrestore(&desc->lock, flags);
+#endif
 
+    r = X86EMUL_OKAY;
 out:
     rcu_read_unlock();
     return r;
xen/include/asm-x86/msi.h +0 -6
@@ -127,12 +127,6 @@ extern const struct hw_interrupt_type pc
 #define PCI_MSIX_FLAGS_BIRMASK		(7 << 0)
 #define PCI_MSIX_FLAGS_BITMASK		(1 << 0)
 
-#define PCI_MSIX_ENTRY_SIZE			16
-#define  PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET	0
-#define  PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET	4
-#define  PCI_MSIX_ENTRY_DATA_OFFSET		8
-#define  PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET	12
-
 #define msi_control_reg(base)		(base + PCI_MSI_FLAGS)
 #define msi_lower_address_reg(base)	(base + PCI_MSI_ADDRESS_LO)
 #define msi_upper_address_reg(base)	(base + PCI_MSI_ADDRESS_HI)
xen/include/xen/pci.h +6 -2
@@ -11,6 +11,8 @@
 #include <xen/types.h>
 #include <xen/list.h>
 #include <xen/spinlock.h>
+#include <xen/pci_regs.h>
+#include <asm/page.h>
 
 /*
  * The PCI interface treats multi-function devices as independent
@@ -29,8 +31,10 @@
 #define PCI_BDF(b,d,f)  ((((b) & 0xff) << 8) | PCI_DEVFN(d,f))
 #define PCI_BDF2(b,df)  ((((b) & 0xff) << 8) | ((df) & 0xff))
 
-#define MAX_MSIX_TABLE_ENTRIES  2048
-#define MAX_MSIX_TABLE_PAGES    8
+#define MAX_MSIX_TABLE_ENTRIES  (PCI_MSIX_FLAGS_QSIZE + 1)
+#define MAX_MSIX_TABLE_PAGES    PFN_UP(MAX_MSIX_TABLE_ENTRIES * \
+                                       PCI_MSIX_ENTRY_SIZE + \
+                                       (~PCI_MSIX_FLAGS_BIRMASK & (PAGE_SIZE - 1)))
 struct pci_dev_info {
     unsigned is_extfn;
     unsigned is_virtfn;
xen/include/xen/pci_regs.h +7 -0
@@ -302,6 +302,13 @@
 #define  PCI_MSIX_FLAGS_ENABLE	(1 << 15)
 #define  PCI_MSIX_FLAGS_MASKALL	(1 << 14)
 #define PCI_MSIX_FLAGS_BIRMASK	(7 << 0)
+
+#define PCI_MSIX_ENTRY_SIZE			16
+#define  PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET	0
+#define  PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET	4
+#define  PCI_MSIX_ENTRY_DATA_OFFSET		8
+#define  PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET	12
+
 #define PCI_MSIX_FLAGS_BITMASK	(1 << 0)
 
 /* CompactPCI Hotswap Register */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Applied
#52 lore raw
Quoted 7 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 1 line · Keir Fraser

24535 (x86/vMSI: miscellaneous fixes)

Applied to 4.1, but does not easily apply to 4.0. You'll need to provide a patch against 4.0-testing.

Here you go.

Applied.

Quoted 2 lines

Jan