x86: Update HVM_PARAM_CALLBACK_IRQ
PATCH 1/1 x86: Update HVM_PARAM_CALLBACK_IRQ
Couple of updates:
- Add an macro to make it easier to use the vector callback.
- Fix the odditity in Xen internal usage of an enum which offset by one compared to the #defines. Make it the same.
- This also clears up the printing of the Callback in the irq_dump() to match up with the #defines.
--- xen/arch/x86/hvm/irq.c | 2 +- xen/include/asm-x86/hvm/irq.h | 12 ++++++++---- xen/include/public/hvm/hvm_op.h | 3 ++- xen/include/public/hvm/params.h | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/irq.c +1 -1
@@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)unsigned int gsi=0 , pdev=0 , pintx=0 ;uint8_t via_type; - via_type = (uint8_t )(via >>56 ) +1 ; + via_type = (uint8_t )(via >>HVM_PARAM_CALLBACK_TYPE_SHIFT );if ( ((via_type == HVMIRQ_callback_gsi) && (via ==0 )) || (via_type > HVMIRQ_callback_vector) ) via_type = HVMIRQ_callback_none;
xen/include/asm-x86/hvm/irq.h +8 -4
@@ -26,6 +26,8 @@#include <asm/hvm/vpic.h> #include <asm/hvm/vioapic.h> +#include <public/hvm/params.h> +struct hvm_irq {/* * Virtual interrupt wires for a single PCI bus.
@@ -50,11 +52,13 @@ struct hvm_irq {/* Virtual interrupt and via-link for paravirtual platform driver. */ uint32_t callback_via_asserted;union { +/* These MUST match with HVM_PARAM_CALLBACK_IRQ types. */ enum { - HVMIRQ_callback_none, - HVMIRQ_callback_gsi, - HVMIRQ_callback_pci_intx, - HVMIRQ_callback_vector + HVMIRQ_callback_gsi =HVM_PARAM_CALLBACK_TYPE_GSI , + HVMIRQ_callback_pci_intx =HVM_PARAM_CALLBACK_TYPE_PCI_INTX , + HVMIRQ_callback_vector =HVM_PARAM_CALLBACK_TYPE_VECTOR , +/* Will change if we add more types. */ + HVMIRQ_callback_none =HVM_PARAM_CALLBACK_TYPE_NUM , } callback_via_type; };union {
xen/include/public/hvm/hvm_op.h +2 -1
@@ -386,7 +386,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_ioreq_server_state_t);* channel upcalls on the specified <vcpu>. If set, * this vector will be used in preference to the * domain global callback via (see -* HVM_PARAM_CALLBACK_IRQ). +* HVM_PARAM_CALLBACK_IRQ and +* HVM_PARAM_CALLBACK_VECTOR). */ #define HVMOP_set_evtchn_upcall_vector 23struct xen_hvm_evtchn_upcall_vector {
xen/include/public/hvm/params.h +15 -0
@@ -56,6 +56,21 @@*/ /* +* In the future this may change. +*/ +#define HVM_PARAM_CALLBACK_TYPE_NUM HVM_PARAM_CALLBACK_TYPE_VECTOR + 1 +/* +* The val[63:56] convenience shift. +*/ +#define HVM_PARAM_CALLBACK_TYPE_SHIFT 56 + +/* +* Wrapper around for HVM_PARAM_CALLBACK_TYPE_VECTOR. +*/ +#define HVM_PARAM_CALLBACK_VECTOR (x) \ + (((uint64_t)HVM_PARAM_CALLBACK_TYPE_VECTOR) << \ + HVM_PARAM_CALLBACK_TYPE_SHIFT | (x)) +/* * These are not used by Xen. They are here for convenience of HVM-guest * xenbus implementations. */
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · Konrad Rzeszutek Wilk
Couple of updates:
- Add an macro to make it easier to use the vector callback.- Fix the odditity in Xen internal usage of an enum which offset by one compared to the #defines. Make it the same.
- This also clears up the printing of the Callback in the
irq_dump()to match up with the #defines.Reported-by Boris Ostrovsky <[email protected]>Signed-off-by Konrad Rzeszutek Wilk <[email protected]>
CC-ing Stefano.
Quoted 94 lines
--- xen/arch/x86/hvm/irq.c | 2 +- xen/include/asm-x86/hvm/irq.h | 12 ++++++++---- xen/include/public/hvm/hvm_op.h | 3 ++- xen/include/public/hvm/params.h | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-)xen/arch/x86/hvm/irq.c +1
-1@@ -325,7 +325,7 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)unsigned int gsi=0 , pdev=0 , pintx=0 ;uint8_t via_type; - via_type = (uint8_t )(via >>56 ) +1 ; + via_type = (uint8_t )(via >>HVM_PARAM_CALLBACK_TYPE_SHIFT );if ( ((via_type == HVMIRQ_callback_gsi) && (via ==0 )) || (via_type > HVMIRQ_callback_vector) ) via_type = HVMIRQ_callback_none;xen/include/asm-x86/hvm/irq.h +8
-4@@ -26,6 +26,8 @@#include <asm/hvm/vpic.h> #include <asm/hvm/vioapic.h> +#include <public/hvm/params.h> +struct hvm_irq {/* * Virtual interrupt wires for a single PCI bus. @@ -50,11 +52,13 @@ struct hvm_irq {/* Virtual interrupt and via-link for paravirtual platform driver. */ uint32_t callback_via_asserted;union { +/* These MUST match with HVM_PARAM_CALLBACK_IRQ types. */ enum { - HVMIRQ_callback_none, - HVMIRQ_callback_gsi, - HVMIRQ_callback_pci_intx, - HVMIRQ_callback_vector + HVMIRQ_callback_gsi =HVM_PARAM_CALLBACK_TYPE_GSI , + HVMIRQ_callback_pci_intx =HVM_PARAM_CALLBACK_TYPE_PCI_INTX , + HVMIRQ_callback_vector =HVM_PARAM_CALLBACK_TYPE_VECTOR , +/* Will change if we add more types. */ + HVMIRQ_callback_none =HVM_PARAM_CALLBACK_TYPE_NUM , } callback_via_type; };union {xen/include/public/hvm/hvm_op.h +2
-1@@ -386,7 +386,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_ioreq_server_state_t);* channel upcalls on the specified <vcpu>. If set, * this vector will be used in preference to the * domain global callback via (see -* HVM_PARAM_CALLBACK_IRQ). +* HVM_PARAM_CALLBACK_IRQ and +* HVM_PARAM_CALLBACK_VECTOR). */ #define HVMOP_set_evtchn_upcall_vector 23struct xen_hvm_evtchn_upcall_vector {xen/include/public/hvm/params.h +15
-0@@ -56,6 +56,21 @@*/ /* +* In the future this may change. +*/ +#define HVM_PARAM_CALLBACK_TYPE_NUM HVM_PARAM_CALLBACK_TYPE_VECTOR + 1 +/* +* The val[63:56] convenience shift. +*/ +#define HVM_PARAM_CALLBACK_TYPE_SHIFT 56 + +/* +* Wrapper around for HVM_PARAM_CALLBACK_TYPE_VECTOR. +*/ +#define HVM_PARAM_CALLBACK_VECTOR (x) \ + (((uint64_t)HVM_PARAM_CALLBACK_TYPE_VECTOR) << \ + HVM_PARAM_CALLBACK_TYPE_SHIFT | (x)) +/* * These are not used by Xen. They are here for convenience of HVM-guest * xenbus implementations. */ Signature · 1 line
2.4.3
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 29.02.16 at 21:39, <[email protected]> wrote:
xen/include/asm-x86/hvm/irq.h +1
-1@@ -50,11 +52,13 @@ struct hvm_irq {/* Virtual interrupt and via-link for paravirtual platform driver. */ uint32_t callback_via_asserted; union { + /* These MUST match with HVM_PARAM_CALLBACK_IRQ types. */ enum { - HVMIRQ_callback_none,
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 63
Quoted 10 lines
xen/include/asm-x86/hvm/irq.h +5
-3- HVMIRQ_callback_gsi, - HVMIRQ_callback_pci_intx, - HVMIRQ_callback_vector + HVMIRQ_callback_gsi =HVM_PARAM_CALLBACK_TYPE_GSI , + HVMIRQ_callback_pci_intx =HVM_PARAM_CALLBACK_TYPE_PCI_INTX , + HVMIRQ_callback_vector =HVM_PARAM_CALLBACK_TYPE_VECTOR , +/* Will change if we add more types. */ + HVMIRQ_callback_none =HVM_PARAM_CALLBACK_TYPE_NUM , } callback_via_type; };
I.e. a domain will now start in HVMIRQ_callback_gsi mode (due to HVM_PARAM_CALLBACK_TYPE_GSI = 0) instead of HVMIRQ_callback_none? That can't be right.
xen/include/public/hvm/params.h line 61
Quoted 9 lines
xen/include/public/hvm/params.h +3
-0@@ -56,6 +56,21 @@*/ /* +* In the future this may change. +*/ +#define HVM_PARAM_CALLBACK_TYPE_NUM HVM_PARAM_CALLBACK_TYPE_VECTOR + 1
Missing parentheses.
xen/include/public/hvm/params.h line 68
Quoted 7 lines
xen/include/public/hvm/params.h +7
-0+/* +* The val[63:56] convenience shift. +*/ +#define HVM_PARAM_CALLBACK_TYPE_SHIFT 56 + +/* +* Wrapper around for HVM_PARAM_CALLBACK_TYPE_VECTOR.
Looks like either "around" or "for" wants to be dropped. I also think this would better live right next to that constant's definition.
Also note that all comments you add are single line ones, and hence don't conform to our coding style (yes, there are other [bad] examples of such in this file).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 29.02.16 at 21:39, <[email protected]> wrote:
xen/include/asm-x86/hvm/irq.h +4
-4@@ -50,11 +52,13 @@ struct hvm_irq {/* Virtual interrupt and via-link for paravirtual platform driver. */ uint32_t callback_via_asserted;union { +/* These MUST match with HVM_PARAM_CALLBACK_IRQ types. */ enum { - HVMIRQ_callback_none, - HVMIRQ_callback_gsi, - HVMIRQ_callback_pci_intx, - HVMIRQ_callback_vector + HVMIRQ_callback_gsi =HVM_PARAM_CALLBACK_TYPE_GSI , + HVMIRQ_callback_pci_intx =HVM_PARAM_CALLBACK_TYPE_PCI_INTX , + HVMIRQ_callback_vector =HVM_PARAM_CALLBACK_TYPE_VECTOR ,
Quoted 8 lines
xen/include/asm-x86/hvm/irq.h struct hvm_irq { · line 63
Quoted 4 lines
xen/include/asm-x86/hvm/irq.h +2
-0+/* Will change if we add more types. */ + HVMIRQ_callback_none =HVM_PARAM_CALLBACK_TYPE_NUM , } callback_via_type; };I.e. a domain will now start in
HVMIRQ_callback_gsimode (due toHVM_PARAM_CALLBACK_TYPE_GSI= 0) instead ofHVMIRQ_callback_none? That can't be right.
Argh. I was looking for all the cases for callback_via_type being set but of course missed the most obvious one!
Quoted 13 lines
xen/include/public/hvm/params.h line 61
Quoted 10 lines
xen/include/public/hvm/params.h +3
-0@@ -56,6 +56,21 @@*/ /* +* In the future this may change. +*/ +#define HVM_PARAM_CALLBACK_TYPE_NUM HVM_PARAM_CALLBACK_TYPE_VECTOR + 1Missing parentheses.
Quoted 10 lines
xen/include/public/hvm/params.h line 68
Quoted 7 lines
xen/include/public/hvm/params.h +7
-0+/* +* The val[63:56] convenience shift. +*/ +#define HVM_PARAM_CALLBACK_TYPE_SHIFT 56 + +/* +* Wrapper around for HVM_PARAM_CALLBACK_TYPE_VECTOR. Looks like either "around" or "for" wants to be dropped. I also think this would better live right next to that constant's definition.
OK.
Quoted 4 lines
Also note that all comments you add are single line ones, and hence don't conform to our coding style (yes, there are other [bad] examples of such in this file).
/me nods. Will make it conform to the single line one type comment.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel