From patchwork Fri Jun 28 20:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 11023697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFB3C1510 for ; Sat, 29 Jun 2019 03:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A97C028846 for ; Sat, 29 Jun 2019 03:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C60D2886B; Sat, 29 Jun 2019 03:53:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D33C28846 for ; Sat, 29 Jun 2019 03:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbfF2DxN (ORCPT ); Fri, 28 Jun 2019 23:53:13 -0400 Received: from mail-pf1-f181.google.com ([209.85.210.181]:38093 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfF2DxM (ORCPT ); Fri, 28 Jun 2019 23:53:12 -0400 Received: by mail-pf1-f181.google.com with SMTP id y15so3928140pfn.5 for ; Fri, 28 Jun 2019 20:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+9qYG8HpSyGgSBE+SHs7lVfiRzAcIP8cCs8Yp2gW3/M=; b=geBE2xNDJAdwhS0VoWpLBSNOSXluklWjtrIUHER3GhIk/GfmVUB/JES+Xn1KOBNTCb W3mYe7Xrrr9Ue7qYp/s31Z+qKYewJd9ZLx9/p2cCtJBIHVOdif1jAKj71cVz8+6OUncL QhUsodlg6PBx90Nw5CJsiU5mDeayV19ybEyX3C2k+/pWbd8qLrhXZVbe8roANR02cORT VROcT+gNoJbfYGe9uQ4N1YHEIDMzr3BX0T0lkb1AE4kr8BSQM8u7CTK1m+6UKm1sMOWh +XvXwcbwXknRwBa5JQkzPm91usGZXGrZD53JaFo6vEcS7opx58sa6ldq9fx6h4m/Xlbp wBIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+9qYG8HpSyGgSBE+SHs7lVfiRzAcIP8cCs8Yp2gW3/M=; b=pjGOXBJo68SNOV3xcetq4x6jyNHd80aYCgmT0yOtEwz97gtze+sVR9/Rvxl2w9RD3X WA7/SlL8I+Se1NM1qU2FlzhV8hC8ocBQm+IgeklWUxrRNICKHuXFw9Dz9YSAYEYqphYU Gz/EWdzyIS8DX0dZHQZ5uLo1KNrectLL3Rsae4Hb8YzqR7vqsbxtINQmVURMo1T9s3AZ z5nSCecNsGm95aAnzTYSE7lGq0PImRBApRQOJgY92XDKi46h3aHSwGmYOwc0fmn86gIZ OGV7cbBab5FHsynbCmH4TW396naVo66bPFTSisJzkx1WuGRZyMltfE5UOJhHSZlC6u4c 3NIA== X-Gm-Message-State: APjAAAWGzaaKHqIiFNLNIOWTN7O1Lq7iUoZ6CSbms3X9q8RhwO0GRwqp ZMGfqivGoAHX4ZChwhZnpWU= X-Google-Smtp-Source: APXvYqx/n9BIsat5VaTVFg7jRmSFl4XF+3JSbwGnOrPYcsNGT4Nam8wgqUXaV4sQT0dNUARdLKIIZg== X-Received: by 2002:a63:78ca:: with SMTP id t193mr12374233pgc.10.1561780392006; Fri, 28 Jun 2019 20:53:12 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id p27sm5597052pfq.136.2019.06.28.20.53.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 20:53:11 -0700 (PDT) From: Nadav Amit To: Paolo Bonzini Cc: kvm@vger.kernel.org, Nadav Amit Subject: [kvm-unit-tests PATCH 1/3] libcflat: use stdbool Date: Fri, 28 Jun 2019 13:30:17 -0700 Message-Id: <20190628203019.3220-2-nadav.amit@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628203019.3220-1-nadav.amit@gmail.com> References: <20190628203019.3220-1-nadav.amit@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To avoid any future build errors, using stdbool instead of defining bool. Signed-off-by: Nadav Amit --- lib/libcflat.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/libcflat.h b/lib/libcflat.h index 7529958..b94d0ac 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -24,6 +24,7 @@ #include #include #include +#include #define __unused __attribute__((__unused__)) @@ -53,10 +54,6 @@ typedef uint64_t u64; typedef int64_t s64; typedef unsigned long ulong; -typedef _Bool bool; -#define false 0 -#define true 1 - #if __SIZEOF_LONG__ == 8 # define __PRI32_PREFIX # define __PRI64_PREFIX "l" From patchwork Fri Jun 28 20:30:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 11023699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 175F2746 for ; Sat, 29 Jun 2019 03:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FE3128846 for ; Sat, 29 Jun 2019 03:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 040EF2886B; Sat, 29 Jun 2019 03:53:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C58628846 for ; Sat, 29 Jun 2019 03:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbfF2DxO (ORCPT ); Fri, 28 Jun 2019 23:53:14 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37942 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfF2DxO (ORCPT ); Fri, 28 Jun 2019 23:53:14 -0400 Received: by mail-pl1-f194.google.com with SMTP id 9so3534609ple.5 for ; Fri, 28 Jun 2019 20:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kg9cnhfWN92/dS8254v6me5wI97CqKprJYMTUglwb9U=; b=MGP5B2704yGyNXdggsl8qxtBCfU+GUokWXioeIOLudoFxBYsSQPOsXG2AaJ28cYCEc FRgt3d5/50IAiH1teixRxEH6ZsTNJQws51ejZBCA1sXV4ksQk/wppB2I4mUgks+Lk8iM w/WksduNTI4fcUhCfXZYkgf4HjniJy5RW+4GBfp+puJJCb4p9P8saHWg02mObpdfimPb +1NSUyhic0e7e+btphdsj0joGMcuYEMDYTY1HD1T4/ZVdTxItI4FYA0xWB/tzWLwiisA 6jvHnqQnJOQiB3CGu+ksSBT0pwYGnW+J8YUOzK5xVL6/cBuv1hDGq6htRMXKhcN2Wo4z nRdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kg9cnhfWN92/dS8254v6me5wI97CqKprJYMTUglwb9U=; b=T9uxv1YVEBMzo4oqCwWtsh5lwiIHvmW7GrXa+rrwZZmwmiXlLULMWGNeDtUtYf+jpG rSG9WtqIVEutntcgHEOS43x+OOP0yAKmonrE70Lth/ER38C89deUwcY+TidzIv2BtXro Yu+PoIz5boVDNYoJ9YQxVbUpz3NRnqdS7R+9aTode8Uk3lD4295QMyVshfUUQjXfmnE3 QtXm7kvrEHg7bdlIIZJpfkinVN/AkMhvZHaNjx5tzv6l3JRZXs/57MCdgaOc3pYxFWwu iVmXPpo1UfWc3UX6eEj3nsFVkmFkRPx1mTbITcE36L/YQqocIDFzAsSlOeR30loQdY/x KH7Q== X-Gm-Message-State: APjAAAVlxXgtIphj1LOQgaLojv8pO9F76polqGLsL1hTybjMmEh0XEmY kV3mMve7oVXkECO98DYqtMc= X-Google-Smtp-Source: APXvYqxXnEIEy73Hu/wps0mZPeVGh0ERbrnCDlsFuZbsCHjP6WGG9kovK/qdqSC28dlPTNNYVQxD2A== X-Received: by 2002:a17:902:7295:: with SMTP id d21mr14474835pll.299.1561780393221; Fri, 28 Jun 2019 20:53:13 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id p27sm5597052pfq.136.2019.06.28.20.53.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 20:53:12 -0700 (PDT) From: Nadav Amit To: Paolo Bonzini Cc: kvm@vger.kernel.org, Nadav Amit Subject: [kvm-unit-tests PATCH 2/3] x86/vmx: Use plus for positive filters Date: Fri, 28 Jun 2019 13:30:18 -0700 Message-Id: <20190628203019.3220-3-nadav.amit@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628203019.3220-1-nadav.amit@gmail.com> References: <20190628203019.3220-1-nadav.amit@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To introduce general boot parameters, avoid vmx boot parameters from colliding with the general ones. Precede the vmx test names with a plus sign ('+') to indicate a test should be executed in vmx, and ignore those that are not preceded with '-' or '+'. Signed-off-by: Nadav Amit --- x86/unittests.cfg | 32 ++++++++++++++++---------------- x86/vmx.c | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/x86/unittests.cfg b/x86/unittests.cfg index 694ee3d..dc7a85d 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -58,55 +58,55 @@ smp = 3 [vmexit_cpuid] file = vmexit.flat -extra_params = -append 'cpuid' +extra_params = -append '+cpuid' groups = vmexit [vmexit_vmcall] file = vmexit.flat -extra_params = -append 'vmcall' +extra_params = -append '+vmcall' groups = vmexit [vmexit_mov_from_cr8] file = vmexit.flat -extra_params = -append 'mov_from_cr8' +extra_params = -append '+mov_from_cr8' groups = vmexit [vmexit_mov_to_cr8] file = vmexit.flat -extra_params = -append 'mov_to_cr8' +extra_params = -append '+mov_to_cr8' groups = vmexit [vmexit_inl_pmtimer] file = vmexit.flat -extra_params = -append 'inl_from_pmtimer' +extra_params = -append '+inl_from_pmtimer' groups = vmexit [vmexit_ipi] file = vmexit.flat smp = 2 -extra_params = -append 'ipi' +extra_params = -append '+ipi' groups = vmexit [vmexit_ipi_halt] file = vmexit.flat smp = 2 -extra_params = -append 'ipi_halt' +extra_params = -append '+ipi_halt' groups = vmexit [vmexit_ple_round_robin] file = vmexit.flat -extra_params = -append 'ple_round_robin' +extra_params = -append '+ple_round_robin' groups = vmexit [vmexit_tscdeadline] file = vmexit.flat groups = vmexit -extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append tscdeadline +extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append '+tscdeadline' [vmexit_tscdeadline_immed] file = vmexit.flat groups = vmexit -extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append tscdeadline_immed +extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append '+tscdeadline_immed' [access] file = access.flat @@ -233,27 +233,27 @@ groups = vmx [ept] file = vmx.flat -extra_params = -cpu host,host-phys-bits,+vmx -m 2560 -append "ept_access*" +extra_params = -cpu host,host-phys-bits,+vmx -m 2560 -append "+ept_access*" arch = x86_64 groups = vmx [vmx_eoi_bitmap_ioapic_scan] file = vmx.flat smp = 2 -extra_params = -cpu host,+vmx -m 2048 -append vmx_eoi_bitmap_ioapic_scan_test +extra_params = -cpu host,+vmx -m 2048 -append '+vmx_eoi_bitmap_ioapic_scan_test' arch = x86_64 groups = vmx [vmx_hlt_with_rvi_test] file = vmx.flat -extra_params = -cpu host,+vmx -append vmx_hlt_with_rvi_test +extra_params = -cpu host,+vmx -append '+vmx_hlt_with_rvi_test' arch = x86_64 groups = vmx timeout = 10 [vmx_apicv_test] file = vmx.flat -extra_params = -cpu host,+vmx -append "apic_reg_virt_test virt_x2apic_mode_test" +extra_params = -cpu host,+vmx -append "+apic_reg_virt_test +virt_x2apic_mode_test" arch = x86_64 groups = vmx timeout = 10 @@ -261,13 +261,13 @@ timeout = 10 [vmx_apic_passthrough_thread] file = vmx.flat smp = 2 -extra_params = -cpu host,+vmx -m 2048 -append vmx_apic_passthrough_thread_test +extra_params = -cpu host,+vmx -m 2048 -append '+vmx_apic_passthrough_thread_test' arch = x86_64 groups = vmx [vmx_vmcs_shadow_test] file = vmx.flat -extra_params = -cpu host,+vmx -append vmx_vmcs_shadow_test +extra_params = -cpu host,+vmx -append '+vmx_vmcs_shadow_test' arch = x86_64 groups = vmx diff --git a/x86/vmx.c b/x86/vmx.c index 872ba11..1aa1ade 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -1894,9 +1894,9 @@ test_wanted(const char *name, const char *filters[], int filter_count) if (filter[0] == '-') { if (simple_glob(clean_name, filter + 1)) return false; - } else { + } else if (filter[0] == '+') { positive = true; - match |= simple_glob(clean_name, filter); + match |= simple_glob(clean_name, filter + 1); } } From patchwork Fri Jun 28 20:30:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 11023701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F324746 for ; Sat, 29 Jun 2019 03:53:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88BC228846 for ; Sat, 29 Jun 2019 03:53:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D5632886B; Sat, 29 Jun 2019 03:53:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA41D28846 for ; Sat, 29 Jun 2019 03:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbfF2DxP (ORCPT ); Fri, 28 Jun 2019 23:53:15 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35456 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfF2DxP (ORCPT ); Fri, 28 Jun 2019 23:53:15 -0400 Received: by mail-pg1-f195.google.com with SMTP id s27so3434817pgl.2 for ; Fri, 28 Jun 2019 20:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yWDeegBe6xR4hlYDTfrosMBm1oewm2DmKR+PQ/GXUs8=; b=MweNHHYX26/weYiecQB2jfpx3L0w4UQwl2UvaEB05nW51XzI/rESMdcyE+7lD+292c yDTZP4SFS65vI/1+vhvlnrXZlGSIyJVXhcwX5XrDrNDQZqbAJ8NmPe9HQzE89uszFT/Z 44c3qU15ErxDLFmRl6npBTgvR+QD4tM8AB2nYAc2Qv4yk9y1j8PFXroU1Q6lpL0HFqV0 jowbtMH11xcFucPEafjYNH+lffWqvwpt+poh+IVw/w8+s3kvsG1es1QUguAhNi+DVbEq SOQwsoZiWArb/+7fA0lQOqpG2vhkS3O5GurDzLYVYhDiZdBeIaE5vvGOf+sTTlvcnC+Y vJcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yWDeegBe6xR4hlYDTfrosMBm1oewm2DmKR+PQ/GXUs8=; b=dk9N1osOxyxy1DnOArIp5b1nyjGolLGdXKTc7tfeSr9sva/IvINFJiDHHOzmvXwIsH XZ5X7NdHvc2XqbqrmvE0iUDA8x8SJ5bGKJ1q9AEtKmlCo2vYbEtfGotF90vZCJ5P/ZpN mMHGBbdcDXONCuMrAOUxC1xLsBqwyL9Hjk22eTestH6hgtm0nLmZpfW37JS+8Qb1y180 G4XqBv7AkneBKIVgL8BV7j2vKUaS9ZDHvFYAQtfwQC8IFbyBODUqqPInYcE/Ez8shdmy LXh9YgBEhz4DKQ2qlMxrwJcYJvx5hSfro6jPFaqXsQqNZSRXJW9oaRbpEvCmSFMRsLcZ V9sA== X-Gm-Message-State: APjAAAWHet9RrCjjgv+vedeIegHQteTLzHdAnDQ8COPGwgNcAMUtk17c hpiMIpNlavS83ARBZbOSEaM= X-Google-Smtp-Source: APXvYqxrqy37dytgYCNQsjSezo4t3/oLS3pG8cvLHPu/OLQnF2qktbZZABqeakuhPwWs1SgLKEEO3A== X-Received: by 2002:a17:90a:20c6:: with SMTP id f64mr17346598pjg.57.1561780394391; Fri, 28 Jun 2019 20:53:14 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id p27sm5597052pfq.136.2019.06.28.20.53.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 20:53:13 -0700 (PDT) From: Nadav Amit To: Paolo Bonzini Cc: kvm@vger.kernel.org, Nadav Amit Subject: [kvm-unit-tests PATCH 3/3] x86: Support environments without test-devices Date: Fri, 28 Jun 2019 13:30:19 -0700 Message-Id: <20190628203019.3220-4-nadav.amit@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628203019.3220-1-nadav.amit@gmail.com> References: <20190628203019.3220-1-nadav.amit@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable to run the tests when test-device is not present (e.g., bare-metal). Users can provide the number of CPUs and ram size through kernel parameters. On Ubuntu, for example, the tests can be run by copying a test to the boot directory (/boot) and adding a menuentry to grub (editing /etc/grub.d/40_custom): menuentry 'idt_test' { set root='ROOT' multiboot BOOT_RELATIVE/idt_test.flat ignore nb_cpus=48 \ ram_size=4294967296 no-test-device } Replace ROOT with `grub-probe --target=bios_hints /boot` and BOOT_RELATIVE with `grub-mkrelpath /boot`, and run update-grub. Note that the first kernel parameter is ignored for compatibility with test executions through QEMU. Remember that the output goes to the serial port. Signed-off-by: Nadav Amit Signed-off-by: Nadav Amit --- lib/x86/fwcfg.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/x86/fwcfg.h | 4 ++++ x86/apic.c | 4 +++- x86/cstart64.S | 13 ++++++++--- x86/eventinj.c | 20 ++++++++++++---- x86/vmx_tests.c | 7 ++++++ 6 files changed, 102 insertions(+), 8 deletions(-) diff --git a/lib/x86/fwcfg.c b/lib/x86/fwcfg.c index c52b445..8d320e2 100644 --- a/lib/x86/fwcfg.c +++ b/lib/x86/fwcfg.c @@ -1,14 +1,76 @@ #include "fwcfg.h" #include "smp.h" +#include "libcflat.h" static struct spinlock lock; +struct fw_override_val { + bool initialized; + uint64_t val; +}; + +static struct fw_override_val fw_override[FW_CFG_MAX_ENTRY]; + +static const char *cfg_names[FW_CFG_MAX_ENTRY] = { + [FW_CFG_NB_CPUS] = "nb_cpus", + [FW_CFG_RAM_SIZE] = "ram_size", +}; + +bool no_test_device; + +void read_cfg_override(int argc, const char *argv[]) +{ + int i, j; + + /* Check if there is no test device */ + for (j = 0; j < argc; j++) { + const char *arg = argv[j]; + + if (!strcmp("no-test-device", arg)) { + no_test_device = true; + continue; + } + + for (i = 0; i < FW_CFG_MAX_ENTRY; i++) { + const char *cfg_name = cfg_names[i]; + size_t name_len; + + name_len = strlen(cfg_name); + + if (cfg_name == NULL) + continue; + + name_len = strlen(cfg_name); + + if (strncmp(cfg_name, arg, name_len)) + continue; + if (arg[name_len] != '=') + continue; + if (strlen(arg) <= name_len + 1) + continue; + + fw_override[i].val = atol(arg + name_len + 1); + fw_override[i].initialized = true; + + printf("cfg-override: %s = 0x%lx\n", cfg_name, fw_override[i].val); + } + } +} + +bool test_device_enabled(void) +{ + return !no_test_device; +} + static uint64_t fwcfg_get_u(uint16_t index, int bytes) { uint64_t r = 0; uint8_t b; int i; + if (fw_override[index].initialized) + return fw_override[index].val; + spin_lock(&lock); asm volatile ("out %0, %1" : : "a"(index), "d"((uint16_t)BIOS_CFG_IOPORT)); for (i = 0; i < bytes; ++i) { diff --git a/lib/x86/fwcfg.h b/lib/x86/fwcfg.h index e0836ca..14801d7 100644 --- a/lib/x86/fwcfg.h +++ b/lib/x86/fwcfg.h @@ -2,6 +2,7 @@ #define FWCFG_H #include +#include #define FW_CFG_SIGNATURE 0x00 #define FW_CFG_ID 0x01 @@ -33,6 +34,9 @@ #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1) #define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2) +void read_cfg_override(int argc, const char *argv[]); +bool test_device_enabled(void); + uint8_t fwcfg_get_u8(unsigned index); uint16_t fwcfg_get_u16(unsigned index); uint32_t fwcfg_get_u32(unsigned index); diff --git a/x86/apic.c b/x86/apic.c index 7617351..f01a5e7 100644 --- a/x86/apic.c +++ b/x86/apic.c @@ -6,6 +6,7 @@ #include "isr.h" #include "msr.h" #include "atomic.h" +#include "fwcfg.h" #define MAX_TPR 0xf @@ -655,7 +656,8 @@ int main(void) test_self_ipi(); test_physical_broadcast(); - test_pv_ipi(); + if (test_device_enabled()) + test_pv_ipi(); test_sti_nmi(); test_multiple_nmi(); diff --git a/x86/cstart64.S b/x86/cstart64.S index 9d89887..cc7926a 100644 --- a/x86/cstart64.S +++ b/x86/cstart64.S @@ -244,9 +244,6 @@ start64: call load_tss call mask_pic_interrupts call enable_apic - call save_id - call smp_init - call enable_x2apic mov mb_boot_info(%rip), %rbx mov %rbx, %rdi call setup_multiboot @@ -254,6 +251,16 @@ start64: mov mb_cmdline(%rbx), %eax mov %rax, __args(%rip) call __setup_args + + /* read configuration override */ + mov __argc(%rip), %edi + lea __argv(%rip), %rsi + call read_cfg_override + + call save_id + call smp_init + call enable_x2apic + mov __argc(%rip), %edi lea __argv(%rip), %rsi lea __environ(%rip), %rdx diff --git a/x86/eventinj.c b/x86/eventinj.c index 901b9db..9e4dbec 100644 --- a/x86/eventinj.c +++ b/x86/eventinj.c @@ -8,6 +8,7 @@ #include "vmalloc.h" #include "alloc_page.h" #include "delay.h" +#include "fwcfg.h" #ifdef __x86_64__ # define R "r" @@ -28,10 +29,15 @@ static void apic_self_nmi(void) apic_icr_write(APIC_DEST_PHYSICAL | APIC_DM_NMI | APIC_INT_ASSERT, 0); } -#define flush_phys_addr(__s) outl(__s, 0xe4) +#define flush_phys_addr(__s) do { \ + if (test_device_enabled()) \ + outl(__s, 0xe4); \ + } while (0) + #define flush_stack() do { \ int __l; \ - flush_phys_addr(virt_to_phys(&__l)); \ + if (test_device_enabled()) \ + flush_phys_addr(virt_to_phys(&__l)); \ } while (0) extern char isr_iret_ip[]; @@ -136,6 +142,8 @@ extern void do_iret(ulong phys_stack, void *virt_stack); // Return to same privilege level won't pop SS or SP, so // save it in RDX while we run on the nested stack +extern bool no_test_device; + asm("do_iret:" #ifdef __x86_64__ "mov %rdi, %rax \n\t" // phys_stack @@ -148,10 +156,14 @@ asm("do_iret:" "pushf"W" \n\t" "mov %cs, %ecx \n\t" "push"W" %"R "cx \n\t" - "push"W" $1f \n\t" + "push"W" $2f \n\t" + + "cmpb $0, no_test_device\n\t" // see if need to flush + "jnz 1f\n\t" "outl %eax, $0xe4 \n\t" // flush page + "1: \n\t" "iret"W" \n\t" - "1: xchg %"R "dx, %"R "sp \n\t" // point to old stack + "2: xchg %"R "dx, %"R "sp \n\t" // point to old stack "ret\n\t" ); diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index c51de1c..5709fa8 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -8017,6 +8017,13 @@ static void vmx_apic_passthrough(bool set_irq_line_from_thread) return; } + /* + * Test device required for generating IRQs + */ + if (!test_device_enabled()) { + report_skip(__func__); + return; + } u64 cpu_ctrl_0 = CPU_SECONDARY; u64 cpu_ctrl_1 = 0;