Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34783 )
Change subject: vc/amd/cimx/sb800: Remove old strict-aliasing workaround
......................................................................
vc/amd/cimx/sb800: Remove old strict-aliasing workaround
C strict aliasing rules state that it is undefined behaviour to access
any pointer using another pointer of a different type (with several small
exceptions). Eg.
uint64_t x = 3;
uint16_t y = *((uint16_t *)&x); // undefined behaviour
From an architectural point of view there is often nothing wrong with
pointer aliasing - the problem is that since it is undefined behaviour,
the compiler will often use this as a cop-out to perform unintended or
unsafe optimizations. The "safe" way to perfom the above assignment is
to cast the pointers to a uint8_t * first (which is allowed to alias
anything), and then work on a byte level:
*((uint8_t *)&y) = *((uint8_t *)&x);
*((uint8_t *)&y + 1) = *((uint8_t *)&x + 1);
Horribly ugly, but there you go. Anyway, in an attempt to follow these
strict aliasing rules, the ReadMEM() function in SB800 does the above
operation when reading a uint16_t. While perfectly fine, however, it
doesn't have to - all calls to ReadMEM() that read a uint16_t are passed
a uint16_t pointer, so there are no strict aliasing violations to worry
about (the WriteMEM() function is exactly similar). The problem is that
using this unnecessary workaround generates almost 50 false positive
warnings in Coverity. Rather than manually ignore them one-by-one, let's
just remove the workaround entirely. As a side note, this change makes
ReadMEM() and WriteMEM() now match their definitions in the SB900 code.
Change-Id: Ia7e3a1eff88b855a05b33c7dafba16ed23784e43
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M src/vendorcode/amd/cimx/sb800/MEMLIB.c
1 file changed, 2 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/34783/1
diff --git a/src/vendorcode/amd/cimx/sb800/MEMLIB.c b/src/vendorcode/amd/cimx/sb800/MEMLIB.c
index 5531c62..d9eb8ff 100644
--- a/src/vendorcode/amd/cimx/sb800/MEMLIB.c
+++ b/src/vendorcode/amd/cimx/sb800/MEMLIB.c
@@ -46,9 +46,7 @@
*((UINT8*)Value) = *((UINT8*) ((UINTN)Address));
break;
case AccWidthUint16:
- //*((UINT16*)Value) = *((UINT16*) ((UINTN)Address)); //gcc break strict-aliasing rules
- *((UINT8*)Value) = *((UINT8*) ((UINTN)Address));
- *((UINT8*)Value + 1) = *((UINT8*)((UINTN)Address) + 1);
+ *((UINT16*)Value) = *((UINT16*) ((UINTN)Address));
break;
case AccWidthUint32:
*((UINT32*)Value) = *((UINT32*) ((UINTN)Address));
@@ -69,9 +67,7 @@
*((UINT8*) ((UINTN)Address)) = *((UINT8*)Value);
break;
case AccWidthUint16:
- //*((UINT16*) ((UINTN)Address)) = *((UINT16*)Value); //gcc break strict-aliasing rules
- *((UINT8*)((UINTN)Address)) = *((UINT8*)Value);
- *((UINT8*)((UINTN)Address) + 1) = *((UINT8*)Value + 1);
+ *((UINT16*) ((UINTN)Address)) = *((UINT16*)Value);
break;
case AccWidthUint32:
*((UINT32*) ((UINTN)Address)) = *((UINT32*)Value);
--
To view, visit https://review.coreboot.org/c/coreboot/+/34783
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ia7e3a1eff88b855a05b33c7dafba16ed23784e43
Gerrit-Change-Number: 34783
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34387 )
Change subject: nb/amd/pi,sr5650: Remove unnecessary memory allocation
......................................................................
nb/amd/pi,sr5650: Remove unnecessary memory allocation
add_ivrs_device_entries() is a recursive function, and each recursive
call is passed a pointer to a root_level variable declared outside the
function. In an attempt to make the function self-contained, the initial
call is made with the root_level pointer set to NULL, and then the
function attempts to detect this and allocate a root_level variable for
the rest of the calls. This makes memory management very tricky - for
example, the pi code incorrectly attempts to free the root_level
variable at the end of *each* recursive call, which only avoids being a
double-free because free() in coreboot is currently a no-op. Let's
dispense with this memory weirdness and declare root_level as a local
variable outside the first function call instead.
Change-Id: Ifd63ee368fb89345b9b42ccb86cebcca64f32ac8
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
Found-by: Coverity CID 1362811
---
M src/northbridge/amd/pi/00730F01/northbridge.c
M src/southbridge/amd/sr5650/sr5650.c
2 files changed, 4 insertions(+), 19 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/87/34387/1
diff --git a/src/northbridge/amd/pi/00730F01/northbridge.c b/src/northbridge/amd/pi/00730F01/northbridge.c
index 377d91e..ba17c61 100644
--- a/src/northbridge/amd/pi/00730F01/northbridge.c
+++ b/src/northbridge/amd/pi/00730F01/northbridge.c
@@ -491,11 +491,6 @@
unsigned int header_type;
unsigned int is_pcie;
- if (!root_level) {
- root_level = malloc(sizeof(int8_t));
- *root_level = -1;
- }
-
if (dev->path.type == DEVICE_PATH_PCI) {
if ((dev->bus->secondary == 0x0) &&
@@ -536,8 +531,6 @@
sibling->sibling)
add_ivrs_device_entries(dev, sibling, depth + 1, depth,
root_level, current, length);
-
- free(root_level);
}
unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current)
@@ -643,7 +636,8 @@
current += 8;
/* Describe PCI devices */
- add_ivrs_device_entries(NULL, all_devices, 0, -1, NULL, ¤t,
+ int8_t root_level = -1;
+ add_ivrs_device_entries(NULL, all_devices, 0, -1, &root_level, ¤t,
&ivrs->ivhd.length);
/* Describe IOAPICs */
diff --git a/src/southbridge/amd/sr5650/sr5650.c b/src/southbridge/amd/sr5650/sr5650.c
index 90ca564..8131e77 100644
--- a/src/southbridge/amd/sr5650/sr5650.c
+++ b/src/southbridge/amd/sr5650/sr5650.c
@@ -725,13 +725,6 @@
struct device *sibling;
struct bus *link;
- if (!root_level) {
- root_level = malloc(sizeof(int8_t));
- if (root_level == NULL)
- die("Error: Could not allocate a byte!\n");
- *root_level = -1;
- }
-
if ((dev->path.type == DEVICE_PATH_PCI) &&
(dev->bus->secondary == 0x0) && (dev->path.pci.devfn == 0x0))
*root_level = depth;
@@ -798,9 +791,6 @@
sibling = sibling->sibling)
add_ivrs_device_entries(dev, sibling, depth + 1,
depth, root_level, current, length);
-
- if (depth == 0)
- free(root_level);
}
unsigned long acpi_fill_mcfg(unsigned long current)
@@ -879,7 +869,8 @@
current += 8;
/* Describe PCI devices */
- add_ivrs_device_entries(NULL, all_devices, 0, -1, NULL, ¤t,
+ int8_t root_level = -1;
+ add_ivrs_device_entries(NULL, all_devices, 0, -1, &root_level, ¤t,
&ivrs->ivhd.length);
/* Describe IOAPICs */
--
To view, visit https://review.coreboot.org/c/coreboot/+/34387
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ifd63ee368fb89345b9b42ccb86cebcca64f32ac8
Gerrit-Change-Number: 34387
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34409 )
Change subject: util/nvidia/cbootimage: Update to upstream master
......................................................................
util/nvidia/cbootimage: Update to upstream master
This brings in 4 new commits from the upstream repository.
65a6d94 Free image buffer on read error
9de64c7 Fix various abort(), crashes, and memory errors
7c9db58 Bump to version 1.8
3b3c3cc Use C99 uintXX_t instead of implementation-specific u_intXX_t types
Change-Id: If949309a7481537de6529c205fe745d5509906a9
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M util/nvidia/cbootimage
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/09/34409/1
diff --git a/util/nvidia/cbootimage b/util/nvidia/cbootimage
index 64045f9..65a6d94 160000
--- a/util/nvidia/cbootimage
+++ b/util/nvidia/cbootimage
@@ -1 +1 @@
-Subproject commit 64045f993c2cd8989838aeaad3d22107d96d5596
+Subproject commit 65a6d94dd5f442578551e0a81ecbe5235e673fd4
--
To view, visit https://review.coreboot.org/c/coreboot/+/34409
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If949309a7481537de6529c205fe745d5509906a9
Gerrit-Change-Number: 34409
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33821 )
Change subject: src: Remove variable length arrays
......................................................................
Patch Set 14: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/33821
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7d9d1ddadbf1cee5f695165bbe3f0effb7bd32b9
Gerrit-Change-Number: 33821
Gerrit-PatchSet: 14
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: David Guckian <david.guckian(a)intel.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Huang Jin <huang.jin(a)intel.com>
Gerrit-Reviewer: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Tue, 20 Aug 2019 15:27:35 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/34916 )
Change subject: em100: Fix malloc() failure checks
......................................................................
em100: Fix malloc() failure checks
The checks should be readback == NULL, since those are the buffers that
we just allocated. The check for data == NULL was already done earlier.
We also need to free() the data buffer if these allocations fail.
Change-Id: Ibc798673a3ce6796bf036bd962da248d12dee47c
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
---
M em100.c
1 file changed, 4 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/16/34916/1
diff --git a/em100.c b/em100.c
index 64a4ab2..f861ffe 100644
--- a/em100.c
+++ b/em100.c
@@ -827,8 +827,9 @@
if (spi_start_address) {
readback = malloc(maxlen);
- if (data == NULL) {
+ if (readback == NULL) {
printf("FATAL: couldn't allocate memory(size: %x)\n", maxlen);
+ free(data);
return 1;
}
done = read_sdram(&em100, readback, 0, maxlen);
@@ -841,8 +842,9 @@
if (verify) {
readback = malloc(length);
- if (data == NULL) {
+ if (readback == NULL) {
printf("FATAL: couldn't allocate memory\n");
+ free(data);
return 1;
}
done = read_sdram(&em100, readback, spi_start_address, length);
--
To view, visit https://review.coreboot.org/c/em100/+/34916
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: em100
Gerrit-Branch: master
Gerrit-Change-Id: Ibc798673a3ce6796bf036bd962da248d12dee47c
Gerrit-Change-Number: 34916
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange
Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34644 )
Change subject: util/cbfstool: Remove unused assignment
......................................................................
util/cbfstool: Remove unused assignment
This variable is overwritten on one branch of the next if statement, and
the other branch returns, so this assignment does nothing.
Change-Id: I63737929d47c882bbcf637182bc8bf73c19daa9f
Signed-off-by: Jacob Garber <jgarber1(a)ualberta.ca>
Found-by: scan-build 8.0.0
---
M util/cbfstool/ifittool.c
1 file changed, 0 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/34644/1
diff --git a/util/cbfstool/ifittool.c b/util/cbfstool/ifittool.c
index 3b16c3f..dce37c8 100644
--- a/util/cbfstool/ifittool.c
+++ b/util/cbfstool/ifittool.c
@@ -336,7 +336,6 @@
case ADD_REGI_OP:
{
struct buffer region;
- addr = 0;
if (partitioned_file_read_region(®ion, image_file, name)) {
addr = -convert_to_from_top_aligned(®ion, 0);
--
To view, visit https://review.coreboot.org/c/coreboot/+/34644
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I63737929d47c882bbcf637182bc8bf73c19daa9f
Gerrit-Change-Number: 34644
Gerrit-PatchSet: 1
Gerrit-Owner: Jacob Garber <jgarber1(a)ualberta.ca>
Gerrit-MessageType: newchange