From patchwork Wed Jul 13 12:56:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1655987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=RvGb7H6G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ljd1t6Hvkz9s09 for ; Wed, 13 Jul 2022 22:57:22 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oBbvO-0006Dk-GX; Wed, 13 Jul 2022 12:57:06 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oBbvM-0006Ac-80 for kernel-team@lists.ubuntu.com; Wed, 13 Jul 2022 12:57:04 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D9DBE3F6FC for ; Wed, 13 Jul 2022 12:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657717023; bh=GOuyPYh3NGNVgV16urBWqz8mWzXAlAMMkjk1HGh8xP8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RvGb7H6GUtnTsbaqutN8mmOigYiAuxIH9BXrWsFnwe8/gpsM/zd2IJJSA86rw2N+g Gu90LWSesOQCvHuwYwt9tW6wH4cNlnJpps/HGI8c1m14Vbsor90Pi1zXR0lCCZMY0G jQ8W7+JUm6Z97hbC2AvPmv15QNhmCEiblrNQmX4gsaaXLDtvhTaArRUpt4Vj7PV71X 1CJBrTjeLMmp+aKtmVI2xYb0Hn0oEW3ux4Cz/IK4wvF4ABSS2pAfDQ1A6wArP88WR+ hkNeLmitpXBVJHdO766V3iaD124/DkA4p5BJgX4hU8sGG70lUEISuZE2+zCR3KUvOA uKzDHyBEZMhZA== Received: by mail-pg1-f197.google.com with SMTP id t37-20020a635365000000b0041965b8ec8eso2643293pgl.0 for ; Wed, 13 Jul 2022 05:57:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GOuyPYh3NGNVgV16urBWqz8mWzXAlAMMkjk1HGh8xP8=; b=JVxDETNMyWNMmw32J0MhTdDbDGB2Sp4OQK7IlN9Mq+3wnoGnZQE/b+mqa4ftJWTGZJ xpHa+g8+A/qu7Pzkb3ra4CLNJOYh3CXJiUO38edId1zDPZUi8GiCxUaZrg/eY8iUsNh3 Z4yOiLJglMr9dJRpRgn0xScaf3z1gEvlS7Rd2Be4Vj6Ft8lbzSFbJOBMgbkliT1/3Psu Z+RPnz6v7aIb28b+FoYhVyJzpe1h9CayLBu37Q09ttMFUefziodgPB63ZL7SN2YUREyw +2NXckRcpHtTxSk+wNQYnAd2APc7gbFPG75tQXxGmyMaJyPAljCjOQeQoKCdiJrhvGTg /LyQ== X-Gm-Message-State: AJIora+9nE1CgdXQOvAZkNYiwj3FF4IXFe1o9QW8HGqlutQOsY7pt4zX Yy6A8TvGggJt4rKB1CIrKyTLYFskqBdiQ+WUecXP61MuQFwPnOQTgGiPVWvov9HFOtdQhqx3+xu hTn486j9ejer/r/CyvMihzcKywx27SVvKciaofp9aIw== X-Received: by 2002:a17:903:1c7:b0:16c:4f00:65df with SMTP id e7-20020a17090301c700b0016c4f0065dfmr3021556plh.158.1657717021554; Wed, 13 Jul 2022 05:57:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/Qqn6WCZVDnSbkxTOEkzwWt/dK2wdJWDM3kAcX+V5Mzc1TukCuzQ2bsVyHm2RSfGsZ3uFEQ== X-Received: by 2002:a17:903:1c7:b0:16c:4f00:65df with SMTP id e7-20020a17090301c700b0016c4f0065dfmr3021532plh.158.1657717021259; Wed, 13 Jul 2022 05:57:01 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id k91-20020a17090a14e400b001ec798b0dc4sm1551135pja.38.2022.07.13.05.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 05:57:00 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4][Focal/linux-azure] PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI Date: Wed, 13 Jul 2022 06:56:36 -0600 Message-Id: <20220713125649.24063-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220713125649.24063-1-tim.gardner@canonical.com> References: <20220713125649.24063-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeffrey Hugo BugLink: https://bugs.launchpad.net/bugs/1981577 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. 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 (backported from commit 455880dfe292a2bdd3b4ad6a107299fce610e64b) [rtg - hv_arch_irq_unmask() does not yet exist, add changes to hv_irq_unmask() instead. ] Signed-off-by: Tim Gardner --- drivers/pci/controller/pci-hyperv.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 7d38cda1cacf..24ef7f76ff30 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -609,13 +609,6 @@ static unsigned int hv_msi_get_int_vector(struct irq_data *data) return cfg->vector; } -static void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry, - struct msi_desc *msi_desc) -{ - msi_entry->address.as_uint32 = msi_desc->msg.address_lo; - msi_entry->data.as_uint32 = msi_desc->msg.data; -} - static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { @@ -665,14 +658,6 @@ static unsigned int hv_msi_get_int_vector(struct irq_data *irqd) return irqd->parent_data->hwirq; } -static void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry, - struct msi_desc *msi_desc) -{ - msi_entry->address = ((u64)msi_desc->msg.address_hi << 32) | - msi_desc->msg.address_lo; - msi_entry->data = msi_desc->msg.data; -} - /* * @nr_bm_irqs: Indicates the number of IRQs that were allocated from * the bitmap. @@ -1483,6 +1468,7 @@ static void hv_irq_unmask(struct irq_data *data) { struct msi_desc *msi_desc = irq_data_get_msi_desc(data); struct hv_retarget_device_interrupt *params; + struct tran_int_desc *int_desc; struct hv_pcibus_device *hbus; struct cpumask *dest; cpumask_var_t tmp; @@ -1497,6 +1483,7 @@ static void hv_irq_unmask(struct irq_data *data) 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); @@ -1504,7 +1491,8 @@ static void hv_irq_unmask(struct irq_data *data) memset(params, 0, sizeof(*params)); params->partition_id = HV_PARTITION_ID_SELF; params->int_entry.source = HV_INTERRUPT_SOURCE_MSI; - hv_set_msi_entry_from_desc(¶ms->int_entry.msi_entry, msi_desc); + params->int_entry.msi_entry.address.as_uint32 = int_desc->address & 0xffffffff; + params->int_entry.msi_entry.data.as_uint32 = 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) |