grub-lakitu: BACKPORT: FROMGIT: safemath: Add some arithmetic primitives that check for overflow

This adds a new header, include/grub/safemath.h, that includes easy to
use wrappers for __builtin_{add,sub,mul}_overflow() declared like:

  bool OP(a, b, res)

where OP is grub_add, grub_sub or grub_mul. OP() returns true in the
case where the operation would overflow and res is not modified.
Otherwise, false is returned and the operation is executed.

These arithmetic primitives require newer compiler versions. So, bump
these requirements in the INSTALL file too.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Upstream-commit-id: de1c315841a
(cherry picked from commit ce53098c1579f0d484f212dafbf3f81f92aca42b
 https://github.com/rhboot/grub2 fedora-31)
Signed-off-by: Robert Kolchmeyer <rkolchmeyer@google.com>

Conflicts:
 - include/grub/compiler.h: Removed context defining the UNUSED macro.
 Our grub does not have or use this macro (documented in
 ChangeLog-2015).

BUG=b/162782466
TEST=shielded_vm_test

Change-Id: Ib5423e137125f86c0ad542edb33e28ebb18c10b7
3 files changed
tree: c83cc5d7828552d8c9927fbf0566ad32b9a74c00
  1. grub-lakitu/
  2. OWNERS
  3. README