coreboot/src
Jacob Garber c43001eb14 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@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34783
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-08-20 15:38:26 +00:00
..
acpi AUTHORS: Move src/acpi copyrights into AUTHORS file 2019-07-30 11:04:14 +00:00
arch src: Remove variable length arrays 2019-08-20 15:27:42 +00:00
commonlib commonlib/region: Fix up overflow check in region_is_subregion() 2019-08-19 21:12:31 +00:00
console arch/x86: Enable POSTCAR_CONSOLE by default 2019-08-11 03:07:36 +00:00
cpu devicetree: Remove duplicate chip_ops declarations 2019-08-20 01:31:44 +00:00
device device/oprom: Drop unnecessary AMD headers 2019-08-20 08:39:27 +00:00
drivers src: Remove variable length arrays 2019-08-20 15:27:42 +00:00
ec src/ec: Drop __PRE_RAM__ and __SMM__ guards 2019-08-20 13:52:14 +00:00
include device/pnp.h: Move __SIMPLE_DEVICE__ guards 2019-08-20 13:51:51 +00:00
lib lib: edid: Move manufacturer name from private extra to public info 2019-08-15 03:04:08 +00:00
mainboard mb,autoport: Fix GCC 9 Port_List build error 2019-08-20 15:31:54 +00:00
northbridge nb/amd/pi,sb/amd/sr5650: Remove unnecessary allocation 2019-08-20 15:30:47 +00:00
security vboot: fix conditional using vboot_setup_tpm return value 2019-08-08 07:03:24 +00:00
soc intel/apollolake: Move LPC decode enables to bootblock 2019-08-20 15:28:13 +00:00
southbridge nb/amd/pi,sb/amd/sr5650: Remove unnecessary allocation 2019-08-20 15:30:47 +00:00
superio src/superio/nuvoton: Add support for NCT5539D 2019-07-29 17:02:12 +00:00
vendorcode vc/amd/cimx/sb800: Remove old strict-aliasing workaround 2019-08-20 15:38:26 +00:00
Kconfig lib/stage_cache: Refactor Kconfig options 2019-08-08 04:50:33 +00:00