From patchwork Mon Jan 9 23:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 13094497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FA0CC5479D for ; Mon, 9 Jan 2023 23:08:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.474080.735000 (Exim 4.92) (envelope-from ) id 1pF1Fu-0008Eu-4v; Mon, 09 Jan 2023 23:08:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 474080.735000; Mon, 09 Jan 2023 23:08:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pF1Fu-0008En-1S; Mon, 09 Jan 2023 23:08:38 +0000 Received: by outflank-mailman (input) for mailman id 474080; Mon, 09 Jan 2023 23:08:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pF1Fs-0008EZ-Aa for xen-devel@lists.xenproject.org; Mon, 09 Jan 2023 23:08:36 +0000 Received: from sonic313-20.consmr.mail.gq1.yahoo.com (sonic313-20.consmr.mail.gq1.yahoo.com [98.137.65.83]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 897301bb-9072-11ed-91b6-6bf2151ebd3b; Tue, 10 Jan 2023 00:08:34 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Mon, 9 Jan 2023 23:08:31 +0000 Received: by hermes--production-ne1-7b69748c4d-bgkrh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 21a3ec8339abfccbadeaea4f5ef812e7; Mon, 09 Jan 2023 23:08:29 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 897301bb-9072-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1673305711; bh=PUsS/L6kSgEs9TSDYOSdibVZnoomFtUQ/2FTOn4ShZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=elXzfvBDLs+x3PQygRw4UOuVqtKHJNztSmeANXFZPKbkjXODD9HVpM6UngsfZNCsUNy2JDgYBHu+ln6Crtg2AcIwICBkBig4MOQJgkIIALddShN1H8ppOWXhxpZFtNqAuktS00wFZqfg6lJ6O7PfrQUbnQy0ZmqYChoK6Pm/JDcuDg8YuX85J6rdPWZxmc4dFbvcBTZ8lNd98XtbK9IBE9yBkNvF1HtzZ7S1SL46zDEXLUHwWJPNfgXiTkS5gbbxVINtGupzdxS50bsCoBeI//O5rV9YHJX+IKfI4jk4NELWBvL+SQWSxj+i/SA3aO3s1dV/gFfSo1b5xBUMVvwpEg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1673305711; bh=Du1eQd5e3lE/n5cyxqbZF1SqsJq9/TIrud4RmL1t+rv=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=EqV1L9DzWBpmfjNT6DFmkvoslb9Tg0hh8943F8fvkbDYhCgCHBpJqoQVumBZeY08ibePhnHlkXpveZRSrdMUqytQo4u9kfYqyZ4+ckXTdRhBMZv7gbcYA4SVCYJzBsWUZrnkJqGHd6LaUdQljLqlh2ca1JDIcwOebu/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JBiU8lEi.PTkvvrndoMMkcNT FKNq3xtVB9mbkLGjx8sAacZ2EKKgW7CWr00ZiKJ4i1HAr07bBOr3_XHixAPdjvatOjV2v7gZx0Ck aZFUySehhNN1lNz5X8EswtAZFZq5T2lH9HLQ2S4i75t4Q2cNs7ODtY.g3jKIMDhqLn4A9_yKNiGJ XMeJayOJhqZPcG5XrpWz4z9UXG58tS9o_Ya_Dtfa.34.FheRV02vFB6U5PxAmgzQDh8uiUwNSxag oaut6Sy1dy9cuOPNcK6SsGMswTpB5v9zuBBiHSObxx9i.GtyqTuPLrMU5Jvv4un9CeKPy X-Sonic-MF: From: Chuck Zmudzinski To: anthony.perard@citrix.com Cc: xen-devel@lists.xenproject.org, Wei Liu , Juergen Gross , qemu-devel@nongnu.org Subject: [XEN PATCH 1/3] libxl/dm: Use "pc" machine type for Intel IGD passthrough Date: Mon, 9 Jan 2023 18:08:11 -0500 Message-Id: X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 The default qemu upstream "xenfv" machine type that is used when an HVM guest is configured for Intel IGD passthrough assigns slot 2 to the xen platform pci device. It is a requirement that slot 2 be assigned to the Intel IGD when it is passed through as the primary graphics adapter. Using the "pc" machine type instead of the "xenfv" machine type in that case makes it possible for qemu upstream to assign slot 2 to the IGD. Using the qemu "pc" machine and adding the xen platform device on the qemu command line instead of using the qemu "xenfv" machine which automatically adds the xen platform device earlier in the guest creation process does come with some degredation of startup performance: startup is slower and some vga drivers in use during early boot are unable to display the screen at the native resolution of the monitor, but once the guest operating system (Windows or Linux) is fully loaded, there is no noticeable difference in the performance of the guest when using the "pc" machine type instead of the "xenfv" machine type. With this patch, libxl continues to use default "xenfv" machine type with the default settings of xen_platform_pci enabled and igd gfx_passthru disabled. The patch only affects machines configured with gfx_passthru enabled. Signed-off-by: Chuck Zmudzinski --- Reviewers might find this patch easier to review by looking at the resulting code in the patched file instead of looking at the diff because it is hard to follow the logical flow of the resulting code in the diff because the patch moves the check for igd gfx_passthru before the check for disabling the xen platform device. That change was made because it results in a more simplified logical flow in the resulting code. tools/libs/light/libxl_dm.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index fc264a3a13..2048815611 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1809,7 +1809,26 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_args, b_info->extra_pv[i]); break; case LIBXL_DOMAIN_TYPE_HVM: - if (!libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) { + if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { + enum libxl_gfx_passthru_kind gfx_passthru_kind = + libxl__detect_gfx_passthru_kind(gc, guest_config); + switch (gfx_passthru_kind) { + case LIBXL_GFX_PASSTHRU_KIND_IGD: + /* + * Using the machine "pc" because with the default machine "xenfv" + * the xen-platform device will be assigned to slot 2, but with + * GFX_PASSTHRU_KIND_IGD, slot 2 needs to be reserved for the Intel IGD. + */ + machinearg = libxl__strdup(gc, "pc,accel=xen,suppress-vmdesc=on,igd-passthru=on"); + break; + case LIBXL_GFX_PASSTHRU_KIND_DEFAULT: + LOGD(ERROR, guest_domid, "unable to detect required gfx_passthru_kind"); + return ERROR_FAIL; + default: + LOGD(ERROR, guest_domid, "invalid value for gfx_passthru_kind"); + return ERROR_INVAL; + } + } else if (!libxl_defbool_val(b_info->u.hvm.xen_platform_pci)) { /* Switching here to the machine "pc" which does not add * the xen-platform device instead of the default "xenfv" machine. */ @@ -1831,22 +1850,6 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } } - if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { - enum libxl_gfx_passthru_kind gfx_passthru_kind = - libxl__detect_gfx_passthru_kind(gc, guest_config); - switch (gfx_passthru_kind) { - case LIBXL_GFX_PASSTHRU_KIND_IGD: - machinearg = GCSPRINTF("%s,igd-passthru=on", machinearg); - break; - case LIBXL_GFX_PASSTHRU_KIND_DEFAULT: - LOGD(ERROR, guest_domid, "unable to detect required gfx_passthru_kind"); - return ERROR_FAIL; - default: - LOGD(ERROR, guest_domid, "invalid value for gfx_passthru_kind"); - return ERROR_INVAL; - } - } - flexarray_append(dm_args, machinearg); for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) flexarray_append(dm_args, b_info->extra_hvm[i]);