From patchwork Thu Apr 6 16:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stanislav Kinsburskii X-Patchwork-Id: 81050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp523033vqo; Fri, 7 Apr 2023 14:00:25 -0700 (PDT) X-Google-Smtp-Source: AKy350YKRKZSjvFQBlht8QnFaXx3Muf3CyhCJx6cNoqYcoeYY12yxTu9eaR9yDy0YkvO2mFLeGXu X-Received: by 2002:aa7:c14c:0:b0:4fb:3ab9:fe81 with SMTP id r12-20020aa7c14c000000b004fb3ab9fe81mr3627496edp.30.1680901225235; Fri, 07 Apr 2023 14:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680901225; cv=none; d=google.com; s=arc-20160816; b=hBvcKnkz6tOGcKygL5xuH4FqpX/lpOBSQn2IBMragQwNU1qehSwbRZIYd6cGXVTwpt U10Qd2Ph28aQoxBryIa+wrRuJYFkvJLkcDVSYtelJrINZPLB2V3UeQ+h2vXZairL8W3F 63G1BVmtdokQWGTxjq/O40aOsShTBe98ldWeV85n95c7vMjuRimaIriQLE1evjDbwgOi j5aWdEVE7DHdMdhHWLj59BTVJHt7I3pjYWxpCdq0aXq4kVT8cmPxlSGOvaed6lqOY9Hd CtCjdiLDD/J4YJeHBX4A0cojsiVKjitNuFKCyK+qQxlSf3Bf/kEdE6zSm+6mzIZ5cSZL IzHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:from:subject :dkim-signature:dkim-filter; bh=32mhPLCSnFqlWC0muL7q44icEI++yknNcaEQIU1ZLvE=; b=ieBYNp8/jZkoXz7xu385xDsHok2359WDuYU2yGtRSa6MuZAwxUBUOWjTLJfXdAgG04 XvpRlT09eJaDwKu0STDZS1DZ4mSgQofzPZeTMCnfPNsYtE5dE2TW7w3XqM4RBqHoesDF BvsFHBwZbczXDSzZS08ybUHaW7B2GWiYWASZRw9awq2weY+VLWPezhdCt1rqox/ZbTqt TggzmeNuaL9m7E84acgOshZ4HNFk3ajQHDNCw+C8Z4yPbDiOcIQJJq6xDOOB4OvY4TeP l9ommDd/OpaCaV52IXf3ValoGioYnGL4XZLxD309xswawP3aObaho0V8opPKEwpqgAL8 vR0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=rLRQUe03; 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=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a056402124100b004abcb9e6563si4114896edw.80.2023.04.07.14.00.01; Fri, 07 Apr 2023 14:00:25 -0700 (PDT) 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=@linux.microsoft.com header.s=default header.b=rLRQUe03; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231262AbjDGU6X (ORCPT + 99 others); Fri, 7 Apr 2023 16:58:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbjDGU6T (ORCPT ); Fri, 7 Apr 2023 16:58:19 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45E1AC17E; Fri, 7 Apr 2023 13:58:17 -0700 (PDT) Received: from skinsburskii.localdomain (unknown [131.107.1.229]) by linux.microsoft.com (Postfix) with ESMTPSA id AE674213B634; Fri, 7 Apr 2023 13:58:16 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AE674213B634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680901096; bh=32mhPLCSnFqlWC0muL7q44icEI++yknNcaEQIU1ZLvE=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=rLRQUe03PQBMKbXvSZ/VJWDxgdc9PySimsj3H5+d3DxKwZjzOd7WeHSUUetID2zxh nayWNjg4p5Co3J52iHGyG4JgzQm14NIt/oJhXv8wMvDRwEzY6CKH3KWd94mThdmOxA wVJYjO39KNVcye7uCLbs6BOrthe+MQi/hGzv8c+c= Subject: [PATCH 2/2] PCI: hv: Deal with nested MSHV setup From: Stanislav Kinsburskii Cc: Stanislav Kinsburskii , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 06 Apr 2023 09:33:24 -0700 Message-ID: <168079879905.14175.16212926378045082102.stgit@skinsburskii.localdomain> In-Reply-To: <168079806973.14175.17999267023207421381.stgit@skinsburskii.localdomain> References: <168079806973.14175.17999267023207421381.stgit@skinsburskii.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-16.2 required=5.0 tests=DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH, MISSING_HEADERS,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762552683021917446?= X-GMAIL-MSGID: =?utf-8?q?1762552683021917446?= From: Stanislav Kinsburskii Running Microsoft hypervisor as nested (i.e., on top of another Microsoft hypervisor) imposes a different requirement for the PCI-hyperv controller. In this setup, the interrupt will first come to the nested (L1) hypervisor from the hypervisor, running on bare metal (L0), and then the L1 hypervisor will deliver the interrupt to the appropriate CPU of the nested root partition. Thus, instead of issuing the RETARGET hypercall to the L0 hypervisor, MAP_DEVICE_INTERRUPT hypercall should be issued to the L1 hypervisor to complete the interrupt setup. Signed-off-by: Stanislav Kinsburskii CC: "K. Y. Srinivasan" CC: Haiyang Zhang CC: Wei Liu CC: Dexuan Cui CC: Lorenzo Pieralisi CC: "Krzysztof WilczyƄski" CC: Rob Herring CC: Bjorn Helgaas CC: linux-hyperv@vger.kernel.org CC: linux-pci@vger.kernel.org CC: linux-kernel@vger.kernel.org --- drivers/pci/controller/pci-hyperv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index f33370b75628..61bee8babad4 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1570,7 +1570,16 @@ static void hv_irq_mask(struct irq_data *data) static void hv_irq_unmask(struct irq_data *data) { - hv_arch_irq_unmask(data); + if (hv_nested && hv_root_partition) + /* + * In case of the nested root partition, the nested hypervisor + * is taking care of interrupt remapping and thus the + * MAP_DEVICE_INTERRUPT hypercall is required instead of the + * RETARGET_INTERRUPT one. + */ + (void)hv_map_msi_interrupt(data, NULL); + else + hv_arch_irq_unmask(data); if (data->parent_data->chip->irq_unmask) irq_chip_unmask_parent(data);