From patchwork Wed Nov 9 23:26:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1701918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=rq4vGEag; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N71MN2HzFz23lW for ; Thu, 10 Nov 2022 10:26:55 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1osuT2-0003iq-QX; Wed, 09 Nov 2022 23:26:48 +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 1osuT0-0003iG-SL for kernel-team@lists.ubuntu.com; Wed, 09 Nov 2022 23:26:46 +0000 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (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 592F0423E0 for ; Wed, 9 Nov 2022 23:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1668036406; bh=ZcV3OkkDIDvSqNjVQqWTebVUEV2C1o0W+y55pj4UvmE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rq4vGEagFc04eLOzDHfSDUiYFuZxwDmBYChuoyVmzoG2BKO7toHWFauVTs6JcSMxb Y58AmEvTIsNAZPznFu0UfVKDOiL9SEHJlnE5wNYzWwn7ApvBcDFiRAm2aWSM1nVhGO N/p4zLL8tLVtTmaKLdvohZN5bW9+XxKis0kkUJXZcMCoJKErgmqo3eV3jY7G2aYnGC A5Gn90dNaQLxjUSpjBZ7euJ+70Jbl1tf9GuzIMUo+FI0huZmRK41d6wkAiyKD5Xl5Z PoFEBrrICbZ5rqR3JaIZJoZusBdTJ9ZvnhqTV0JlmK3sGQJr2goTv+CMRHQIUdbUkl 43rrl1wzaneiA== Received: by mail-pg1-f200.google.com with SMTP id a33-20020a630b61000000b00429d91cc649so28638pgl.8 for ; Wed, 09 Nov 2022 15:26:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZcV3OkkDIDvSqNjVQqWTebVUEV2C1o0W+y55pj4UvmE=; b=p55HX9VxxT6SPk3vD3AtkZSKSweYHAz92C43ZFIvQIjHPe32R7cP5qbQwS1p9PzkcI D66/wG+XgVTyu64pQvcve7Uo4rtI+E3AqmL6k9gRQxwV6ntj7B7yeFhGwYiiV0koORqh g+AdX4cnt8KqcjIHrhEieQ7MS0rrqZtlcq3zVKIyGYzTB9Up8zy0W1sy30srDxpbiMUR bcz+6fQ9MibJqVgdevfhE+UsogGbUI3qeLcjF/ehiBbb9thYRwCMs8Nuy+2RL9Jz4AxC iA4NTj0/GMYUM21vqAw+1jB69cfG5SCmQ4tzf4SVr4ZdwcJ9Oy/Av3PHbt3PZNn92IQK E/bQ== X-Gm-Message-State: ACrzQf2l1KOh7pWg4vKy0fRbeLmb5sHk7TRGKl4XTt7FXMtGsVptVadP e4ve6I6nV4gqn4eAtbq/dWuv7MCh29kvedASxkUIHqdHCXt7ZjDtbJMJuIeheZRa4DijQR8EN5W psVjC+k3XybB3Ok+eHltc7A9ePXidK6wgU7P7Cq5a/w== X-Received: by 2002:a17:902:b215:b0:187:204d:15ca with SMTP id t21-20020a170902b21500b00187204d15camr52873380plr.86.1668036403279; Wed, 09 Nov 2022 15:26:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM5WQGm/jv0UhOmGRH9rFGNKeO3dhY1lk4OkKnAbupeY/HcWTqFXGd8KprUbN3Hkzw7f0cOEVA== X-Received: by 2002:a17:902:b215:b0:187:204d:15ca with SMTP id t21-20020a170902b21500b00187204d15camr52873369plr.86.1668036402983; Wed, 09 Nov 2022 15:26:42 -0800 (PST) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id l5-20020a170903244500b0017f48a9e2d6sm9677225pls.292.2022.11.09.15.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 15:26:42 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH][kinetic:linux-azure] PCI: hv: Fix the definition of vector in hv_compose_msi_msg() Date: Wed, 9 Nov 2022 16:26:00 -0700 Message-Id: <20221109232600.28297-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109232600.28297-1-tim.gardner@canonical.com> References: <20221109232600.28297-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: Dexuan Cui BugLink: https://bugs.launchpad.net/bugs/1996117 The local variable 'vector' must be u32 rather than u8: see the struct hv_msi_desc3. 'vector_count' should be u16 rather than u8: see struct hv_msi_desc, hv_msi_desc2 and hv_msi_desc3. Fixes: a2bad844a67b ("PCI: hv: Fix interrupt mapping for multi-MSI") Signed-off-by: Dexuan Cui Cc: Jeffrey Hugo Cc: Carl Vanderlip Reviewed-by: Jeffrey Hugo Link: https://lore.kernel.org/r/20221027205256.17678-1-decui@microsoft.com Signed-off-by: Wei Liu (backported from commit e70af8d040d2b7904dca93d942ba23fb722e21b1 linux-next) [rtg - context adjustments] Signed-off-by: Tim Gardner --- drivers/pci/controller/pci-hyperv.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index c10548243d65..49fa882aea1c 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1614,7 +1614,7 @@ static void hv_pci_compose_compl(void *context, struct pci_response *resp, static u32 hv_compose_msi_req_v1( struct pci_create_interrupt *int_pkt, - u32 slot, u8 vector, u8 vector_count) + u32 slot, u8 vector, u16 vector_count) { int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE; int_pkt->wslot.slot = slot; @@ -1666,7 +1666,7 @@ static int hv_compose_multi_msi_req_get_cpu(void) static u32 hv_compose_msi_req_v2( struct pci_create_interrupt2 *int_pkt, int cpu, - u32 slot, u8 vector, u8 vector_count) + u32 slot, u8 vector, u16 vector_count) { int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE2; int_pkt->wslot.slot = slot; @@ -1682,7 +1682,7 @@ static u32 hv_compose_msi_req_v2( static u32 hv_compose_msi_req_v3( struct pci_create_interrupt3 *int_pkt, int cpu, - u32 slot, u32 vector, u8 vector_count) + u32 slot, u32 vector, u16 vector_count) { int_pkt->message_type.type = PCI_CREATE_INTERRUPT_MESSAGE3; int_pkt->wslot.slot = slot; @@ -1719,7 +1719,12 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) struct compose_comp_ctxt comp; struct tran_int_desc *int_desc; struct msi_desc *msi_desc; - u8 vector, vector_count; + /* + * vector_count should be u16: see hv_msi_desc, hv_msi_desc2 + * and hv_msi_desc3. vector must be u32: see hv_msi_desc3. + */ + u16 vector_count; + u32 vector; struct { struct pci_packet pci_pkt; union { @@ -1799,6 +1804,11 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) cpu = hv_compose_msi_req_get_cpu(dest); } + /* + * hv_compose_msi_req_v1 and v2 are for x86 only, meaning 'vector' + * can't exceed u8. Cast 'vector' down to u8 for v1/v2 explicitly + * for better readability. + */ memset(&ctxt, 0, sizeof(ctxt)); init_completion(&comp.comp_pkt.host_event); ctxt.pci_pkt.completion_func = hv_pci_compose_compl; @@ -1808,7 +1818,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) case PCI_PROTOCOL_VERSION_1_1: size = hv_compose_msi_req_v1(&ctxt.int_pkts.v1, hpdev->desc.win_slot.slot, - vector, + (u8)vector, vector_count); break; @@ -1817,7 +1827,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) size = hv_compose_msi_req_v2(&ctxt.int_pkts.v2, cpu, hpdev->desc.win_slot.slot, - vector, + (u8)vector, vector_count); break;