Files
linux-nvgpu/drivers/gpu/nvgpu/include
Nicolas Benech 73f37a4c8a gpu: nvgpu: posix: fix EXPECT_BUG behavior
Initially, EXPECT_BUG was implemented with a if (!setjmp) which was
semantically incorrect for the setjmp construct and caused a MISRA
violation. Upon fixing the MISRA violation, it was changed to
if (setjmp != 0) which fixed the MISRA violation but made the test
code to never actually run because setjmp will first return 0 during
the init of the jump point. This caused EXPECT_BUG to always return
true as if a BUG() occurred.

In addition, setjmp is relying internally on CPU registers. As a
result, local variables may get clobbered. This mainly happens when
compiler optimizations are enabled (release builds) and the compiler
relies more on registers to hold local variables. In the case of the
EXPECT_BUG statement expression, the variable holding the return value
was incorrectly getting clobbered in some corner cases leading to
false negatives. The easy workaround for this is to declare it as
volatile, which prevents the compiler from only relying on registers
for this variable.

JIRA NVGPU-3562

Change-Id: Ie5e262d630bdd38b22449347a396d4c2cdd3bbe2
Signed-off-by: Nicolas Benech <nbenech@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2126872
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-06-05 13:35:22 -07:00
..