From: Bjorn Helgaas <helgaas@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: marek.vasut+renesas@gmail.com, lpieralisi@kernel.org,
kw@linux.com, robh@kernel.org, bhelgaas@google.com,
ndesaulniers@google.com, trix@redhat.com,
fancer.lancer@gmail.com, mani@kernel.org,
linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
llvm@lists.linux.dev, patches@lists.linux.dev
Subject: Re: [PATCH] PCI: rcar-gen4: Fix type of type parameter in rcar_gen4_pcie_ep_raise_irq()
Date: Tue, 17 Oct 2023 13:51:19 -0500 [thread overview]
Message-ID: <20231017185119.GA1315341@bhelgaas> (raw)
In-Reply-To: <20231017-pcie-rcar-wifpts-v1-1-ab1f42bf9386@kernel.org>
On Tue, Oct 17, 2023 at 11:41:58AM -0700, Nathan Chancellor wrote:
> With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> indirect call targets are validated against the expected function
> pointer prototype to make sure the call target is valid to help mitigate
> ROP attacks. If they are not identical, there is a failure at run time,
> which manifests as either a kernel panic or thread getting killed. A
> warning in clang aims to catch these at compile time, which reveals:
>
> drivers/pci/controller/dwc/pcie-rcar-gen4.c:403:15: error: incompatible function pointer types initializing 'int (*)(struct dw_pcie_ep *, u8, enum pci_epc_irq_type, u16)' (aka 'int (*)(struct dw_pcie_ep *, unsigned char, enum pci_epc_irq_type, unsigned sort)') with an expression of type 'int (struct dw_pcie_ep *, u8, unsigned int, u16)' (aka 'int (struct dw_pcie_ep *, unsigned char, unsigned int, unsigned short)') [-Werror,-Wincompatible-function-pointer-types-strict]
> 403 | .raise_irq = rcar_gen4_pcie_ep_raise_irq,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> '->raise_irq()' in 'struct dw_pcie_ep_ops' expects a type parameter of
> type 'enum pci_epc_irq_type', not 'unsigned int'. Adjust the type to
> match and use the proper enum values in the switch. The underlying value
> of both the enum and the macro is the same, so there is no functional
> change while clearing up the warning and avoiding a CFI failure at run
> time.
>
> Fixes: 32b83c68d634 ("PCI: rcar-gen4: Add endpoint mode support")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks, Nathan.
Yoshihiro, can you fold this in on the next rev of your rcar-gen4
series?
I dropped the rcar-gen4 branch for today since it broke Marek's system
(Samsung Exynos5433-based TM2e board), so when we fix that we should
be able to fold in this fix at the same time.
> ---
> drivers/pci/controller/dwc/pcie-rcar-gen4.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index 619262d32f4e..0c0f5c257b14 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -353,14 +353,15 @@ static void rcar_gen4_pcie_ep_deinit(struct dw_pcie_ep *ep)
> }
>
> static int rcar_gen4_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
> - unsigned int type, u16 interrupt_num)
> + enum pci_epc_irq_type type,
> + u16 interrupt_num)
> {
> struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
>
> switch (type) {
> - case PCI_IRQ_LEGACY:
> + case PCI_EPC_IRQ_LEGACY:
> return dw_pcie_ep_raise_legacy_irq(ep, func_no);
> - case PCI_IRQ_MSI:
> + case PCI_EPC_IRQ_MSI:
> return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num);
> default:
> dev_err(dw->dev, "Unknown IRQ type\n");
>
> ---
> base-commit: de45624e69e14ccd6b4b2886155578bb218925de
> change-id: 20231017-pcie-rcar-wifpts-6c65df6f8c8b
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
next prev parent reply other threads:[~2023-10-17 18:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 18:41 [PATCH] PCI: rcar-gen4: Fix type of type parameter in rcar_gen4_pcie_ep_raise_irq() Nathan Chancellor
2023-10-17 18:51 ` Bjorn Helgaas [this message]
2023-10-18 0:16 ` Yoshihiro Shimoda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231017185119.GA1315341@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=fancer.lancer@gmail.com \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=robh@kernel.org \
--cc=trix@redhat.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox