brcmfmac: add basic validation of shared RAM address
PATCH 1/1 brcmfmac: add basic validation of shared RAM address
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address 0x04000001. It was causing:
[ 94.448015] Unable to handle kernel paging request at virtual address cd680001
due to reading out of the mapped memory.
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +6 -0
@@ -1560,6 +1560,12 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,brcmf_err (bus,"FW failed to initialize\n" );return -ENODEV ; } +if (sharedram_addr < devinfo->ci->rambase || + sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) { +brcmf_err (bus,"Invalid shared RAM address 0x%08x\n" , + sharedram_addr); +return -ENODEV ; + }brcmf_dbg (PCIE ,"Shared RAM addr: 0x%08x\n" , sharedram_addr);return (brcmf_pcie_init_share_ram_info (devinfo, sharedram_addr));
Signature · 1 line
2.20.1
Quoted 9 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
Quoted 4 lines
Signed-off-by Rafał Miłecki <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 4 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:
Quoted 8 lines
[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
Signed-off-by Rafał Miłecki <[email protected]>Acked-by Arend van Spriel <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
e0a8ef4d7b43 brcmfmac: add basic validation of shared RAM address
Signature · 3 lines
https://patchwork.kernel.org/patch/10821803/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 9 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
For a reference for the further hackers. That has been caused by a BCMA_CORE_SYS_MEM core on my BCM4366/4 not being up.
Arend Van Spriel
maintainerQuoted 8 lines · Rafał Miłecki
Quoted 7 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
Quoted 5 lines
Quoted 2 lines
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
For a reference for the further hackers. That has been caused by a
BCMA_CORE_SYS_MEMcore on my BCM4366/4 not being up.
Thanks, Rafał
Does that happen all the time or in some specific scenario. Anyway, it seems like we need to add a check in brcmf_chip_sysmem_ramsize() and bringup the core if needed. Although, I am curious in what the state the other cores are at that time. Might need a chip-wide reset.
Regards,
Arend
Quoted 15 lines · Arend Van Spriel
Quoted 8 lines · Rafał Miłecki
Quoted 7 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
Quoted 5 lines
Quoted 2 lines
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
For a reference for the further hackers. That has been caused by a
BCMA_CORE_SYS_MEMcore on my BCM4366/4 not being up.
Quoted 6 lines
Thanks, Rafał
Does that happen all the time or in some specific scenario. Anyway, it seems like we need to add a check in
brcmf_chip_sysmem_ramsize()and bringup the core if needed. Although, I am curious in what the state the other cores are at that time. Might need a chip-wide reset.
It happens after brcmf_pcie_reset_device() which is probably a 100% expected case ;)
Normally brcmfmac does not call brcmf_pcie_reset_device() between brcmf_chip_sysmem_ramsize() and the brcmf_pcie_download_fw_nvram() so it was only my hacking that caused that issue for me.
Signature · 1 line
Rafał
Arend Van Spriel
maintainerQuoted 19 lines · Rafał Miłecki
Quoted 17 lines · Arend Van Spriel
Quoted 8 lines · Rafał Miłecki
Quoted 7 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
While experimenting with firmware loading I ended up in a state of firmware reporting shared RAM address
0x04000001. It was causing:[ 94.448015] Unable to handle kernel paging request at virtual address cd680001due to reading out of the mapped memory.
Quoted 5 lines
Quoted 2 lines
This patch adds some basic validation to avoid kernel crashes due to the unexpected firmware behavior.
For a reference for the further hackers. That has been caused by a
BCMA_CORE_SYS_MEMcore on my BCM4366/4 not being up.Thanks, Rafał
Quoted 7 lines
Quoted 4 lines
Does that happen all the time or in some specific scenario. Anyway, it seems like we need to add a check in
brcmf_chip_sysmem_ramsize()and bringup the core if needed. Although, I am curious in what the state the other cores are at that time. Might need a chip-wide reset.It happens after
brcmf_pcie_reset_device()which is probably a 100% expected case ;)
Did not check what that function exactly does, but could be expected.
Quoted 3 lines
Normally brcmfmac does not call
brcmf_pcie_reset_device()betweenbrcmf_chip_sysmem_ramsize()and thebrcmf_pcie_download_fw_nvram()so it was only my hacking that caused that issue for me.
Ah. Can only wish you happy hacking then ;-)
Gr. AvS