From patchwork Fri Jan 25 18:07:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781807 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 9F8C41515 for ; Fri, 25 Jan 2019 18:08:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9015B302F7 for ; Fri, 25 Jan 2019 18:08:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8415E30359; Fri, 25 Jan 2019 18:08:11 +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=-7.9 required=2.0 tests=BAYES_00,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 1DCE8302F7 for ; Fri, 25 Jan 2019 18:08:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729504AbfAYSIK (ORCPT ); Fri, 25 Jan 2019 13:08:10 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51952 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729322AbfAYSII (ORCPT ); Fri, 25 Jan 2019 13:08:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 80F621596; Fri, 25 Jan 2019 10:08:08 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 95D053F5AF; Fri, 25 Jan 2019 10:08:07 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 1/6] arm: turn pr_info() into pr_debug() messages Date: Fri, 25 Jan 2019 18:07:56 +0000 Message-Id: <20190125180801.209910-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For whatever reason on ARM/arm64 machines kvmtool greets us with quite some elaborate messages: Info: Loaded kernel to 0x80080000 (18704896 bytes) Info: Placing fdt at 0x8fe00000 - 0x8fffffff Info: virtio-mmio.devices=0x200@0x10000:36 Info: virtio-mmio.devices=0x200@0x10200:37 Info: virtio-mmio.devices=0x200@0x10400:38 This is not really useful information for the casual user, so change those lines to use pr_debug(). This also fixes the long standing line ending issue for the mmio output. Signed-off-by: Andre Przywara --- arm/fdt.c | 2 +- arm/kvm.c | 16 ++++++++-------- virtio/mmio.c | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arm/fdt.c b/arm/fdt.c index 980015b4..28ba1c2c 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -36,7 +36,7 @@ static void dump_fdt(const char *dtb_file, void *fdt) if (count < 0) die_perror("Failed to dump dtb"); - pr_info("Wrote %d bytes to dtb %s\n", count, dtb_file); + pr_debug("Wrote %d bytes to dtb %s", count, dtb_file); close(fd); } diff --git a/arm/kvm.c b/arm/kvm.c index b824f637..8dc6989c 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -113,8 +113,8 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, die_perror("kernel read"); } kernel_end = pos + file_size; - pr_info("Loaded kernel to 0x%llx (%zd bytes)", - kvm->arch.kern_guest_start, file_size); + pr_debug("Loaded kernel to 0x%llx (%zd bytes)", + kvm->arch.kern_guest_start, file_size); /* * Now load backwards from the end of memory so the kernel @@ -129,9 +129,9 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, die("fdt overlaps with kernel image."); kvm->arch.dtb_guest_start = guest_addr; - pr_info("Placing fdt at 0x%llx - 0x%llx", - kvm->arch.dtb_guest_start, - host_to_guest_flat(kvm, limit)); + pr_debug("Placing fdt at 0x%llx - 0x%llx", + kvm->arch.dtb_guest_start, + host_to_guest_flat(kvm, limit)); limit = pos; /* ... and finally the initrd, if we have one. */ @@ -159,9 +159,9 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd, kvm->arch.initrd_guest_start = initrd_start; kvm->arch.initrd_size = file_size; - pr_info("Loaded initrd to 0x%llx (%llu bytes)", - kvm->arch.initrd_guest_start, - kvm->arch.initrd_size); + pr_debug("Loaded initrd to 0x%llx (%llu bytes)", + kvm->arch.initrd_guest_start, + kvm->arch.initrd_size); } else { kvm->arch.initrd_size = 0; } diff --git a/virtio/mmio.c b/virtio/mmio.c index 8c0f1cc1..9e0cd05d 100644 --- a/virtio/mmio.c +++ b/virtio/mmio.c @@ -307,7 +307,8 @@ int virtio_mmio_init(struct kvm *kvm, void *dev, struct virtio_device *vdev, * * virtio_mmio.devices=0x200@0xd2000000:5,0x200@0xd2000200:6 */ - pr_info("virtio-mmio.devices=0x%x@0x%x:%d\n", VIRTIO_MMIO_IO_SIZE, vmmio->addr, vmmio->irq); + pr_debug("virtio-mmio.devices=0x%x@0x%x:%d", VIRTIO_MMIO_IO_SIZE, + vmmio->addr, vmmio->irq); return 0; } From patchwork Fri Jan 25 18:07:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781809 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 D9C811399 for ; Fri, 25 Jan 2019 18:08:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9ED3302F7 for ; Fri, 25 Jan 2019 18:08:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE45B30358; Fri, 25 Jan 2019 18:08:12 +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=-7.9 required=2.0 tests=BAYES_00,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 6F905302F7 for ; Fri, 25 Jan 2019 18:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729509AbfAYSIL (ORCPT ); Fri, 25 Jan 2019 13:08:11 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51964 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729497AbfAYSIK (ORCPT ); Fri, 25 Jan 2019 13:08:10 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A967E1650; Fri, 25 Jan 2019 10:08:09 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE5E63F5AF; Fri, 25 Jan 2019 10:08:08 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 2/6] arm: fdt: add stdout-path to /chosen node Date: Fri, 25 Jan 2019 18:07:57 +0000 Message-Id: <20190125180801.209910-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DT spec describes the stdout-path property in the /chosen node to contain the DT path for a default device usable for outputting characters. The Linux kernel uses this for earlycon (without further parameters), other DT users might rely on this as well. Add a property containing the path to our emulated 8250 serial device. Even when we use the virtio console, the serial console is still there and works, so we can expose this unconditionally. Putting the virtio console path in there will not work anyway. Signed-off-by: Andre Przywara --- arm/fdt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arm/fdt.c b/arm/fdt.c index 28ba1c2c..8cda3ded 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -143,6 +143,7 @@ static int setup_fdt(struct kvm *kvm) _FDT(fdt_property_cell(fdt, "linux,pci-probe-only", 1)); _FDT(fdt_property_string(fdt, "bootargs", kvm->cfg.real_cmdline)); _FDT(fdt_property_u64(fdt, "kaslr-seed", kvm->cfg.arch.kaslr_seed)); + _FDT(fdt_property_string(fdt, "stdout-path", "/U6_16550A@3f8")); /* Initrd */ if (kvm->arch.initrd_size != 0) { From patchwork Fri Jan 25 18:07:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781813 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 BAED91399 for ; Fri, 25 Jan 2019 18:08:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6FBB302F7 for ; Fri, 25 Jan 2019 18:08:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B6923033E; Fri, 25 Jan 2019 18:08:15 +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=-7.9 required=2.0 tests=BAYES_00,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 4FA4030368 for ; Fri, 25 Jan 2019 18:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729521AbfAYSIN (ORCPT ); Fri, 25 Jan 2019 13:08:13 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51974 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbfAYSIL (ORCPT ); Fri, 25 Jan 2019 13:08:11 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D51171596; Fri, 25 Jan 2019 10:08:10 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E717A3F5AF; Fri, 25 Jan 2019 10:08:09 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 3/6] Makefile: support -s switch Date: Fri, 25 Jan 2019 18:07:58 +0000 Message-Id: <20190125180801.209910-4-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "make -s" suppresses normal output, just shows warnings and errors. But since we explicitly override the make output with our fancy concise version, we miss out on this feature. Do as the kernel does and explicitly suppress every normal output when -s is given. This helps to spot warnings that scroll out of the terminal window too quickly. Signed-off-by: Andre Przywara --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c4faff66..a68cfcd5 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,22 @@ # Define WERROR=0 to disable -Werror. # +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) + silent=1 +endif +else # make-3.8x +ifneq ($(filter s% -s%,$(MAKEFLAGS)),) + silent=1 +endif +endif + ifeq ($(strip $(V)),) - E = @echo + ifeq ($(silent),) + E = @echo + else + E = @\# + endif Q = @ else E = @\# From patchwork Fri Jan 25 18:07:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781811 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 54F2E13B4 for ; Fri, 25 Jan 2019 18:08:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4556C302F7 for ; Fri, 25 Jan 2019 18:08:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3976430359; Fri, 25 Jan 2019 18:08:15 +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=-7.9 required=2.0 tests=BAYES_00,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 17841302F7 for ; Fri, 25 Jan 2019 18:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbfAYSIN (ORCPT ); Fri, 25 Jan 2019 13:08:13 -0500 Received: from foss.arm.com ([217.140.101.70]:51982 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729512AbfAYSIM (ORCPT ); Fri, 25 Jan 2019 13:08:12 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0AD25EBD; Fri, 25 Jan 2019 10:08:12 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E98D3F5AF; Fri, 25 Jan 2019 10:08:10 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 4/6] Makefile: Remove echoing of kvmtools version file Date: Fri, 25 Jan 2019 18:07:59 +0000 Message-Id: <20190125180801.209910-5-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On every build we report the kvmtool "version" number, which isn't meaningful at all anymore. Remove the line from the KVMTOOLS-VERSION-GEN script to drop a pointless message. Signed-off-by: Andre Przywara --- util/KVMTOOLS-VERSION-GEN | 1 - 1 file changed, 1 deletion(-) diff --git a/util/KVMTOOLS-VERSION-GEN b/util/KVMTOOLS-VERSION-GEN index f0dcfdea..91ee2c2f 100755 --- a/util/KVMTOOLS-VERSION-GEN +++ b/util/KVMTOOLS-VERSION-GEN @@ -35,6 +35,5 @@ else VC=unset fi test "$VN" = "$VC" || { - echo >&2 "KVMTOOLS_VERSION = $VN" echo "KVMTOOLS_VERSION = $VN" >$GVF } From patchwork Fri Jan 25 18:08:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781819 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 39E3E1399 for ; Fri, 25 Jan 2019 18:08:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28856302CF for ; Fri, 25 Jan 2019 18:08:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D212302F7; Fri, 25 Jan 2019 18:08:27 +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=-7.9 required=2.0 tests=BAYES_00,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 C951A302CF for ; Fri, 25 Jan 2019 18:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729524AbfAYSIR (ORCPT ); Fri, 25 Jan 2019 13:08:17 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51986 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729497AbfAYSIN (ORCPT ); Fri, 25 Jan 2019 13:08:13 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 32A691596; Fri, 25 Jan 2019 10:08:13 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 474153F5AF; Fri, 25 Jan 2019 10:08:12 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 5/6] arm: pmu: Improve PMU error reporting Date: Fri, 25 Jan 2019 18:08:00 +0000 Message-Id: <20190125180801.209910-6-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The KVM ioctls mostly just return -1 in the error case, leaving the actual error code in errno. Change the output of the PMU error message to actually print this error code instead of the generic -1. Signed-off-by: Andre Przywara --- arm/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arm/pmu.c b/arm/pmu.c index 69c37fae..ffd152e2 100644 --- a/arm/pmu.c +++ b/arm/pmu.c @@ -18,7 +18,7 @@ static int set_pmu_attr(struct kvm *kvm, int vcpu_idx, if (!ret) { ret = ioctl(fd, KVM_SET_DEVICE_ATTR, attr); if (ret) - pr_err("PMU KVM_SET_DEVICE_ATTR failed (%d)\n", ret); + perror("PMU KVM_SET_DEVICE_ATTR failed"); } else { pr_err("Unsupported PMU on vcpu%d\n", vcpu_idx); } From patchwork Fri Jan 25 18:08:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10781815 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 3401713B4 for ; Fri, 25 Jan 2019 18:08:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2467C302F7 for ; Fri, 25 Jan 2019 18:08:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 184CF30358; Fri, 25 Jan 2019 18:08: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=-7.9 required=2.0 tests=BAYES_00,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 A8FB4302F7 for ; Fri, 25 Jan 2019 18:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729526AbfAYSIQ (ORCPT ); Fri, 25 Jan 2019 13:08:16 -0500 Received: from foss.arm.com ([217.140.101.70]:51992 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729523AbfAYSIO (ORCPT ); Fri, 25 Jan 2019 13:08:14 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B2B9EBD; Fri, 25 Jan 2019 10:08:14 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7003A3F5AF; Fri, 25 Jan 2019 10:08:13 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH kvmtool 6/6] arm: Auto-detect guest GIC type Date: Fri, 25 Jan 2019 18:08:01 +0000 Message-Id: <20190125180801.209910-7-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190125180801.209910-1-andre.przywara@arm.com> References: <20190125180801.209910-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At the moment kvmtool always tries to instantiate a virtual GICv2 for the guest, and fails with some scary error message if that doesn't work. The user has then to manually specify "--irqchip=gicv3", which is not really obvious. With the advent of more GICv3-only machines, let's try to be more clever and implement some auto-detection of the GIC type needed: - We try GICv3 first. On GICv3-only hosts this will be the only working option, so we don't loose anything. On GICv2-backwards compatible GICv3 machines GICv3 is probably the better choice these days. - If that fails, we try GICv2. - If that fails, we ran out out options and bail out. We deduce the choice between "ITS vs. pure GICv3" and "GICv2m vs. GICv2" by the presence of PCI devices, they would be the only MSI users anyway. This algorithm is in effect is there is no explicit --irqchip parameter on the command line. We still allow the GIC type to be set explicitly. Signed-off-by: Andre Przywara --- arm/gic.c | 25 +++++++++++++++++++++++++ arm/include/arm-common/gic.h | 1 + 2 files changed, 26 insertions(+) diff --git a/arm/gic.c b/arm/gic.c index abcbcc09..e6b66047 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -182,6 +182,8 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type) gic_device.type = KVM_DEV_TYPE_ARM_VGIC_V3; dist_attr.attr = KVM_VGIC_V3_ADDR_TYPE_DIST; break; + case IRQCHIP_AUTO: + return -ENODEV; } err = ioctl(kvm->vm_fd, KVM_CREATE_DEVICE, &gic_device); @@ -199,6 +201,8 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type) case IRQCHIP_GICV3: err = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &redist_attr); break; + case IRQCHIP_AUTO: + return -ENODEV; } if (err) goto out_err; @@ -249,9 +253,30 @@ static int gic__create_irqchip(struct kvm *kvm) int gic__create(struct kvm *kvm, enum irqchip_type type) { + enum irqchip_type try; + bool needs_msis; int err; switch (type) { + case IRQCHIP_AUTO: + needs_msis = kvm->cfg.arch.virtio_trans_pci; + if (needs_msis) + try = IRQCHIP_GICV3_ITS; + else + try = IRQCHIP_GICV3; + err = gic__create(kvm, try); + if (!err) { + kvm->cfg.arch.irqchip = try; + return 0; + } + if (needs_msis) + try = IRQCHIP_GICV2M; + else + try = IRQCHIP_GICV2; + err = gic__create(kvm, try); + if (!err) + kvm->cfg.arch.irqchip = try; + return err; case IRQCHIP_GICV2M: gic_msi_size = KVM_VGIC_V2M_SIZE; gic_msi_base = ARM_GIC_CPUI_BASE - gic_msi_size; diff --git a/arm/include/arm-common/gic.h b/arm/include/arm-common/gic.h index 1125d601..ec9cf31a 100644 --- a/arm/include/arm-common/gic.h +++ b/arm/include/arm-common/gic.h @@ -24,6 +24,7 @@ #define KVM_VGIC_V2M_SIZE 0x1000 enum irqchip_type { + IRQCHIP_AUTO, IRQCHIP_GICV2, IRQCHIP_GICV2M, IRQCHIP_GICV3,