Message ID | 20230404113546.856813-1-jinankjain@linux.microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2963563vqo; Tue, 4 Apr 2023 04:54:39 -0700 (PDT) X-Google-Smtp-Source: AKy350ZCQZoVm8BphmukSCNADCspc41R10DjmYTSgYg6iO8FP/7yfcypAhhHlETGaE+3tgsdJuLs X-Received: by 2002:a05:6a20:4a30:b0:e0:316a:d62c with SMTP id fr48-20020a056a204a3000b000e0316ad62cmr2068718pzb.60.1680609279035; Tue, 04 Apr 2023 04:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680609279; cv=none; d=google.com; s=arc-20160816; b=L2E6C4j5cUFKNpr58ap429yzzkId1YpzCQqGdlJqXLLCotWedLY7DN1heTKSHwrUec G2U1o6k33Ca6VHyg9MkgchR8hSacXZV1c58RGm+vXJTMJX4AYAXJtyd5VbgcFzp77AHg yx0Dbtf2CS4acE61WjDIfILmu9D97WSf/B3tvb2LqYX8T5yzbjMpBmtiw+b8ENeKHNLc AC0QDT4O9vtTtAx8CD9Kw+UL3GHLH786Fsl57jwjFE73YW0N+xiw4NWH5Er1kiCUeCjo DjV6tpAyQFRxbmwf15+mizLEZZBYKn1JTQqzhNNXLXe2mnx9/UEn9ih2zdQDLa2hbKjo GtgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Xb9yuM7R3oQ9NGgUVXpfb5wLOmXOn+CR7TrZ/4l7qqo=; b=xw7+TSQICuOfxvPOky5+gnhO+R4R9YHX+1QUuzfKF8k/aa+BTg7w2uMvh/c7ADOXTM 8VJV6GxblSV1lieEJP4jTDgw20AKWUl/zlnkSwo3FKHZflyAytfyD+arnkR7X9G63a6c dwPnftkZ/98CmEafybWIM22hdTZ7vSGI9fLqBZr0hicRb1/AK6j4e/dKZDIySZLMrxOb HUzlxHNlrh/LvmblSVxF2AjID/rTpUNIcirLq5bDmAaDAe1rO6Da/UwjS3x7khGbqAOb rCGTtv9UMWR6tRQ0MrerCVAh1buTGXDqNRN2C7vwP1b8dY9kXt7MEALPTzItIp3y2ko+ bNcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=rvQv8Wqi; 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 d23-20020a631d57000000b0050f692470fasi10184127pgm.301.2023.04.04.04.54.24; Tue, 04 Apr 2023 04:54:39 -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=rvQv8Wqi; 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 S234000AbjDDLgg (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Tue, 4 Apr 2023 07:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234159AbjDDLgd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 4 Apr 2023 07:36:33 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 383A3420E; Tue, 4 Apr 2023 04:35:58 -0700 (PDT) Received: from jinankjain-dranzer.zrrkmle5drku1h0apvxbr2u2ee.ix.internal.cloudapp.net (unknown [20.188.121.5]) by linux.microsoft.com (Postfix) with ESMTPSA id C077B209A868; Tue, 4 Apr 2023 04:35:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C077B209A868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680608151; bh=Xb9yuM7R3oQ9NGgUVXpfb5wLOmXOn+CR7TrZ/4l7qqo=; h=From:To:Cc:Subject:Date:From; b=rvQv8WqiXyc1xM/K7HQGFRvxtzOHIyOVnKmRSnqnIOxAKKv6T29e8EON04+yt5ZaF 3N62HcinnlpAAR5QpC+f4/4OrNNEI9EY3DV+B5eHHff8BmMmkKVevFiynlQwTwbojB SgXazHdLuIXX+CG0FCK6LPvFcZys+/7LgXU4CPl0= From: Jinank Jain <jinankjain@linux.microsoft.com> To: jinankjain@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com Cc: linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, nunodasneves@linux.microsoft.com Subject: [PATCH] PCI: hv: Use nested hypercall for retargeting interrupts Date: Tue, 4 Apr 2023 11:35:46 +0000 Message-Id: <20230404113546.856813-1-jinankjain@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-17.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,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 Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762246555544006605?= X-GMAIL-MSGID: =?utf-8?q?1762246555544006605?= |
Series |
PCI: hv: Use nested hypercall for retargeting interrupts
|
|
Commit Message
Jinank Jain
April 4, 2023, 11:35 a.m. UTC
In case of nested MSHV, retargeting interrupt hypercall should be sent
to L0 hypervisor instead of L1 hypervisor.
Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com>
---
drivers/pci/controller/pci-hyperv.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Comments
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com> On 4/4/2023 4:35 AM, Jinank Jain wrote: > In case of nested MSHV, retargeting interrupt hypercall should be sent > to L0 hypervisor instead of L1 hypervisor. > > Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> > --- > drivers/pci/controller/pci-hyperv.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index f33370b75628..2123f632ecf7 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data) > } > } > > - res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17), > - params, NULL); > + if (hv_nested) > + res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT | > + (var_size << 17), > + params, NULL); > + else > + res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | > + (var_size << 17), > + params, NULL); > > exit_unlock: > spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);
On Tue, Apr 04, 2023 at 11:35:46AM +0000, Jinank Jain wrote: > In case of nested MSHV, retargeting interrupt hypercall should be sent > to L0 hypervisor instead of L1 hypervisor. > > Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> While I think this is a sensible change -- how did you discover this? Can you provide a bit more information? > --- > drivers/pci/controller/pci-hyperv.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index f33370b75628..2123f632ecf7 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data) > } > } > > - res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17), > - params, NULL); > + if (hv_nested) > + res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT | > + (var_size << 17), > + params, NULL); > + else > + res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | > + (var_size << 17), > + params, NULL); > > exit_unlock: > spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); > -- > 2.34.1 >
This was observed while testing pass-through PCI devices on the nested MSHV setup. Regards, Jinank On 4/6/2023 4:47 AM, Wei Liu wrote: > On Tue, Apr 04, 2023 at 11:35:46AM +0000, Jinank Jain wrote: >> In case of nested MSHV, retargeting interrupt hypercall should be sent >> to L0 hypervisor instead of L1 hypervisor. >> >> Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> > While I think this is a sensible change -- how did you discover this? > Can you provide a bit more information? > >> --- >> drivers/pci/controller/pci-hyperv.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c >> index f33370b75628..2123f632ecf7 100644 >> --- a/drivers/pci/controller/pci-hyperv.c >> +++ b/drivers/pci/controller/pci-hyperv.c >> @@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data) >> } >> } >> >> - res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17), >> - params, NULL); >> + if (hv_nested) >> + res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT | >> + (var_size << 17), >> + params, NULL); >> + else >> + res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | >> + (var_size << 17), >> + params, NULL); >> >> exit_unlock: >> spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags); >> -- >> 2.34.1 >>
On Tue, Apr 04, 2023 at 11:35:46AM +0000, Jinank Jain wrote: > In case of nested MSHV, retargeting interrupt hypercall should be sent > to L0 hypervisor instead of L1 hypervisor. > > Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> Applied to hyperv-next. Thanks.
From: Wei Liu <wei.liu@kernel.org> Sent: Wednesday, April 12, 2023 6:23 PM > > On Tue, Apr 04, 2023 at 11:35:46AM +0000, Jinank Jain wrote: > > In case of nested MSHV, retargeting interrupt hypercall should be sent > > to L0 hypervisor instead of L1 hypervisor. > > > > Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> > > Applied to hyperv-next. Thanks. I'd like to hold off on taking this change. Nuno and I are discussing how best to handle nested hypercalls. In addition to the proposed nested changes, we have hypercall changes coming as part of the TDX and fully enlightened SNP patch sets. If possible, I'd like to avoid adding logic at the hv_do_hypercall() call sites. It's not clear whether avoiding such logic will really be feasible, but I'd like to think about it for a bit before reaching that conclusion. Michael
On Thu, Apr 13, 2023 at 03:05:09AM +0000, Michael Kelley (LINUX) wrote: > From: Wei Liu <wei.liu@kernel.org> Sent: Wednesday, April 12, 2023 6:23 PM > > > > On Tue, Apr 04, 2023 at 11:35:46AM +0000, Jinank Jain wrote: > > > In case of nested MSHV, retargeting interrupt hypercall should be sent > > > to L0 hypervisor instead of L1 hypervisor. > > > > > > Signed-off-by: Jinank Jain <jinankjain@linux.microsoft.com> > > > > Applied to hyperv-next. Thanks. > > I'd like to hold off on taking this change. Nuno and I are discussing > how best to handle nested hypercalls. In addition to the proposed > nested changes, we have hypercall changes coming as part of the > TDX and fully enlightened SNP patch sets. If possible, I'd like to > avoid adding logic at the hv_do_hypercall() call sites. It's not clear > whether avoiding such logic will really be feasible, but I'd like to > think about it for a bit before reaching that conclusion. I thought that discussion will go on for a while but this patch fixed a real bug. Holding off is fine too. I will remove this patch from hyperv-next. Thanks, Wei. > > Michael >
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index f33370b75628..2123f632ecf7 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data) } } - res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17), - params, NULL); + if (hv_nested) + res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT | + (var_size << 17), + params, NULL); + else + res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | + (var_size << 17), + params, NULL); exit_unlock: spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);