use pirq_eoi_map in modern Linux kernels
cover use pirq_eoi_map in modern Linux kernels
Hi all,
this small patch series consists of two patches: a patch for Xen and a patch for Linux.
The Xen patch implements PHYSDEVOP_pirq_eoi_gmfn_new, a new hypercall similar to PHYSDEVOP_pirq_eoi_gmfn but it does not change the semantics of PHYSDEVOP_eoi.
The Linux patch introduces pirq_eoi_map in drivers/xen/events.c, using PHYSDEVOP_pirq_eoi_gmfn_new.
Cheers,
Stefano
PATCH 1/2 xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. Introduce PHYSDEVOP_pirq_eoi_gmfn_new, that is like PHYSDEVOP_pirq_eoi_gmfn but it doesn't modify the behaviour of another hypercall.
--- xen/arch/ia64/xen/domain.c | 1 + xen/arch/ia64/xen/hypercall.c | 5 ++++- xen/arch/x86/domain.c | 1 + xen/arch/x86/physdev.c | 6 +++++- xen/include/asm-ia64/domain.h | 3 +++ xen/include/asm-x86/domain.h | 3 +++ xen/include/public/physdev.h | 8 ++++++++ 7 files changed, 25 insertions(+), 2 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
@@ -1731,6 +1731,7 @@ int domain_relinquish_resources(struct domain *d)if (d->arch.pirq_eoi_map !=NULL ) {put_page (virt_to_page (d->arch.pirq_eoi_map)); d->arch.pirq_eoi_map =NULL ; + d->arch.auto_unmask =0 ; }/* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +4 -1
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq) {if ( pirq <0 || pirq >=NR_IRQS )return -EINVAL ; -if ( d->arch.pirq_eoi_map ) { +if ( d->arch.pirq_eoi_map && d->arch.auto_unmask ) {spin_lock (&d->event_lock);evtchn_unmask (pirq_to_evtchn (d, pirq));spin_unlock (&d->event_lock);
@@ -508,6 +508,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;
@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + current->domain->arch.auto_unmask =1 ; ret =0 ;break ; }
xen/arch/x86/domain.c +1 -0
@@ -2125,6 +2125,7 @@ int domain_relinquish_resources(struct domain *d)put_page_and_type (mfn_to_page (d->arch.pv_domain.pirq_eoi_map_mfn)); d->arch.pv_domain.pirq_eoi_map =NULL ; + d->arch.pv_domain.auto_unmask =0 ; } }
xen/arch/x86/physdev.c +5 -1
@@ -271,7 +271,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.pirq_eoi_map && + v->domain->arch.pv_domain.auto_unmask )evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )
@@ -293,6 +294,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;
@@ -329,6 +331,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) ret = -ENOSPC ;break ; } +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + v->domain->arch.pv_domain.auto_unmask =1 ;put_gfn (current->domain, info.gmfn); ret =0 ;
xen/include/asm-ia64/domain.h +3 -0
@@ -186,6 +186,9 @@ struct arch_domain {/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Address of efi_runtime_services_t (placed in domain memory) */ void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
@@ -231,6 +231,9 @@ struct pv_domain/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;
xen/include/public/physdev.h +8 -0
@@ -50,6 +50,14 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);* array indexed by Xen's PIRQ value. */ #define PHYSDEVOP_pirq_eoi_gmfn 17 +/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to +* PHYSDEVOP_pirq_eoi_gmfn but it doesn't change the semantics of +* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by +* Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn_new 28struct physdev_pirq_eoi_gmfn {/* IN */ xen_pfn_t gmfn;
Signature · 1 line
1.7.2.5
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.
I keep forgetting why you think the auto-unmasking does any harm. It was done that way to avoid an extra hypercall.
xen/arch/ia64/xen/hypercall.c long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) · line 536
Quoted 6 lines
xen/arch/ia64/xen/hypercall.c +2
-0@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + current->domain->arch.auto_unmask =1 ;
Indentation.,
xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) · line 275
Quoted 12 lines
xen/arch/ia64/xen/hypercall.c +0
-0ret =0 ;break ; }xen/arch/x86/physdev.c +2
-1@@ -271,7 +271,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.pirq_eoi_map && + v->domain->arch.pv_domain.auto_unmask )
Could you not avoid the checking of v->domain->arch.pv_domain.pirq_eoi_map by making sure v->domain->arch.pv_domain.auto_unmask gets cleared when the map gets destroyed (not sure if that is permitted at all).
xen/include/asm-x86/domain.h struct pv_domain · line 236
Quoted 12 lines
xen/arch/x86/physdev.c +0
-0evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )xen/include/asm-x86/domain.h +3
-0@@ -231,6 +231,9 @@ struct pv_domain/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;
bool_t?
Jan
Quoted 3 lines
xen/include/asm-x86/domain.h +0
-0/* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 8 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.I keep forgetting why you think the auto-unmasking does any harm. It was done that way to avoid an extra hypercall.
We let Linux mask/unmask the event channel whenever it would make/unmask the irq, so an automatic unmask is equivalent to unmasking an irq without Linux knowing or wanting to do so.
Quoted 9 lines
xen/arch/ia64/xen/hypercall.c long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) · line 536
Quoted 6 lines
xen/arch/ia64/xen/hypercall.c +2
-0@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + current->domain->arch.auto_unmask =1 ;Indentation.,
Quoted 16 lines
xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) · line 275
Quoted 12 lines
xen/arch/ia64/xen/hypercall.c +0
-0ret =0 ;break ; }xen/arch/x86/physdev.c +2
-1@@ -271,7 +271,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.pirq_eoi_map && + v->domain->arch.pv_domain.auto_unmask )Could you not avoid the checking of
v->domain->arch.pv_domain.pirq_eoi_mapby making surev->domain->arch.pv_domain.auto_unmaskgets cleared when the map gets destroyed (not sure if that is permitted at all).
I think I can, I'll change it that way.
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/physdev.c +0
-0evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )xen/include/asm-x86/domain.h +0
-0@@ -231,6 +231,9 @@ struct pv_domain
Quoted 8 lines
xen/include/asm-x86/domain.h struct pv_domain · line 236
Quoted 6 lines
xen/include/asm-x86/domain.h +3
-0/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;
bool_t?
good idea
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
In reply to Stefano StabelliniQuoted 4 lines · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.
It's nasty that pirq_eoi_gmfn has the side effect. I suggest add a PHYSDEVOP to explicitly enable/disable unmask-on-eoi (i.e., the command accepts a boolean parameter). Once it is explicitly enabled/disabled in this way, pirq_eoi_gmfn no longer has the side effect (regardless of whether it is called before or after the explicit setting). So e.g., pv_domain.auto_unmask becomes an int where 0/1 means no/yes, and -1 means default (i.e., old behavour where it depends on whether PHYSDEVOP_pirq_eoi_gmfn has been called).
This seems to me to move a bad interface in a better direction.
-- Keir
Quoted 143 lines
Signed-off-by Stefano Stabellini <[email protected]>--- xen/arch/ia64/xen/domain.c | 1 + xen/arch/ia64/xen/hypercall.c | 5 ++++- xen/arch/x86/domain.c | 1 + xen/arch/x86/physdev.c | 6 +++++- xen/include/asm-ia64/domain.h | 3 +++ xen/include/asm-x86/domain.h | 3 +++ xen/include/public/physdev.h | 8 ++++++++ 7 files changed, 25 insertions(+), 2 deletions(-)xen/arch/ia64/xen/domain.c +1
-0@@ -1731,6 +1731,7 @@ int domain_relinquish_resources(struct domain *d)if (d->arch.pirq_eoi_map !=NULL ) {put_page (virt_to_page (d->arch.pirq_eoi_map)); d->arch.pirq_eoi_map =NULL ; + d->arch.auto_unmask =0 ; }/* Tear down shadow mode stuff. */ xen/arch/ia64/xen/hypercall.c +4
-1@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq) {if ( pirq <0 || pirq >=NR_IRQS )return -EINVAL ; -if ( d->arch.pirq_eoi_map ) { +if ( d->arch.pirq_eoi_map && d->arch.auto_unmask ) {spin_lock (&d->event_lock);evtchn_unmask (pirq_to_evtchn (d, pirq));spin_unlock (&d->event_lock);@@ -508,6 +508,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + current->domain->arch.auto_unmask =1 ; ret =0 ;break ; }xen/arch/x86/domain.c +1
-0@@ -2125,6 +2125,7 @@ int domain_relinquish_resources(struct domain *d)put_page_and_type (mfn_to_page (d->arch.pv_domain.pirq_eoi_map_mfn)); d->arch.pv_domain.pirq_eoi_map =NULL ; + d->arch.pv_domain.auto_unmask =0 ; } }xen/arch/x86/physdev.c +5
-1@@ -271,7 +271,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.pirq_eoi_map && + v->domain->arch.pv_domain.auto_unmask )evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )@@ -293,6 +294,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;@@ -329,6 +331,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) ret = -ENOSPC ;break ; } +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + v->domain->arch.pv_domain.auto_unmask =1 ;put_gfn (current->domain, info.gmfn); ret =0 ;xen/include/asm-ia64/domain.h +3
-0@@ -186,6 +186,9 @@ struct arch_domain {/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Address of efi_runtime_services_t (placed in domain memory) */ void *efi_runtime;xen/include/asm-x86/domain.h +3
-0@@ -231,6 +231,9 @@ struct pv_domain/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;xen/include/public/physdev.h +8
-0@@ -50,6 +50,14 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);* array indexed by Xen's PIRQ value. */ #define PHYSDEVOP_pirq_eoi_gmfn 17 +/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to +* PHYSDEVOP_pirq_eoi_gmfn but it doesn't change the semantics of +* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by +* Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn_new 28struct physdev_pirq_eoi_gmfn {/* IN */ xen_pfn_t gmfn;
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 17 lines · Keir Fraser
Quoted 4 lines · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.It's nasty that
pirq_eoi_gmfnhas the side effect. I suggest add a PHYSDEVOP to explicitly enable/disable unmask-on-eoi (i.e., the command accepts a boolean parameter). Once it is explicitly enabled/disabled in this way,pirq_eoi_gmfnno longer has the side effect (regardless of whether it is called before or after the explicit setting). So e.g., pv_domain.auto_unmask becomes an int where 0/1 means no/yes, and -1 means default (i.e., old behavour where it depends on whetherPHYSDEVOP_pirq_eoi_gmfnhas been called).
Quoted 1 line
This seems to me to move a bad interface in a better direction.
...in that the auto-unmask behaviour becomes explicitly selectable, rather than implicitly, via two different commands for setting *something else* which only differ in a side effect. That's kind of as gross as what we have already, or worse.
-- Keir
Quoted 147 lines
-- Keir
Quoted 143 lines
Signed-off-by Stefano Stabellini <[email protected]>--- xen/arch/ia64/xen/domain.c | 1 + xen/arch/ia64/xen/hypercall.c | 5 ++++- xen/arch/x86/domain.c | 1 + xen/arch/x86/physdev.c | 6 +++++- xen/include/asm-ia64/domain.h | 3 +++ xen/include/asm-x86/domain.h | 3 +++ xen/include/public/physdev.h | 8 ++++++++ 7 files changed, 25 insertions(+), 2 deletions(-)xen/arch/ia64/xen/domain.c +1
-0@@ -1731,6 +1731,7 @@ int domain_relinquish_resources(struct domain *d)if (d->arch.pirq_eoi_map !=NULL ) {put_page (virt_to_page (d->arch.pirq_eoi_map)); d->arch.pirq_eoi_map =NULL ; + d->arch.auto_unmask =0 ; }/* Tear down shadow mode stuff. */ xen/arch/ia64/xen/hypercall.c +4
-1@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq) {if ( pirq <0 || pirq >=NR_IRQS )return -EINVAL ; -if ( d->arch.pirq_eoi_map ) { +if ( d->arch.pirq_eoi_map && d->arch.auto_unmask ) {spin_lock (&d->event_lock);evtchn_unmask (pirq_to_evtchn (d, pirq));spin_unlock (&d->event_lock);@@ -508,6 +508,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + current->domain->arch.auto_unmask =1 ; ret =0 ;break ; }xen/arch/x86/domain.c +1
-0@@ -2125,6 +2125,7 @@ int domain_relinquish_resources(struct domain *d)put_page_and_type (mfn_to_page (d->arch.pv_domain.pirq_eoi_map_mfn)); d->arch.pv_domain.pirq_eoi_map =NULL ; + d->arch.pv_domain.auto_unmask =0 ; } }xen/arch/x86/physdev.c +5
-1@@ -271,7 +271,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.pirq_eoi_map && + v->domain->arch.pv_domain.auto_unmask )evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )@@ -293,6 +294,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } +case PHYSDEVOP_pirq_eoi_gmfn_new:case PHYSDEVOP_pirq_eoi_gmfn: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;@@ -329,6 +331,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) ret = -ENOSPC ;break ; } +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn ) + v->domain->arch.pv_domain.auto_unmask =1 ;put_gfn (current->domain, info.gmfn); ret =0 ;xen/include/asm-ia64/domain.h +3
-0@@ -186,6 +186,9 @@ struct arch_domain {/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Address of efi_runtime_services_t (placed in domain memory) */ void *efi_runtime;xen/include/asm-x86/domain.h +3
-0@@ -231,6 +231,9 @@ struct pv_domain/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +unsigned int auto_unmask;/* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;xen/include/public/physdev.h +8
-0@@ -50,6 +50,14 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);* array indexed by Xen's PIRQ value. */ #define PHYSDEVOP_pirq_eoi_gmfn 17 +/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to +* PHYSDEVOP_pirq_eoi_gmfn but it doesn't change the semantics of +* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by +* Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn_new 28struct physdev_pirq_eoi_gmfn {/* IN */ xen_pfn_t gmfn;
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
In reply to Keir FraserQuoted 17 lines · Keir Fraser
Quoted 4 lines · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.It's nasty that
pirq_eoi_gmfnhas the side effect. I suggest add a PHYSDEVOP to explicitly enable/disable unmask-on-eoi (i.e., the command accepts a boolean parameter). Once it is explicitly enabled/disabled in this way,pirq_eoi_gmfnno longer has the side effect (regardless of whether it is called before or after the explicit setting). So e.g., pv_domain.auto_unmask becomes an int where 0/1 means no/yes, and -1 means default (i.e., old behavour where it depends on whetherPHYSDEVOP_pirq_eoi_gmfnhas been called).
Quoted 1 line
This seems to me to move a bad interface in a better direction.
The problem with this approach is that by default we have an hypercall (PHYSDEVOP_pirq_eoi_gmfn) changing the behaviour of another one (PHYSDEVOP_eoi). Not only this but we have an hypercall (PHYSDEVOP_pirq_eoi_gmfn) violating the public interface of shared_info as documented in public/xen.h.
Introducing a new hypercall with the same name (PHYSDEVOP_pirq_eoi_gmfn_new) is the first step in admitting that the old hypercall was a mistake and should not be used.
I don't think we should ever change the semantics of PHYSDEVOP_eoi with another hypercall. If we want a PHYSDEVOP that eoi and unmask and event channel let's introduce PHYSDEVOP_eoi_unmask.
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 4 lines · Stefano Stabellini
Introducing a new hypercall with the same name (
PHYSDEVOP_pirq_eoi_gmfn_new) is the first step in admitting that the old hypercall was a mistake and should not be used.
If that's the case then there is precedent (e.g. sched_op, physdev_op, evtchn_op) for renaming the existing thing FOO_compat and taking over the name with the new semantics.
That's certainly better than _new->_newer->really_new etc. If you must go down that route then adding a number seems preferable.
Ian.
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini
Introducing a new hypercall with the same name (
PHYSDEVOP_pirq_eoi_gmfn_new) is the first step in admitting that the old hypercall was a mistake and should not be used.
Quoted 6 lines
If that's the case then there is precedent (e.g.
sched_op,physdev_op,evtchn_op) for renaming the existing thingFOO_compatand taking over the name with the new semantics.That's certainly better than
_new->_newer->really_newetc. If you must go down that route then adding a number seems preferable.
In that case, I vote for taking over the existing name with the new hypercall.
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 9 lines · Stefano Stabellini
Quoted 6 lines
If that's the case then there is precedent (e.g.
sched_op,physdev_op,evtchn_op) for renaming the existing thingFOO_compatand taking over the name with the new semantics.That's certainly better than
_new->_newer->really_newetc. If you must go down that route then adding a number seems preferable.In that case, I vote for taking over the existing name with the new hypercall.
Agreed, but you have to be careful because other codebases expect to be able to sync with our public headers without subtle side effects.
The correct thing to do here is probably to rename the old command to PHYSDEVOP_pirq_eoi_gmfn_v1, and your new one ..._v2.
Then you bump XEN_LATEST_INTERFACE_VERSION to 0x00040200 (somewhat arbitrarily!), and at the end of physdev.h you put something like:
#if __XEN_INTERFACE_VERSION < 0x00040200
#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1 #else
#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2 #endif
Perfect, those who want the explicitly versioned command can use it. Old codebases can sync with new headers safely. Or codebases can be updated for latest XEN_INTERFACE_VERSION and default to the latest sanest command versions.
-- Keir
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
Quoted 27 lines · Keir Fraser
Quoted 9 lines · Stefano Stabellini
Quoted 6 lines
If that's the case then there is precedent (e.g.
sched_op,physdev_op,evtchn_op) for renaming the existing thingFOO_compatand taking over the name with the new semantics.That's certainly better than
_new->_newer->really_newetc. If you must go down that route then adding a number seems preferable.In that case, I vote for taking over the existing name with the new hypercall.
Agreed, but you have to be careful because other codebases expect to be able to sync with our public headers without subtle side effects.
The correct thing to do here is probably to rename the old command to
PHYSDEVOP_pirq_eoi_gmfn_v1, and your new one ..._v2.Then you bump
XEN_LATEST_INTERFACE_VERSIONto0x00040200(somewhat arbitrarily!), and at the end ofphysdev.hyou put something like:
#if__XEN_INTERFACE_VERSION<0x00040200
#definePHYSDEVOP_pirq_eoi_gmfnPHYSDEVOP_pirq_eoi_gmfn_v1#else
#definePHYSDEVOP_pirq_eoi_gmfnPHYSDEVOP_pirq_eoi_gmfn_v2#endif
Quoted 4 lines
Perfect, those who want the explicitly versioned command can use it. Old codebases can sync with new headers safely. Or codebases can be updated for latest
XEN_INTERFACE_VERSIONand default to the latest sanest command versions.
Great, I'll make the change and repost.
PATCH v2 1/2 xen: introduce PHYSDEVOP_pirq_eoi_gmfn_v2
PHYSDEVOP_pirq_eoi_gmfn changes the semantics of PHYSDEVOP_eoi. In order to improve the interface this patch:
- renames PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1;
- introduces PHYSDEVOP_pirq_eoi_gmfn_v2, that is like PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't modify the behaviour of another hypercall;
- bump __XEN_LATEST_INTERFACE_VERSION__;
- #define PHYSDEVOP_pirq_eoi_gmfn to PHYSDEVOP_pirq_eoi_gmfn_v1 or PHYSDEVOP_pirq_eoi_gmfn_v2 depending on the __XEN_INTERFACE_VERSION.
--- xen/arch/ia64/xen/domain.c | 1 + xen/arch/ia64/xen/hypercall.c | 7 +++++-- xen/arch/x86/domain.c | 1 + xen/arch/x86/physdev.c | 7 +++++-- xen/include/asm-ia64/domain.h | 3 +++ xen/include/asm-x86/domain.h | 3 +++ xen/include/public/physdev.h | 16 +++++++++++++++- xen/include/public/xen-compat.h | 2 +- 8 files changed, 34 insertions(+), 6 deletions(-)
xen/arch/ia64/xen/domain.c +1 -0
@@ -1731,6 +1731,7 @@ int domain_relinquish_resources(struct domain *d)if (d->arch.pirq_eoi_map !=NULL ) {put_page (virt_to_page (d->arch.pirq_eoi_map)); d->arch.pirq_eoi_map =NULL ; + d->arch.auto_unmask =0 ; }/* Tear down shadow mode stuff. */
xen/arch/ia64/xen/hypercall.c +5 -2
@@ -65,7 +65,7 @@ static long __do_pirq_guest_eoi(struct domain *d, int pirq) {if ( pirq <0 || pirq >=NR_IRQS )return -EINVAL ; -if ( d->arch.pirq_eoi_map ) { +if ( d->arch.auto_unmask ) {spin_lock (&d->event_lock);evtchn_unmask (pirq_to_evtchn (d, pirq));spin_unlock (&d->event_lock);
@@ -508,7 +508,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } -case PHYSDEVOP_pirq_eoi_gmfn: { +case PHYSDEVOP_pirq_eoi_gmfn_v1: +case PHYSDEVOP_pirq_eoi_gmfn_v2: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;
@@ -531,6 +532,8 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) } current->domain->arch.pirq_eoi_map =mfn_to_virt (mfn); +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 ) + current->domain->arch.auto_unmask =1 ; ret =0 ;break ; }
xen/arch/x86/domain.c +1 -0
@@ -2125,6 +2125,7 @@ int domain_relinquish_resources(struct domain *d)put_page_and_type (mfn_to_page (d->arch.pv_domain.pirq_eoi_map_mfn)); d->arch.pv_domain.pirq_eoi_map =NULL ; + d->arch.pv_domain.auto_unmask =0 ; } }
xen/arch/x86/physdev.c +5 -2
@@ -271,7 +271,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; }if ( !is_hvm_domain (v->domain) && - v->domain->arch.pv_domain.pirq_eoi_map ) + v->domain->arch.pv_domain.auto_unmask )evtchn_unmask (pirq->evtchn);if ( !is_hvm_domain (v->domain) ||domain_pirq_to_irq (v->domain, eoi.irq) >0 )
@@ -293,7 +293,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)break ; } -case PHYSDEVOP_pirq_eoi_gmfn: { +case PHYSDEVOP_pirq_eoi_gmfn_v2: +case PHYSDEVOP_pirq_eoi_gmfn_v1: {struct physdev_pirq_eoi_gmfn info;unsigned long mfn;
@@ -329,6 +330,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) ret = -ENOSPC ;break ; } +if ( cmd == PHYSDEVOP_pirq_eoi_gmfn_v1 ) + v->domain->arch.pv_domain.auto_unmask =1 ;put_gfn (current->domain, info.gmfn); ret =0 ;
xen/include/asm-ia64/domain.h +3 -0
@@ -186,6 +186,9 @@ struct arch_domain {/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +bool_t auto_unmask;/* Address of efi_runtime_services_t (placed in domain memory) */ void *efi_runtime;
xen/include/asm-x86/domain.h +3 -0
@@ -231,6 +231,9 @@ struct pv_domain/* Shared page for notifying that explicit PIRQ EOI is required. */ unsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; +/* set auto_unmask to 1 if you want PHYSDEVOP_eoi to automatically +* unmask the event channel */ +bool_t auto_unmask;/* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;
xen/include/public/physdev.h +15 -1
@@ -49,7 +49,15 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);* will automatically get unmasked. The page registered is used as a bit * array indexed by Xen's PIRQ value. */ -#define PHYSDEVOP_pirq_eoi_gmfn 17 +#define PHYSDEVOP_pirq_eoi_gmfn_v1 17 +/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to +* PHYSDEVOP_pirq_eoi_gmfn_v1 but it doesn't change the semantics of +* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by +* Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn_v2 28struct physdev_pirq_eoi_gmfn {/* IN */ xen_pfn_t gmfn;
@@ -325,6 +333,12 @@ DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t);#define PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY XENIRQSTAT_needs_eoi#define PHYSDEVOP_IRQ_SHARED XENIRQSTAT_shared +#if __XEN_INTERFACE_VERSION <0x00040200 +#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v1 +#else +#define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2 +#endif +#endif /* __XEN_PUBLIC_PHYSDEV_H__ */ /*
xen/include/public/xen-compat.h +1 -1
@@ -27,7 +27,7 @@#ifndef __XEN_PUBLIC_XEN_COMPAT_H__#define __XEN_PUBLIC_XEN_COMPAT_H__ -#define __XEN_LATEST_INTERFACE_VERSION__ 0x0003020a +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040200#if defined(__XEN__) || defined(__XEN_TOOLS__)/* Xen is built with matching headers and implements the latest interface. */
Signature · 1 line
1.7.2.5
PATCH v2 2/2 linux/xen: support pirq_eoi_map
In reply to Stefano StabelliniThe pirq_eoi_map is a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We use PHYSDEVOP_pirq_eoi_gmfn (v2) to map the bitmap, then, if we succeed, we use pirq_eoi_map to check whether pirqs need eoi.
--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)
drivers/xen/events.c +16 -1
@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h>
@@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);
@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }
@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );
@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init (); }else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn, &eoi_gmfn); +if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }
include/xen/interface/physdev.h +12 -0
@@ -39,6 +39,18 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 28 +struct physdev_pirq_eoi_gmfn { +/* IN */ +unsigned long gmfn; +}; + + +/* * Query the status of an IRQ line. * @arg == pointer to physdev_irq_status_query structure. */
Signature · 1 line
1.7.2.5
Re: [PATCH v2 2/2] linux/xen: support pirq_eoi_map
Quoted 32 lines · Stefano Stabellini
The
pirq_eoi_mapis a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We usePHYSDEVOP_pirq_eoi_gmfn(v2) to map the bitmap, then, if we succeed, we usepirq_eoi_mapto check whether pirqs need eoi.Signed-off-by Stefano Stabellini <[email protected]>--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)drivers/xen/events.c +2
-0@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);
drivers/xen/events.c static bool pirq_needs_eoi(unsigned irq) · line 281
Quoted 6 lines
drivers/xen/events.c +3
-0@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +
How about just having a different function calledpirq_needs_eoi_v2 which will just do
return test_bit(irq, pirq_eoi_map)?
And then set the pirq_needs_eoi_v2 in the function table?
Quoted 15 lines
drivers/xen/events.c +1
-1return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init ();
drivers/xen/events.c void __init xen_init_IRQ(void) · line 1730
Quoted 10 lines
drivers/xen/events.c +6
-0}else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn, &eoi_gmfn);
Don't we want the v2 version?
Quoted 11 lines
drivers/xen/events.c +4
-0+if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }include/xen/interface/physdev.h +0
-0
include/xen/interface/physdev.h struct physdev_eoi { · line 46
Quoted 8 lines
include/xen/interface/physdev.h +5
-0@@ -39,6 +39,18 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 28
Ah, the number is right, but the name is the generic one.
We should really mention that this is different from v1 or just
#define PHYSDEVOP_pirq_eoi_gmfn_v2 28
and use that in the code?
Quoted 12 lines
include/xen/interface/physdev.h +7
-0+struct physdev_pirq_eoi_gmfn { +/* IN */ +unsigned long gmfn; +}; + + +/* * Query the status of an IRQ line. * @arg == pointer to physdev_irq_status_query structure. */ Signature · 1 line
1.7.2.5
Re: [PATCH v2 2/2] linux/xen: support pirq_eoi_map
Quoted 43 lines · Konrad Rzeszutek Wilk
Quoted 32 lines · Stefano Stabellini
The
pirq_eoi_mapis a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We usePHYSDEVOP_pirq_eoi_gmfn(v2) to map the bitmap, then, if we succeed, we usepirq_eoi_mapto check whether pirqs need eoi.Signed-off-by Stefano Stabellini <[email protected]>--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)drivers/xen/events.c +2
-0@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);drivers/xen/events.c static bool pirq_needs_eoi(unsigned irq) · line 281
Quoted 6 lines
drivers/xen/events.c +3
-0@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +How about just having a different function called
pirq_needs_eoi_v2which will just do
Quoted 3 lines
return
test_bit(irq, pirq_eoi_map)?And then set the
pirq_needs_eoi_v2in the function table?
Ok, but the name "pirq_needs_eoi_v2" is misleading because PHYSDEVOP_pirq_eoi_gmfn only works for PV guests at the moment. How about I call the new function "pirq_check_eoi_map" and rename the old one "pirq_needs_eoi_flag" and the generic name of the function pointer would remain "pirq_needs_eoi"?
Quoted 51 lines
Quoted 15 lines
drivers/xen/events.c +1
-1return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init ();drivers/xen/events.c void __init xen_init_IRQ(void) · line 1730
Quoted 10 lines
drivers/xen/events.c +6
-0}else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn, &eoi_gmfn);Don't we want the v2 version?
Quoted 11 lines
drivers/xen/events.c +4
-0+if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }include/xen/interface/physdev.h +0
-0include/xen/interface/physdev.h struct physdev_eoi { · line 46
Quoted 8 lines
include/xen/interface/physdev.h +5
-0@@ -39,6 +39,18 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 28Ah, the number is right, but the name is the generic one.
Quoted 4 lines
We should really mention that this is different from v1 or just
#define
PHYSDEVOP_pirq_eoi_gmfn_v228
and use that in the code?
Maybe we should:
#define PHYSDEVOP_pirq_eoi_gmfn_v2 28
in order not to hide the fact that there are two versions of this hypercall.
Then we do:
/* we use the second version of the hypercall */ #define PHYSDEVOP_pirq_eoi_gmfn PHYSDEVOP_pirq_eoi_gmfn_v2
This way we just have PHYSDEVOP_pirq_eoi_gmfn in the code but we don't hide the version with are using.
Re: [PATCH v2 2/2] linux/xen: support pirq_eoi_map
Quoted 46 lines · Stefano Stabellini
Quoted 45 lines · Konrad Rzeszutek Wilk
Quoted 32 lines · Stefano Stabellini
The
pirq_eoi_mapis a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We usePHYSDEVOP_pirq_eoi_gmfn(v2) to map the bitmap, then, if we succeed, we usepirq_eoi_mapto check whether pirqs need eoi.Signed-off-by Stefano Stabellini <[email protected]>--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)drivers/xen/events.c +2
-0@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);drivers/xen/events.c static bool pirq_needs_eoi(unsigned irq) · line 281
Quoted 6 lines
drivers/xen/events.c +3
-0@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +How about just having a different function called
pirq_needs_eoi_v2which will just doreturn
test_bit(irq, pirq_eoi_map)?
Quoted 7 lines
Quoted 1 line
And then set the
pirq_needs_eoi_v2in the function table?Ok, but the name "
pirq_needs_eoi_v2" is misleading becausePHYSDEVOP_pirq_eoi_gmfnonly works for PV guests at the moment. How about I call the new function "pirq_check_eoi_map" and rename the old one "pirq_needs_eoi_flag" and the generic name of the function pointer would remain "pirq_needs_eoi"?
Even better!
Quoted 66 lines
Quoted 53 lines
Quoted 17 lines
drivers/xen/events.c +1
-1return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init ();drivers/xen/events.c void __init xen_init_IRQ(void) · line 1730
Quoted 10 lines
drivers/xen/events.c +6
-0}else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn, &eoi_gmfn);Don't we want the v2 version?
Quoted 11 lines
drivers/xen/events.c +4
-0+if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }include/xen/interface/physdev.h +0
-0include/xen/interface/physdev.h struct physdev_eoi { · line 46
Quoted 8 lines
include/xen/interface/physdev.h +5
-0@@ -39,6 +39,18 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 28Ah, the number is right, but the name is the generic one.
Quoted 4 lines
We should really mention that this is different from v1 or just
#define
PHYSDEVOP_pirq_eoi_gmfn_v228
and use that in the code?Maybe we should:
#define
PHYSDEVOP_pirq_eoi_gmfn_v228in order not to hide the fact that there are two versions of this hypercall.
Then we do:
Quoted 6 lines
/* we use the second version of the hypercall */ #define
PHYSDEVOP_pirq_eoi_gmfnPHYSDEVOP_pirq_eoi_gmfn_v2This way we just have
PHYSDEVOP_pirq_eoi_gmfnin the code but we don't hide the version with are using.
That could work. However using a v2 everywhere will clearly show to to somebody why it won't work with say Xen 4.0 (if they are trying to run it under it and wonder why that hypercall did not work). Which reminds me, once the hypervisor patch is in, we should definitly mention that in this git commit.
Re: [PATCH v2 2/2] linux/xen: support pirq_eoi_map
Quoted 126 lines · Konrad Rzeszutek Wilk
Quoted 46 lines · Stefano Stabellini
Quoted 45 lines · Konrad Rzeszutek Wilk
Quoted 32 lines · Stefano Stabellini
The
pirq_eoi_mapis a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We usePHYSDEVOP_pirq_eoi_gmfn(v2) to map the bitmap, then, if we succeed, we usepirq_eoi_mapto check whether pirqs need eoi.Signed-off-by Stefano Stabellini <[email protected]>--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)drivers/xen/events.c +2
-0@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h> @@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);drivers/xen/events.c static bool pirq_needs_eoi(unsigned irq) · line 281
Quoted 6 lines
drivers/xen/events.c +3
-0@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +How about just having a different function called
pirq_needs_eoi_v2which will just doreturn
test_bit(irq, pirq_eoi_map)?Quoted 7 lines
Quoted 1 line
And then set the
pirq_needs_eoi_v2in the function table?Ok, but the name "
pirq_needs_eoi_v2" is misleading becausePHYSDEVOP_pirq_eoi_gmfnonly works for PV guests at the moment. How about I call the new function "pirq_check_eoi_map" and rename the old one "pirq_needs_eoi_flag" and the generic name of the function pointer would remain "pirq_needs_eoi"?Even better!
Quoted 70 lines
Quoted 53 lines
Quoted 17 lines
drivers/xen/events.c +1
-1return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init ();drivers/xen/events.c void __init xen_init_IRQ(void) · line 1730
Quoted 10 lines
drivers/xen/events.c +6
-0}else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn, &eoi_gmfn);Don't we want the v2 version?
Quoted 11 lines
drivers/xen/events.c +4
-0+if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }include/xen/interface/physdev.h +0
-0include/xen/interface/physdev.h struct physdev_eoi { · line 46
Quoted 8 lines
include/xen/interface/physdev.h +5
-0@@ -39,6 +39,18 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 28Ah, the number is right, but the name is the generic one.
Quoted 4 lines
We should really mention that this is different from v1 or just
#define
PHYSDEVOP_pirq_eoi_gmfn_v228
and use that in the code?Maybe we should:
#define
PHYSDEVOP_pirq_eoi_gmfn_v228in order not to hide the fact that there are two versions of this hypercall.
Then we do:/* we use the second version of the hypercall */ #define
PHYSDEVOP_pirq_eoi_gmfnPHYSDEVOP_pirq_eoi_gmfn_v2
Quoted 7 lines
Quoted 2 lines
This way we just have
PHYSDEVOP_pirq_eoi_gmfnin the code but we don't hide the version with are using.That could work. However using a v2 everywhere will clearly show to to somebody why it won't work with say Xen 4.0 (if they are trying to run it under it and wonder why that hypercall did not work). Which reminds me, once the hypervisor patch is in, we should definitly mention that in this git commit.
OK then, let's go with PHYSDEVOP_pirq_eoi_gmfn_v2
Re: [PATCH 1/2] xen: Introduce PHYSDEVOP_pirq_eoi_gmfn_new
In reply to Stefano StabelliniQuoted 26 lines · Stefano Stabellini
Quoted 17 lines · Keir Fraser
Quoted 4 lines · Stefano Stabellini
PHYSDEVOP_pirq_eoi_gmfnchanges the semantics ofPHYSDEVOP_eoi. IntroducePHYSDEVOP_pirq_eoi_gmfn_new, that is likePHYSDEVOP_pirq_eoi_gmfnbut it doesn't modify the behaviour of another hypercall.It's nasty that
pirq_eoi_gmfnhas the side effect. I suggest add a PHYSDEVOP to explicitly enable/disable unmask-on-eoi (i.e., the command accepts a boolean parameter). Once it is explicitly enabled/disabled in this way,pirq_eoi_gmfnno longer has the side effect (regardless of whether it is called before or after the explicit setting). So e.g., pv_domain.auto_unmask becomes an int where 0/1 means no/yes, and -1 means default (i.e., old behavour where it depends on whetherPHYSDEVOP_pirq_eoi_gmfnhas been called).Quoted 1 line
This seems to me to move a bad interface in a better direction.
The problem with this approach is that by default we have an hypercall (
PHYSDEVOP_pirq_eoi_gmfn) changing the behaviour of another one (PHYSDEVOP_eoi). Not only this but we have an hypercall (PHYSDEVOP_pirq_eoi_gmfn) violating the public interface ofshared_infoas documented inpublic/xen.h.
Quoted 7 lines
Introducing a new hypercall with the same name (
PHYSDEVOP_pirq_eoi_gmfn_new) is the first step in admitting that the old hypercall was a mistake and should not be used.I don't think we should ever change the semantics of
PHYSDEVOP_eoiwith another hypercall. If we want a PHYSDEVOP that eoi and unmask and event channel let's introducePHYSDEVOP_eoi_unmask.
Okay, fine by me. See my comments on naming in the email I sent just a sec ago.
-- Keir
PATCH 2/2 linux/xen: support pirq_eoi_map
In reply to Stefano StabelliniThe pirq_eoi_map is a bitmap offered by Xen to check which pirqs need to be EOI'd without having to issue an hypercall every time.
We use the new PHYSDEVOP_pirq_eoi_gmfn_new to map the bitmap, so that Xen does not change the semantics of PHYSDEVOP_eoi behind our backs.
--- drivers/xen/events.c | 17 ++++++++++++++++- include/xen/interface/physdev.h | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletions(-)
drivers/xen/events.c +16 -1
@@ -37,6 +37,7 @@#include <asm/idle.h> #include <asm/io_apic.h> #include <asm/sync_bitops.h> +#include <asm/xen/page.h> #include <asm/xen/pci.h> #include <asm/xen/hypercall.h> #include <asm/xen/hypervisor.h>
@@ -108,6 +109,7 @@ struct irq_info {#define PIRQ_SHAREABLE (1 << 1)static int *evtchn_to_irq; +static unsigned long *pirq_eoi_map; static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], cpu_evtchn_mask);
@@ -274,6 +276,9 @@ static bool pirq_needs_eoi(unsigned irq)BUG_ON (info->type !=IRQT_PIRQ ); +if (pirq_eoi_map !=NULL ) +return test_bit (irq, pirq_eoi_map); +return info->u.pirq.flags &PIRQ_NEEDS_EOI ; }
@@ -1693,7 +1698,7 @@ void xen_callback_vector(void) {}void __init xen_init_IRQ (void ) { -int i; +int i, rc; evtchn_to_irq =kcalloc (NR_EVENT_CHANNELS ,sizeof (*evtchn_to_irq),GFP_KERNEL );
@@ -1714,8 +1719,18 @@ void __init xen_init_IRQ(void)* __acpi_register_gsi can point at the right function */ pci_xen_hvm_init (); }else { +struct physdev_pirq_eoi_gmfn eoi_gmfn; +irq_ctx_init (smp_processor_id ());if (xen_initial_domain ())pci_xen_initial_domain (); + + pirq_eoi_map = (void *)__get_free_page (GFP_KERNEL |__GFP_ZERO); + eoi_gmfn.gmfn =virt_to_mfn (pirq_eoi_map); + rc =HYPERVISOR_physdev_op (PHYSDEVOP_pirq_eoi_gmfn_new, &eoi_gmfn); +if (rc !=0 ) { +free_page ((unsigned long ) pirq_eoi_map); + pirq_eoi_map =NULL ; + } } }
include/xen/interface/physdev.h +22 -0
@@ -39,6 +39,28 @@ struct physdev_eoi { };/* +* Register a shared page for the hypervisor to indicate whether the guest +* must issue PHYSDEVOP_eoi. The semantics of PHYSDEVOP_eoi change slightly +* once the guest used this function in that the associated event channel +* will automatically get unmasked. The page registered is used as a bit +* array indexed by Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn 17 +/* +* Register a shared page for the hypervisor to indicate whether the +* guest must issue PHYSDEVOP_eoi. This hypercall is very similar to +* PHYSDEVOP_pirq_eoi_gmfn but it doesn't change the semantics of +* PHYSDEVOP_eoi. The page registered is used as a bit array indexed by +* Xen's PIRQ value. +*/ +#define PHYSDEVOP_pirq_eoi_gmfn_new 28 +struct physdev_pirq_eoi_gmfn { +/* IN */ +unsigned long gmfn; +}; + + +/* * Query the status of an IRQ line. * @arg == pointer to physdev_irq_status_query structure. */
Signature · 1 line
1.7.2.5