* [PATCH kvm-unit-tests] x86: ioapic: add tests around retriggering of level interrupts
@ 2015-07-29 13:28 Paolo Bonzini
2015-07-30 3:14 ` Steve Rutherford
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2015-07-29 13:28 UTC (permalink / raw)
To: kvm; +Cc: srutherford
Test resampling of level interrupts after EOI, by leaving the IRQ
line set in the ISR. One tests does reset the IRQ line after a while,
the other uses masking instead in the ISR.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
x86/ioapic.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/x86/ioapic.c b/x86/ioapic.c
index 1fcf67e..d43d5c1 100644
--- a/x86/ioapic.c
+++ b/x86/ioapic.c
@@ -188,6 +188,31 @@ static void test_ioapic_level_sequential(void)
report("sequential level interrupts", g_isr_99 == 2);
}
+static volatile int g_isr_9a;
+
+static void ioapic_isr_9a(isr_regs_t *regs)
+{
+ ++g_isr_9a;
+ if (g_isr_9a == 2)
+ set_irq_line(0x0e, 0);
+ eoi();
+}
+
+static void test_ioapic_level_retrigger(void)
+{
+ handle_irq(0x9a, ioapic_isr_9a);
+ set_ioapic_redir(0x0e, 0x9a, LEVEL_TRIGGERED);
+
+ asm volatile ("cli");
+ set_irq_line(0x0e, 1);
+ while (g_isr_9a != 2)
+ asm volatile ("sti; hlt; cli");
+
+ asm volatile ("sti");
+
+ report("retriggered level interrupts without masking", g_isr_9a == 2);
+}
+
static volatile int g_isr_81;
static void ioapic_isr_81(isr_regs_t *regs)
@@ -242,6 +267,30 @@ static void test_ioapic_level_mask(void)
report("unmasked level interrupt", g_isr_82 == 1);
}
+static volatile int g_isr_83;
+
+static void ioapic_isr_83(isr_regs_t *regs)
+{
+ ++g_isr_83;
+ set_mask(0x0e, true);
+ eoi();
+}
+
+static void test_ioapic_level_retrigger_mask(void)
+{
+ handle_irq(0x83, ioapic_isr_83);
+ set_ioapic_redir(0x0e, 0x83, LEVEL_TRIGGERED);
+
+ set_irq_line(0x0e, 1);
+ asm volatile ("nop");
+ set_mask(0x0e, false);
+ asm volatile ("nop");
+ report("retriggered level interrupts with mask", g_isr_83 == 2);
+
+ set_irq_line(0x0e, 0);
+ set_mask(0x0e, false);
+}
+
int main(void)
{
@@ -263,9 +312,11 @@ int main(void)
test_ioapic_simultaneous();
test_ioapic_level_coalesce();
test_ioapic_level_sequential();
+ test_ioapic_level_retrigger();
test_ioapic_edge_mask();
test_ioapic_level_mask();
+ test_ioapic_level_retrigger_mask();
return report_summary();
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH kvm-unit-tests] x86: ioapic: add tests around retriggering of level interrupts
2015-07-29 13:28 [PATCH kvm-unit-tests] x86: ioapic: add tests around retriggering of level interrupts Paolo Bonzini
@ 2015-07-30 3:14 ` Steve Rutherford
2015-07-30 7:13 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Steve Rutherford @ 2015-07-30 3:14 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm
On Wed, Jul 29, 2015 at 03:28:13PM +0200, Paolo Bonzini wrote:
> Test resampling of level interrupts after EOI, by leaving the IRQ
> line set in the ISR. One tests does reset the IRQ line after a while,
> the other uses masking instead in the ISR.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> x86/ioapic.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/x86/ioapic.c b/x86/ioapic.c
> index 1fcf67e..d43d5c1 100644
> --- a/x86/ioapic.c
> +++ b/x86/ioapic.c
> @@ -188,6 +188,31 @@ static void test_ioapic_level_sequential(void)
> report("sequential level interrupts", g_isr_99 == 2);
> }
>
> +static volatile int g_isr_9a;
> +
> +static void ioapic_isr_9a(isr_regs_t *regs)
> +{
> + ++g_isr_9a;
> + if (g_isr_9a == 2)
> + set_irq_line(0x0e, 0);
> + eoi();
> +}
> +
> +static void test_ioapic_level_retrigger(void)
> +{
> + handle_irq(0x9a, ioapic_isr_9a);
> + set_ioapic_redir(0x0e, 0x9a, LEVEL_TRIGGERED);
> +
> + asm volatile ("cli");
> + set_irq_line(0x0e, 1);
> + while (g_isr_9a != 2)
> + asm volatile ("sti; hlt; cli");
This seems sketchy. The test should be able to exit this and fail.
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH kvm-unit-tests] x86: ioapic: add tests around retriggering of level interrupts
2015-07-30 3:14 ` Steve Rutherford
@ 2015-07-30 7:13 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-07-30 7:13 UTC (permalink / raw)
To: Steve Rutherford; +Cc: kvm
On 30/07/2015 05:14, Steve Rutherford wrote:
>> > +static void test_ioapic_level_retrigger(void)
>> > +{
>> > + handle_irq(0x9a, ioapic_isr_9a);
>> > + set_ioapic_redir(0x0e, 0x9a, LEVEL_TRIGGERED);
>> > +
>> > + asm volatile ("cli");
>> > + set_irq_line(0x0e, 1);
>> > + while (g_isr_9a != 2)
>> > + asm volatile ("sti; hlt; cli");
> This seems sketchy. The test should be able to exit this and fail.
You're right, this shouldn't take more than 10-15 iterations of the
while loop.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-30 7:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-29 13:28 [PATCH kvm-unit-tests] x86: ioapic: add tests around retriggering of level interrupts Paolo Bonzini
2015-07-30 3:14 ` Steve Rutherford
2015-07-30 7:13 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).