* [PATCH] x86/HVM: EOI handling function adjustments
@ 2015-06-18 12:51 Jan Beulich
2015-06-18 13:29 ` Andrew Cooper
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-06-18 12:51 UTC (permalink / raw)
To: xen-devel
Cc: Andrew Cooper, Kevin Tian, Keir Fraser, Eddie Dong, Jun Nakajima
[-- Attachment #1: Type: text/plain, Size: 4232 bytes --]
The vector parameters are more usefully u8 right away. This is
particularly important for the vioapic_update_EOI() invocation from
vioapic_write() (which luckily is only a latent issue, as
VIOAPIC_VERSION_ID is still hard coded to 0x11 right now). But it at
once allows simplifying VMX's EXIT_REASON_EOI_INDUCED handling (the
kind of pointless helper function should have been static anyway; not
being use for anything else, it gets removed altogether).
Plus vlapic_handle_EOI() (now renamed for that purpose) can be used as
the tail of vlapic_EOI_set() instead of duplicating that code.
Finally replace a stray current->domain use in vlapic_handle_EOI().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -386,7 +386,7 @@ void vioapic_irq_positive_edge(struct do
}
}
-void vioapic_update_EOI(struct domain *d, int vector)
+void vioapic_update_EOI(struct domain *d, u8 vector)
{
struct hvm_hw_vioapic *vioapic = domain_vioapic(d);
struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -421,18 +421,17 @@ void vlapic_EOI_set(struct vlapic *vlapi
if ( hvm_funcs.handle_eoi )
hvm_funcs.handle_eoi(vector);
- if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
- vioapic_update_EOI(vlapic_domain(vlapic), vector);
-
- hvm_dpci_msi_eoi(current->domain, vector);
+ vlapic_handle_EOI(vlapic, vector);
}
-void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
+void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector)
{
+ struct domain *d = vlapic_domain(vlapic);
+
if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
- vioapic_update_EOI(vlapic_domain(vlapic), vector);
+ vioapic_update_EOI(d, vector);
- hvm_dpci_msi_eoi(current->domain, vector);
+ hvm_dpci_msi_eoi(d, vector);
}
static bool_t is_multicast_dest(struct vlapic *vlapic, unsigned int short_hand,
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2683,17 +2683,6 @@ static int vmx_handle_apic_write(void)
return vlapic_apicv_write(current, exit_qualification & 0xfff);
}
-/*
- * When "Virtual Interrupt Delivery" is enabled, this function is used
- * to handle EOI-induced VM exit
- */
-void vmx_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
-{
- ASSERT(cpu_has_vmx_virtual_intr_delivery);
-
- vlapic_handle_EOI_induced_exit(vlapic, vector);
-}
-
void vmx_vmexit_handler(struct cpu_user_regs *regs)
{
unsigned long exit_qualification, exit_reason, idtv_info, intr_info = 0;
@@ -3127,15 +3116,12 @@ void vmx_vmexit_handler(struct cpu_user_
break;
case EXIT_REASON_EOI_INDUCED:
- {
- int vector;
-
__vmread(EXIT_QUALIFICATION, &exit_qualification);
- vector = exit_qualification & 0xff;
- vmx_handle_EOI_induced_exit(vcpu_vlapic(v), vector);
+ ASSERT(cpu_has_vmx_virtual_intr_delivery);
+
+ vlapic_handle_EOI(vcpu_vlapic(v), exit_qualification);
break;
- }
case EXIT_REASON_IO_INSTRUCTION:
__vmread(EXIT_QUALIFICATION, &exit_qualification);
--- a/xen/include/asm-x86/hvm/vioapic.h
+++ b/xen/include/asm-x86/hvm/vioapic.h
@@ -62,6 +62,6 @@ int vioapic_init(struct domain *d);
void vioapic_deinit(struct domain *d);
void vioapic_reset(struct domain *d);
void vioapic_irq_positive_edge(struct domain *d, unsigned int irq);
-void vioapic_update_EOI(struct domain *d, int vector);
+void vioapic_update_EOI(struct domain *d, u8 vector);
#endif /* __ASM_X86_HVM_VIOAPIC_H__ */
--- a/xen/include/asm-x86/hvm/vlapic.h
+++ b/xen/include/asm-x86/hvm/vlapic.h
@@ -127,7 +127,7 @@ uint32_t vlapic_set_ppr(struct vlapic *v
void vlapic_adjust_i8259_target(struct domain *d);
void vlapic_EOI_set(struct vlapic *vlapic);
-void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector);
+void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector);
void vlapic_ipi(struct vlapic *vlapic, uint32_t icr_low, uint32_t icr_high);
[-- Attachment #2: x86-vIOAPIC-EOI-handling.patch --]
[-- Type: text/plain, Size: 4274 bytes --]
x86/HVM: EOI handling function adjustments
The vector parameters are more usefully u8 right away. This is
particularly important for the vioapic_update_EOI() invocation from
vioapic_write() (which luckily is only a latent issue, as
VIOAPIC_VERSION_ID is still hard coded to 0x11 right now). But it at
once allows simplifying VMX's EXIT_REASON_EOI_INDUCED handling (the
kind of pointless helper function should have been static anyway; not
being use for anything else, it gets removed altogether).
Plus vlapic_handle_EOI() (now renamed for that purpose) can be used as
the tail of vlapic_EOI_set() instead of duplicating that code.
Finally replace a stray current->domain use in vlapic_handle_EOI().
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -386,7 +386,7 @@ void vioapic_irq_positive_edge(struct do
}
}
-void vioapic_update_EOI(struct domain *d, int vector)
+void vioapic_update_EOI(struct domain *d, u8 vector)
{
struct hvm_hw_vioapic *vioapic = domain_vioapic(d);
struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -421,18 +421,17 @@ void vlapic_EOI_set(struct vlapic *vlapi
if ( hvm_funcs.handle_eoi )
hvm_funcs.handle_eoi(vector);
- if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
- vioapic_update_EOI(vlapic_domain(vlapic), vector);
-
- hvm_dpci_msi_eoi(current->domain, vector);
+ vlapic_handle_EOI(vlapic, vector);
}
-void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
+void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector)
{
+ struct domain *d = vlapic_domain(vlapic);
+
if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
- vioapic_update_EOI(vlapic_domain(vlapic), vector);
+ vioapic_update_EOI(d, vector);
- hvm_dpci_msi_eoi(current->domain, vector);
+ hvm_dpci_msi_eoi(d, vector);
}
static bool_t is_multicast_dest(struct vlapic *vlapic, unsigned int short_hand,
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2683,17 +2683,6 @@ static int vmx_handle_apic_write(void)
return vlapic_apicv_write(current, exit_qualification & 0xfff);
}
-/*
- * When "Virtual Interrupt Delivery" is enabled, this function is used
- * to handle EOI-induced VM exit
- */
-void vmx_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
-{
- ASSERT(cpu_has_vmx_virtual_intr_delivery);
-
- vlapic_handle_EOI_induced_exit(vlapic, vector);
-}
-
void vmx_vmexit_handler(struct cpu_user_regs *regs)
{
unsigned long exit_qualification, exit_reason, idtv_info, intr_info = 0;
@@ -3127,15 +3116,12 @@ void vmx_vmexit_handler(struct cpu_user_
break;
case EXIT_REASON_EOI_INDUCED:
- {
- int vector;
-
__vmread(EXIT_QUALIFICATION, &exit_qualification);
- vector = exit_qualification & 0xff;
- vmx_handle_EOI_induced_exit(vcpu_vlapic(v), vector);
+ ASSERT(cpu_has_vmx_virtual_intr_delivery);
+
+ vlapic_handle_EOI(vcpu_vlapic(v), exit_qualification);
break;
- }
case EXIT_REASON_IO_INSTRUCTION:
__vmread(EXIT_QUALIFICATION, &exit_qualification);
--- a/xen/include/asm-x86/hvm/vioapic.h
+++ b/xen/include/asm-x86/hvm/vioapic.h
@@ -62,6 +62,6 @@ int vioapic_init(struct domain *d);
void vioapic_deinit(struct domain *d);
void vioapic_reset(struct domain *d);
void vioapic_irq_positive_edge(struct domain *d, unsigned int irq);
-void vioapic_update_EOI(struct domain *d, int vector);
+void vioapic_update_EOI(struct domain *d, u8 vector);
#endif /* __ASM_X86_HVM_VIOAPIC_H__ */
--- a/xen/include/asm-x86/hvm/vlapic.h
+++ b/xen/include/asm-x86/hvm/vlapic.h
@@ -127,7 +127,7 @@ uint32_t vlapic_set_ppr(struct vlapic *v
void vlapic_adjust_i8259_target(struct domain *d);
void vlapic_EOI_set(struct vlapic *vlapic);
-void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector);
+void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector);
void vlapic_ipi(struct vlapic *vlapic, uint32_t icr_low, uint32_t icr_high);
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/HVM: EOI handling function adjustments
2015-06-18 12:51 [PATCH] x86/HVM: EOI handling function adjustments Jan Beulich
@ 2015-06-18 13:29 ` Andrew Cooper
2015-06-18 13:46 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-06-18 13:29 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Keir Fraser, Kevin Tian, Eddie Dong, Jun Nakajima
On 18/06/15 13:51, Jan Beulich wrote:
> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -421,18 +421,17 @@ void vlapic_EOI_set(struct vlapic *vlapi
> if ( hvm_funcs.handle_eoi )
> hvm_funcs.handle_eoi(vector);
>
> - if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
> - vioapic_update_EOI(vlapic_domain(vlapic), vector);
> -
> - hvm_dpci_msi_eoi(current->domain, vector);
> + vlapic_handle_EOI(vlapic, vector);
> }
>
> -void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
> +void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector)
> {
> + struct domain *d = vlapic_domain(vlapic);
> +
> if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
> - vioapic_update_EOI(vlapic_domain(vlapic), vector);
> + vioapic_update_EOI(d, vector);
>
> - hvm_dpci_msi_eoi(current->domain, vector);
> + hvm_dpci_msi_eoi(d, vector);
It might be worth retaining an ASSERT(current->domain == d) at this point.
Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/HVM: EOI handling function adjustments
2015-06-18 13:29 ` Andrew Cooper
@ 2015-06-18 13:46 ` Jan Beulich
0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2015-06-18 13:46 UTC (permalink / raw)
To: Andrew Cooper
Cc: xen-devel, Kevin Tian, Keir Fraser, Eddie Dong, Jun Nakajima
>>> On 18.06.15 at 15:29, <andrew.cooper3@citrix.com> wrote:
> On 18/06/15 13:51, Jan Beulich wrote:
>> -void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector)
>> +void vlapic_handle_EOI(struct vlapic *vlapic, u8 vector)
>> {
>> + struct domain *d = vlapic_domain(vlapic);
>> +
>> if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) )
>> - vioapic_update_EOI(vlapic_domain(vlapic), vector);
>> + vioapic_update_EOI(d, vector);
>>
>> - hvm_dpci_msi_eoi(current->domain, vector);
>> + hvm_dpci_msi_eoi(d, vector);
>
> It might be worth retaining an ASSERT(current->domain == d) at this point.
For one, there would be many more places where this should then
be added. And then, even with the current (unpatched) code things
would go wrong if that wasn't already the case.
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-18 13:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-18 12:51 [PATCH] x86/HVM: EOI handling function adjustments Jan Beulich
2015-06-18 13:29 ` Andrew Cooper
2015-06-18 13:46 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.