Skip to content

Commit 84d582d

Browse files
bostrovsjgross1
authored andcommitted
xen: Revert commits da72ff5 and 72a9b18
Recent discussion (http://marc.info/?l=xen-devel&m=149192184523741) established that commit 72a9b18 ("xen: Remove event channel notification through Xen PCI platform device") (and thus commit da72ff5 ("partially revert "xen: Remove event channel notification through Xen PCI platform device"")) are unnecessary and, in fact, prevent HVM guests from booting on Xen releases prior to 4.0 Therefore we revert both of those commits. The summary of that discussion is below: Here is the brief summary of the current situation: Before the offending commit (72a9b18): 1) INTx does not work because of the reset_watches path. 2) The reset_watches path is only taken if you have Xen > 4.0 3) The Linux Kernel by default will use vector inject if the hypervisor support. So even INTx does not work no body running the kernel with Xen > 4.0 would notice. Unless he explicitly disabled this feature either in the kernel or in Xen (and this can only be disabled by modifying the code, not user-supported way to do it). After the offending commit (+ partial revert): 1) INTx is no longer support for HVM (only for PV guests). 2) Any HVM guest The kernel will not boot on Xen < 4.0 which does not have vector injection support. Since the only other mode supported is INTx which. So based on this summary, I think before commit (72a9b18) we were in much better position from a user point of view. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 5f6a161 commit 84d582d

7 files changed

Lines changed: 54 additions & 23 deletions

File tree

‎arch/x86/include/asm/xen/events.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
2020
/* No need for a barrier -- XCHG is a barrier on x86. */
2121
#define xchg_xen_ulong(ptr, val) xchg((ptr), (val))
2222

23+
extern int xen_have_vector_callback;
24+
25+
/*
26+
* Events delivered via platform PCI interrupts are always
27+
* routed to vcpu 0 and hence cannot be rebound.
28+
*/
29+
static inline bool xen_support_evtchn_rebind(void)
30+
{
31+
return (!xen_hvm_domain() || xen_have_vector_callback);
32+
}
33+
2334
#endif /* _ASM_X86_XEN_EVENTS_H */

‎arch/x86/pci/xen.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ void __init xen_msi_init(void)
447447

448448
int __init pci_xen_hvm_init(void)
449449
{
450-
if (!xen_feature(XENFEAT_hvm_pirqs))
450+
if (!xen_have_vector_callback || !xen_feature(XENFEAT_hvm_pirqs))
451451
return 0;
452452

453453
#ifdef CONFIG_ACPI

‎arch/x86/xen/enlighten_hvm.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "mmu.h"
1919
#include "smp.h"
2020

21+
__read_mostly int xen_have_vector_callback;
22+
EXPORT_SYMBOL_GPL(xen_have_vector_callback);
23+
2124
void __ref xen_hvm_init_shared_info(void)
2225
{
2326
int cpu;
@@ -123,7 +126,7 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu)
123126
per_cpu(xen_vcpu_id, cpu) = cpu;
124127
xen_vcpu_setup(cpu);
125128

126-
if (xen_feature(XENFEAT_hvm_safe_pvclock))
129+
if (xen_have_vector_callback && xen_feature(XENFEAT_hvm_safe_pvclock))
127130
xen_setup_timer(cpu);
128131

129132
rc = xen_smp_intr_init(cpu);
@@ -139,7 +142,7 @@ static int xen_cpu_dead_hvm(unsigned int cpu)
139142
{
140143
xen_smp_intr_free(cpu);
141144

142-
if (xen_feature(XENFEAT_hvm_safe_pvclock))
145+
if (xen_have_vector_callback && xen_feature(XENFEAT_hvm_safe_pvclock))
143146
xen_teardown_timer(cpu);
144147

145148
return 0;
@@ -156,7 +159,8 @@ static void __init xen_hvm_guest_init(void)
156159

157160
xen_panic_handler_init();
158161

159-
BUG_ON(!xen_feature(XENFEAT_hvm_callback_vector));
162+
if (xen_feature(XENFEAT_hvm_callback_vector))
163+
xen_have_vector_callback = 1;
160164

161165
xen_hvm_smp_init();
162166
WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_hvm, xen_cpu_dead_hvm));
@@ -189,7 +193,7 @@ bool xen_hvm_need_lapic(void)
189193
return false;
190194
if (!xen_hvm_domain())
191195
return false;
192-
if (xen_feature(XENFEAT_hvm_pirqs))
196+
if (xen_feature(XENFEAT_hvm_pirqs) && xen_have_vector_callback)
193197
return false;
194198
return true;
195199
}

‎arch/x86/xen/smp_hvm.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <asm/smp.h>
22

3+
#include <xen/events.h>
4+
35
#include "xen-ops.h"
46
#include "smp.h"
57

@@ -49,6 +51,9 @@ static void xen_hvm_cpu_die(unsigned int cpu)
4951

5052
void __init xen_hvm_smp_init(void)
5153
{
54+
if (!xen_have_vector_callback)
55+
return;
56+
5257
smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
5358
smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
5459
smp_ops.cpu_die = xen_hvm_cpu_die;

‎arch/x86/xen/time.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ static void xen_hvm_setup_cpu_clockevents(void)
436436

437437
void __init xen_hvm_init_time_ops(void)
438438
{
439+
/*
440+
* vector callback is needed otherwise we cannot receive interrupts
441+
* on cpu > 0 and at this point we don't know how many cpus are
442+
* available.
443+
*/
444+
if (!xen_have_vector_callback)
445+
return;
446+
439447
if (!xen_feature(XENFEAT_hvm_safe_pvclock)) {
440448
printk(KERN_INFO "Xen doesn't support pvclock on HVM,"
441449
"disable pv timer\n");

‎drivers/xen/events/events_base.c‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,9 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
13121312
if (!VALID_EVTCHN(evtchn))
13131313
return -1;
13141314

1315+
if (!xen_support_evtchn_rebind())
1316+
return -1;
1317+
13151318
/* Send future instances of this interrupt to other vcpu. */
13161319
bind_vcpu.port = evtchn;
13171320
bind_vcpu.vcpu = xen_vcpu_nr(tcpu);
@@ -1646,14 +1649,20 @@ void xen_callback_vector(void)
16461649
int rc;
16471650
uint64_t callback_via;
16481651

1649-
callback_via = HVM_CALLBACK_VECTOR(HYPERVISOR_CALLBACK_VECTOR);
1650-
rc = xen_set_callback_via(callback_via);
1651-
BUG_ON(rc);
1652-
pr_info("Xen HVM callback vector for event delivery is enabled\n");
1653-
/* in the restore case the vector has already been allocated */
1654-
if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
1655-
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
1656-
xen_hvm_callback_vector);
1652+
if (xen_have_vector_callback) {
1653+
callback_via = HVM_CALLBACK_VECTOR(HYPERVISOR_CALLBACK_VECTOR);
1654+
rc = xen_set_callback_via(callback_via);
1655+
if (rc) {
1656+
pr_err("Request for Xen HVM callback vector failed\n");
1657+
xen_have_vector_callback = 0;
1658+
return;
1659+
}
1660+
pr_info("Xen HVM callback vector for event delivery is enabled\n");
1661+
/* in the restore case the vector has already been allocated */
1662+
if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
1663+
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
1664+
xen_hvm_callback_vector);
1665+
}
16571666
}
16581667
#else
16591668
void xen_callback_vector(void) {}

‎drivers/xen/platform-pci.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ static int xen_allocate_irq(struct pci_dev *pdev)
9090
static int platform_pci_resume(struct pci_dev *pdev)
9191
{
9292
int err;
93-
if (!xen_pv_domain())
93+
94+
if (xen_have_vector_callback)
9495
return 0;
96+
9597
err = xen_set_callback_via(callback_via);
9698
if (err) {
9799
dev_err(&pdev->dev, "platform_pci_resume failure!\n");
@@ -137,15 +139,7 @@ static int platform_pci_probe(struct pci_dev *pdev,
137139

138140
platform_mmio = mmio_addr;
139141
platform_mmiolen = mmio_len;
140-
141-
/*
142-
* Xen HVM guests always use the vector callback mechanism.
143-
* L1 Dom0 in a nested Xen environment is a PV guest inside in an
144-
* HVM environment. It needs the platform-pci driver to get
145-
* notifications from L0 Xen, but it cannot use the vector callback
146-
* as it is not exported by L1 Xen.
147-
*/
148-
if (xen_pv_domain()) {
142+
if (!xen_have_vector_callback) {
149143
ret = xen_allocate_irq(pdev);
150144
if (ret) {
151145
dev_warn(&pdev->dev, "request_irq failed err=%d\n", ret);

0 commit comments

Comments
 (0)