Skip to contentSkip to conversation

translate pirq to irq

DISCUSSION Igor Kozhukhov 2 participants 7 messages Jan 11, 2014 – Jan 14, 2014

lore
Share & tools
lore
#0 lore raw

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

--
Best regards,
Igor Kozhukhov

#1 lore raw
Quoted 18 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

Quoted 6 lines

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

~Andrew

#2 lore raw

Hi Andrew,

Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

Quoted 7 lines
Quoted 3 lines

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

it is for dom0.

full boot log with xen debug info and DDI_DEBUG on illumos you can find here :
http://apt2.dilos.org/dilos/logs/putty.log.dom0.txt

if it is possible - could you please let me know how to work MSI irq translation to APIC irq table for xen-4.2 ?

i see - in xen code we have a range from 16 to 784 for 4 CPU for MSI IRQ (irq_create() function) but - how to correct translate it to APIC IRQ (physical irq)?

Quoted 2 lines

~Andrew

-Igor

#3 lore raw
Quoted 34 lines · Igor Kozhukhov

Hi Andrew,

Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

Quoted 6 lines
Quoted 3 lines

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

it is for dom0.

Quoted 8 lines

full boot log with xen debug info and DDI_DEBUG on illumos you can find here :
http://apt2.dilos.org/dilos/logs/putty.log.dom0.txt

if it is possible - could you please let me know how to work MSI irq translation to APIC irq table for xen-4.2 ?

i see - in xen code we have a range from 16 to 784 for 4 CPU for MSI IRQ (irq_create() function) but - how to correct translate it to APIC IRQ (physical irq)?

Why do you need to know?

Xen controls all interrupts on the system. Event channels which you register with Xen have no mapping/relation to local apic vectors. Your device drivers should not expect to have an apic vector in their hand.

The reason behind this is that as virtual cpus get scheduled around physical cpus, Xen needs to move the interrupts from IDT to IDT at which point their vector will change.

~Andrew

#4 lore raw
Quoted 46 lines · Andrew Cooper
Quoted 34 lines · Igor Kozhukhov

Hi Andrew,

Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

Quoted 6 lines
Quoted 3 lines

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

it is for dom0.

Quoted 8 lines

full boot log with xen debug info and DDI_DEBUG on illumos you can find here :
http://apt2.dilos.org/dilos/logs/putty.log.dom0.txt

if it is possible - could you please let me know how to work MSI irq translation to APIC irq table for xen-4.2 ?

i see - in xen code we have a range from 16 to 784 for 4 CPU for MSI IRQ (irq_create() function) but - how to correct translate it to APIC IRQ (physical irq)?

Why do you need to know?

Quoted 7 lines

Xen controls all interrupts on the system. Event channels which you register with Xen have no mapping/relation to local apic vectors. Your device drivers should not expect to have an apic vector in their hand.

The reason behind this is that as virtual cpus get scheduled around physical cpus, Xen needs to move the interrupts from IDT to IDT at which point their vector will change.

is it possible to receive IRQ from APIC table from Xen as index ? i need it for local APIC pointer to APIC table array as index. all others functions is using index from apic_irq_table[] as APIC IRQ.

i have function apic_find_irq() for this.
it is not my realization - it is original code.

Quoted 1 line

~Andrew

-Igor

#5 lore raw
Quoted 47 lines · Igor Kozhukhov
Quoted 45 lines · Andrew Cooper
Quoted 34 lines · Igor Kozhukhov

Hi Andrew,

Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

Quoted 6 lines
Quoted 3 lines

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

it is for dom0.

Quoted 8 lines

full boot log with xen debug info and DDI_DEBUG on illumos you can find here :
http://apt2.dilos.org/dilos/logs/putty.log.dom0.txt

if it is possible - could you please let me know how to work MSI irq translation to APIC irq table for xen-4.2 ?

i see - in xen code we have a range from 16 to 784 for 4 CPU for MSI IRQ (irq_create() function) but - how to correct translate it to APIC IRQ (physical irq)?

Why do you need to know?

Quoted 8 lines
Quoted 7 lines

Xen controls all interrupts on the system. Event channels which you register with Xen have no mapping/relation to local apic vectors. Your device drivers should not expect to have an apic vector in their hand.

The reason behind this is that as virtual cpus get scheduled around physical cpus, Xen needs to move the interrupts from IDT to IDT at which point their vector will change.

is it possible to receive IRQ from APIC table from Xen as index ?

No.

Quoted 5 lines

i need it for local APIC pointer to APIC table array as index. all others functions is using index from apic_irq_table[] as APIC IRQ.

i have function apic_find_irq() for this.
it is not my realization - it is original code.

Nothing in a dom0 system should know/care about apic vectors. Dom0 cannot use the IDT, nor can it even write to MSI/MSI-X configuration registers (they get trapped and fixed-up by Xen).

Even if there were a hypercall to map an event channel back to an apic-id/vector, it is possible that the data would be stale by the time the vcpu ran again.

~Andrew

#6 lore raw

hi Andrew,

Quoted 65 lines · Andrew Cooper
Quoted 47 lines · Igor Kozhukhov
Quoted 45 lines · Andrew Cooper
Quoted 34 lines · Igor Kozhukhov

Hi Andrew,

Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Igor Kozhukhov

Hello All,

I see a comment in physdev.h for 'struct physdev_map_pirq', var 'pirq':
/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */

i have received 'pirq' from hypervisor > 255.

map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_MSI;
map_irq.index = -1; /* hypervisor auto allocates vector */ map_irq.pirq = -1;
map_irq.bus = busnum;
map_irq.devfn = devfn;
map_irq.entry_nr = i;
map_irq.table_base = 0;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); irqno = map_irq.pirq;

i have:
irqno = 279 - it is more APIC_MAX_VECTOR(255)

Quoted 6 lines
Quoted 3 lines

i have a question: how to correct translate pirq to irq for APIC map table ?

all work well on xen-3.4, but it has another realization in function physdev_map_pirq() then for xen-4.2.

Is this for a PV or HVM guest? I suspect PV, in which case the irqno handed back will be the event channel on which the notification will arrive, and has nothing to do with regular IDT vectors.

it is for dom0.

Quoted 8 lines

full boot log with xen debug info and DDI_DEBUG on illumos you can find here :
http://apt2.dilos.org/dilos/logs/putty.log.dom0.txt

if it is possible - could you please let me know how to work MSI irq translation to APIC irq table for xen-4.2 ?

i see - in xen code we have a range from 16 to 784 for 4 CPU for MSI IRQ (irq_create() function) but - how to correct translate it to APIC IRQ (physical irq)?

Why do you need to know?

Quoted 8 lines
Quoted 7 lines

Xen controls all interrupts on the system. Event channels which you register with Xen have no mapping/relation to local apic vectors. Your device drivers should not expect to have an apic vector in their hand.

The reason behind this is that as virtual cpus get scheduled around physical cpus, Xen needs to move the interrupts from IDT to IDT at which point their vector will change.

is it possible to receive IRQ from APIC table from Xen as index ?

No.

Quoted 5 lines

i need it for local APIC pointer to APIC table array as index. all others functions is using index from apic_irq_table[] as APIC IRQ.

i have function apic_find_irq() for this.
it is not my realization - it is original code.

Quoted 7 lines

Nothing in a dom0 system should know/care about apic vectors. Dom0 cannot use the IDT, nor can it even write to MSI/MSI-X configuration registers (they get trapped and fixed-up by Xen).

Even if there were a hypercall to map an event channel back to an apic-id/vector, it is possible that the data would be stale by the time the vcpu ran again.

thanks for your details. I have found and fixed a problem. now i have finished illumos side and have to fork with xen-4.2 sources.

it was interest problem.
details:
i have array:
#define APIC_MAX_VECTOR 255
uchar_t msi_vector_to_pirq[APIC_MAX_VECTOR+1]

i have received map_irq.pirq = 279(0x117)
it is more then 255(0xff)

i have operation:
msi_vector_to_pirq[vector] = (uchar_t)pirq;

by this operation i have msi_vector_to_pirq[vector] = 0x17; :)

it was a mistake, because i tried to use APIC IRQs from reserved space with additional PIRQs.
i have replaced it by: get free APIC IRQ from range 0x10 - 0xff and update info about IRQ with additional field for PIRQ for mapping by event.

now i have correct APIC IRQs with sync it for PIRQ map.

Quoted 1 line

~Andrew

-Igor