From patchwork Thu Feb 3 14:32:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12734212 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 0B929C433EF for ; Thu, 3 Feb 2022 14:32:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.264878.458145 (Exim 4.92) (envelope-from ) id 1nFd9s-0006o1-5v; Thu, 03 Feb 2022 14:32:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 264878.458145; Thu, 03 Feb 2022 14:32:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nFd9s-0006nu-25; Thu, 03 Feb 2022 14:32:24 +0000 Received: by outflank-mailman (input) for mailman id 264878; Thu, 03 Feb 2022 14:32:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nFd9r-0006no-HF for xen-devel@lists.xenproject.org; Thu, 03 Feb 2022 14:32:23 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 18178f12-84fe-11ec-8f75-fffcc8bd4f1a; Thu, 03 Feb 2022 15:32:22 +0100 (CET) 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: 18178f12-84fe-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1643898741; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=oBUglG6X8uiWkqddQZ6935oCf0m9hHKC4JL6UB+D6dQ=; b=PgrO+KHfxcEy+JtMzvi1LnkWNBf7o19ngq/z2nbpEcJjZGtuV3IloZzt 7uYAjH2x2FUd4j4CXoC3h3DJXhLtS3Q50YJi419xDp2D1RkKJMFciZVmy mcZ9+dxFhpufOW/d1BcgtOR3K7au3f7OTQiXqWjOV3PhkT+6X/070oZHq k=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: MCNAOIjh+atY4GbeYkBGJiiWl48Se2YP6bivFr9byG9pU1fhnyB8Gq59t8ksoVQXdxGrxcoxcz e8w3JbkNsIo/gK6wvJ5ACJS8Kzxsn90/q2/v3X3yFimzSHOqQrawz7txKA+Mp016TDQfdvMCmT WsAtXhK7KloPi4GcN02t4ApiMupvDYGGzI6zfSwGwijEcczqds3KCPCGXA0cHbITOvDCY/Jhfn 6ffFJNnNNUP4mGMgD4zpIi8AV1pgg58lubH3wGdh+tfZcK9y4NrLgU6xwxp8j9+uqiVpj42sWF Q6YiFzlQqeyqdB1JI1YRzspN X-SBRS: 5.2 X-MesageID: 63417709 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:zgNHJ6vnjQMD/4t029Oji8QUeefnVKdZMUV32f8akzHdYApBsoF/q tZmKTiHPfmNM2Hycttzbt/k8R5XupLUndZqHgU9/HpkFisX+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHdJZS5LwbZj2NYy2YPhWWthh PupyyHhEA79s9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cselector9901; d=microsoft.com; cv=none; b=bcPEZFcjmRHpE2l+MQRNP+mIWWP2EvvsQHApnda30qSZsPL6dUiwkU8izpy3gIrky6p00gQVB2tqa/hk6Xrg1A/Rm0Vu7BQNAqQv7A7u9utw/U5193DObg+AHKdpIo4WMIC8z6HS2JMnvs8OQHhbfjzq7imAue47hBSZsOAZDtbS9F1xvO4x5YFEJUU3Puhau4N2NLSwOyEV1XN8lOVjCLrzZUiK9ua2aqN4f7aTOo1KnmuSrtzxnHQIMfFTQkQslnxzXacZ5uJ5TbQX2NAnzbpckeM1/ZrkykU14biZOlcDLFuYY6zLJGttSmZSIOwCjKdK1P6Ea0WsslAioooxcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tdZCE3jW8S28XPDZ2yi5CBt3HMczKkZ71EmvZ40xOhI=; b=IcV5Of9PPlCDp59QzR+5xV0BI4lpELCsSu/8+jE8ExKQMGdfnCJdZtZsyI0AZ9VpkQu6OW0eChXCltNtRbS5UlOpaZ7L+K79wGd2qPK34cCnoZQxemZP+1AeW6pdlwP/rBl842RewdTKL+IG3OhoKow6yr8QKQWhLljT5rEv7B2qdgd24BowImgfxNDihAabmUnCnaDm7HjTn8wzL+KbWDlDR8fv14avjItGDPWiK7cj/M2OAfwhGDgk4BnDvOiB5NmFqGxB1LLkot0QIh6a3yZLxc+b0PhWjX0/ivqoCQYN5jy8AN6fpX688LiSv8a9pSfKFW2qVS1D0q2ZKA5Ubw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tdZCE3jW8S28XPDZ2yi5CBt3HMczKkZ71EmvZ40xOhI=; b=JaQnCxFLeoT3OUrQNEz0Rz7cousvE7v9gSaj/REn7SRnLp+7yYY2i2Ijlki2UcDNBXWWbB14n93klJx9hXT2Pd3YP6bIuun1mUO+CDM+kToGolcIgM2yTfFGWbOhGT8qzQqTrnQoE9yyOl8qag4cqIXhYyPdhVLltg6V77QrfR8= From: Roger Pau Monne To: CC: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross , Jan Beulich Subject: [PATCH v2] tools/libxl: don't allow IOMMU usage with PoD Date: Thu, 3 Feb 2022 15:32:11 +0100 Message-ID: <20220203143211.18967-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: LO2P265CA0457.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::13) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d57dc1a3-29fb-4de0-c564-08d9e721f952 X-MS-TrafficTypeDiagnostic: MN2PR03MB4942:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uRTZzmOuuR9181fwqoT61dIhqLzP4DDisH5LBzaPGdHSY5zI8rP2zMX+MfO1KV5DCxBCU8XtrZO6kxM1e05aLgTn8DMI7yi1pK4LcrsgPd0R1GvhhVOam+RozE72n9E/JRstxyNh0HTlnMF0hSPvLhc4xzlbuXKzgt1UvkXsDd0dZTniyqxUhP2XKSh42ERjeDRioSpNFVuaEYLEHFZKAWUc4LLGhW7F/EcLOoTikKfEUN5XBW2YdScVUDtl4byWl6aNbkGe+705f7FiPfZKFOYYgRb6D6ZylMpV31xHwf2LUNa2NtCg460/Keeq1SBNDpFNYXTWoMChoRVKe4MyJ79mITRyJh1UIUNqSJHOuqgFA/3NxdFjctrsgO3E9JzTqXnHjkzzMgiasclB7DrwkUWzcA15PrsTt8GqtsH25W5ZffSh7g2i1mIHjkEKrKkd2nlDOnzBfBXgs1ZjQPxv8jannHUtB5Mo+fRojuq+Mxq67z+jCRy3E3+XK9Bie8QFh8an3/gfoZhHIQ5JTS8XArvDwelddlN3YE60s3DPhZZQRfLNzWI2u1D+oBPFfP/VWNN2yfdrVRDc7ou/CiesMPLXBpsWm3NGR+PuV+5gJhMsa8liAQvdH4a5kYmgHKwklPvLVpXCoe0Tkm8wr4GEBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(6916009)(38100700002)(508600001)(6512007)(86362001)(316002)(36756003)(6486002)(8936002)(8676002)(5660300002)(6666004)(66476007)(66556008)(66946007)(83380400001)(6506007)(26005)(186003)(1076003)(2906002)(2616005)(82960400001)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TO+V/3CnrNSckQXLfVowbsPUe3FW?= =?utf-8?q?KbJEq5u5pG+i6YQh8ttr+5gIl8MyyVbwz1b9lW1wIA4ZBXiuw9DQoTQp0omobzxfT?= =?utf-8?q?EBll9DeO0thBMJs9fgA9gnY93ZFegCVIv8OZQ/EURsSPeRBNsPpmzg+ZN1c7QJwbk?= =?utf-8?q?HPMMFUmBQsky4N0/dLs9Fg5iSxSJ2CpA6Q9/7fqUte3XXxC6PBUP5b0cdtzAP/6Lu?= =?utf-8?q?W0lgQJXZUj90gGOzMdRApMXtHy7pr4nBeqrUAhCR15t8mhkvYpm4MgjXYSeLo3qii?= =?utf-8?q?UCzIDl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QzLuthZDgNHL+PwjNyYFMvYU39oSBW5L9ZRLpz1F5WxXc16?= =?utf-8?q?eMBmOtHF/l05YUbSGnhYl9hvwAxPaFo+brfIlffJrJuIwyOI/bA/+xX35h3A45wYW?= =?utf-8?q?Ckem0z8EyI0v7bOTY6CzKiSjX6dAuRi2+xi0KhgIngD2uXxRF3gCEOWT32rBvKTNs?= =?utf-8?q?mWq8fLmdVEag3D8p0IX1RfbfCIA4MhapYGkXR87j7iGz27SCGz+kfEuT+Dv++jurc?= =?utf-8?q?635Fqc4CF6pWJjG0vZ7P1vqslCZFMTfBMwoVWV9ip+xXUGCzseWqQ/NZ6IFdBLZnt?= =?utf-8?q?mG6qI3PhceylWPMqZtjMK9+maRulneVYhMrYXdYZ1CVgGBnh7Dhfhcc9TLIUwN8Te?= =?utf-8?q?kg+yhxtqd/dQIU/C0FIl26AcPWYGFiw0nx8TTjuybVaSFqEFCEGfxl0=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: d57dc1a3-29fb-4de0-c564-08d9e721f952 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:32:15.4554 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vjaH/8ZWXeZUMX08K5U2ambf3w2EqGgXIFauCvQNZd0sk5Q6g1ui6oOWF9R4kLAJMWlNxo7+hYJAVnzFpoiT5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4942 X-OriginatorOrg: citrix.com Prevent libxl from creating guests that attempts to use PoD together with an IOMMU, even if no devices are actually assigned. While the hypervisor could support using PoD together with an IOMMU as long as no devices are assigned, such usage seems doubtful. There's no guarantee the guest has PoD no longer be active, and thus a later assignment of a PCI device to such domain could fail. Preventing the usage of PoD together with an IOMMU at guest creation avoids having to add checks for active PoD entries in the device assignment paths. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich --- Changes since v1: - Reword commit message. --- tools/libs/light/libxl_create.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c index d7a40d7550..7499922088 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1160,17 +1160,16 @@ int libxl__domain_config_setdefault(libxl__gc *gc, pod_enabled = (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV) && (d_config->b_info.target_memkb < d_config->b_info.max_memkb); - /* We cannot have PoD and PCI device assignment at the same time - * for HVM guest. It was reported that IOMMU cannot work with PoD - * enabled because it needs to populated entire page table for - * guest. To stay on the safe side, we disable PCI device - * assignment when PoD is enabled. + /* We don't support having PoD and an IOMMU at the same time for HVM + * guests. An active IOMMU cannot work with PoD because it needs a fully + * populated page-table. Prevent PoD usage if the domain has an IOMMU + * assigned, even if not active. */ if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV && - d_config->num_pcidevs && pod_enabled) { + d_config->c_info.passthrough != LIBXL_PASSTHROUGH_DISABLED && + pod_enabled) { ret = ERROR_INVAL; - LOGD(ERROR, domid, - "PCI device assignment for HVM guest failed due to PoD enabled"); + LOGD(ERROR, domid, "IOMMU not supported together with PoD"); goto error_out; }