kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nitesh Narayan Lal <nitesh@redhat.com>
To: Christophe de Dinechin <christophe.de.dinechin@gmail.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, thuth@redhat.com,
	mtosatti@redhat.com
Subject: Re: [kvm-unit-tests Patch v1 2/2] x86: ioapic: Test physical and logical destination mode
Date: Wed, 4 Dec 2019 22:28:05 -0500	[thread overview]
Message-ID: <5fac8c7b-ddcd-de22-568d-bc7ab6c7c71f@redhat.com> (raw)
In-Reply-To: <7hblsw8fji.fsf@crazypad.dinechin.lan>


On 11/28/19 5:25 AM, Christophe de Dinechin wrote:
> Nitesh Narayan Lal writes:
>
>> This patch tests the physical destination mode by sending an
>> interrupt to one of the vcpus and logical destination mode by
>> sending an interrupt to more than one vcpus.
>>
>> Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
>> ---
>>  x86/ioapic.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 65 insertions(+)
>>
>> diff --git a/x86/ioapic.c b/x86/ioapic.c
>> index c32dabd..31aec03 100644
>> --- a/x86/ioapic.c
>> +++ b/x86/ioapic.c
>> @@ -405,12 +405,73 @@ static void test_ioapic_self_reconfigure(void)
>>  	report("Reconfigure self", g_isr_84 == 1 && e.remote_irr == 0);
>>  }
>>
>> +static volatile int g_isr_85;
>> +
>> +static void ioapic_isr_85(isr_regs_t *regs)
>> +{
>> +	++g_isr_85;
>> +	set_irq_line(0x0e, 0);
>> +	eoi();
>> +}
>> +
>> +static void test_ioapic_physical_destination_mode(void)
>> +{
>> +	ioapic_redir_entry_t e = {
>> +		.vector = 0x85,
>> +		.delivery_mode = 0,
>> +		.dest_mode = 0,
>> +		.dest_id = 0x1,
>> +		.trig_mode = TRIGGER_LEVEL,
>> +	};
>> +	handle_irq(0x85, ioapic_isr_85);
>> +	ioapic_write_redir(0xe, e);
>> +	set_irq_line(0x0e, 1);
>> +	do {
>> +		pause();
>> +	} while(g_isr_85 != 1);
> Does this loop (and the next one) end up running forever if the test
> fails? Would it be worth adding some timeout to detect failure?

AFAIK there is already a timeout in place. i.e., if we don't receive an
interrupt then eventually the timeout will occur and the test will terminate.

>
>> +	report("ioapic physical destination mode", g_isr_85 == 1);
>> +}
>> +
>> +static volatile int g_isr_86;
>> +
>> +static void ioapic_isr_86(isr_regs_t *regs)
>> +{
>> +	++g_isr_86;
>> +	set_irq_line(0x0e, 0);
>> +	eoi();
>> +}
>> +
>> +static void test_ioapic_logical_destination_mode(void)
>> +{
>> +	/* Number of vcpus which are configured/set in dest_id */
>> +	int nr_vcpus = 3;
>> +	ioapic_redir_entry_t e = {
>> +		.vector = 0x86,
>> +		.delivery_mode = 0,
>> +		.dest_mode = 1,
>> +		.dest_id = 0xd,
>> +		.trig_mode = TRIGGER_LEVEL,
>> +	};
>> +	handle_irq(0x86, ioapic_isr_86);
>> +	ioapic_write_redir(0xe, e);
>> +	set_irq_line(0x0e, 1);
>> +	do {
>> +		pause();
>> +	} while(g_isr_86 < nr_vcpus);
>> +	report("ioapic logical destination mode", g_isr_86 == nr_vcpus);
>> +}
>> +
>> +static void update_cr3(void *cr3)
>> +{
>> +	write_cr3((ulong)cr3);
>> +}
>>
>>  int main(void)
>>  {
>>  	setup_vm();
>>  	smp_init();
>>
>> +	on_cpus(update_cr3, (void *)read_cr3());
>>  	mask_pic_interrupts();
>>
>>  	if (enable_x2apic())
>> @@ -448,7 +509,11 @@ int main(void)
>>  		test_ioapic_edge_tmr_smp(true);
>>
>>  		test_ioapic_self_reconfigure();
>> +		test_ioapic_physical_destination_mode();
>>  	}
>>
>> +	if (cpu_count() > 3)
>> +		test_ioapic_logical_destination_mode();
>> +
>>  	return report_summary();
>>  }
>
> --
> Cheers,
> Christophe de Dinechin (IRC c3d)
>
-- 
Thanks
Nitesh


  reply	other threads:[~2019-12-05  3:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 12:47 [kvm-unit-tests Patch v1 0/2] x86: Test IOAPIC physical and logical destination mode Nitesh Narayan Lal
2019-11-06 12:47 ` [kvm-unit-tests Patch v1 1/2] x86: ioapic: Add the smp configuration to ioapic unittest Nitesh Narayan Lal
2019-11-06 12:47 ` [kvm-unit-tests Patch v1 2/2] x86: ioapic: Test physical and logical destination mode Nitesh Narayan Lal
2019-11-28  6:38   ` Thomas Huth
2019-12-05  3:26     ` Nitesh Narayan Lal
2019-12-05 13:59     ` Nitesh Narayan Lal
2019-11-28 10:25   ` Christophe de Dinechin
2019-12-05  3:28     ` Nitesh Narayan Lal [this message]
2019-11-22 19:21 ` [kvm-unit-tests Patch v1 0/2] x86: Test IOAPIC " Nitesh Narayan Lal
2019-11-22 19:41 ` Marcelo Tosatti
2019-11-23 10:33 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fac8c7b-ddcd-de22-568d-bc7ab6c7c71f@redhat.com \
    --to=nitesh@redhat.com \
    --cc=christophe.de.dinechin@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).