Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp486732imn; Wed, 27 Jul 2022 11:33:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1smu+3LtA2JjfcXnWyc8UE6Zuoa2dydZ7W+A7g2EpP1pewp16IpFLVDciiXFc29ZJR97iVm X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr24465444edb.410.1658946781209; Wed, 27 Jul 2022 11:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946781; cv=none; d=google.com; s=arc-20160816; b=GVdcL5oz+HDjGso8giZqxjYv6j4sHIoLHDfa4jndJI7Z2t+BuTDMw1QDu8Ytt2Rkl2 OJ9yEzrpcOml4e9BtxafiV0WLcAupocn0TlbqXZMi2aSP/8RueMiXnlC0uWiEQlBGV9m GnZyXIf7hYxwX3LXpNbNDWhKmm1lrBdO08JHeNHR6mdt+SQuhRR0HwnI7ZNrOB0DrRR7 2tDmnqXN6NZO9PajXaGB5ARwd1XSE4Wek3JChEucQBUyh/KaN73ep77O8YGAY3Kq7byX AMk8hJVnquMaesiRlLsTKS8KTi3Nl+4+JoT0uFYXPlKSCWAHPcvePTnWQJCnkvbRxIU0 ackA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f+it1zWSVg2e8OWokXMyi6qbr12xBmr/4u2ASsWTn0Q=; b=c9EY3Uvbr2AvgNH5fJCgpmDQZRIaTMNgr1+SKjITH5BHd0kVqQA0+LpwnF3OOlRpdJ TWNE8b27tiuAyrOz1HVChiqYA8wWL/k9GmtASg0JkRijV6Teq537XcT28xBsb9uLuUKF ftQcnvwrOYedrQeI2/POUVh23E/8jO3EzMK+R9iq7ZUlkxS9sNJMHltAGcsY7lk8PEM7 C1GblPoJyL85wvqIWO4XmseZvU03ScSSiVU4pj0FSZOgMCgV8pYKpd6NV6kQdUU2ljHx nupyozQC+Zg5I9pAFL4y9xOrwftGfxe/qnJ0q17qXzf/FPMs3YFUnGYF83x3F9L4aBax vwWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lbJvGp0M; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a056402518e00b0043ac5ba36easi21065172edd.419.2022.07.27.11.32.36; Wed, 27 Jul 2022 11:33:01 -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=@linuxfoundation.org header.s=korg header.b=lbJvGp0M; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235935AbiG0QgR (ORCPT + 99 others); Wed, 27 Jul 2022 12:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238670AbiG0Qee (ORCPT ); Wed, 27 Jul 2022 12:34:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B41C4558F4; Wed, 27 Jul 2022 09:27:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 71076617EF; Wed, 27 Jul 2022 16:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FA5BC433D6; Wed, 27 Jul 2022 16:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939232; bh=YZ7zYuglbJZv2KjAVhigP6ic7xbN35pVa9r4sHEmF9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbJvGp0Mwf8+5ReTOOQnWCNPeXfQhY9VLWyAGF3HDYf7QxQh5WsJ56UhoMvFvdfju pdg8KUPBtBlL4NOe7dqbCfQ0INuVFjIYIahOxtvhvPfptRuP9zP+BlPx93UUZYSkMM NkR2/MJ5sHmqDMLwcVtkijZNUgIyNNAh/X85RPz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Michael Kelley , Wei Liu , Carl Vanderlip Subject: [PATCH 4.19 60/62] PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI Date: Wed, 27 Jul 2022 18:11:09 +0200 Message-Id: <20220727161006.486102474@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: Jeffrey Hugo commit 455880dfe292a2bdd3b4ad6a107299fce610e64b upstream. In the multi-MSI case, hv_arch_irq_unmask() will only operate on the first MSI of the N allocated. This is because only the first msi_desc is cached and it is shared by all the MSIs of the multi-MSI block. This means that hv_arch_irq_unmask() gets the correct address, but the wrong data (always 0). This can break MSIs. Lets assume MSI0 is vector 34 on CPU0, and MSI1 is vector 33 on CPU0. hv_arch_irq_unmask() is called on MSI0. It uses a hypercall to configure the MSI address and data (0) to vector 34 of CPU0. This is correct. Then hv_arch_irq_unmask is called on MSI1. It uses another hypercall to configure the MSI address and data (0) to vector 33 of CPU0. This is wrong, and results in both MSI0 and MSI1 being routed to vector 33. Linux will observe extra instances of MSI1 and no instances of MSI0 despite the endpoint device behaving correctly. For the multi-MSI case, we need unique address and data info for each MSI, but the cached msi_desc does not provide that. However, that information can be gotten from the int_desc cached in the chip_data by compose_msi_msg(). Fix the multi-MSI case to use that cached information instead. Since hv_set_msi_entry_from_desc() is no longer applicable, remove it. 4.19 backport - hv_set_msi_entry_from_desc doesn't exist to be removed. int_entry replaces msi_entry for location int_desc is written to. Signed-off-by: Jeffrey Hugo Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/1651068453-29588-1-git-send-email-quic_jhugo@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-hyperv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -923,6 +923,7 @@ static void hv_irq_unmask(struct irq_dat struct msi_desc *msi_desc = irq_data_get_msi_desc(data); struct irq_cfg *cfg = irqd_cfg(data); struct retarget_msi_interrupt *params; + struct tran_int_desc *int_desc; struct hv_pcibus_device *hbus; struct cpumask *dest; struct pci_bus *pbus; @@ -937,6 +938,7 @@ static void hv_irq_unmask(struct irq_dat pdev = msi_desc_to_pci_dev(msi_desc); pbus = pdev->bus; hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); + int_desc = data->chip_data; spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); @@ -944,8 +946,8 @@ static void hv_irq_unmask(struct irq_dat memset(params, 0, sizeof(*params)); params->partition_id = HV_PARTITION_ID_SELF; params->int_entry.source = 1; /* MSI(-X) */ - params->int_entry.address = msi_desc->msg.address_lo; - params->int_entry.data = msi_desc->msg.data; + params->int_entry.address = int_desc->address & 0xffffffff; + params->int_entry.data = int_desc->data; params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | (hbus->hdev->dev_instance.b[4] << 16) | (hbus->hdev->dev_instance.b[7] << 8) |