x86/vioapic: introduce support for multiple vIO APICs
v2 cover x86/vioapic: introduce support for multiple vIO APICs
Hello,
This patch series introduce support for having a variable number of entries in vIO APICs, and also having a variable number of vIO APICs per domain. This functionality is not used by unprivileged guests, that are still limited to a single IO APIC with 48 entries.
The functionality introduced is only used by PVHv2 Dom0, in order to copy the IO APIC topology found on bare metal.
I'm in the process of setting up an osstest run in order to test this series.
They can also be found in my personal git tree:
git://xenbits.xen.org/people/royger/xen.git vioapics_v2
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 1/7 x86/vioapic: introduce a internal vIO APIC structure
This is required in order to have a variable number of vIO APIC pins, instead of the current fixed value (48). Note that this patch only expands the fields of the hvm_vioapic struct, without actually introducing any new fields or functionality.
The reason to expand the hvm_vioapic structure instead of the hvm_hw_vioapic one is that the variable number of pins functionality is only going to be used by the hardware domain, so no modifications are needed to the save format.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
---
Changes since v1:
- New in this version.
--- xen/arch/x86/hvm/vioapic.c | 43 ++++++++++++++++++++++----------------- xen/include/asm-x86/hvm/vioapic.h | 11 ++++++---- 2 files changed, 31 insertions(+), 23 deletions(-)
xen/arch/x86/hvm/vioapic.c +24 -19
@@ -42,9 +42,9 @@/* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */ #define IRQ0_SPECIAL_ROUTING 1 -static void vioapic_deliver (struct hvm_hw_vioapic *vioapic,int irq); +static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq); -static uint32_t vioapic_read_indirect (const struct hvm_hw_vioapic *vioapic) +static uint32_t vioapic_read_indirect (const struct hvm_vioapic *vioapic) {uint32_t result =0 ;
@@ -94,7 +94,7 @@ static int vioapic_read( struct vcpu *v, unsigned long addr, unsigned int length, unsigned long *pval) { - const struct hvm_hw_vioapic *vioapic = domain_vioapic(v->domain); + const struct hvm_vioapic *vioapic = domain_vioapic(v->domain);uint32_t result;HVM_DBG_LOG (DBG_LEVEL_IOAPIC ,"addr %lx" , addr);
@@ -119,7 +119,7 @@ static int vioapic_read( }static void vioapic_write_redirent ( -struct hvm_hw_vioapic *vioapic,unsigned int idx, +struct hvm_vioapic *vioapic,unsigned int idx,int top_word,uint32_t val) {struct domain *d =vioapic_domain (vioapic);
@@ -170,7 +170,7 @@ static void vioapic_write_redirent( }static void vioapic_write_indirect ( -struct hvm_hw_vioapic *vioapic,uint32_t val) +struct hvm_vioapic *vioapic,uint32_t val) {switch ( vioapic->ioregsel ) {
@@ -215,7 +215,7 @@ static int vioapic_write( struct vcpu *v, unsigned long addr, unsigned int length, unsigned long val) { - struct hvm_hw_vioapic *vioapic = domain_vioapic(v->domain); + struct hvm_vioapic *vioapic = domain_vioapic(v->domain);switch ( addr &0xff ) {
@@ -242,7 +242,7 @@ static int vioapic_write(static int vioapic_range (struct vcpu *v,unsigned long addr) { -struct hvm_hw_vioapic *vioapic =domain_vioapic (v->domain); +struct hvm_vioapic *vioapic =domain_vioapic (v->domain);return ((addr >= vioapic->base_address && (addr < vioapic->base_address +VIOAPIC_MEM_LENGTH )));
@@ -255,7 +255,7 @@ static const struct hvm_mmio_ops vioapic_mmio_ops = { }; static void ioapic_inj_irq( - struct hvm_hw_vioapic *vioapic, + struct hvm_vioapic *vioapic, struct vlapic *target, uint8_t vector, uint8_t trig_mode,
@@ -275,7 +275,7 @@ static inline int pit_channel0_enabled(void)return pt_active (¤t->domain->arch.vpit.pt0); } -static void vioapic_deliver (struct hvm_hw_vioapic *vioapic,int irq) +static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq) {uint16_t dest = vioapic->redirtbl[irq].fields.dest_id;uint8_t dest_mode = vioapic->redirtbl[irq].fields.dest_mode;
@@ -361,7 +361,7 @@ static void vioapic_deliver(struct hvm_hw_vioapic *vioapic, int irq)void vioapic_irq_positive_edge (struct domain *d,unsigned int irq) { -struct hvm_hw_vioapic *vioapic =domain_vioapic (d); +struct hvm_vioapic *vioapic =domain_vioapic (d);union vioapic_redir_entry *ent;ASSERT (has_vioapic (d));
@@ -388,7 +388,7 @@ void vioapic_irq_positive_edge(struct domain *d, unsigned int irq)void vioapic_update_EOI (struct domain *d,u8 vector) { -struct hvm_hw_vioapic *vioapic =domain_vioapic (d); +struct hvm_vioapic *vioapic =domain_vioapic (d);struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;union vioapic_redir_entry *ent;int gsi;
@@ -426,38 +426,43 @@ void vioapic_update_EOI(struct domain *d, u8 vector)static int ioapic_save (struct domain *d,hvm_domain_context_t *h) { -struct hvm_hw_vioapic *s =domain_vioapic (d); +struct hvm_vioapic *s =domain_vioapic (d);if ( !has_vioapic (d) )return 0 ; -return hvm_save_entry (IOAPIC ,0 , h, s); +BUILD_BUG_ON (sizeof (struct hvm_hw_vioapic ) != +sizeof (struct hvm_vioapic ) - + offsetof(struct hvm_vioapic , base_address)); + +return hvm_save_entry (IOAPIC ,0 , h, &s->base_address); }static int ioapic_load (struct domain *d,hvm_domain_context_t *h) { -struct hvm_hw_vioapic *s =domain_vioapic (d); +struct hvm_vioapic *s =domain_vioapic (d);if ( !has_vioapic (d) )return -ENODEV ; -return hvm_load_entry (IOAPIC , h, s); +return hvm_load_entry (IOAPIC , h, &s->base_address); }HVM_REGISTER_SAVE_RESTORE (IOAPIC , ioapic_save, ioapic_load,1 ,HVMSR_PER_DOM );void vioapic_reset (struct domain *d) { -struct hvm_vioapic *vioapic = d->arch.hvm_domain.vioapic; +struct hvm_vioapic *vioapic =domain_vioapic (d);int i;if ( !has_vioapic (d) )return ; -memset (&vioapic->hvm_hw_vioapic,0 ,sizeof (vioapic->hvm_hw_vioapic)); +memset (vioapic,0 ,sizeof (*vioapic)); + vioapic->domain = d;for ( i =0 ; i <VIOAPIC_NUM_PINS ; i++ ) - vioapic->hvm_hw_vioapic.redirtbl[i].fields.mask =1 ; - vioapic->hvm_hw_vioapic.base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; + vioapic->redirtbl[i].fields.mask =1 ; + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; }int vioapic_init (struct domain *d)
xen/include/asm-x86/hvm/vioapic.h +7 -4
@@ -48,13 +48,16 @@#define VIOAPIC_REG_RTE0 0x10struct hvm_vioapic { -struct hvm_hw_vioapic hvm_hw_vioapic;struct domain *domain; +/* Layout below must match hvm_hw_vioapic. */ +uint64_t base_address; +uint32_t ioregsel; +uint32_t id; +union vioapic_redir_entry redirtbl[VIOAPIC_NUM_PINS ]; }; -#define domain_vioapic (d) (&(d)->arch.hvm_domain.vioapic->hvm_hw_vioapic) -#define vioapic_domain (v) (container_of((v), struct hvm_vioapic, \ - hvm_hw_vioapic)->domain) +#define domain_vioapic (d) ((d)->arch.hvm_domain.vioapic) +#define vioapic_domain (v) ((v)->domain)int vioapic_init (struct domain *d);void vioapic_deinit (struct domain *d);
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 1/7] x86/vioapic: introduce a internal vIO APIC structure
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
The reason to expand the
hvm_vioapicstructure instead of thehvm_hw_vioapicone is that the variable number of pins functionality is only going to be used by the hardware domain, so no modifications are needed to the save format.
As you say here you expand an existing structure, so the title isn't really correct.
Quoted 4 lines
xen/arch/x86/hvm/vioapic.c +0
-0@@ -426,38 +426,43 @@ void vioapic_update_EOI(struct domain *d, u8 vector)static int ioapic_save (struct domain *d,hvm_domain_context_t *h) {
xen/arch/x86/hvm/vioapic.c void vioapic_update_EOI(struct domain *d, u8 vector) · line 436
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +4
-2-struct hvm_hw_vioapic *s =domain_vioapic (d); +struct hvm_vioapic *s =domain_vioapic (d);if ( !has_vioapic (d) )return 0 ; -return hvm_save_entry (IOAPIC ,0 , h, s); +BUILD_BUG_ON (sizeof (struct hvm_hw_vioapic ) != +sizeof (struct hvm_vioapic ) - + offsetof(struct hvm_vioapic , base_address));
This is too weak a check for my taste, and ...
xen/arch/x86/hvm/vioapic.c void vioapic_update_EOI(struct domain *d, u8 vector) · line 438
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+return hvm_save_entry (IOAPIC ,0 , h, &s->base_address);
... this too fragile a use. See also below.
Quoted 4 lines
xen/include/asm-x86/hvm/vioapic.h +0
-0@@ -48,13 +48,16 @@#define VIOAPIC_REG_RTE0 0x10
xen/include/asm-x86/hvm/vioapic.h line 57
Quoted 10 lines
xen/include/asm-x86/hvm/vioapic.h +5
-1struct hvm_vioapic { -struct hvm_hw_vioapic hvm_hw_vioapic;struct domain *domain; +/* Layout below must match hvm_hw_vioapic. */ +uint64_t base_address; +uint32_t ioregsel; +uint32_t id; +union vioapic_redir_entry redirtbl[VIOAPIC_NUM_PINS ]; };
It is mere luck that last old and first new fields aren't both 32-bit ones, or else this approach would not have worked at all. I think we need some better approach here, but the absolute minimum would be to also add a comment on the other side.
One possible approach would be to move the entire set of field declarations of struct hvm_hw_vioapic into a macro, using it both there and here. Which would then leave making sure there are no alignment effects because of fields added ahead of that macro's use (perhaps via BUILD_BUG_ON(), or maybe even better by making this an unnamed structure member inside struct hvm_ioapic).
The macro should then be #undef-ed in the header, except in the __XEN__ case. Perhaps the macro would also want to be given a parameter right away for the invoking site to specify the number of pins.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/7] x86/vioapic: introduce a internal vIO APIC structure
Quoted 18 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
The reason to expand the
hvm_vioapicstructure instead of thehvm_hw_vioapicone is that the variable number of pins functionality is only going to be used by the hardware domain, so no modifications are needed to the save format.As you say here you expand an existing structure, so the title isn't really correct.
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +1
-1@@ -426,38 +426,43 @@ void vioapic_update_EOI(struct domain *d, u8 vector)static int ioapic_save (struct domain *d,hvm_domain_context_t *h) { -struct hvm_hw_vioapic *s =domain_vioapic (d); +struct hvm_vioapic *s =domain_vioapic (d);if ( !has_vioapic (d) )return 0 ;
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c void vioapic_update_EOI(struct domain *d, u8 vector) · line 436
Quoted 4 lines
xen/arch/x86/hvm/vioapic.c +3
-1-return hvm_save_entry (IOAPIC ,0 , h, s); +BUILD_BUG_ON (sizeof (struct hvm_hw_vioapic ) != +sizeof (struct hvm_vioapic ) - + offsetof(struct hvm_vioapic , base_address));This is too weak a check for my taste, and ...
I've removed this BUILD_BUG_ON.
Quoted 32 lines
xen/arch/x86/hvm/vioapic.c void vioapic_update_EOI(struct domain *d, u8 vector) · line 438
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+return hvm_save_entry (IOAPIC ,0 , h, &s->base_address);... this too fragile a use. See also below.
Quoted 4 lines
xen/include/asm-x86/hvm/vioapic.h +0
-0@@ -48,13 +48,16 @@#define VIOAPIC_REG_RTE0 0x10xen/include/asm-x86/hvm/vioapic.h line 57
Quoted 10 lines
xen/include/asm-x86/hvm/vioapic.h +5
-1struct hvm_vioapic { -struct hvm_hw_vioapic hvm_hw_vioapic;struct domain *domain; +/* Layout below must match hvm_hw_vioapic. */ +uint64_t base_address; +uint32_t ioregsel; +uint32_t id; +union vioapic_redir_entry redirtbl[VIOAPIC_NUM_PINS ]; };It is mere luck that last old and first new fields aren't both 32-bit ones, or else this approach would not have worked at all. I think we need some better approach here, but the absolute minimum would be to also add a comment on the other side.
One possible approach would be to move the entire set of field declarations of struct
hvm_hw_vioapicinto a macro, using it both there and here. Which would then leave making sure there are no alignment effects because of fields added ahead of that macro's use (perhaps viaBUILD_BUG_ON(), or maybe even better by making this an unnamed structure member inside structhvm_ioapic).
Quoted 4 lines
The macro should then be #undef-ed in the header, except in the
__XEN__case. Perhaps the macro would also want to be given a parameter right away for the invoking site to specify the number of pins.
Yes, I think the unnamed structure is way better, here's what I've done:
save.h:
union vioapic_redir_entry
{
uint64_t bits;
struct {
uint8_t vector;
uint8_t delivery_mode:3;
uint8_t dest_mode:1;
uint8_t delivery_status:1;
uint8_t polarity:1;
uint8_t remote_irr:1;
uint8_t trig_mode:1;
uint8_t mask:1;
uint8_t reserve:7;
uint8_t reserved[4];
uint8_t dest_id;
} fields;
};#define VIOAPIC_NUM_PINS 48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */
#define DECLARE_VIOAPIC(name, cnt) \
struct name { \
uint64_t base_address; \
uint32_t ioregsel; \
uint32_t id; \
union vioapic_redir_entry redirtbl[cnt]; \
}DECLARE_VIOAPIC(hvm_hw_vioapic, VIOAPIC_NUM_PINS);
#ifndef __XEN__
#undef DECLARE_VIOAPIC
#endif
vioapic.h:
struct hvm_vioapic {
struct domain *domain;
DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS);
};This seems to work fine, and now the BUILD_BUG_ON is just pointless.
Thanks for the tip, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/7] x86/vioapic: introduce a internal vIO APIC structure
Quoted 39 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 18:49, <[email protected]> wrote:
Yes, I think the unnamed structure is way better, here's what I've done:
save.h:union
vioapic_redir_entry{ uint64_t bits; struct { uint8_t vector; uint8_t delivery_mode:3; uint8_t dest_mode:1; uint8_t delivery_status:1; uint8_t polarity:1; uint8_t remote_irr:1; uint8_t trig_mode:1; uint8_t mask:1; uint8_t reserve:7; uint8_t reserved[4]; uint8_t dest_id; } fields; };#define
VIOAPIC_NUM_PINS48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */#define DECLARE_VIOAPIC(name, cnt) \ struct name { \ uint64_t base_address; \ uint32_t ioregsel; \ uint32_t id; \ union vioapic_redir_entry redirtbl[cnt]; \ }
DECLARE_VIOAPIC(hvm_hw_vioapic, VIOAPIC_NUM_PINS);#ifndef
__XEN__
#undefDECLARE_VIOAPIC
#endif
Quoted 8 lines
vioapic.h:struct hvm_vioapic { struct domain *domain; DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS); };This seems to work fine, and now the
BUILD_BUG_ONis just pointless.
Well, no, not entirely. As said you still want to exclude alignment effects prior structure members of hvm_vioapic may have (please continue to not make assumptions on the alignment of the first field of the structure here).
Furthermore, despite the #undef the macro name should start with XEN_, perhaps even with XEN_HVM_. Whether the DECLARE part is really needed/useful I'm not sure.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/7] x86/vioapic: introduce a internal vIO APIC structure
Quoted 46 lines · Jan Beulich
Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 18:49, <[email protected]> wrote:
Yes, I think the unnamed structure is way better, here's what I've done:
save.h:union
vioapic_redir_entry{ uint64_t bits; struct { uint8_t vector; uint8_t delivery_mode:3; uint8_t dest_mode:1; uint8_t delivery_status:1; uint8_t polarity:1; uint8_t remote_irr:1; uint8_t trig_mode:1; uint8_t mask:1; uint8_t reserve:7; uint8_t reserved[4]; uint8_t dest_id; } fields; };#define
VIOAPIC_NUM_PINS48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */#define DECLARE_VIOAPIC(name, cnt) \ struct name { \ uint64_t base_address; \ uint32_t ioregsel; \ uint32_t id; \ union vioapic_redir_entry redirtbl[cnt]; \ }
DECLARE_VIOAPIC(hvm_hw_vioapic, VIOAPIC_NUM_PINS);#ifndef
__XEN__
#undefDECLARE_VIOAPIC
#endif
vioapic.h:struct hvm_vioapic { struct domain *domain; DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS); };
Quoted 6 lines
Quoted 1 line
This seems to work fine, and now the
BUILD_BUG_ONis just pointless.Well, no, not entirely. As said you still want to exclude alignment effects prior structure members of
hvm_vioapicmay have (please continue to not make assumptions on the alignment of the first field of the structure here).
But doesn't the usage of an unnamed structure get rid of the alignment issue? For example I have the following code:
struct bar {
uint8_t b;
uint8_t c;
uint32_t d;
uint32_t e;
};struct foo {
uint8_t a;
struct {
uint8_t b;
uint8_t c;
uint32_t d;
uint32_t e;
};
};struct foobar {
uint8_t a;
uint8_t b;
uint8_t c;
uint32_t d;
uint32_t e;
};This according to pahole has the following layout:
struct bar {
uint8_t b; /* 0 1 */
uint8_t c; /* 1 1 */
/* XXX 2 bytes hole, try to pack */
uint32_t d; /* 4 4 */
uint32_t e; /* 8 4 */
/* size: 12, cachelines: 1, members: 4 */
/* sum members: 10, holes: 1, sum holes: 2 */
/* last cacheline: 12 bytes */
};
struct foo {
uint8_t a; /* 0 1 */
/* XXX 3 bytes hole, try to pack */
struct {
uint8_t b; /* 4 1 */
uint8_t c; /* 5 1 */
uint32_t d; /* 8 4 */
uint32_t e; /* 12 4 */
}; /* 4 12 */
/* size: 16, cachelines: 1, members: 2 */
/* sum members: 13, holes: 1, sum holes: 3 */
/* last cacheline: 16 bytes */
};
struct foobar {
uint8_t a; /* 0 1 */
uint8_t b; /* 1 1 */
uint8_t c; /* 2 1 *//* XXX 1 byte hole, try to pack */ uint32_t d; /* 4 4 */ uint32_t e; /* 8 4 */ /* size: 12, cachelines: 1, members: 5 */ /* sum members: 11, holes: 1, sum holes: 1 */ /* last cacheline: 12 bytes */ };
The unnamed struct (clone of bar) inside of foo is already aligned (so it ends up with the same layout as bar), as opposed to foobar, which indeed ends up with a different layout.
Quoted 3 lines
Furthermore, despite the #undef the macro name should start with
XEN_, perhaps even withXEN_HVM_. Whether the DECLARE part is really needed/useful I'm not sure.
I've renamed it to XEN_HVM_VIOAPIC.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/7] x86/vioapic: introduce a internal vIO APIC structure
Quoted 48 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:15, <[email protected]> wrote:
Quoted 46 lines · Jan Beulich
Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 18:49, <[email protected]> wrote:
Yes, I think the unnamed structure is way better, here's what I've done:
save.h:union
vioapic_redir_entry{ uint64_t bits; struct { uint8_t vector; uint8_t delivery_mode:3; uint8_t dest_mode:1; uint8_t delivery_status:1; uint8_t polarity:1; uint8_t remote_irr:1; uint8_t trig_mode:1; uint8_t mask:1; uint8_t reserve:7; uint8_t reserved[4]; uint8_t dest_id; } fields; };#define
VIOAPIC_NUM_PINS48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */#define DECLARE_VIOAPIC(name, cnt) \ struct name { \ uint64_t base_address; \ uint32_t ioregsel; \ uint32_t id; \ union vioapic_redir_entry redirtbl[cnt]; \ }
DECLARE_VIOAPIC(hvm_hw_vioapic, VIOAPIC_NUM_PINS);#ifndef
__XEN__
#undefDECLARE_VIOAPIC
#endif
vioapic.h:struct hvm_vioapic { struct domain *domain; DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS); };
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This seems to work fine, and now the
BUILD_BUG_ONis just pointless.Well, no, not entirely. As said you still want to exclude alignment effects prior structure members of
hvm_vioapicmay have (please continue to not make assumptions on the alignment of the first field of the structure here).But doesn't the usage of an unnamed structure get rid of the alignment issue?
Oh, of course it does - provided there are no differing packing options in effect at the time the two structures get actually declared. But yes, perhaps we can live with this being implied. And too big of an alignment is no problem in the first place.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 2/7 x86/hvm: introduce hvm_domain_irq macro
In reply to Roger Pau MonneIntroduce a macro to get a pointer to the hvm_irq for a HVM domain. No functional change.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/irq.c | 30 +++++++++++++++--------------- xen/arch/x86/hvm/vioapic.c | 4 ++-- xen/arch/x86/hvm/vlapic.c | 6 +++--- xen/arch/x86/physdev.c | 2 +- xen/drivers/passthrough/vtd/x86/vtd.c | 2 +- xen/include/asm-x86/hvm/irq.h | 1 + 6 files changed, 23 insertions(+), 22 deletions(-)
xen/arch/x86/hvm/irq.c +15 -15
@@ -60,7 +60,7 @@ static void deassert_irq(struct domain *d, unsigned isa_irq)static void __hvm_pci_intx_assert (struct domain *d,unsigned int device,unsigned int intx) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi, link, isa_irq;ASSERT ((device <=31 ) && (intx <=3 ));
@@ -90,7 +90,7 @@ void hvm_pci_intx_assert(static void __hvm_pci_intx_deassert (struct domain *d,unsigned int device,unsigned int intx) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi, link, isa_irq;ASSERT ((device <=31 ) && (intx <=3 ));
@@ -119,7 +119,7 @@ void hvm_pci_intx_deassert(void hvm_isa_irq_assert (struct domain *d,unsigned int isa_irq) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq);ASSERT (isa_irq <=15 );
@@ -136,7 +136,7 @@ void hvm_isa_irq_assert(void hvm_isa_irq_deassert (struct domain *d,unsigned int isa_irq) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq);ASSERT (isa_irq <=15 );
@@ -153,7 +153,7 @@ void hvm_isa_irq_deassert(static void hvm_set_callback_irq_level (struct vcpu *v) {struct domain *d = v->domain; -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi, pdev, pintx, asserted;ASSERT (v->vcpu_id ==0 );
@@ -201,7 +201,7 @@ static void hvm_set_callback_irq_level(struct vcpu *v)void hvm_maybe_deassert_evtchn_irq (void ) {struct domain *d = current->domain; -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);if ( hvm_irq->callback_via_asserted && !vcpu_info (d->vcpu[0 ], evtchn_upcall_pending) )
@@ -230,7 +230,7 @@ void hvm_assert_evtchn_irq(struct vcpu *v)int hvm_set_pci_link_route (struct domain *d,u8 link,u8 isa_irq) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);u8 old_isa_irq;int i;
@@ -323,7 +323,7 @@ int hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data)void hvm_set_callback_via (struct domain *d,uint64_t via) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi=0 , pdev=0 , pintx=0 ;uint8_t via_type;
@@ -486,7 +486,7 @@ void arch_evtchn_inject(struct vcpu *v)static void irq_dump (struct domain *d) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);int i;printk ("Domain %d:\n" , d->domain_id); printk("PCI 0x%16.16"PRIx64"%16.16"PRIx64
@@ -541,7 +541,7 @@ __initcall(dump_irq_info_key_init);static int irq_save_pci (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int asserted, pdev, pintx;int rc;
@@ -573,7 +573,7 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)static int irq_save_isa (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);/* Save ISA IRQ lines */ return (hvm_save_entry (ISA_IRQ ,0 , h, &hvm_irq->isa_irq) );
@@ -581,7 +581,7 @@ static int irq_save_isa(struct domain *d, hvm_domain_context_t *h)static int irq_save_link (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);/* Save PCI-ISA link state */ return (hvm_save_entry (PCI_LINK ,0 , h, &hvm_irq->pci_link) );
@@ -589,7 +589,7 @@ static int irq_save_link(struct domain *d, hvm_domain_context_t *h)static int irq_load_pci (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi;/* Load the PCI IRQ lines */
@@ -622,7 +622,7 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)static int irq_load_isa (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);int irq;/* Load the ISA IRQ lines */
@@ -641,7 +641,7 @@ static int irq_load_isa(struct domain *d, hvm_domain_context_t *h)static int irq_load_link (struct domain *d,hvm_domain_context_t *h) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, gsi;/* Load the PCI-ISA IRQ link routing table */
xen/arch/x86/hvm/vioapic.c +2 -2
@@ -123,7 +123,7 @@ static void vioapic_write_redirent( int top_word, uint32_t val) {struct domain *d =vioapic_domain (vioapic); -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);union vioapic_redir_entry *pent, ent;int unmasked =0 ;
@@ -389,7 +389,7 @@ void vioapic_irq_positive_edge(struct domain *d, unsigned int irq)void vioapic_update_EOI (struct domain *d,u8 vector) {struct hvm_vioapic *vioapic =domain_vioapic (d); -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);union vioapic_redir_entry *ent;int gsi;
xen/arch/x86/hvm/vlapic.c +3 -3
@@ -373,7 +373,7 @@ struct vlapic *vlapic_lowest_prio( struct domain *d, const struct vlapic *source, int short_hand, uint32_t dest, bool_t dest_mode) { - int old = d->arch.hvm_domain.irq.round_robin_prev_vcpu; + int old = hvm_domain_irq(d)->round_robin_prev_vcpu;uint32_t ppr, target_ppr =UINT_MAX ;struct vlapic *vlapic, *target =NULL ;struct vcpu *v;
@@ -394,8 +394,8 @@ struct vlapic *vlapic_lowest_prio( }while ( v->vcpu_id != old );if ( target !=NULL ) - d->arch.hvm_domain.irq.round_robin_prev_vcpu = -vlapic_vcpu (target)->vcpu_id; +hvm_domain_irq (d)->round_robin_prev_vcpu = +vlapic_vcpu (target)->vcpu_id;return target; }
xen/arch/x86/physdev.c +1 -1
@@ -317,7 +317,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (is_hvm_domain (currd) &&domain_pirq_to_emuirq (currd, eoi.irq) >0 ) { -struct hvm_irq *hvm_irq = &currd->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (currd);int gsi =domain_pirq_to_emuirq (currd, eoi.irq);/* if this is a level irq and count > 0, send another
xen/drivers/passthrough/vtd/x86/vtd.c +1 -1
@@ -66,7 +66,7 @@ void flush_all_cache()static int _hvm_dpci_isairq_eoi (struct domain *d,struct hvm_pirq_dpci *pirq_dpci,void *arg) { -struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq; +struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int isairq = (long )arg;const struct dev_intx_gsi_link *digl;
xen/include/asm-x86/hvm/irq.h +1 -0
@@ -95,6 +95,7 @@ struct hvm_irq { (((((dev)<<2) + ((dev)>>3) + (intx)) & 31) + 16)#define hvm_pci_intx_link (dev, intx) \ (((dev) + (intx)) & 3) +#define hvm_domain_irq (d) (&(d)->arch.hvm_domain.irq)#define hvm_isa_irq_to_gsi (isa_irq) ((isa_irq) ? : 2)
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 2/7] x86/hvm: introduce hvm_domain_irq macro
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
Introduce a macro to get a pointer to the
hvm_irqfor a HVM domain.
What does this buy us? I don't (yet?) see the connection to this series.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/7] x86/hvm: introduce hvm_domain_irq macro
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
Introduce a macro to get a pointer to the
hvm_irqfor a HVM domain.What does this buy us? I don't (yet?) see the connection to this series.
It's a pre-patch to make #3 smaller, I should probably mention this in the commit.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 3/7 x86/hvm: convert gsi_assert_count into a variable size array
In reply to Roger Pau MonneRearrange the fields of hvm_irq so that gsi_assert_count can be converted into a variable size array and add a new field to account the number of GSIs.
Due to this changes the irq member in the hvm_domain struct also needs to become a pointer set at runtime.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 13 +++++++++++-- xen/arch/x86/hvm/irq.c | 27 +++++++++++++++++++++------ xen/drivers/passthrough/io.c | 8 ++++---- xen/drivers/passthrough/pci.c | 2 +- xen/include/asm-x86/domain.h | 2 +- xen/include/asm-x86/hvm/domain.h | 2 +- xen/include/asm-x86/hvm/irq.h | 28 +++++++++++++++------------- 7 files changed, 54 insertions(+), 28 deletions(-)
xen/arch/x86/hvm/hvm.c +11 -2
@@ -457,7 +457,7 @@ void hvm_migrate_pirqs(struct vcpu *v) {struct domain *d = v->domain; -if ( !iommu_enabled || !d->arch.hvm_domain.irq.dpci ) +if ( !iommu_enabled || !d->arch.hvm_domain.irq->dpci )return ;spin_lock (&d->event_lock);
@@ -619,11 +619,16 @@ int hvm_domain_initialise(struct domain *d) d->arch.hvm_domain.params =xzalloc_array (uint64_t,HVM_NR_PARAMS ); d->arch.hvm_domain.io_handler = xzalloc_array(struct hvm_io_handler,NR_IO_HANDLERS ); + d->arch.hvm_domain.irq =xzalloc_bytes (hvm_irq_size (VIOAPIC_NUM_PINS )); + rc = -ENOMEM ; -if ( !d->arch.hvm_domain.pl_time || +if ( !d->arch.hvm_domain.pl_time || !d->arch.hvm_domain.irq || !d->arch.hvm_domain.params || !d->arch.hvm_domain.io_handler ) goto fail1; +/* Set the default number of GSIs */ +hvm_domain_irq (d)->nr_gsis =VIOAPIC_NUM_PINS ; +/* need link to containing domain */ d->arch.hvm_domain.pl_time->domain = d;
@@ -680,6 +685,7 @@ int hvm_domain_initialise(struct domain *d)xfree (d->arch.hvm_domain.io_handler);xfree (d->arch.hvm_domain.params);xfree (d->arch.hvm_domain.pl_time); +xfree (d->arch.hvm_domain.irq); fail0:hvm_destroy_cacheattr_region_list (d);return rc;
@@ -722,6 +728,9 @@ void hvm_domain_destroy(struct domain *d)xfree (d->arch.hvm_domain.pl_time); d->arch.hvm_domain.pl_time =NULL ; + +xfree (d->arch.hvm_domain.irq); + d->arch.hvm_domain.irq =NULL ; }static int hvm_save_tsc_adjust (struct domain *d,hvm_domain_context_t *h)
xen/arch/x86/hvm/irq.c +21 -6
@@ -69,6 +69,7 @@ static void __hvm_pci_intx_assert(return ; gsi =hvm_pci_intx_gsi (device, intx); +ASSERT (gsi < hvm_irq->nr_gsis);if ( hvm_irq->gsi_assert_count[gsi]++ ==0 )assert_gsi (d, gsi);
@@ -99,6 +100,7 @@ static void __hvm_pci_intx_deassert(return ; gsi =hvm_pci_intx_gsi (device, intx); +ASSERT (gsi < hvm_irq->nr_gsis); --hvm_irq->gsi_assert_count[gsi]; link =hvm_pci_intx_link (device, intx);
@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);
@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);
@@ -363,7 +365,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via) {case HVMIRQ_callback_gsi: gsi = hvm_irq->callback_via.gsi = (uint8_t )via; -if ( (gsi ==0 ) || (gsi >=ARRAY_SIZE (hvm_irq->gsi_assert_count)) ) +if ( (gsi ==0 ) || (gsi >= hvm_irq->nr_gsis) ) hvm_irq->callback_via_type = HVMIRQ_callback_none;else if ( hvm_irq->callback_via_asserted && (hvm_irq->gsi_assert_count[gsi]++ ==0 ) )
@@ -419,9 +421,9 @@ struct hvm_intack hvm_vcpu_has_pending_irq(struct vcpu *v)if (unlikely (v->mce_pending) )return hvm_intack_mce; -if ( (plat->irq.callback_via_type == HVMIRQ_callback_vector) +if ( (plat->irq->callback_via_type == HVMIRQ_callback_vector) &&vcpu_info (v, evtchn_upcall_pending) ) -return hvm_intack_vector (plat->irq.callback_via.vector); +return hvm_intack_vector (plat->irq->callback_via.vector);if (vlapic_accept_pic_intr (v) && plat->vpic[0 ].int_output )return hvm_intack_pic (0 );
@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,
@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + { +printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + } printk("Link %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", hvm_irq->pci_link_assert_count[0], hvm_irq->pci_link_assert_count[1],
@@ -545,6 +554,9 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)unsigned int asserted, pdev, pintx;int rc; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +spin_lock (&d->arch.hvm_domain.irq_lock); pdev = hvm_irq->callback_via.pci.dev;
@@ -592,6 +604,9 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +/* Load the PCI IRQ lines */ if (hvm_load_entry (PCI_IRQ , h, &hvm_irq->pci_intx) !=0 )return -EINVAL ;
xen/drivers/passthrough/io.c +4 -4
@@ -195,7 +195,7 @@ struct hvm_irq_dpci *domain_get_irq_dpci(const struct domain *d)if ( !d || !is_hvm_domain (d) )return NULL ; -return d->arch.hvm_domain.irq.dpci; +return d->arch.hvm_domain.irq->dpci; }void free_hvm_irq_dpci (struct hvm_irq_dpci *dpci)
@@ -333,7 +333,7 @@ int pt_irq_create_bind(for ( i =0 ; i <NR_HVM_IRQS ; i++ )INIT_LIST_HEAD (&hvm_irq_dpci->girq[i]); - d->arch.hvm_domain.irq.dpci = hvm_irq_dpci; + d->arch.hvm_domain.irq->dpci = hvm_irq_dpci; } info =pirq_get_info (d, pirq);
@@ -788,7 +788,7 @@ static int _hvm_dpci_msi_eoi(struct domain *d,void hvm_dpci_msi_eoi (struct domain *d,int vector) { -if ( !iommu_enabled || !d->arch.hvm_domain.irq.dpci ) +if ( !iommu_enabled || !d->arch.hvm_domain.irq->dpci )return ;spin_lock (&d->event_lock);
@@ -798,7 +798,7 @@ void hvm_dpci_msi_eoi(struct domain *d, int vector)static void hvm_dirq_assist (struct domain *d,struct hvm_pirq_dpci *pirq_dpci) { -if (unlikely (!d->arch.hvm_domain.irq.dpci) ) +if (unlikely (!d->arch.hvm_domain.irq->dpci) ) {ASSERT_UNREACHABLE ();return ;
xen/drivers/passthrough/pci.c +1 -1
@@ -815,7 +815,7 @@ static int pci_clean_dpci_irqs(struct domain *d)return ret; } - d->arch.hvm_domain.irq.dpci =NULL ; + d->arch.hvm_domain.irq->dpci =NULL ;free_hvm_irq_dpci (hvm_irq_dpci); }spin_unlock (&d->event_lock);
xen/include/asm-x86/domain.h +1 -1
@@ -17,7 +17,7 @@#define is_pv_32bit_vcpu (v) (is_pv_32bit_domain((v)->domain))#define is_hvm_pv_evtchn_domain (d) (is_hvm_domain(d) && \ - d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector) + d->arch.hvm_domain.irq->callback_via_type == HVMIRQ_callback_vector)#define is_hvm_pv_evtchn_vcpu (v) (is_hvm_pv_evtchn_domain(v->domain))#define is_domain_direct_mapped (d) ((void)(d), 0)
xen/include/asm-x86/hvm/domain.h +1 -1
@@ -125,7 +125,7 @@ struct hvm_domain {/* Lock protects access to irq, vpic and vioapic. */ spinlock_t irq_lock; -struct hvm_irq irq; +struct hvm_irq *irq;struct hvm_hw_vpic vpic[2 ];/* 0=master; 1=slave */ struct hvm_vioapic *vioapic;struct hvm_hw_stdvga stdvga;
xen/include/asm-x86/hvm/irq.h +15 -13
@@ -67,18 +67,6 @@ struct hvm_irq {u8 pci_link_assert_count[4 ];/* -* Number of wires asserting each GSI. -* -* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space -* except ISA IRQ 0, which is connected to GSI 2. -* PCI links map into this space via the PCI-ISA bridge. -* -* GSIs 16+ are used only be PCI devices. The mapping from PCI device to -* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 -*/ -u8 gsi_assert_count[VIOAPIC_NUM_PINS ]; - -/* * GSIs map onto PIC/IO-APIC in the usual way: * 0-7: Master 8259 PIC, IO-APIC pins 0-7 * 8-15: Slave 8259 PIC, IO-APIC pins 8-15
@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 +*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };#define hvm_pci_intx_gsi (dev, intx) \ (((((dev)<<2) + ((dev)>>3) + (intx)) & 31) + 16)#define hvm_pci_intx_link (dev, intx) \ (((dev) + (intx)) & 3) -#define hvm_domain_irq (d) (&(d)->arch.hvm_domain.irq) +#define hvm_domain_irq (d) ((d)->arch.hvm_domain.irq) +#define hvm_irq_size (cnt) offsetof(struct hvm_irq, gsi_assert_count[cnt])#define hvm_isa_irq_to_gsi (isa_irq) ((isa_irq) ? : 2)
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
Rearrange the fields of
hvm_irqso thatgsi_assert_countcan be converted into a variable size array and add a new field to account the number of GSIs.
xen/arch/x86/hvm/hvm.c void hvm_migrate_pirqs(struct vcpu *v) · line 460
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -457,7 +457,7 @@ void hvm_migrate_pirqs(struct vcpu *v) {struct domain *d = v->domain; -if ( !iommu_enabled || !d->arch.hvm_domain.irq.dpci ) +if ( !iommu_enabled || !d->arch.hvm_domain.irq->dpci )
If the prior patch is really needed - why did it not convert this? (There are more such instances further down.)
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);
xen/arch/x86/hvm/hvm.c void hvm_isa_irq_deassert( · line 144
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);
Not sure about these two - perhaps they'd better be BUILD_BUG_ON()s for the DomU side, and Dom0 should never be allocated less than 16?
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,
xen/arch/x86/hvm/hvm.c static void irq_dump(struct domain *d) · line 518
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +7
-0@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + { +printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }
I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Quoted 11 lines
xen/arch/x86/hvm/hvm.c +3
-0@@ -545,6 +554,9 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)unsigned int asserted, pdev, pintx;int rc; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +spin_lock (&d->arch.hvm_domain.irq_lock); pdev = hvm_irq->callback_via.pci.dev;
xen/arch/x86/hvm/hvm.c static int irq_load_pci(struct domain *d, hvm_domain_context_t *h) · line 608
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +2
-0@@ -592,6 +604,9 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ;
Why do you add these checks here?
xen/include/asm-x86/domain.h line 20
Quoted 8 lines
xen/include/asm-x86/domain.h +1
-1@@ -17,7 +17,7 @@#define is_pv_32bit_vcpu (v) (is_pv_32bit_domain((v)->domain))#define is_hvm_pv_evtchn_domain (d) (is_hvm_domain(d) && \ - d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector) + d->arch.hvm_domain.irq->callback_via_type == HVMIRQ_callback_vector)
Please take the opportunity and properly parenthesize the use of d here.
Quoted 8 lines
xen/include/asm-x86/domain.h +4
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +*
xen/include/asm-x86/domain.h struct hvm_irq { · line 93
Quoted 10 lines
xen/include/asm-x86/domain.h +9
-0+* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 +*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };
I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0
-0@@ -457,7 +457,7 @@ void hvm_migrate_pirqs(struct vcpu *v) {struct domain *d = v->domain;
Quoted 5 lines
xen/arch/x86/hvm/hvm.c void hvm_migrate_pirqs(struct vcpu *v) · line 460
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1
-1-if ( !iommu_enabled || !d->arch.hvm_domain.irq.dpci ) +if ( !iommu_enabled || !d->arch.hvm_domain.irq->dpci )If the prior patch is really needed - why did it not convert this? (There are more such instances further down.)
It's now done.
Quoted 13 lines
Quoted 13 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq);
Quoted 6 lines
xen/arch/x86/hvm/hvm.c void hvm_isa_irq_deassert( · line 144
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1
-1-ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);Not sure about these two - perhaps they'd better be BUILD_BUG_ON()s for the DomU side, and Dom0 should never be allocated less than 16?
Hm, I could add:
BUILD_BUG_ON(VIOAPIC_NUM_PINS < 16);
But this is going to make it harder to remove VIOAPIC_NUM_PINS later on.
Quoted 15 lines
Quoted 15 lines
xen/arch/x86/hvm/hvm.c +3
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + {
Quoted 8 lines
xen/arch/x86/hvm/hvm.c static void irq_dump(struct domain *d) · line 518
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +5
-0+printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Quoted 14 lines
Quoted 14 lines
xen/arch/x86/hvm/hvm.c +3
-0@@ -545,6 +554,9 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)unsigned int asserted, pdev, pintx;int rc; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +spin_lock (&d->arch.hvm_domain.irq_lock); pdev = hvm_irq->callback_via.pci.dev;@@ -592,6 +604,9 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi;
Quoted 4 lines
xen/arch/x86/hvm/hvm.c static int irq_load_pci(struct domain *d, hvm_domain_context_t *h) · line 608
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +2
-0+if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ;Why do you add these checks here?
Because there's a:
for ( gsi = 0; gsi < VIOAPIC_NUM_PINS; gsi++ )
hvm_irq->gsi_assert_count[gsi] = 0;
A little bit below. I can change that to use nr_gsis instead and remove those checks (both here and in irq_save_pci).
Quoted 11 lines
xen/include/asm-x86/domain.h line 20
Quoted 8 lines
xen/include/asm-x86/domain.h +1
-1@@ -17,7 +17,7 @@#define is_pv_32bit_vcpu (v) (is_pv_32bit_domain((v)->domain))#define is_hvm_pv_evtchn_domain (d) (is_hvm_domain(d) && \ - d->arch.hvm_domain.irq.callback_via_type == HVMIRQ_callback_vector) + d->arch.hvm_domain.irq->callback_via_type == HVMIRQ_callback_vector)Please take the opportunity and properly parenthesize the use of d here.
Done.
Quoted 14 lines
Quoted 14 lines
xen/include/asm-x86/domain.h +10
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16
Quoted 8 lines
xen/include/asm-x86/domain.h struct hvm_irq { · line 93
Quoted 4 lines
xen/include/asm-x86/domain.h +3
-0+*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
This one seems to be fine for PVH Dom0 (you will have to look at the next series), but I specifically avoid touching pci_link_assert_count. Again, better to comment this on the next patch series that actually implements the interrupt binding. This is needed because code in vioapic makes use of gsi_assert_count.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 19:28, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/irq.c +1
-1@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq);Quoted 6 lines
Review void hvm_isa_irq_deassert( · line 144
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(isa_irq <= 15); + ASSERT(isa_irq <= 15 && isa_irq < hvm_irq->nr_gsis);Not sure about these two - perhaps they'd better be BUILD_BUG_ON()s for the DomU side, and Dom0 should never be allocated less than 16?
Quoted 5 lines
Hm, I could add:
BUILD_BUG_ON(VIOAPIC_NUM_PINS < 16);But this is going to make it harder to remove
VIOAPIC_NUM_PINSlater on.
As said elsewhere, those remaining uses could/should become ARRAY_SIZE().
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
xen/arch/x86/hvm/irq.c +3
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + {Quoted 8 lines
xen/arch/x86/hvm/irq.c static void irq_dump(struct domain *d) · line 518
Quoted 5 lines
xen/arch/x86/hvm/irq.c +5
-0+printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Quoted 2 lines
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Well, if you also want to change the existing ones, then a separate patch would be preferred. As to %2 vs %3 - how would the latter be any better if we want/need to change the type from u8 anyway?
Quoted 19 lines
Quoted 14 lines
Quoted 14 lines
xen/arch/x86/hvm/irq.c +3
-0@@ -545,6 +554,9 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)unsigned int asserted, pdev, pintx;int rc; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +spin_lock (&d->arch.hvm_domain.irq_lock); pdev = hvm_irq->callback_via.pci.dev;@@ -592,6 +604,9 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi;Quoted 4 lines
Review static int irq_load_pci(struct domain *d, hvm_domain_context_t *h) · line 608
Quoted 2 lines
(quoted diff) +2
-0+ if ( hvm_irq->nr_gsis != VIOAPIC_NUM_PINS ) + return -EOPNOTSUPP;Why do you add these checks here?
Quoted 6 lines
Because there's a:
for ( gsi = 0; gsi <
VIOAPIC_NUM_PINS; gsi++ )
hvm_irq->gsi_assert_count[gsi] = 0;A little bit below.
True for the load side, but I can't see anything like that for save.
Quoted 2 lines
I can change that to use
nr_gsisinstead and remove those checks (both here and inirq_save_pci).
Please do, there's no harm using the dynamic upper bound in that case.
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
xen/include/asm-x86/hvm/irq.h +10
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 Quoted 8 lines
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 93
Quoted 4 lines
xen/include/asm-x86/hvm/irq.h +3
-0+*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
Quoted 5 lines
This one seems to be fine for PVH Dom0 (you will have to look at the next series), but I specifically avoid touching
pci_link_assert_count. Again, better to comment this on the next patch series that actually implements the interrupt binding. This is needed because code in vioapic makes use ofgsi_assert_count.
Well, we can certainly discuss this there (whenever I get to look at it, as that's not 4.9 stuff now anymore), but for now I don't see the connection between my comment and your reply.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 19:28, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/irq.c +1
-1@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);xen/arch/x86/hvm/irq.c void hvm_isa_irq_deassert( · line 144
Quoted 5 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);Not sure about these two - perhaps they'd better be BUILD_BUG_ON()s for the DomU side, and Dom0 should never be allocated less than 16?
Quoted 8 lines
Quoted 5 lines
Hm, I could add:
BUILD_BUG_ON(VIOAPIC_NUM_PINS < 16);But this is going to make it harder to remove
VIOAPIC_NUM_PINSlater on.As said elsewhere, those remaining uses could/should become
ARRAY_SIZE().
Hm, but then I will have to use:
ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)
Which is kind of cumbersome? I can define that into a macro I guess.
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,xen/arch/x86/hvm/irq.c static void irq_dump(struct domain *d) · line 518
Quoted 10 lines
xen/arch/x86/hvm/irq.c +7
-0@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + { +printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Quoted 6 lines
Quoted 2 lines
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Well, if you also want to change the existing ones, then a separate patch would be preferred. As to %2 vs %3 - how would the latter be any better if we want/need to change the type from u8 anyway?
ATM uint8_t can be 255, so %3 seems better (although AFAICT this is limited to 4, because there are 4 INT# lines to each GSI, and pending GSIs are not accumulated). I'm not sure I follow why do we want/need to change the type.
Quoted 26 lines
Quoted 19 lines
Quoted 14 lines
Quoted 14 lines
xen/arch/x86/hvm/irq.c +3
-0@@ -545,6 +554,9 @@ static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)unsigned int asserted, pdev, pintx;int rc; +if ( hvm_irq->nr_gsis !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +spin_lock (&d->arch.hvm_domain.irq_lock); pdev = hvm_irq->callback_via.pci.dev;@@ -592,6 +604,9 @@ static int irq_load_pci(struct domain *d, hvm_domain_context_t *h)struct hvm_irq *hvm_irq =hvm_domain_irq (d);int link, dev, intx, gsi;Quoted 4 lines
Review static int irq_load_pci(struct domain *d, hvm_domain_context_t *h) · line 608
Quoted 2 lines
(quoted diff) +2
-0+ if ( hvm_irq->nr_gsis != VIOAPIC_NUM_PINS ) + return -EOPNOTSUPP;Why do you add these checks here?
Quoted 6 lines
Because there's a:
for ( gsi = 0; gsi <
VIOAPIC_NUM_PINS; gsi++ )
hvm_irq->gsi_assert_count[gsi] = 0;A little bit below.
Quoted 7 lines
True for the load side, but I can't see anything like that for save.
Quoted 2 lines
I can change that to use
nr_gsisinstead and remove those checks (both here and inirq_save_pci).Please do, there's no harm using the dynamic upper bound in that case.
Now done.
Quoted 29 lines
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
xen/include/asm-x86/hvm/irq.h +10
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 Quoted 8 lines
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 93
Quoted 4 lines
xen/include/asm-x86/hvm/irq.h +3
-0+*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
Quoted 5 lines
This one seems to be fine for PVH Dom0 (you will have to look at the next series), but I specifically avoid touching
pci_link_assert_count. Again, better to comment this on the next patch series that actually implements the interrupt binding. This is needed because code in vioapic makes use ofgsi_assert_count.
Quoted 3 lines
Well, we can certainly discuss this there (whenever I get to look at it, as that's not 4.9 stuff now anymore), but for now I don't see the connection between my comment and your reply.
Hm, I'm not sure I understand why would you like to change the type of this array. AFAICT the type of the array is not related to the number of vIO APIC pins, or the number of vIO APICs.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
Quoted 29 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 19:28, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/irq.c +1
-1@@ -122,7 +124,7 @@ void hvm_isa_irq_assert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); -ASSERT (isa_irq <=15 ); +ASSERT (isa_irq <=15 && isa_irq < hvm_irq->nr_gsis);spin_lock (&d->arch.hvm_domain.irq_lock);@@ -139,7 +141,7 @@ void hvm_isa_irq_deassert(struct hvm_irq *hvm_irq =hvm_domain_irq (d);unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq);Quoted 6 lines
Review void hvm_isa_irq_deassert( · line 144
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(isa_irq <= 15); + ASSERT(isa_irq <= 15 && isa_irq < hvm_irq->nr_gsis);Not sure about these two - perhaps they'd better be BUILD_BUG_ON()s for the DomU side, and Dom0 should never be allocated less than 16?
Hm, I could add:
BUILD_BUG_ON(VIOAPIC_NUM_PINS < 16);But this is going to make it harder to remove
VIOAPIC_NUM_PINSlater on.
Quoted 8 lines
Quoted 2 lines
As said elsewhere, those remaining uses could/should become
ARRAY_SIZE().Hm, but then I will have to use:
ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)Which is kind of cumbersome? I can define that into a macro I guess.
Indeed, ugly. How about
struct hvm_vioapic {
struct domain *domain;
union {
DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS);
struct hvm_hw_vioapic domU;
};
};(with "domU" subject to improvement)? This might at once allow making the save/restore code look better.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
xen/arch/x86/hvm/irq.c +3
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + {Quoted 8 lines
xen/arch/x86/hvm/irq.c static void irq_dump(struct domain *d) · line 518
Quoted 5 lines
xen/arch/x86/hvm/irq.c +5
-0+printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Quoted 7 lines
Quoted 3 lines
Well, if you also want to change the existing ones, then a separate patch would be preferred. As to %2 vs %3 - how would the latter be any better if we want/need to change the type from u8 anyway?
ATM
uint8_tcan be 255, so %3 seems better (although AFAICT this is limited to 4, because there are 4 INT# lines to each GSI, and pending GSIs are not accumulated). I'm not sure I follow why do we want/need to change the type.
For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
xen/include/asm-x86/hvm/irq.h +10
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 Quoted 8 lines
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 93
Quoted 4 lines
xen/include/asm-x86/hvm/irq.h +3
-0+*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
This one seems to be fine for PVH Dom0 (you will have to look at the next series), but I specifically avoid touching
pci_link_assert_count. Again, better to comment this on the next patch series that actually implements the interrupt binding. This is needed because code in vioapic makes use ofgsi_assert_count.
Quoted 7 lines
Quoted 3 lines
Well, we can certainly discuss this there (whenever I get to look at it, as that's not 4.9 stuff now anymore), but for now I don't see the connection between my comment and your reply.
Hm, I'm not sure I understand why would you like to change the type of this array. AFAICT the type of the array is not related to the number of vIO APIC pins, or the number of vIO APICs.
See above - I think it is related to the number of declared INTx lines (of which a DomU at present would only have 4). Or maybe I'm mistaken where the INTx value comes from here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 17 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 27.03.17 at 19:28, <[email protected]> wrote:
ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)Which is kind of cumbersome? I can define that into a macro I guess.
Indeed, ugly. How about
struct hvm_vioapic { struct domain *domain; union { DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS); struct hvm_hw_vioapic domU; }; };
Quoted 2 lines
(with "domU" subject to improvement)? This might at once allow making the save/restore code look better.
Right, this indeed looks better, and will make the save/restore code neater. I'm not sure I can come up with a better name, "guest", "static"?
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
xen/arch/x86/hvm/irq.c +3
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t ) hvm_irq->isa_irq.pad[0 ], hvm_irq->pci_link.route[0 ], hvm_irq->pci_link.route[1 ], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i +=8 ) +for ( i =0 ; i < hvm_irq->nr_gsis && i +8 <= hvm_irq->nr_gsis; i +=8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5 ], hvm_irq->gsi_assert_count[i+6 ], hvm_irq->gsi_assert_count[i+7]); +if ( i != hvm_irq->nr_gsis ) + {Quoted 8 lines
xen/arch/x86/hvm/irq.c static void irq_dump(struct domain *d) · line 518
Quoted 5 lines
xen/arch/x86/hvm/irq.c +5
-0+printk ("GSI [%x - %x]" , i, hvm_irq->nr_gsis -1 ); +for ( ; i < hvm_irq->nr_gsis; i++) +printk (" %2.2" PRIu8, hvm_irq->gsi_assert_count[i]); +printk ("\n" ); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Quoted 2 lines
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Well, if you also want to change the existing ones, then a separate patch would be preferred. As to %2 vs %3 - how would the latter be any better if we want/need to change the type from u8 anyway?
Quoted 7 lines
Quoted 3 lines
ATM
uint8_tcan be 255, so %3 seems better (although AFAICT this is limited to 4, because there are 4 INT# lines to each GSI, and pending GSIs are not accumulated). I'm not sure I follow why do we want/need to change the type.For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
In any case, I'm not sure this is relevant to PVH Dom0, where Xen should simply bind GSIs, but has no idea of all the interrupt routing behind them. This is relevant to DomUs because in that case Xen acts as a PCI interrupt router AFAICT.
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
xen/include/asm-x86/hvm/irq.h +10
-0@@ -89,13 +77,27 @@ struct hvm_irq {u8 round_robin_prev_vcpu;struct hvm_irq_dpci *dpci; + +/* +* Number of wires asserting each GSI. +* +* GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space +* except ISA IRQ 0, which is connected to GSI 2. +* PCI links map into this space via the PCI-ISA bridge. +* +* GSIs 16+ are used only be PCI devices. The mapping from PCI device to +* GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16 Quoted 8 lines
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 93
Quoted 4 lines
xen/include/asm-x86/hvm/irq.h +3
-0+*/ +unsigned int nr_gsis; +u8 gsi_assert_count[]; };I'm afraid at the same time (or in a later patch) the type of this array (and maybe also the type of pci_link_assert_count[]) will need to be widened.
Quoted 5 lines
This one seems to be fine for PVH Dom0 (you will have to look at the next series), but I specifically avoid touching
pci_link_assert_count. Again, better to comment this on the next patch series that actually implements the interrupt binding. This is needed because code in vioapic makes use ofgsi_assert_count.Well, we can certainly discuss this there (whenever I get to look at it, as that's not 4.9 stuff now anymore), but for now I don't see the connection between my comment and your reply.
Quoted 7 lines
Quoted 3 lines
Hm, I'm not sure I understand why would you like to change the type of this array. AFAICT the type of the array is not related to the number of vIO APIC pins, or the number of vIO APICs.
See above - I think it is related to the number of declared INTx lines (of which a DomU at present would only have 4). Or maybe I'm mistaken where the INTx value comes from here.
AFAICT in any case the INTx is always limited to INTA-INTD (4), but I don't think this is important for Dom0, because there Xen doesn't act as a PCI interrupt router, and thus doesn't need to know the INTx. In fact gsi_assert_count used with a PVH Dom0 should either be 0 or 1, because Xen is identity mapping machine GSIs into guest GSIs, without any kind of routing.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:34, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 27.03.17 at 19:28, <[email protected]> wrote:
ARRAY_SIZE(((struct hvm_hw_vioapic *)0)->redirtbl)Which is kind of cumbersome? I can define that into a macro I guess.
Indeed, ugly. How about
struct hvm_vioapic { struct domain *domain; union { DECLARE_VIOAPIC(, VIOAPIC_NUM_PINS); struct hvm_hw_vioapic domU; }; };
Quoted 5 lines
Quoted 2 lines
(with "domU" subject to improvement)? This might at once allow making the save/restore code look better.
Right, this indeed looks better, and will make the save/restore code neater. I'm not sure I can come up with a better name, "guest", "static"?
Well, "static" is a keyword, so can't be used, and Dom0 is a "guest" too.
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
(quoted diff) +1
-1@@ -495,7 +497,7 @@ static void irq_dump(struct domain *d) (uint32_t) hvm_irq->isa_irq.pad[0], hvm_irq->pci_link.route[0], hvm_irq->pci_link.route[1], hvm_irq->pci_link.route[2], hvm_irq->pci_link.route[3]); - for ( i = 0 ; i < VIOAPIC_NUM_PINS; i += 8 ) + for ( i = 0; i < hvm_irq->nr_gsis && i + 8 <= hvm_irq->nr_gsis; i += 8 ) printk("GSI [%x - %x] %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8 " %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8" %2.2"PRIu8"\n", i, i+7,Review static void irq_dump(struct domain *d) · line 518
Quoted 10 lines
(quoted diff) +7
-0@@ -507,6 +509,13 @@ static void irq_dump(struct domain *d) hvm_irq->gsi_assert_count[i+5], hvm_irq->gsi_assert_count[i+6], hvm_irq->gsi_assert_count[i+7]); + if ( i != hvm_irq->nr_gsis ) + { + printk("GSI [%x - %x]", i, hvm_irq->nr_gsis - 1); + for ( ; i < hvm_irq->nr_gsis; i++) + printk(" %2.2"PRIu8, hvm_irq->gsi_assert_count[i]); + printk("\n"); + }I realize you've just copied this from existing code, but what advantage does %2.2 have over just %2 here?
Quoted 6 lines
Quoted 2 lines
Shouldn't it be just %3 anyway? Would you be fine with me fixing this here, or would you rather prefer a separate patch?
Well, if you also want to change the existing ones, then a separate patch would be preferred. As to %2 vs %3 - how would the latter be any better if we want/need to change the type from u8 anyway?
ATM
uint8_tcan be 255, so %3 seems better (although AFAICT this is limited to 4, because there are 4 INT# lines to each GSI, and pending GSIs are not accumulated). I'm not sure I follow why do we want/need to change the type.
Quoted 8 lines
Quoted 3 lines
For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
In any case, I'm not sure this is relevant to PVH Dom0, where Xen should simply bind GSIs, but has no idea of all the interrupt routing behind them. This is relevant to DomUs because in that case Xen acts as a PCI interrupt router AFAICT.
Good point. But is all this refcounting code being bypassed for Dom0? If so, you wouldn't need to extend the array here. If not, overflows may still matter.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:34, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
On Tue, Mar 28, 2017 at 01:25:44AM -0600, Jan Beulich wrote:
For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
Quoted 8 lines
Quoted 4 lines
In any case, I'm not sure this is relevant to PVH Dom0, where Xen should simply bind GSIs, but has no idea of all the interrupt routing behind them. This is relevant to DomUs because in that case Xen acts as a PCI interrupt router AFAICT.
Good point. But is all this refcounting code being bypassed for Dom0? If so, you wouldn't need to extend the array here. If not, overflows may still matter.
It's not really bypassed for Dom0 (Xen still needs to keep track of pending interrupts), but it's more simple.
As said above a GSI is either pending (gsi_assert_count[gsi] == 1) or not (gsi_assert_count[gsi] == 0). I could maybe use a bitmap for that and avoid touching gsi_assert_count at all, but then I will have to introduce more changes.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:59, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:34, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
On Tue, Mar 28, 2017 at 01:25:44AM -0600, Jan Beulich wrote:
For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
Quoted 8 lines
Quoted 4 lines
In any case, I'm not sure this is relevant to PVH Dom0, where Xen should simply bind GSIs, but has no idea of all the interrupt routing behind them. This is relevant to DomUs because in that case Xen acts as a PCI interrupt router AFAICT.
Good point. But is all this refcounting code being bypassed for Dom0? If so, you wouldn't need to extend the array here. If not, overflows may still matter.
Quoted 7 lines
It's not really bypassed for Dom0 (Xen still needs to keep track of pending interrupts), but it's more simple.
As said above a GSI is either pending (gsi_assert_count[gsi] == 1) or not (gsi_assert_count[gsi] == 0). I could maybe use a bitmap for that and avoid touching
gsi_assert_countat all, but then I will have to introduce more changes.
I don't think there's a need, indeed. But I'd appreciate if you would add ASSERT()s to that effect.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/7] x86/hvm: convert gsi_assert_count into a variable size array
Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:59, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 11:34, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 10:40, <[email protected]> wrote:
On Tue, Mar 28, 2017 at 01:25:44AM -0600, Jan Beulich wrote:
For our DomU model there are four lines. Physical machines often declare more in ACPI, and I'm not sure there's a theoretical upper limit.
Quoted 8 lines
Quoted 4 lines
In any case, I'm not sure this is relevant to PVH Dom0, where Xen should simply bind GSIs, but has no idea of all the interrupt routing behind them. This is relevant to DomUs because in that case Xen acts as a PCI interrupt router AFAICT.
Good point. But is all this refcounting code being bypassed for Dom0? If so, you wouldn't need to extend the array here. If not, overflows may still matter.
It's not really bypassed for Dom0 (Xen still needs to keep track of pending interrupts), but it's more simple.
Quoted 7 lines
Quoted 4 lines
As said above a GSI is either pending (gsi_assert_count[gsi] == 1) or not (gsi_assert_count[gsi] == 0). I could maybe use a bitmap for that and avoid touching
gsi_assert_countat all, but then I will have to introduce more changes.I don't think there's a need, indeed. But I'd appreciate if you would add ASSERT()s to that effect.
OK, such ASSERTs would be added to hvm_gsi_{de}assert in patch #3 of the next series ("x86/dpci: bind legacy PCI interrupts to PVHv2 Dom0").
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 4/7 x86/vioapic: allow the vIO APIC to have a variable number of pins
In reply to Roger Pau MonneAlthough it's still always set to VIOAPIC_NUM_PINS (48).
Add a new field to the hvm_ioapic struct to contain the number of pins (number of IO redirection table entries) and turn the redirection table into a variable sized array.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
---
Changes since v1:
- Almost completely reworked due to previous changes.
--- xen/arch/x86/hvm/vioapic.c | 28 +++++++++++++++++----------- xen/include/asm-x86/hvm/vioapic.h | 4 +++- 2 files changed, 20 insertions(+), 12 deletions(-)
xen/arch/x86/hvm/vioapic.c +17 -11
@@ -53,7 +53,7 @@ static uint32_t vioapic_read_indirect(const struct hvm_vioapic *vioapic)case VIOAPIC_REG_VERSION : result = ((union IO_APIC_reg_01 ){ .bits = { .version =VIOAPIC_VERSION_ID , - .entries =VIOAPIC_NUM_PINS -1 } + .entries = vioapic->nr_pins -1 } }).raw;break ;
@@ -73,7 +73,7 @@ static uint32_t vioapic_read_indirect(const struct hvm_vioapic *vioapic)uint32_t redir_index = (vioapic->ioregsel -VIOAPIC_REG_RTE0 ) >>1 ;uint64_t redir_content; -if ( redir_index >=VIOAPIC_NUM_PINS ) +if ( redir_index >= vioapic->nr_pins ) {gdprintk (XENLOG_WARNING ,"apic_mem_readl:undefined ioregsel %x\n" , vioapic->ioregsel);
@@ -197,7 +197,7 @@ static void vioapic_write_indirect(HVM_DBG_LOG (DBG_LEVEL_IOAPIC ,"rte[%02x].%s = %08x" , redir_index, vioapic->ioregsel &1 ?"hi" :"lo" , val); -if ( redir_index >=VIOAPIC_NUM_PINS ) +if ( redir_index >= vioapic->nr_pins ) {gdprintk (XENLOG_WARNING ,"vioapic_write_indirect " "error register %x\n" , vioapic->ioregsel);
@@ -368,7 +368,7 @@ void vioapic_irq_positive_edge(struct domain *d, unsigned int irq)HVM_DBG_LOG (DBG_LEVEL_IOAPIC ,"irq %x" , irq); -ASSERT (irq <VIOAPIC_NUM_PINS ); +ASSERT (irq < vioapic->nr_pins);ASSERT (spin_is_locked (&d->arch.hvm_domain.irq_lock)); ent = &vioapic->redirtbl[irq];
@@ -397,7 +397,7 @@ void vioapic_update_EOI(struct domain *d, u8 vector)spin_lock (&d->arch.hvm_domain.irq_lock); -for ( gsi =0 ; gsi <VIOAPIC_NUM_PINS ; gsi++ ) +for ( gsi =0 ; gsi < vioapic->nr_pins; gsi++ ) { ent = &vioapic->redirtbl[gsi];if ( ent->fields.vector != vector )
@@ -431,9 +431,8 @@ static int ioapic_save(struct domain *d, hvm_domain_context_t *h)if ( !has_vioapic (d) )return 0 ; -BUILD_BUG_ON (sizeof (struct hvm_hw_vioapic ) != -sizeof (struct hvm_vioapic ) - - offsetof(struct hvm_vioapic , base_address)); +if ( s->nr_pins !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ;return hvm_save_entry (IOAPIC ,0 , h, &s->base_address); }
@@ -445,6 +444,9 @@ static int ioapic_load(struct domain *d, hvm_domain_context_t *h)if ( !has_vioapic (d) )return -ENODEV ; +if ( s->nr_pins !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ; +return hvm_load_entry (IOAPIC , h, &s->base_address); }
@@ -453,14 +455,16 @@ HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);void vioapic_reset (struct domain *d) {struct hvm_vioapic *vioapic =domain_vioapic (d); +uint32_t nr_pins = vioapic->nr_pins;int i;if ( !has_vioapic (d) )return ; -memset (vioapic,0 ,sizeof (*vioapic)); +memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); vioapic->domain = d; -for ( i =0 ; i <VIOAPIC_NUM_PINS ; i++ ) + vioapic->nr_pins = nr_pins; +for ( i =0 ; i < nr_pins; i++ ) vioapic->redirtbl[i].fields.mask =1 ; vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; }
@@ -471,10 +475,12 @@ int vioapic_init(struct domain *d)return 0 ;if ( (d->arch.hvm_domain.vioapic ==NULL ) && - ((d->arch.hvm_domain.vioapic = xmalloc(struct hvm_vioapic)) == NULL) ) + ((d->arch.hvm_domain.vioapic = +xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) )return -ENOMEM ; d->arch.hvm_domain.vioapic->domain = d; + d->arch.hvm_domain.vioapic->nr_pins =VIOAPIC_NUM_PINS ;vioapic_reset (d);register_mmio_handler (d, &vioapic_mmio_ops);
xen/include/asm-x86/hvm/vioapic.h +3 -1
@@ -49,13 +49,15 @@struct hvm_vioapic {struct domain *domain; +uint32_t nr_pins;/* Layout below must match hvm_hw_vioapic. */ uint64_t base_address;uint32_t ioregsel;uint32_t id; -union vioapic_redir_entry redirtbl[VIOAPIC_NUM_PINS ]; +union vioapic_redir_entry redirtbl[]; }; +#define hvm_vioapic_size (cnt) offsetof(struct hvm_vioapic, redirtbl[cnt])#define domain_vioapic (d) ((d)->arch.hvm_domain.vioapic)#define vioapic_domain (v) ((v)->domain)
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 4/7] x86/vioapic: allow the vIO APIC to have a variable number of pins
xen/arch/x86/hvm/vioapic.c static int ioapic_save(struct domain *d, hvm_domain_context_t *h) · line 435
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/vioapic.c +2
-3@@ -431,9 +431,8 @@ static int ioapic_save(struct domain *d, hvm_domain_context_t *h)if ( !has_vioapic (d) )return 0 ; -BUILD_BUG_ON (sizeof (struct hvm_hw_vioapic ) != -sizeof (struct hvm_vioapic ) - - offsetof(struct hvm_vioapic , base_address)); +if ( s->nr_pins !=VIOAPIC_NUM_PINS ) +return -EOPNOTSUPP ;
So now you remove the little bit of guarding you had altogether?
It would also be nice if you #undef-ed VIOAPIC_NUM_PINS in the __XEN__ case to document that all uses of it were caught. In the few cases were you really still need the number (like above) you could easily use ARRAY_SIZE().
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 5/7 x86/vioapic: introduce support for multiple vIO APICS
In reply to Roger Pau MonneAdd support for multiple vIO APICs on the same domain, thus turning d->arch.hvm_domain.vioapic into an array of vIO APIC control structures.
Note that this functionality is not exposed to unprivileged guests, and will only be used by PVHv2 Dom0.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
---
Changes since v1:
- Constify some parameters.
- Make gsi_vioapic return the base GSI of the IO APIC.
- Add checks to pt_irq_vector in order to prevent dereferencing NULL.
--- xen/arch/x86/hvm/dom0_build.c | 2 +- xen/arch/x86/hvm/vioapic.c | 216 ++++++++++++++++++++++++++++---------- xen/arch/x86/hvm/vlapic.c | 2 +- xen/arch/x86/hvm/vpt.c | 19 +++- xen/include/asm-x86/hvm/domain.h | 3 +- xen/include/asm-x86/hvm/vioapic.h | 4 +- 6 files changed, 181 insertions(+), 65 deletions(-)
xen/arch/x86/hvm/dom0_build.c +1 -1
@@ -729,7 +729,7 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr) io_apic = (void *)(madt +1 ); io_apic->header.type =ACPI_MADT_TYPE_IO_APIC ; io_apic->header.length =sizeof (*io_apic); - io_apic->id =domain_vioapic (d)->id; + io_apic->id =domain_vioapic (d,0 )->id; io_apic->address =VIOAPIC_DEFAULT_BASE_ADDRESS ; x2apic = (void *)(io_apic +1 );
xen/arch/x86/hvm/vioapic.c +159 -57
358 lines not on this page · raw message
xen/arch/x86/hvm/vlapic.c +1 -1
@@ -1107,7 +1107,7 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)if ( !has_vioapic (d) )return 0 ; - redir0 =domain_vioapic (d)->redirtbl[0 ]; + redir0 =domain_vioapic (d,0 )->redirtbl[0 ];/* We deliver 8259 interrupts to the appropriate CPU as follows. */ return ((/* IOAPIC pin0 is unmasked and routing to this LAPIC? */
xen/arch/x86/hvm/vpt.c +15 -4
@@ -78,7 +78,8 @@ void hvm_set_guest_time(struct vcpu *v, u64 guest_time)static int pt_irq_vector (struct periodic_time *pt,enum hvm_intsrc src) {struct vcpu *v = pt->vcpu; -unsigned int gsi, isa_irq; +struct hvm_vioapic *vioapic; +unsigned int gsi, isa_irq, base_gsi;if ( pt->source == PTSRC_lapic )return pt->irq;
@@ -91,13 +92,22 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) + (isa_irq & 7));ASSERT (src == hvm_intsrc_lapic); -return domain_vioapic (v->domain)->redirtbl[gsi].fields.vector; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi); +if ( !vioapic ) + { +gdprintk (XENLOG_WARNING ,"Invalid GSI (%u) for platform timer\n" , gsi); +domain_crash (v->domain); +return -1 ; + } + +return vioapic->redirtbl[gsi - base_gsi].fields.vector; }static int pt_irq_masked (struct periodic_time *pt) {struct vcpu *v = pt->vcpu; -unsigned int gsi, isa_irq; +unsigned int gsi, isa_irq, base_gsi; +struct hvm_vioapic *vioapic;uint8_t pic_imr;if ( pt->source == PTSRC_lapic )
@@ -110,9 +120,10 @@ static int pt_irq_masked(struct periodic_time *pt) isa_irq = pt->irq; gsi =hvm_isa_irq_to_gsi (isa_irq); pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >>3 ].imr; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi);return (((pic_imr & (1 << (isa_irq &7 ))) || !vlapic_accept_pic_intr (v)) && -domain_vioapic (v->domain)->redirtbl[gsi].fields.mask); + vioapic->redirtbl[gsi - base_gsi].fields.mask); }static void pt_lock (struct periodic_time *pt)
xen/include/asm-x86/hvm/domain.h +2 -1
@@ -127,7 +127,8 @@ struct hvm_domain {spinlock_t irq_lock;struct hvm_irq *irq;struct hvm_hw_vpic vpic[2 ];/* 0=master; 1=slave */ -struct hvm_vioapic *vioapic; +struct hvm_vioapic **vioapic; +unsigned int nr_vioapics;struct hvm_hw_stdvga stdvga;/*
xen/include/asm-x86/hvm/vioapic.h +3 -1
@@ -58,8 +58,10 @@ struct hvm_vioapic { };#define hvm_vioapic_size (cnt) offsetof(struct hvm_vioapic, redirtbl[cnt]) -#define domain_vioapic (d) ((d)->arch.hvm_domain.vioapic) +#define domain_vioapic (d, i) ((d)->arch.hvm_domain.vioapic[i])#define vioapic_domain (v) ((v)->domain) +struct hvm_vioapic *gsi_vioapic (const struct domain *d,unsigned int gsi, +unsigned int *base_gsi);int vioapic_init (struct domain *d);void vioapic_deinit (struct domain *d);
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 5/7] x86/vioapic: introduce support for multiple vIO APICS
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
Changes since v1:
- Constify some parameters.
Considering this I'm surprised the first thing I have to ask is ...
xen/arch/x86/hvm/vioapic.c line 47
Quoted 7 lines
xen/arch/x86/hvm/vioapic.c +1
-0@@ -44,6 +44,54 @@static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq); +static struct hvm_vioapic *addr_vioapic (struct domain *d,unsigned long addr)
... const? The more that you have it like this ...
xen/arch/x86/hvm/vioapic.c line 48
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+struct hvm_vioapic *gsi_vioapic(const struct domain *d, unsigned int gsi,
... here.
xen/arch/x86/hvm/vioapic.c line 64
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+ unsigned int *base_gsi)
All callers of the function really want the pin number rather than the base GSI - why don't you make the function provide that instead?
xen/arch/x86/hvm/vioapic.c line 67
Quoted 3 lines
xen/arch/x86/hvm/vioapic.c +3
-0+{ +unsigned int i; + *base_gsi =0 ;
Blank line between declaration(s) and statement(s) please.
xen/arch/x86/hvm/vioapic.c line 93
Quoted 12 lines
xen/arch/x86/hvm/vioapic.c +12
-0+static unsigned int pin_gsi (const struct domain *d, +const struct hvm_vioapic *vioapic, +unsigned int pin) +{ +const struct hvm_vioapic *tmp; +unsigned int base_gsi =0 ; + +for ( tmp =domain_vioapic (d,0 ); tmp != vioapic; tmp++ ) + base_gsi += tmp->nr_pins; + +return base_gsi + pin; +}
Didn't we settle on having a function base_gsi(), with callers adding in the pin number as needed? The only reason the function here takes pin as a parameter is this final addition.
Also shouldn't this function somehow guard itself against overrunning the array?
xen/arch/x86/hvm/vioapic.c static inline int pit_channel0_enabled(void) · line 330
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c +1
-1@@ -275,16 +327,17 @@ static inline int pit_channel0_enabled(void)return pt_active (¤t->domain->arch.vpit.pt0); } -static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq) +static void vioapic_deliver (struct hvm_vioapic *vioapic,int pin)
Occasionally we pass around negative IRQ numbers, but if this really is a pin number, I think the type wants changing to unsigned int - the more that it is being used as an array index below.
Quoted 26 lines
xen/arch/x86/hvm/vioapic.c +9
-9@@ -454,33 +517,70 @@ HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);void vioapic_reset (struct domain *d) { -struct hvm_vioapic *vioapic =domain_vioapic (d); -uint32_t nr_pins = vioapic->nr_pins; -int i; +unsigned int i;if ( !has_vioapic (d) ) + { +ASSERT (!d->arch.hvm_domain.nr_vioapics);return ; + } -memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); - vioapic->domain = d; - vioapic->nr_pins = nr_pins; -for ( i =0 ; i < nr_pins; i++ ) - vioapic->redirtbl[i].fields.mask =1 ; - vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; +for ( i =0 ; i < d->arch.hvm_domain.nr_vioapics; i++ ) + { +struct hvm_vioapic *vioapic =domain_vioapic (d, i); +unsigned int j, nr_pins = vioapic->nr_pins; +
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 542
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +10
-0+memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); +for ( j =0 ; j < nr_pins; j++ ) + vioapic->redirtbl[j].fields.mask =1 ; + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + +VIOAPIC_MEM_LENGTH * i; + vioapic->id = i; + vioapic->nr_pins = nr_pins; + vioapic->domain = d; + } +}
Is this function validly reachable for Dom0? If not, better leave it alone (adding a nr_vioapics == 1 check), as at least the base address calculation looks rather suspicious (there shouldn't be multiple IO-APICs on a single page). If so, that same memory address calculation is actively wrong in the Dom0 case.
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 551
Quoted 8 lines
xen/arch/x86/hvm/vioapic.c +8
-0+static void vioapic_free (const struct domain *d,unsigned int nr_vioapics) +{ +unsigned int i; + +for ( i =0 ; i < nr_vioapics; i++) + { +if (domain_vioapic (d, i) ==NULL ) +break ;
Is this if() really needed?
Quoted 21 lines
xen/arch/x86/hvm/vioapic.c +9
-3int vioapic_init(struct domain *d) { + unsigned int i, nr_vioapics = 1; + if ( !has_vioapic(d) ) + { + ASSERT(!d->arch.hvm_domain.nr_vioapics); return 0; + } if ( (d->arch.hvm_domain.vioapic == NULL) && ((d->arch.hvm_domain.vioapic = -xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) ) + xzalloc_array(struct hvm_vioapic *, nr_vioapics)) == NULL) ) return -ENOMEM; - d->arch.hvm_domain.vioapic->domain = d; - d->arch.hvm_domain.vioapic->nr_pins =VIOAPIC_NUM_PINS ; + for ( i = 0; i < nr_vioapics; i++ ) + { + if ( (domain_vioapic(d, i) =
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 584
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +9
-0+ xmalloc_bytes(hvm_vioapic_size(VIOAPIC_NUM_PINS))) == NULL ) + { +vioapic_free (d, nr_vioapics); +return -ENOMEM ; + } +domain_vioapic (d, i)->nr_pins =VIOAPIC_NUM_PINS ; + } + + d->arch.hvm_domain.nr_vioapics = nr_vioapics;vioapic_reset (d);
These adjustments again don't look right for nr_vioapics > 1, so I wonder whether again this function wouldn't better be left alone. Alternatively, if Dom0 needs to come here, a comment is going to be needed to explain the (temporary) wrong setting of nr_pins.
xen/arch/x86/hvm/vioapic.c static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) · line 101
Quoted 12 lines
xen/arch/x86/hvm/vioapic.c +7
-1@@ -91,13 +92,22 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) + (isa_irq & 7));ASSERT (src == hvm_intsrc_lapic); -return domain_vioapic (v->domain)->redirtbl[gsi].fields.vector; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi); +if ( !vioapic ) + { +gdprintk (XENLOG_WARNING ,"Invalid GSI (%u) for platform timer\n" , gsi); +domain_crash (v->domain); +return -1 ; + }
Now that you have this check, ...
xen/arch/x86/hvm/vioapic.c static int pt_irq_masked(struct periodic_time *pt) · line 127
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +2
-1@@ -110,9 +120,10 @@ static int pt_irq_masked(struct periodic_time *pt) isa_irq = pt->irq; gsi =hvm_isa_irq_to_gsi (isa_irq); pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >>3 ].imr; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi);return (((pic_imr & (1 << (isa_irq &7 ))) || !vlapic_accept_pic_intr (v)) && -domain_vioapic (v->domain)->redirtbl[gsi].fields.mask); + vioapic->redirtbl[gsi - base_gsi].fields.mask); }
... why is there still none here?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 5/7] x86/vioapic: introduce support for multiple vIO APICS
Quoted 10 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
Changes since v1:
- Constify some parameters.Considering this I'm surprised the first thing I have to ask is ...
Quoted 4 lines
xen/arch/x86/hvm/vioapic.c +0
-0@@ -44,6 +44,54 @@
Quoted 5 lines
xen/arch/x86/hvm/vioapic.c line 47
Quoted 3 lines
xen/arch/x86/hvm/vioapic.c +1
-0static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq); +static struct hvm_vioapic *addr_vioapic (struct domain *d,unsigned long addr)... const? The more that you have it like this ...
Shame, I guess I missed this one, sorry.
Quoted 9 lines
xen/arch/x86/hvm/vioapic.c line 48
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+struct hvm_vioapic *gsi_vioapic(const struct domain *d, unsigned int gsi,... here.
xen/arch/x86/hvm/vioapic.c line 64
Quoted 1 line
xen/arch/x86/hvm/vioapic.c +1
-0+ unsigned int *base_gsi)All callers of the function really want the pin number rather than the base GSI - why don't you make the function provide that instead?
Done.
Quoted 17 lines
xen/arch/x86/hvm/vioapic.c line 93
Quoted 12 lines
xen/arch/x86/hvm/vioapic.c +12
-0+static unsigned int pin_gsi (const struct domain *d, +const struct hvm_vioapic *vioapic, +unsigned int pin) +{ +const struct hvm_vioapic *tmp; +unsigned int base_gsi =0 ; + +for ( tmp =domain_vioapic (d,0 ); tmp != vioapic; tmp++ ) + base_gsi += tmp->nr_pins; + +return base_gsi + pin; +}Didn't we settle on having a function
base_gsi(), with callers adding in the pin number as needed? The only reason the function here takes pin as a parameter is this final addition.
Quoted 2 lines
Also shouldn't this function somehow guard itself against overrunning the array?
Done for both.
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c static inline int pit_channel0_enabled(void) · line 330
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c +1
-1@@ -275,16 +327,17 @@ static inline int pit_channel0_enabled(void)return pt_active (¤t->domain->arch.vpit.pt0); } -static void vioapic_deliver (struct hvm_vioapic *vioapic,int irq) +static void vioapic_deliver (struct hvm_vioapic *vioapic,int pin)Occasionally we pass around negative IRQ numbers, but if this really is a pin number, I think the type wants changing to unsigned int - the more that it is being used as an array index below.
Fixed.
Quoted 34 lines
Quoted 34 lines
xen/arch/x86/hvm/vioapic.c +17
-9@@ -454,33 +517,70 @@ HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);void vioapic_reset (struct domain *d) { -struct hvm_vioapic *vioapic =domain_vioapic (d); -uint32_t nr_pins = vioapic->nr_pins; -int i; +unsigned int i;if ( !has_vioapic (d) ) + { +ASSERT (!d->arch.hvm_domain.nr_vioapics);return ; + } -memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); - vioapic->domain = d; - vioapic->nr_pins = nr_pins; -for ( i =0 ; i < nr_pins; i++ ) - vioapic->redirtbl[i].fields.mask =1 ; - vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; +for ( i =0 ; i < d->arch.hvm_domain.nr_vioapics; i++ ) + { +struct hvm_vioapic *vioapic =domain_vioapic (d, i); +unsigned int j, nr_pins = vioapic->nr_pins; + +memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); +for ( j =0 ; j < nr_pins; j++ ) + vioapic->redirtbl[j].fields.mask =1 ; + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + +VIOAPIC_MEM_LENGTH * i; + vioapic->id = i; + vioapic->nr_pins = nr_pins; + vioapic->domain = d;
Quoted 8 lines
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 542
Quoted 2 lines
xen/arch/x86/hvm/vioapic.c +2
-0+ } +}Is this function validly reachable for Dom0? If not, better leave it alone (adding a
nr_vioapics== 1 check), as at least the base address calculation looks rather suspicious (there shouldn't be multiple IO-APICs on a single page). If so, that same memory address calculation is actively wrong in the Dom0 case.
Yes, this is called from vioapic_init in order to set the initial vIO APIC state and mask all the redir entries. For the Dom0 case we use what's found on the native MADT tables.
For now I could fix that by adding:
BUILD_BUG_ON(VIOAPIC_MEM_LENGTH > PAGE_SIZE);
And then use PAGE_SIZE above instead of VIOAPIC_MEM_LENGTH.
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 551
Quoted 8 lines
xen/arch/x86/hvm/vioapic.c +8
-0+static void vioapic_free (const struct domain *d,unsigned int nr_vioapics) +{ +unsigned int i; + +for ( i =0 ; i < nr_vioapics; i++) + { +if (domain_vioapic (d, i) ==NULL ) +break ;Is this
if()really needed?
Not at all, thanks for pointing it out.
Quoted 28 lines
Quoted 28 lines
xen/arch/x86/hvm/vioapic.c +16
-3int vioapic_init (struct domain *d) { +unsigned int i, nr_vioapics =1 ; +if ( !has_vioapic (d) ) + { +ASSERT (!d->arch.hvm_domain.nr_vioapics);return 0 ; + }if ( (d->arch.hvm_domain.vioapic ==NULL ) && ((d->arch.hvm_domain.vioapic = -xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) ) + xzalloc_array(struct hvm_vioapic *, nr_vioapics)) == NULL) )return -ENOMEM ; - d->arch.hvm_domain.vioapic->domain = d; - d->arch.hvm_domain.vioapic->nr_pins =VIOAPIC_NUM_PINS ; +for ( i =0 ; i < nr_vioapics; i++ ) + { +if ( (domain_vioapic (d, i) = +xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) + { +vioapic_free (d, nr_vioapics); +return -ENOMEM ; + } +domain_vioapic (d, i)->nr_pins =VIOAPIC_NUM_PINS ; + }
Quoted 8 lines
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 584
Quoted 3 lines
xen/arch/x86/hvm/vioapic.c +2
-0+ + d->arch.hvm_domain.nr_vioapics = nr_vioapics;vioapic_reset (d);These adjustments again don't look right for
nr_vioapics> 1, so I wonder whether again this function wouldn't better be left alone. Alternatively, if Dom0 needs to come here, a comment is going to be needed to explain the (temporary) wrong setting ofnr_pins.
Yes, Dom0 will need to come here. If it's cleaner I could have two different init functions, one for DomU and one for Dom0, and call them from vioapic_init.
Or add something like:
ASSERT(is_hardware_domain(d) || nr_vioapics == 1);
(the same could be added to vioapic_reset).
Quoted 21 lines
xen/arch/x86/hvm/vioapic.c static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) · line 101
Quoted 12 lines
xen/arch/x86/hvm/vioapic.c +7
-1@@ -91,13 +92,22 @@ static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) + (isa_irq & 7));ASSERT (src == hvm_intsrc_lapic); -return domain_vioapic (v->domain)->redirtbl[gsi].fields.vector; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi); +if ( !vioapic ) + { +gdprintk (XENLOG_WARNING ,"Invalid GSI (%u) for platform timer\n" , gsi); +domain_crash (v->domain); +return -1 ; + }Now that you have this check, ...
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c +1
-0@@ -110,9 +120,10 @@ static int pt_irq_masked(struct periodic_time *pt) isa_irq = pt->irq; gsi =hvm_isa_irq_to_gsi (isa_irq); pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >>3 ].imr; + vioapic =gsi_vioapic (v->domain, gsi, &base_gsi);
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c static int pt_irq_masked(struct periodic_time *pt) · line 127
Quoted 4 lines
xen/arch/x86/hvm/vioapic.c +1
-1return (((pic_imr & (1 << (isa_irq &7 ))) || !vlapic_accept_pic_intr (v)) && -domain_vioapic (v->domain)->redirtbl[gsi].fields.mask); + vioapic->redirtbl[gsi - base_gsi].fields.mask); }... why is there still none here?
Fixed.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 5/7] x86/vioapic: introduce support for multiple vIO APICS
Quoted 50 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 13:40, <[email protected]> wrote:
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
xen/arch/x86/hvm/vioapic.c +17
-9@@ -454,33 +517,70 @@ HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);void vioapic_reset (struct domain *d) { -struct hvm_vioapic *vioapic =domain_vioapic (d); -uint32_t nr_pins = vioapic->nr_pins; -int i; +unsigned int i;if ( !has_vioapic (d) ) + { +ASSERT (!d->arch.hvm_domain.nr_vioapics);return ; + } -memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); - vioapic->domain = d; - vioapic->nr_pins = nr_pins; -for ( i =0 ; i < nr_pins; i++ ) - vioapic->redirtbl[i].fields.mask =1 ; - vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS ; +for ( i =0 ; i < d->arch.hvm_domain.nr_vioapics; i++ ) + { +struct hvm_vioapic *vioapic =domain_vioapic (d, i); +unsigned int j, nr_pins = vioapic->nr_pins; + +memset (vioapic,0 ,hvm_vioapic_size (nr_pins)); +for ( j =0 ; j < nr_pins; j++ ) + vioapic->redirtbl[j].fields.mask =1 ; + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + +VIOAPIC_MEM_LENGTH * i; + vioapic->id = i; + vioapic->nr_pins = nr_pins; + vioapic->domain = d;Quoted 8 lines
Review HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 542
Quoted 2 lines
(quoted diff) +2
-0+ } +}Is this function validly reachable for Dom0? If not, better leave it alone (adding a
nr_vioapics== 1 check), as at least the base address calculation looks rather suspicious (there shouldn't be multiple IO-APICs on a single page). If so, that same memory address calculation is actively wrong in the Dom0 case.Yes, this is called from
vioapic_initin order to set the initial vIO APIC state and mask all the redir entries. For the Dom0 case we use what's found on the native MADT tables.
Quoted 5 lines
For now I could fix that by adding:
BUILD_BUG_ON(VIOAPIC_MEM_LENGTH > PAGE_SIZE);And then use
PAGE_SIZEabove instead ofVIOAPIC_MEM_LENGTH.
Hmm - see my reply to patch 7.
Quoted 41 lines
Quoted 28 lines
Quoted 28 lines
xen/arch/x86/hvm/vioapic.c +16
-3int vioapic_init (struct domain *d) { +unsigned int i, nr_vioapics =1 ; +if ( !has_vioapic (d) ) + { +ASSERT (!d->arch.hvm_domain.nr_vioapics);return 0 ; + }if ( (d->arch.hvm_domain.vioapic ==NULL ) && ((d->arch.hvm_domain.vioapic = -xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) ) + xzalloc_array(struct hvm_vioapic *, nr_vioapics)) == NULL) )return -ENOMEM ; - d->arch.hvm_domain.vioapic->domain = d; - d->arch.hvm_domain.vioapic->nr_pins =VIOAPIC_NUM_PINS ; +for ( i =0 ; i < nr_vioapics; i++ ) + { +if ( (domain_vioapic (d, i) = +xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) + { +vioapic_free (d, nr_vioapics); +return -ENOMEM ; + } +domain_vioapic (d, i)->nr_pins =VIOAPIC_NUM_PINS ; + }Quoted 8 lines
xen/arch/x86/hvm/vioapic.c HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM); · line 584
Quoted 3 lines
xen/arch/x86/hvm/vioapic.c +2
-0+ + d->arch.hvm_domain.nr_vioapics = nr_vioapics;vioapic_reset (d);These adjustments again don't look right for
nr_vioapics> 1, so I wonder whether again this function wouldn't better be left alone. Alternatively, if Dom0 needs to come here, a comment is going to be needed to explain the (temporary) wrong setting ofnr_pins.Yes, Dom0 will need to come here. If it's cleaner I could have two different init functions, one for DomU and one for Dom0, and call them from
vioapic_init.
Quoted 5 lines
Or add something like:
ASSERT(is_hardware_domain(d) || nr_vioapics == 1);(the same could be added to
vioapic_reset).
Which is basically in line with what I've said in reply to patch 7.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 6/7 x86/ioapic: add prototype for apic_gsi_base to io_apic.h
In reply to Roger Pau MonneSo that the function can be called from other files without adding prototypes to each of them.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
---
Changes since v1:
- Add io_ prefix to avoid confusion.
- Make the parameter unsigned.
--- xen/arch/x86/io_apic.c | 4 +--- xen/arch/x86/mpparse.c | 2 +- xen/include/asm-x86/io_apic.h | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-)
xen/arch/x86/io_apic.c +1 -3
@@ -2274,8 +2274,6 @@ static int ioapic_physbase_to_id(unsigned long physbase)return -EINVAL ; } -unsigned apic_gsi_base (int apic); -static int apic_pin_2_gsi_irq (int apic,int pin) {int idx;
@@ -2286,7 +2284,7 @@ static int apic_pin_2_gsi_irq(int apic, int pin) idx =find_irq_entry (apic, pin, mp_INT);return idx >=0 ?pin_2_irq (idx, apic, pin) - :apic_gsi_base (apic) + pin; + :io_apic_gsi_base (apic) + pin; }int ioapic_guest_read (unsigned long physbase,unsigned int reg,u32 *pval)
xen/arch/x86/mpparse.c +1 -1
@@ -913,7 +913,7 @@ unsigned __init highest_gsi(void)return res; } -unsigned apic_gsi_base (int apic) +unsigned int io_apic_gsi_base (unsigned int apic) {return mp_ioapic_routing[apic].gsi_base; }
xen/include/asm-x86/io_apic.h +3 -0
@@ -127,6 +127,9 @@ struct __packed IO_APIC_route_entry {/* I/O APIC entries */ extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS ]; +/* Base GSI for this IO APIC */ +unsigned int io_apic_gsi_base (unsigned int apic); +/* Only need to remap ioapic RTE (reg: 10~3Fh) */ #define ioapic_reg_remapped (reg) (iommu_intremap && ((reg) >= 0x10))
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 6/7] x86/ioapic: add prototype for apic_gsi_base to io_apic.h
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
So that the function can be called from other files without adding prototypes to each of them.
Signed-off-by Roger Pau Monné <[email protected]>
albeit perhaps ...
Quoted 2 lines
Changes since v1:
- Addio_prefix to avoid confusion.
... this should be carried through to the title.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 7/7 x86/vioapic: allow PVHv2 Dom0 to have more than one IO APIC
In reply to Roger Pau MonneThe base address, id and number of pins of the vIO APICs exposed to PVHv2 Dom0 is the same as the values found on bare metal.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
--- xen/arch/x86/hvm/dom0_build.c | 33 ++++++++++++--------------------- xen/arch/x86/hvm/hvm.c | 8 +++++--- xen/arch/x86/hvm/vioapic.c | 30 ++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 30 deletions(-)
xen/arch/x86/hvm/dom0_build.c +12 -21
@@ -681,12 +681,7 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr) max_vcpus =dom0_max_vcpus ();/* Calculate the size of the crafted MADT. */ size =sizeof (*madt); -/* -* FIXME: the current vIO-APIC code just supports one IO-APIC instance -* per domain. This must be fixed in order to provide the same amount of -* IO APICs as available on bare metal. -*/ - size +=sizeof (*io_apic); + size +=sizeof (*io_apic) * nr_ioapics; size +=sizeof (*intsrcovr) * acpi_intr_overrides; size +=sizeof (*nmisrc) * acpi_nmi_sources; size +=sizeof (*x2apic) * max_vcpus;
@@ -716,23 +711,19 @@ static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr)*/ madt->header.revision = min_t(unsigned char, table->revision, 4); -/* -* Setup the IO APIC entry. -* FIXME: the current vIO-APIC code just supports one IO-APIC instance -* per domain. This must be fixed in order to provide the same amount of -* IO APICs as available on bare metal, and with the same IDs as found in -* the native IO APIC MADT entries. -*/ -if ( nr_ioapics >1 ) -printk ("WARNING: found %d IO APICs, Dom0 will only have access to 1 emulated IO APIC\n" , - nr_ioapics); +/* Setup the IO APIC entries. */ io_apic = (void *)(madt +1 ); - io_apic->header.type =ACPI_MADT_TYPE_IO_APIC ; - io_apic->header.length =sizeof (*io_apic); - io_apic->id =domain_vioapic (d,0 )->id; - io_apic->address =VIOAPIC_DEFAULT_BASE_ADDRESS ; +for ( i =0 ; i < nr_ioapics; i++ ) + { + io_apic->header.type =ACPI_MADT_TYPE_IO_APIC ; + io_apic->header.length =sizeof (*io_apic); + io_apic->id =domain_vioapic (d, i)->id; + io_apic->address =domain_vioapic (d, i)->base_address; + io_apic->global_irq_base =io_apic_gsi_base (i); + io_apic++; + } - x2apic = (void *)(io_apic +1 ); + x2apic = (void *)io_apic;for ( i =0 ; i < max_vcpus; i++ ) { x2apic->header.type =ACPI_MADT_TYPE_LOCAL_X2APIC ;
xen/arch/x86/hvm/hvm.c +5 -3
@@ -595,6 +595,7 @@ static int hvm_print_line(int hvm_domain_initialise (struct domain *d) { +unsigned int nr_gsis;int rc;if ( !hvm_enabled )
@@ -615,19 +616,20 @@ int hvm_domain_initialise(struct domain *d)if ( rc !=0 ) goto fail0; + nr_gsis =is_hardware_domain (d) ? nr_irqs_gsi :VIOAPIC_NUM_PINS ; d->arch.hvm_domain.pl_time = xzalloc(struct pl_time); d->arch.hvm_domain.params =xzalloc_array (uint64_t,HVM_NR_PARAMS ); d->arch.hvm_domain.io_handler = xzalloc_array(struct hvm_io_handler,NR_IO_HANDLERS ); - d->arch.hvm_domain.irq =xzalloc_bytes (hvm_irq_size (VIOAPIC_NUM_PINS )); + d->arch.hvm_domain.irq =xzalloc_bytes (hvm_irq_size (nr_gsis)); rc = -ENOMEM ;if ( !d->arch.hvm_domain.pl_time || !d->arch.hvm_domain.irq || !d->arch.hvm_domain.params || !d->arch.hvm_domain.io_handler ) goto fail1; -/* Set the default number of GSIs */ -hvm_domain_irq (d)->nr_gsis =VIOAPIC_NUM_PINS ; +/* Set the number of GSIs */ +hvm_domain_irq (d)->nr_gsis = nr_gsis;/* need link to containing domain */ d->arch.hvm_domain.pl_time->domain = d;
xen/arch/x86/hvm/vioapic.c +24 -6
@@ -533,9 +533,19 @@ void vioapic_reset(struct domain *d)memset (vioapic,0 ,hvm_vioapic_size (nr_pins));for ( j =0 ; j < nr_pins; j++ ) vioapic->redirtbl[j].fields.mask =1 ; - vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + -VIOAPIC_MEM_LENGTH * i; - vioapic->id = i; + +if ( !is_hardware_domain (d) ) + { + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + +VIOAPIC_MEM_LENGTH * i; + vioapic->id = i; + } +else + { + vioapic->base_address = mp_ioapics[i].mpc_apicaddr; + vioapic->id = mp_ioapics[i].mpc_apicid; + } + vioapic->nr_pins = nr_pins; vioapic->domain = d; }
@@ -556,7 +566,7 @@ static void vioapic_free(const struct domain *d, unsigned int nr_vioapics)int vioapic_init (struct domain *d) { -unsigned int i, nr_vioapics =1 ; +unsigned int i, nr_vioapics, nr_gsis =0 ;if ( !has_vioapic (d) ) {
@@ -564,6 +574,8 @@ int vioapic_init(struct domain *d)return 0 ; } + nr_vioapics =is_hardware_domain (d) ? nr_ioapics :1 ; +if ( (d->arch.hvm_domain.vioapic ==NULL ) && ((d->arch.hvm_domain.vioapic = xzalloc_array(struct hvm_vioapic *, nr_vioapics)) == NULL) )
@@ -571,15 +583,21 @@ int vioapic_init(struct domain *d)for ( i =0 ; i < nr_vioapics; i++ ) { +unsigned int nr_pins =is_hardware_domain (d) ? nr_ioapic_entries[i] + :VIOAPIC_NUM_PINS ; +if ( (domain_vioapic (d, i) = -xmalloc_bytes (hvm_vioapic_size (VIOAPIC_NUM_PINS ))) ==NULL ) +xmalloc_bytes (hvm_vioapic_size (nr_pins))) ==NULL ) {vioapic_free (d, nr_vioapics);return -ENOMEM ; } -domain_vioapic (d, i)->nr_pins =VIOAPIC_NUM_PINS ; +domain_vioapic (d, i)->nr_pins = nr_pins; + nr_gsis += nr_pins; } +ASSERT (hvm_domain_irq (d)->nr_gsis == nr_gsis); + d->arch.hvm_domain.nr_vioapics = nr_vioapics;vioapic_reset (d);
Signature · 7 lines
2.12.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 7/7] x86/vioapic: allow PVHv2 Dom0 to have more than one IO APIC
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 27.03.17 at 12:18, <[email protected]> wrote:
The base address, id and number of pins of the vIO APICs exposed to PVHv2 Dom0 is the same as the values found on bare metal.
Signed-off-by Roger Pau Monné <[email protected]>
with ...
Quoted 6 lines
xen/arch/x86/hvm/vioapic.c +0
-0@@ -533,9 +533,19 @@ void vioapic_reset(struct domain *d)memset (vioapic,0 ,hvm_vioapic_size (nr_pins));for ( j =0 ; j < nr_pins; j++ ) vioapic->redirtbl[j].fields.mask =1 ;
xen/arch/x86/hvm/vioapic.c void vioapic_reset(struct domain *d) · line 542
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +7
-3- vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + -VIOAPIC_MEM_LENGTH * i; - vioapic->id = i; + +if ( !is_hardware_domain (d) ) + { + vioapic->base_address =VIOAPIC_DEFAULT_BASE_ADDRESS + +VIOAPIC_MEM_LENGTH * i; + vioapic->id = i; + }
... this suitably adjusted according to the earlier requested change, avoiding to leave bogus address calculations here. One option would be to remove the dependency on i from the calculation, adding ASSERT(!i).
Quoted 8 lines
xen/arch/x86/hvm/vioapic.c +3
-0@@ -571,15 +583,21 @@ int vioapic_init(struct domain *d) for ( i = 0; i < nr_vioapics; i++ ) { + unsigned int nr_pins = is_hardware_domain(d) ? nr_ioapic_entries[i] + : VIOAPIC_NUM_PINS; + if ( (domain_vioapic(d, i) =
xen/arch/x86/hvm/vioapic.c int vioapic_init(struct domain *d) · line 597
Quoted 10 lines
xen/arch/x86/hvm/vioapic.c +3
-2- xmalloc_bytes(hvm_vioapic_size(VIOAPIC_NUM_PINS))) == NULL ) + xmalloc_bytes(hvm_vioapic_size(nr_pins))) == NULL ) {vioapic_free (d, nr_vioapics);return -ENOMEM ; } -domain_vioapic (d, i)->nr_pins =VIOAPIC_NUM_PINS ; +domain_vioapic (d, i)->nr_pins = nr_pins; + nr_gsis += nr_pins; }
Hmm, seeing this I can accept how patch 5 altered this function. As per above this doesn't extend to ioapic_reset() though.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel