xen: legacy PVH fixes for the new interrupt count

Register interrupts using the PIC pic_register_sources method instead
of doing it in apic_setup_io. This is now required, since the internal
interrupt structures are not yet setup when calling apic_setup_io.

Approved by:		re (gjb)
Sponsored by:		Citrix Systems R&D
This commit is contained in:
Roger Pau Monné 2018-09-13 07:14:11 +00:00
parent d7627401ec
commit a74cdf4e74
3 changed files with 66 additions and 40 deletions

View File

@ -193,54 +193,67 @@ xenpv_setup_io(void)
{
if (xen_initial_domain()) {
int i, ret;
/* Map MADT */
madt_physaddr = acpi_find_table(ACPI_SIG_MADT);
madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT);
madt_length = madt->Header.Length;
/* Try to initialize ACPI so that we can access the FADT. */
i = acpi_Startup();
if (ACPI_FAILURE(i)) {
printf("MADT: ACPI Startup failed with %s\n",
AcpiFormatException(i));
printf("Try disabling either ACPI or apic support.\n");
panic("Using MADT but ACPI doesn't work");
}
/* Run through the table to see if there are any overrides. */
madt_walk_table(madt_parse_ints, NULL);
/*
* If there was not an explicit override entry for the SCI,
* force it to use level trigger and active-low polarity.
* NB: we could iterate over the MADT IOAPIC entries in order
* to figure out the exact number of IOAPIC interrupts, but
* this is legacy code so just keep using the previous
* behaviour and assume a maximum of 256 interrupts.
*/
if (!madt_found_sci_override) {
printf(
"MADT: Forcing active-low polarity and level trigger for SCI\n");
ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt,
INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
if (ret != 0)
panic("Unable to register SCI IRQ");
}
/* Register legacy ISA IRQs */
for (i = 1; i < 16; i++) {
if (intr_lookup_source(i) != NULL)
continue;
ret = xen_register_pirq(i, INTR_TRIGGER_EDGE,
INTR_POLARITY_LOW);
if (ret != 0 && bootverbose)
printf("Unable to register legacy IRQ#%d: %d\n",
i, ret);
}
num_io_irqs = max(MINIMUM_MSI_INT - 1, num_io_irqs);
acpi_SetDefaultIntrModel(ACPI_INTR_APIC);
}
return (0);
}
void
xenpv_register_pirqs(struct pic *pic __unused)
{
unsigned int i;
int ret;
/* Map MADT */
madt_physaddr = acpi_find_table(ACPI_SIG_MADT);
madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT);
madt_length = madt->Header.Length;
/* Try to initialize ACPI so that we can access the FADT. */
ret = acpi_Startup();
if (ACPI_FAILURE(ret)) {
printf("MADT: ACPI Startup failed with %s\n",
AcpiFormatException(ret));
printf("Try disabling either ACPI or apic support.\n");
panic("Using MADT but ACPI doesn't work");
}
/* Run through the table to see if there are any overrides. */
madt_walk_table(madt_parse_ints, NULL);
/*
* If there was not an explicit override entry for the SCI,
* force it to use level trigger and active-low polarity.
*/
if (!madt_found_sci_override) {
printf(
"MADT: Forcing active-low polarity and level trigger for SCI\n");
ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt,
INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW);
if (ret != 0)
panic("Unable to register SCI IRQ");
}
/* Register legacy ISA IRQs */
for (i = 1; i < 16; i++) {
if (intr_lookup_source(i) != NULL)
continue;
ret = xen_register_pirq(i, INTR_TRIGGER_EDGE,
INTR_POLARITY_LOW);
if (ret != 0 && bootverbose)
printf("Unable to register legacy IRQ#%u: %d\n", i,
ret);
}
}
static void
xenpv_register(void *dummy __unused)
{

View File

@ -178,6 +178,9 @@ struct pic xen_intr_pic = {
* physical interrupt sources.
*/
struct pic xen_intr_pirq_pic = {
#ifdef __amd64__
.pic_register_sources = xenpv_register_pirqs,
#endif
.pic_enable_source = xen_intr_pirq_enable_source,
.pic_disable_source = xen_intr_pirq_disable_source,
.pic_eoi_source = xen_intr_pirq_eoi_source,

View File

@ -274,4 +274,14 @@ int xen_intr_add_handler(const char *name, driver_filter_t filter,
int xen_intr_get_evtchn_from_port(evtchn_port_t port,
xen_intr_handle_t *handlep);
/**
* Register the IO-APIC PIRQs when running in legacy PVH Dom0 mode.
*
* \param pic PIC instance.
*
* NB: this should be removed together with the support for legacy PVH mode.
*/
struct pic;
void xenpv_register_pirqs(struct pic *pic);
#endif /* _XEN_INTR_H_ */