From mboxrd@z Thu Jan 1 00:00:00 1970 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 14340C5479D for ; Mon, 9 Jan 2023 23:09:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF1Fu-0008HO-Sg; Mon, 09 Jan 2023 18:08:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF1Fs-0008Gc-SP for qemu-devel@nongnu.org; Mon, 09 Jan 2023 18:08:36 -0500 Received: from sonic313-20.consmr.mail.gq1.yahoo.com ([98.137.65.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF1Fq-0003cX-Rd for qemu-devel@nongnu.org; Mon, 09 Jan 2023 18:08:36 -0500 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/JDcuDg8YuX85J6rdPWZxmc4dFbvcBTZ8lNd98XtbK9IBE9yBkNvF1HtzZ7S1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T1p1CWJ_EaVxHi76Vu5.5SuD.QCMOHnZKhzYydG0QVA8hTMSzAv8.FrVFubj1zAsvzhc4 Wv7evMcbCTkZVnQIKLUvfFiWUYcTATWbTYB72kTqwuiag34m9DTdF3TGv3usYpNCufF8L.PSXZbu YG7onspgwGcxqrBYJ72t_xZ07YyzgZX2ao1yl1U.dcUkbbHYPdtr.ThkapBpFfuTLoxxfqU70ug2 cHmSgF9Ftgxb8tXIQsWjGJFt8F5pZJukq8h3ymGMywD35Ga1SFcxNLjwDmuZufEXJfsm4qlF_8gy FMZTnw80uNNLhAKM0XqaZpO2LuFC5JicviG0wilgsRH9kepIKWlwy3JqfUJtk2Ppsvqei0yumIhk ixUKrFiSOAEDyutmFkY6_VHIDLSoiC6CWmwyB5cYSPLLeL0oPpg0JBiU8lEi.PTkvvrndoMMkcNT FKNq3xtVB9mbkLGjx8sAacZ2EKKgW7CWr00ZiKJ4i1HAr07bBOr3_XHixAPdjvatOjV2v7gZx0Ck aZFUySehhNN1lNz5X8EswtAZFZq5T2lH9HLQ2S4i75t4Q2cNs7ODtY.g3jKIMDhqLn4A9_yKNiGJ XMeJayOJhqZPcG5XrpWz4z9UXG58tS9o_Ya_Dtfa.34.FheRV02vFB6U5PxAmgzQDh8uiUwNSxag oaut6Sy1dy9cuOPNcK6SsGMswTpB5v9zuBBiHSObxx9i.GtyqTuPLrMU5Jvv4un9CeKPy X-Sonic-MF: 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) 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 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=98.137.65.83; envelope-from=brchuckz@aim.com; helo=sonic313-20.consmr.mail.gq1.yahoo.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.096, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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]); -- 2.39.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 13689C46467 for ; Tue, 10 Jan 2023 07:33:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF97a-0007Sb-Bi; Tue, 10 Jan 2023 02:32:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF97Y-0007R0-Cp for qemu-devel@nongnu.org; Tue, 10 Jan 2023 02:32:32 -0500 Received: from sonic314-21.consmr.mail.gq1.yahoo.com ([98.137.69.84]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF97V-0007Dm-RB for qemu-devel@nongnu.org; Tue, 10 Jan 2023 02:32:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1673335946; bh=MlYqfxn4vwPKUpewBFfsPqn045LoqxLP6nhibRvkmMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=E/1qai2PiOIqbUTF+XBOHFQuXUBMbVzW1ho8Ij2gjZ27xRD1dwjXCtNrNQ4E0unkmGIUM3s8WmahRg0TmTsyf4yQMF2t1SpFRc3gh5fUOS6Mijgvqp4JcPgWC/3Uw/0puNm2BNIrF26KL/OwkwKFiwnWU29U9Or0WK1uj75QiHplwK8ho9cMZiFmmi5Jko0yavTTPJa3jHOY3KFr5sZoyLo2LY4CH4jllmRO0630p210u+u2NSTbj7atbAJAM0dseG9/9MGkWMRqwYhC37K4NB7tUvweCDC/cKsQ5Kif53rXB/aQIV5VV+B+iidUvyby/jUEV/l3ysCP3mMmsbaf3Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1673335946; bh=LQMlvZQo4JgVkUeUOy2EtUHA3/Ts7yg0JQfMLc1ODBG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=beDqLG/dZStPkhBKkGVBGhI6zDoDXQyqQKA8cmNBIWiB9Omm6MFO/BIE63xINC/+2lowa2lyXFhXBVaR9pvEm45TmpGaZJlgdonwD4LggH3kdzy+ji5+M+keoV0WS0ABPIX3YR79EUq4M+Y//skWtGKY+WDiaQfImZMkUhYE4/u9U+GJImKG+0gCm8RpdraoON62pKwrfgm9j/rf/roST/Z5BypVOR2kuzaxeIaMjglqaZyoHifWYf68zNB9bDvbSSI0I4wUVy3aWM6BFF6/TRRvbX7PlMQHDv/7KJRS90ZR1J8IaSW4k+ns0Qo6uTw9NqRDtQ+3rdYPTkZ3mQjQMA== X-YMail-OSG: NoXoiVwVM1kCuc.PBP0ELv0IIHyBv1HK6yJ2Lb_Fz4clgpQN0YG76Zddmac7_wE gpkPS9B_wOnXL8pAzvaCN.zNUKJP8cB6x0aW9l1HF1isRiT8qqQnue2kFc_lRJ5mTteg.y48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mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Tue, 10 Jan 2023 07:32:26 +0000 Received: by hermes--production-ne1-7b69748c4d-bxfkx (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 00995f78f0d4fd001b9b8f1699ee7ed7; Tue, 10 Jan 2023 07:32:22 +0000 (UTC) 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 v2 1/3] libxl/dm: Use "pc" machine type for Intel IGD passthrough Date: Tue, 10 Jan 2023 02:32:02 -0500 Message-ID: X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=98.137.69.84; envelope-from=brchuckz@aim.com; helo=sonic314-21.consmr.mail.gq1.yahoo.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.096, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Message-ID: <20230110073202.FBIw-gS3MMqBoNYNnOH4amuGQ_oYp4J7YQt2FIhEeXA@z> 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. v2: No changes to this patch since v1 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]); -- 2.39.0