Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2471193rwb; Fri, 11 Nov 2022 09:43:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4SPump/HfoMNNRQ9EBdJiOAOq3MS3Crn5runyXqO9HwU1a4sV0YV/VPZ8+R3I8l4KP/yil X-Received: by 2002:a17:907:98b6:b0:7ad:c0ec:7ad4 with SMTP id ju22-20020a17090798b600b007adc0ec7ad4mr2622833ejc.585.1668188609103; Fri, 11 Nov 2022 09:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668188609; cv=none; d=google.com; s=arc-20160816; b=tvkVV/73os/KLsERha8K8HPcjLvw4F9Rxqmq0X+ISoBsfOQev5ah0/vPD4ZdzqiRjS /E92WyN3KhDykuLJlK9RnW6/71C+r+qhpQ3NfSu4JkUJcm02NrE0YmbAHtXeRppp7DB4 6jSBAWrmX8UxQVisp0hQ7R9dXyuTrBF4EpoipZL/zEarANlwbbRufpURQj4YuiKzEKHi MaicrBftXQuF8fg/UVMSphFHhhMdiDqbqWIue/2gLbr+0AAHl9jHnu2JJlfB1Zu+gGCl 3oTn98OG9kbKXLEuusM+oUVuDAvB+x0XSRm6ukshqRoNY1p+T+8JKiowNszjmSMrCr9d /ajg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2/3uL0cJaLOTxEva/CGuhHjJZAqpIjvQpF8FNaVhRZ0=; b=UoP27VYEoW+yjb69MEDmG6yhZ6UuJtz0ySs/muL5C1JXDtpw+rlACfqxS44/yuP+Oi uVnowH93+NV80rf6zeo2o3LLSgDuFWoVP+bmukdGshX1/eZc8jPCnWec6ZAx1UYre6Em tt3eK2b2wR0CtvcqOrQieCpYKaL9tybUakOjiFESvp2Zs3TvDbHA88dCTMUSW4LRRYZe wLJF8bXsXgicJwNMHudmWGfPcM1MfVuP7K2ck+yp3ZZ/MYfp/Ky8e/WSgStbUnVRcUET Beb2M527BEoM3XqKOfj8rOJ049lWh6+gRKagFADDmfrNVFPLldQFwMK2FDjhOT65WZW8 JFdA== ARC-Authentication-Results: i=1; mx.google.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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji17-20020a170907981100b0078d9d67841fsi2587155ejc.400.2022.11.11.09.43.07; Fri, 11 Nov 2022 09:43:29 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbiKKR11 (ORCPT + 91 others); Fri, 11 Nov 2022 12:27:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232372AbiKKR1Z (ORCPT ); Fri, 11 Nov 2022 12:27:25 -0500 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97811FCFD; Fri, 11 Nov 2022 09:27:24 -0800 (PST) Received: by mail-wm1-f48.google.com with SMTP id l39-20020a05600c1d2700b003cf93c8156dso3548626wms.4; Fri, 11 Nov 2022 09:27:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2/3uL0cJaLOTxEva/CGuhHjJZAqpIjvQpF8FNaVhRZ0=; b=sIO67htFCPAC9EcfuzSUuB5o/Rl303zCk6n19MGsioep/3/6FPn9P4ENCZ5HZbNKhL t1DD1R3QYq6D0QUFQESTQ4Q0EokREBZJNK2EBAhxAfe//eUWe3gCqmPpYG/Bb2eQtqtm QiU+MTgbVZFXxb+9Da3ytPQXeU108i9MVB34fbrsOQVJiW8Mp4FdMC6xLoKOVrGqa7+n v3BzBKk7pPzvQ8NOi7HZCx11ZSVx/JEl19trL4UbKB60fqpfqEc4XuE1fjuJmeZUP0Bo dtsIegIc6a7Cdbd/F0+1iGieel+mcusbXWiDhqCsMrt0Wm7AN1emVFHYnduP9If1tI/j hueQ== X-Gm-Message-State: ANoB5pnJgRNmpo/hokW9mDipfC67ID5A1U7e70rbAg6QruEl0BZkkPSY iDbGJpA61LU8PbzkIs1/BIQ= X-Received: by 2002:a05:600c:348e:b0:3cf:6e78:e2aa with SMTP id a14-20020a05600c348e00b003cf6e78e2aamr2001990wmq.121.1668187643223; Fri, 11 Nov 2022 09:27:23 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id co19-20020a0560000a1300b0022e66749437sm2440234wrb.93.2022.11.11.09.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 09:27:22 -0800 (PST) Date: Fri, 11 Nov 2022 17:27:20 +0000 From: Wei Liu To: "Michael Kelley (LINUX)" Cc: Wei Liu , Nuno Das Neves , Tianyu Lan , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux.dev" , Sunil Muthuswamy , KY Srinivasan , 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 Message-ID: References: <1668020853-23950-1-git-send-email-nunodasneves@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 On Fri, Nov 11, 2022 at 04:55:22PM +0000, Michael Kelley (LINUX) wrote: > From: Wei Liu Sent: Friday, November 11, 2022 8:33 AM > > > > Hi Tianyu > > > > 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. > > > > > > > Do you remember why it was x2apic only? > > > > 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. > > > > 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. Thanks for the information. > > I think more recent versions of Hyper-V now provide the x2apic > in the guest in some cases when # of vCPUs is < 255. > On Azure the default for AMD SKUs is still xapic unless the number of VCPUs exceeds 2XX (can't remember the exact number -- maybe it is 255). Nuno, can you list the tests you've done? They will need to cover Linux running as a normal guest on Azure and Hyper-V. Thanks, Wei. > Michael > > > > > > 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 = { > > > -- > > > 2.25.1 > > >