Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2446314rwb; Fri, 11 Nov 2022 09:22:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Y3jtoR+4emTiflxa+rTOTf8lIimac0Sz/8j3m/9wmvMjQ+VigCslaTlfE5mgF0D6GCdjR X-Received: by 2002:a17:906:68d8:b0:78d:e786:e322 with SMTP id y24-20020a17090668d800b0078de786e322mr2586596ejr.308.1668187365833; Fri, 11 Nov 2022 09:22:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668187365; cv=pass; d=google.com; s=arc-20160816; b=C/08waj39sbzY0tqRLq8byGBvbxe+FCC0ED6FRv0H+22x1J44PVRmRiHa+R3zCg/8o wGHRkIu6fhv8I6vgTRrTyUunIrv/vs3AjQfo08HU+V06OctD0ZlhvIBFqH5d2Znx2SHj 2SD5QHvwP6lAunIpDLHkP13cEyX/Jb1xZdcSzB7BPnaoFBu8O6Dvkg5DhzQakAiteJbv wPDQxowyOJhgK3DYxhEJwxBq1ScDjHe7X+mjYQW6aA0h7iA4XjF14Vl+OYSXTHdCW3DC 9z9aQhDN5kv046Vg0C0b8Iqo77JHiMH0dDjkajZz39GV2EJU4MPBq/vrZ0WEzimXtnt9 fgnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :msip_labels:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=njfqHttk9pjKKUJbQ0Z2fnLftNx30e5cBTY2yX3NcQA=; b=fZNJ9fIDzNoKhtiqw8yJNGeHA7yjpxDP43Tidx/d9ruDslYkhai1WTkv67dJxIx4Cn kYBMeNjWLBI1OuzldetdvN8OX/aMNa3rluQ24xxZ9sSXCZOrJJqN5wpKRDP0AjbAq4wa ebaT8amBBKRo1FFZzqSsCMoTjKJpLNqr+0eo3anlim0+in5g7eZqT8LXvnEr3OUNfsDg AlveSXa+U81/PJ889DXFz+w9DrwIDGlFbhTVf2D5t2hTWHVOzmK/ADfF0mUHoifzyInq MzhGJFlcWTyqeNEt+7M7PkO23nCLvY3r+IbDGJXXAYCZtg7xzhzpdLJbgvYM+/oAwBNy BzHg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=bra9d7le; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg2-20020a1709072cc200b0078dc3cb8b41si2513260ejc.507.2022.11.11.09.22.20; Fri, 11 Nov 2022 09:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=bra9d7le; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbiKKQzc (ORCPT + 92 others); Fri, 11 Nov 2022 11:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbiKKQz3 (ORCPT ); Fri, 11 Nov 2022 11:55:29 -0500 Received: from na01-obe.outbound.protection.outlook.com (mail-eastusazon11022026.outbound.protection.outlook.com [52.101.53.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA46E17406; Fri, 11 Nov 2022 08:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EdE4s9QQfN58Niebzcj3jpODZFBNVvUFgZudlPBjGjqt5k31d8RxQDG0DB9EOVLKvjf92TFi6un7wKanPzfmDL4JXtGK+8DdZ2TBfsXV4W0dxtIorgSNn4nlDG3v9NzNzQwm/LqbERBwV2okappez+4AUsEWf9BaWaU6sHVDUnqmEEBwD992DZ4SLVaw0W8U/9SI33MlaJfXzTetoFbQzS1FxPZADmefZG39edufnSqPTgskYM+jWvag13UJCvJLbUNSbzQoMr5CfWbMf30sSkHEengkAYwhMUVwW2NKlGL27sE2cJDjAtSNLTY+b86jLGeX99J5hAJlZsHihFYBWQ== 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=njfqHttk9pjKKUJbQ0Z2fnLftNx30e5cBTY2yX3NcQA=; b=cHM504BSlnJDjmKay6wsR8HU2OYzC3Nkcso8pYBlmrHrtK7cPJQIi12SKImP4CjVg5bDWcm9RIKb1SFMvFmagA5Bbp4ohTA4Mdn9kzhToxl6LnUr1gbT7+7CUR7SGfueRSX/gdUW/y7Jzr6UHrATkm8/rOoU3aSpthzAidDyr5BzxKg1YEHmmoZpRDVaUQQevxG8aNlDH1vRiVHsLPMWOVB4M7q7NLkcZoEI6F4F1v5jBYO7cqGpTAM225ToR7w9vEICsDiBVohTQrNIHAH3NBo0G3svptEZR5TmSX3ZKbMV1HC9/ewr4a9xVZA2Lft6AiJYu7CVwNHGBh1NnEgf4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=njfqHttk9pjKKUJbQ0Z2fnLftNx30e5cBTY2yX3NcQA=; b=bra9d7lexK/Xiqjet12mimEILVW6j42p6YpA8Q+En6O2oJCVRNTztGCdi5SGzij1J2YaJECJCdWD1llbm3tVH+KDSsLOILCjRN3ffRMnMZ2r/YR8QgFrHFEfyGhcVMHlZXrdUMkVSt1tkPOyJLCvFraMX26csU3tg9r0QDGx/wg= Received: from BYAPR21MB1688.namprd21.prod.outlook.com (2603:10b6:a02:bf::26) by LV2PR21MB3110.namprd21.prod.outlook.com (2603:10b6:408:179::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.2; Fri, 11 Nov 2022 16:55:22 +0000 Received: from BYAPR21MB1688.namprd21.prod.outlook.com ([fe80::1e50:78ec:6954:d6dd]) by BYAPR21MB1688.namprd21.prod.outlook.com ([fe80::1e50:78ec:6954:d6dd%7]) with mapi id 15.20.5813.015; Fri, 11 Nov 2022 16:55:22 +0000 From: "Michael Kelley (LINUX)" To: Wei Liu , Nuno Das Neves , Tianyu Lan CC: "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux.dev" , Sunil Muthuswamy , KY Srinivasan , Tianyu Lan , Haiyang Zhang , Dexuan Cui , "dwmw2@infradead.org" , "joro@8bytes.org" , "will@kernel.org" Subject: RE: [PATCH] iommu/hyper-v: Allow hyperv irq remapping without x2apic Thread-Topic: [PATCH] iommu/hyper-v: Allow hyperv irq remapping without x2apic Thread-Index: AQHY9G6MTvL64VjEeUSlJ0XIa/5zY6457YUAgAAElfA= Date: Fri, 11 Nov 2022 16:55:22 +0000 Message-ID: References: <1668020853-23950-1-git-send-email-nunodasneves@linux.microsoft.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=1bacf23e-a9f8-475d-ad63-d3ca2bb3d22d;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-11-11T16:48:54Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BYAPR21MB1688:EE_|LV2PR21MB3110:EE_ x-ms-office365-filtering-correlation-id: e7c261da-499a-4a54-9c6a-08dac40585dc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pgXg1eUn8a0juaQHiB7Kd2HGHlrqMo6cH92Ibq6r05BnbFw5p6GGtP+Je9Ijr76qfmBvBV578EFVezetFlb34XHq1iRr4v4hYQhwSXePpjsvY0o/6x299MCgba05b+9UD5PIkZMLZA+8Wn5w7HhPE6mKV8pvUNEn491q7N863JAgHW2ZYIwD2iL3d3h9YyJ+A85GNTfsAet0xCAmnFImtj2MRZZ0Ay1GMC9cGZZDX6pyVxhPXsr9T0aFjH2busQ2Kk3J22cUDRyZy9n6kwAxF3bikMxGV77uBlflTH1Y+rG3wy7tdujR8eY/sdtere+6Umtesk+9gxNX979FxYQfSjuls547ZlrsXzHQSlRCAwo98YqDdqXLVFZJ955yzNymHK9Se3QpYZ3Wg1V9E5v8HTixSisOHt5DGl/HQENO1NLD6jIrESIlPUm2I5o+V4FP4Bd3FM70RCFdH51z+VYp0kbIBRLdGut9IydywbEu40n7noJ975tkoseHrsr+5sXR0LRKRXESVIi7m7pJ8hIEh4Zh3hSQaPXLrTk1F6cfJGqknwThD9Xp3tlS2k0Mlkijrkz6XyopBzqetz5JTprz27AWZLnz3vwPos801b673oDjcPXUj8eB8IQ1PK46HF6unhkTgMvqT2VfoJ27b/sFCipWKN37QMrBR8oTUt/kpIc0brfWvkYCuqvxJ+o3EQE/aw27UXRRCQUe10CqEqsJOJDxhAYt89RGsqiFXbirgPvx4/0OwbPaccubI+CAW7kLQOoWVylF1TwsuQVcFLJ5JQrSQFS/RF8EZXHCOFtexJaD56qPZvqLdxpWs8Vyhrsy x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR21MB1688.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199015)(6506007)(7696005)(26005)(83380400001)(316002)(8936002)(52536014)(33656002)(9686003)(5660300002)(4326008)(186003)(2906002)(64756008)(8990500004)(41300700001)(66946007)(10290500003)(55016003)(76116006)(66476007)(66556008)(8676002)(66446008)(122000001)(71200400001)(478600001)(54906003)(6636002)(110136005)(82950400001)(38100700002)(82960400001)(86362001)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?h8qIHyu433cuHxL/lUnaMfsBKU9vGNVUJ0b/YtEFLc4l+O0lxj33fsc90KWO?= =?us-ascii?Q?kOVqh3fqNCed53nR79KYDBPIxYs+X0w9lqXo3vwyAekyl36F+rh7acc14Fbj?= =?us-ascii?Q?9cG57zElR/6l6sgBvDHeX7+2zVKT/UNwaoKse84iqOGrrjA08vU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tOOLXGzEqKBiFt6wDgfRPVWRuNFSSv5/iJ32iRhfFmz3lwJg?= =?us-ascii?Q?kkli9XUv7+Xw+42Yu8MOm+jnO35R34z8NBE8+iC84ott11MsGWReaqlyvKRp?= =?us-ascii?Q?NbddYIWr7DbuODTVMLfcotz1C2HVLscz96rzcHaNKzeRuYSuygcKCNvstvD6?= =?us-ascii?Q?i3hod5hHByQ9gZnTt6kvBnOzHKgYN4WNoXYd1ssG/O49BXV0nuQyX5jEM1O7?= =?us-ascii?Q?msmh65+o0YEQVJkcfCx91Bjbsqd0zNt1jNTYfq8SPmNqkD8j+YmPbLjFQQT0?= =?us-ascii?Q?mhU3LRoB1bExd/wEk4tQge1aHj3EjRGs/9/cY7VKNi1NCnLIKuHWCVx5OKn0?= =?us-ascii?Q?vfyRwkEUKoPbB0Wtbpqul7l6OUsOhczVPNRW8bA0QP22pMA8qeXOQ4Huq2n8?= =?us-ascii?Q?U5cXQzxplVDYtFSb7rUwLwpOHN4f0sBildFibzMza+YTc8uJKlBXJskRxFDc?= =?us-ascii?Q?Tyq77dacfa+Ur+E7q0jTkGbljSDCQ5PcL5PuOSAqK81+uBnroxs8VpAL/67p?= =?us-ascii?Q?Wbf6iFGT+SqlFKZwO/Hg2ugq/SZq6ZN0WXrZX0HJR4OeppddhU5Tz9sWyE+x?= =?us-ascii?Q?Qw=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR21MB1688.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7c261da-499a-4a54-9c6a-08dac40585dc X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2022 16:55:22.5742 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qtPMyYnpz+z7ZJVmDjlytidmJ90zvJ56Gz2u6NTgLeWIfEZ5064aolTEwwtKFeivv/tFxHuDRgvnc5wRQT/axxg9J9XSKxCCbTD7oT9qm3Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR21MB3110 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Liu Sent: Friday, November 11, 2022 8:33 AM >=20 > Hi Tianyu >=20 > On Wed, Nov 09, 2022 at 11:07:33AM -0800, Nuno Das Neves wrote: > > If x2apic is not available, hyperv-iommu skips remapping > > irqs. This breaks root partition which always needs irqs > > remapped. > > > > Fix this by allowing irq remapping regardless of x2apic, > > and change hyperv_enable_irq_remapping() to return > > IRQ_REMAP_XAPIC_MODE in case x2apic is missing. > > >=20 > Do you remember why it was x2apic only? >=20 > We tested this patch on different VM SKUs and it worked fine. I'm just > wondering if there would be some subtle breakages that we couldn't > easily test. >=20 > Thanks, > Wei. My recollection is that originally Hyper-V provided the x2apic in the guest only when the number of vCPUs exceeded 255, and that was the only case where IRQ remapping was needed. The intent was to not disturb the case where # of vCPUs was < 255 and the xapic is used. I don't remember there being any potential for subtle breakages. I think more recent versions of Hyper-V now provide the x2apic in the guest in some cases when # of vCPUs is < 255. Michael >=20 > > Tested with root and non-root hyperv partitions. > > > > Signed-off-by: Nuno Das Neves > > --- > > drivers/iommu/Kconfig | 6 +++--- > > drivers/iommu/hyperv-iommu.c | 7 ++++--- > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index dc5f7a156ff5..cf7433652db0 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -474,13 +474,13 @@ config QCOM_IOMMU > > Support for IOMMU on certain Qualcomm SoCs. > > > > config HYPERV_IOMMU > > - bool "Hyper-V x2APIC IRQ Handling" > > + bool "Hyper-V IRQ Handling" > > depends on HYPERV && X86 > > select IOMMU_API > > default HYPERV > > help > > - Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux > > - guests to run with x2APIC mode enabled. > > + Stub IOMMU driver to handle IRQs to support Hyper-V Linux > > + guest and root partitions. > > > > config VIRTIO_IOMMU > > tristate "Virtio IOMMU driver" > > diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.= c > > index e190bb8c225c..abd1826a9e63 100644 > > --- a/drivers/iommu/hyperv-iommu.c > > +++ b/drivers/iommu/hyperv-iommu.c > > @@ -123,8 +123,7 @@ static int __init hyperv_prepare_irq_remapping(void= ) > > const struct irq_domain_ops *ops; > > > > if (!hypervisor_is_type(X86_HYPER_MS_HYPERV) || > > - x86_init.hyper.msi_ext_dest_id() || > > - !x2apic_supported()) > > + x86_init.hyper.msi_ext_dest_id()) > > return -ENODEV; > > > > if (hv_root_partition) { > > @@ -170,7 +169,9 @@ static int __init hyperv_prepare_irq_remapping(void= ) > > > > static int __init hyperv_enable_irq_remapping(void) > > { > > - return IRQ_REMAP_X2APIC_MODE; > > + if (x2apic_supported()) > > + return IRQ_REMAP_X2APIC_MODE; > > + return IRQ_REMAP_XAPIC_MODE; > > } > > > > struct irq_remap_ops hyperv_irq_remap_ops =3D { > > -- > > 2.25.1 > >