Skip to content

Commit

Permalink
xen/events: don't use chip_data for legacy IRQs
Browse files Browse the repository at this point in the history
Since commit c330fb1 ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.")
Xen is using the chip_data pointer for storing IRQ specific data. When
running as a HVM domain this can result in problems for legacy IRQs, as
those might use chip_data for their own purposes.

Use a local array for this purpose in case of legacy IRQs, avoiding the
double use.

Cc: [email protected]
Fixes: c330fb1 ("XEN uses irqdesc::irq_data_common::handler_data to store a per interrupt XEN data pointer which contains XEN specific information.")
Signed-off-by: Juergen Gross <[email protected]>
Tested-by: Stefan Bader <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Juergen Gross <[email protected]>
  • Loading branch information
jgross1 committed Oct 1, 2020
1 parent a1b8638 commit 0891fb3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions drivers/xen/events/events_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ static bool (*pirq_needs_eoi)(unsigned irq);
/* Xen will never allocate port zero for any purpose. */
#define VALID_EVTCHN(chn) ((chn) != 0)

static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY];

static struct irq_chip xen_dynamic_chip;
static struct irq_chip xen_percpu_chip;
static struct irq_chip xen_pirq_chip;
Expand Down Expand Up @@ -156,7 +158,18 @@ int get_evtchn_to_irq(evtchn_port_t evtchn)
/* Get info for IRQ */
struct irq_info *info_for_irq(unsigned irq)
{
return irq_get_chip_data(irq);
if (irq < nr_legacy_irqs())
return legacy_info_ptrs[irq];
else
return irq_get_chip_data(irq);
}

static void set_info_for_irq(unsigned int irq, struct irq_info *info)
{
if (irq < nr_legacy_irqs())
legacy_info_ptrs[irq] = info;
else
irq_set_chip_data(irq, info);
}

/* Constructors for packed IRQ information. */
Expand Down Expand Up @@ -377,7 +390,7 @@ static void xen_irq_init(unsigned irq)
info->type = IRQT_UNBOUND;
info->refcnt = -1;

irq_set_chip_data(irq, info);
set_info_for_irq(irq, info);

list_add_tail(&info->list, &xen_irq_list_head);
}
Expand Down Expand Up @@ -426,14 +439,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)

static void xen_free_irq(unsigned irq)
{
struct irq_info *info = irq_get_chip_data(irq);
struct irq_info *info = info_for_irq(irq);

if (WARN_ON(!info))
return;

list_del(&info->list);

irq_set_chip_data(irq, NULL);
set_info_for_irq(irq, NULL);

WARN_ON(info->refcnt > 0);

Expand Down Expand Up @@ -603,7 +616,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
static void __unbind_from_irq(unsigned int irq)
{
evtchn_port_t evtchn = evtchn_from_irq(irq);
struct irq_info *info = irq_get_chip_data(irq);
struct irq_info *info = info_for_irq(irq);

if (info->refcnt > 0) {
info->refcnt--;
Expand Down Expand Up @@ -1108,7 +1121,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,

void unbind_from_irqhandler(unsigned int irq, void *dev_id)
{
struct irq_info *info = irq_get_chip_data(irq);
struct irq_info *info = info_for_irq(irq);

if (WARN_ON(!info))
return;
Expand Down Expand Up @@ -1142,7 +1155,7 @@ int evtchn_make_refcounted(evtchn_port_t evtchn)
if (irq == -1)
return -ENOENT;

info = irq_get_chip_data(irq);
info = info_for_irq(irq);

if (!info)
return -ENOENT;
Expand Down Expand Up @@ -1170,7 +1183,7 @@ int evtchn_get(evtchn_port_t evtchn)
if (irq == -1)
goto done;

info = irq_get_chip_data(irq);
info = info_for_irq(irq);

if (!info)
goto done;
Expand Down

0 comments on commit 0891fb3

Please sign in to comment.