pci: Add boundary check for hose->regions
PATCH 1/2 pci: Add boundary check for hose->regions
From: Thierry Reding <[email protected]>
Make sure that we don't overflow the hose->regions array, otherwise we would end up overwriting the hose->region_count field and cause mayhem to ensue. Also print an error message when we'd be overflowing because it indicates that there aren't enough regions available and the number needs to be increased.
--- drivers/pci/pci-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/pci-uclass.c +5 -0
@@ -918,6 +918,11 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,return ;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) { +if (hose->region_count ==MAX_PCI_REGIONS ) { +pr_err ("maximum number of regions parsed, aborting\n" ); +break ; + } +if (bd->bi_dram[i].size) { pci_set_region(hose->regions + hose->region_count++, bd->bi_dram[i].start,
Signature · 1 line
2.20.1
PATCH 1/2 pci: Add boundary check for hose->regions
Quoted 8 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Make sure that we don't overflow the
hose->regionsarray, otherwise we would end up overwriting thehose->region_countfield and cause mayhem to ensue. Also print an error message when we'd be overflowing because it indicates that there aren't enough regions available and the number needs to be increased.
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- drivers/pci/pci-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
Hi Tom,
have you had a chance to look at these two patches? Simon's reviewed them and they are needed to restore PCI support on Jetson TX2 (P2771).
Thierry
Quoted 19 lines
drivers/pci/pci-uclass.c +5
-0@@ -918,6 +918,11 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,return ;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) { +if (hose->region_count ==MAX_PCI_REGIONS ) { +pr_err ("maximum number of regions parsed, aborting\n" ); +break ; + } +if (bd->bi_dram[i].size) { pci_set_region(hose->regions + hose->region_count++, bd->bi_dram[i].start,Signature · 1 line
2.20.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190416/4588f1dc/attachment.sig>
PATCH 1/2 pci: Add boundary check for hose->regions
Quoted 14 lines · Thierry Reding
Quoted 8 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Make sure that we don't overflow the
hose->regionsarray, otherwise we would end up overwriting thehose->region_countfield and cause mayhem to ensue. Also print an error message when we'd be overflowing because it indicates that there aren't enough regions available and the number needs to be increased.Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- drivers/pci/pci-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 4 lines
Hi Tom,
have you had a chance to look at these two patches? Simon's reviewed them and they are needed to restore PCI support on Jetson TX2 (P2771).
They're on my list, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190422/b44f215a/attachment.sig>
PATCH 1/2 pci: Add boundary check for hose->regions
In reply to Thierry RedingQuoted 9 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Make sure that we don't overflow the
hose->regionsarray, otherwise we would end up overwriting thehose->region_countfield and cause mayhem to ensue. Also print an error message when we'd be overflowing because it indicates that there aren't enough regions available and the number needs to be increased.
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- drivers/pci/pci-uclass.c | 5 +++++ 1 file changed, 5 insertions(+)
PATCH 2/2 pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
If a platform defines CONFIG_NR_DRAM_BANKS, each DRAM bank will be added as a PCI region. The number of MAX_PCI_REGIONS therefore needs to scale with the number of DRAM banks, otherwise we will end up with too little space in the hose->regions array to store all system memory regions.
--- include/pci.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/pci.h +5 -1
@@ -534,7 +534,11 @@ extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev,extern void pci_cfgfunc_config_device (struct pci_controller * hose,pci_dev_t dev,struct pci_config_table *); -#define MAX_PCI_REGIONS 7 +#ifdef CONFIG_NR_DRAM_BANKS +#define MAX_PCI_REGIONS (CONFIG_NR_DRAM_BANKS + 7) +#else +#define MAX_PCI_REGIONS 7 +#endif #define INDIRECT_TYPE_NO_PCIE_LINK 1
Signature · 1 line
2.20.1
PATCH 2/2 pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS
Quoted 8 lines · Thierry Reding
From: Thierry Reding <[email protected]>
If a platform defines
CONFIG_NR_DRAM_BANKS, each DRAM bank will be added as a PCI region. The number ofMAX_PCI_REGIONStherefore needs to scale with the number of DRAM banks, otherwise we will end up with too little space in thehose->regionsarray to store all system memory regions.
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- include/pci.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
PATCH 2/2 pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS
In reply to Thierry RedingQuoted 9 lines · Thierry Reding
From: Thierry Reding <[email protected]>
If a platform defines
CONFIG_NR_DRAM_BANKS, each DRAM bank will be added as a PCI region. The number ofMAX_PCI_REGIONStherefore needs to scale with the number of DRAM banks, otherwise we will end up with too little space in thehose->regionsarray to store all system memory regions.Signed-off-by Thierry Reding <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/7eb3c9b6/attachment.sig>
PATCH 1/2 pci: Add boundary check for hose->regions
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Make sure that we don't overflow the
hose->regionsarray, otherwise we would end up overwriting thehose->region_countfield and cause mayhem to ensue. Also print an error message when we'd be overflowing because it indicates that there aren't enough regions available and the number needs to be increased.Signed-off-by Thierry Reding <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190424/a49fef0e/attachment.sig>