x86/HVM: adjust pIRQ calculation in hvm_inject_msi()
PATCH 1/1 x86/HVM: adjust pIRQ calculation in hvm_inject_msi()
While the referenced commit came without any update to the public header (which doesn't clarify how the upper address bits are used), the intention looks to have been that bits 12..19 and 40..63 form the pIRQ. Negative values simply make no sense, and pirq_info() also generally wants invoking with an unsigned (and not just positive) value.
Since the line was pointed out by Eclair, address Misra rule 7.2 at the same time, by adding the missing U suffix.
xen/arch/x86/hvm/irq.c +1 -1
@@ -383,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uinif ( !vector ) { -int pirq = ((addr >>32 ) &0xffffff00 ) | dest; +unsigned int pirq = ((addr >>32 ) &0xffffff00U ) | dest;if ( pirq >0 ) {
Quoted 11 lines · Jan Beulich
While the referenced commit came without any update to the public header (which doesn't clarify how the upper address bits are used), the intention looks to have been that bits 12..19 and 40..63 form the pIRQ. Negative values simply make no sense, and
pirq_info()also generally wants invoking with an unsigned (and not just positive) value.Since the line was pointed out by Eclair, address Misra rule 7.2 at the same time, by adding the missing U suffix.
Fixes 88fccdd11ca0 ("xen: event channel remapping for emulated MSIs")Signed-off-by Jan Beulich <[email protected]>
I have a question below, but not related to the change here.
xen/arch/x86/hvm/irq.c int hvm_inject_msi(struct domain *d, uin · line 388
Quoted 11 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -383,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uinif ( !vector ) { -int pirq = ((addr >>32 ) &0xffffff00 ) | dest; +unsigned int pirq = ((addr >>32 ) &0xffffff00U ) | dest;if ( pirq >0 )
I do wonder whether this check is also accurate, as pIRQ 0 could be a valid value. Should it instead use INVALID_PIRQ?
Since there's no specification or documentation how this is supposed to work it's hard to tell.
Thanks, Roger.
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
While the referenced commit came without any update to the public header (which doesn't clarify how the upper address bits are used), the intention looks to have been that bits 12..19 and 40..63 form the pIRQ. Negative values simply make no sense, and
pirq_info()also generally wants invoking with an unsigned (and not just positive) value.
Quoted 7 lines
Quoted 5 lines
Since the line was pointed out by Eclair, address Misra rule 7.2 at the same time, by adding the missing U suffix.
Fixes 88fccdd11ca0 ("xen: event channel remapping for emulated MSIs")Signed-off-by Jan Beulich <[email protected]>Acked-by Roger Pau Monné <[email protected]>
Thanks.
Quoted 12 lines
I have a question below, but not related to the change here.
Quoted 10 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -383,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uinif ( !vector ) { -int pirq = ((addr >>32 ) &0xffffff00 ) | dest; +unsigned int pirq = ((addr >>32 ) &0xffffff00U ) | dest;
Quoted 4 lines
xen/arch/x86/hvm/irq.c int hvm_inject_msi(struct domain *d, uin · line 388
Quoted 1 line
xen/arch/x86/hvm/irq.c +0
-0if ( pirq >0 )I do wonder whether this check is also accurate, as pIRQ 0 could be a valid value. Should it instead use
INVALID_PIRQ?
I think 0 is okay to use here, as the low IRQs (at least the 16 ISA ones) are all 1:1 mapped to their "machine" (i.e. Xen's) IRQ numbers. And IRQ0 is always the timer, never given to guests (not even to Dom0).
If we wanted to use INVALID_PIRQ here, we'd first need to make this part of the public interface.
Quoted 2 lines
Since there's no specification or documentation how this is supposed to work it's hard to tell.
Indeed.
Jan
Quoted 35 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
While the referenced commit came without any update to the public header (which doesn't clarify how the upper address bits are used), the intention looks to have been that bits 12..19 and 40..63 form the pIRQ. Negative values simply make no sense, and
pirq_info()also generally wants invoking with an unsigned (and not just positive) value.Quoted 7 lines
Quoted 5 lines
Since the line was pointed out by Eclair, address Misra rule 7.2 at the same time, by adding the missing U suffix.
Fixes 88fccdd11ca0 ("xen: event channel remapping for emulated MSIs")Signed-off-by Jan Beulich <[email protected]>Acked-by Roger Pau Monné <[email protected]>Thanks.
Quoted 12 lines
I have a question below, but not related to the change here.
Quoted 10 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -383,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uinif ( !vector ) { -int pirq = ((addr >>32 ) &0xffffff00 ) | dest; +unsigned int pirq = ((addr >>32 ) &0xffffff00U ) | dest;Quoted 4 lines
xen/arch/x86/hvm/irq.c int hvm_inject_msi(struct domain *d, uin · line 388
Quoted 1 line
xen/arch/x86/hvm/irq.c +0
-0if ( pirq >0 )I do wonder whether this check is also accurate, as pIRQ 0 could be a valid value. Should it instead use
INVALID_PIRQ?
Quoted 4 lines
I think 0 is okay to use here, as the low IRQs (at least the 16 ISA ones) are all 1:1 mapped to their "machine" (i.e. Xen's) IRQ numbers. And IRQ0 is always the timer, never given to guests (not even to Dom0).
I'm kind of confused by this not being dom0, but rather an HVM guest, so pIRQ 0 of that HVM guest should be available to the guest itself?
IOW: the possible values here should be the full pIRQ range, as there are never Xen owned pIRQs in the context of an HVM guest. One further limitation is that even in that case pIRQs for (guest) GSIs would still be identity mapped, so GSI 0 won't be a suitable pIRQ for an MSI source.
The usage of pIRQs here even for emulated devices makes me very confused.
Thanks, Roger.
Quoted 36 lines · Roger Pau Monné
Quoted 35 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
While the referenced commit came without any update to the public header (which doesn't clarify how the upper address bits are used), the intention looks to have been that bits 12..19 and 40..63 form the pIRQ. Negative values simply make no sense, and
pirq_info()also generally wants invoking with an unsigned (and not just positive) value.Quoted 7 lines
Quoted 5 lines
Since the line was pointed out by Eclair, address Misra rule 7.2 at the same time, by adding the missing U suffix.
Fixes 88fccdd11ca0 ("xen: event channel remapping for emulated MSIs")Signed-off-by Jan Beulich <[email protected]>Acked-by Roger Pau Monné <[email protected]>Thanks.
Quoted 16 lines
I have a question below, but not related to the change here.
xen/arch/x86/hvm/irq.c int hvm_inject_msi(struct domain *d, uin · line 388
Quoted 11 lines
xen/arch/x86/hvm/irq.c +1
-1@@ -383,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uinif ( !vector ) { -int pirq = ((addr >>32 ) &0xffffff00 ) | dest; +unsigned int pirq = ((addr >>32 ) &0xffffff00U ) | dest;if ( pirq >0 )I do wonder whether this check is also accurate, as pIRQ 0 could be a valid value. Should it instead use
INVALID_PIRQ?
Quoted 8 lines
Quoted 4 lines
I think 0 is okay to use here, as the low IRQs (at least the 16 ISA ones) are all 1:1 mapped to their "machine" (i.e. Xen's) IRQ numbers. And IRQ0 is always the timer, never given to guests (not even to Dom0).
I'm kind of confused by this not being dom0, but rather an HVM guest, so pIRQ 0 of that HVM guest should be available to the guest itself?
pIRQ is a Xen concept; Xen assigns them, for the guest to use them in (e.g.) hypercalls. As long as Xen hands out 0 only ever for (guest) GSI 0, all should be fine. That said, ...
Quoted 8 lines
IOW: the possible values here should be the full pIRQ range, as there are never Xen owned pIRQs in the context of an HVM guest. One further limitation is that even in that case pIRQs for (guest) GSIs would still be identity mapped, so GSI 0 won't be a suitable pIRQ for an MSI source.
The usage of pIRQs here even for emulated devices makes me very confused.
... I'm with you here; I'm not convinced this logic is sound.
Jan