From patchwork Wed Nov 6 12:47:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitesh Narayan Lal X-Patchwork-Id: 11230217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF14E1599 for ; Wed, 6 Nov 2019 12:47:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FB4721882 for ; Wed, 6 Nov 2019 12:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VkkIKRl/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730622AbfKFMrc (ORCPT ); Wed, 6 Nov 2019 07:47:32 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21977 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730392AbfKFMrc (ORCPT ); Wed, 6 Nov 2019 07:47:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573044451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2/QDEapR+pQoQB46goTREYq60QE/KAIKC9jcYxuCF9M=; b=VkkIKRl/xKvgfnhWb6KzsWhM6YVadIEaKUxe2hBz4AGNnet2/a2t/bY35folWe0AttZdyE ME4om8cVb0hmLRWVfMcFrnIDzqtgY/NEPYuLnLkVCVD7N4t3TycLkkokHCBzwlvPdgskAf QOKhpLvDwreFZk3KDLlK29sWn2vyFRc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-6epujcizPnyPP0ZuD06fpw-1; Wed, 06 Nov 2019 07:47:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 463DC477 for ; Wed, 6 Nov 2019 12:47:29 +0000 (UTC) Received: from virtlab512.virt.lab.eng.bos.redhat.com (virtlab512.virt.lab.eng.bos.redhat.com [10.19.152.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E5F36056B; Wed, 6 Nov 2019 12:47:24 +0000 (UTC) From: Nitesh Narayan Lal To: kvm@vger.kernel.org, pbonzini@redhat.com, thuth@redhat.com, mtosatti@redhat.com Subject: [kvm-unit-tests Patch v1 1/2] x86: ioapic: Add the smp configuration to ioapic unittest Date: Wed, 6 Nov 2019 07:47:08 -0500 Message-Id: <1573044429-7390-2-git-send-email-nitesh@redhat.com> In-Reply-To: <1573044429-7390-1-git-send-email-nitesh@redhat.com> References: <1573044429-7390-1-git-send-email-nitesh@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: 6epujcizPnyPP0ZuD06fpw-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Adds -smp configuration for ioapic unittest. This is essentially required to test IOAPIC Logical destination mode, where we send an interrupt to more than one vcpus at the same time. Signed-off-by: Nitesh Narayan Lal --- x86/unittests.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/x86/unittests.cfg b/x86/unittests.cfg index 5ecb9bb..6ed0b86 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -45,6 +45,7 @@ timeout = 30 [ioapic] file = ioapic.flat +smp = 4 extra_params = -cpu qemu64 arch = x86_64 From patchwork Wed Nov 6 12:47:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitesh Narayan Lal X-Patchwork-Id: 11230225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01B4C1599 for ; Wed, 6 Nov 2019 12:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D17C121882 for ; Wed, 6 Nov 2019 12:47:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C+QUuuPo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731366AbfKFMrk (ORCPT ); Wed, 6 Nov 2019 07:47:40 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47239 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731055AbfKFMrj (ORCPT ); Wed, 6 Nov 2019 07:47:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573044458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oZ5DlZZRn/H8QWvlIUGoovruvTB43OZ3JDNZPnaz2gs=; b=C+QUuuPoyQNYk93PuatZ5t0cSwLRJ6uEm2TayaVQfGaGJMjbFyA6fZXV+KAjYlIeV7PYg8 L/4KaXarRIwWgR0BOkDTmi8Dh91U048W2gyeKiN3NWWGk0/xc0lkUfBtXpoQvhyVddou5a Q012Wa2DEEpuK6iYYaJcXocgZn4G3Vg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-z2Q2i2huO4yiu-HLLVnw9g-1; Wed, 06 Nov 2019 07:47:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3920A1800D6B for ; Wed, 6 Nov 2019 12:47:35 +0000 (UTC) Received: from virtlab512.virt.lab.eng.bos.redhat.com (virtlab512.virt.lab.eng.bos.redhat.com [10.19.152.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6512D600CC; Wed, 6 Nov 2019 12:47:29 +0000 (UTC) From: Nitesh Narayan Lal To: kvm@vger.kernel.org, pbonzini@redhat.com, thuth@redhat.com, mtosatti@redhat.com Subject: [kvm-unit-tests Patch v1 2/2] x86: ioapic: Test physical and logical destination mode Date: Wed, 6 Nov 2019 07:47:09 -0500 Message-Id: <1573044429-7390-3-git-send-email-nitesh@redhat.com> In-Reply-To: <1573044429-7390-1-git-send-email-nitesh@redhat.com> References: <1573044429-7390-1-git-send-email-nitesh@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: z2Q2i2huO4yiu-HLLVnw9g-1 X-Mimecast-Spam-Score: 0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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); + 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(); }