Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/32086
to review the following change.
Change subject: libpayload: Deduplicate strtol and strtoull
......................................................................
libpayload: Deduplicate strtol and strtoull
Our strtol() and strtoull() function contain almost exactly the same
code. This is a) bad in general and b) may cause the code to get out of
sync, such as it recently happened with CB:32029.
This patch changes strtol() to be based on strtoull() so that the main
parsing code exists only once, and also adds a strtoll() to round off
the library. Also fix the bounds imposed by strtoul() to be based on the
actual length of a 'long', not hardcoded to 32-bits (which is not
equivalent on all architectures).
Change-Id: I919c65a773cecdb11739c3f22dd0d182ed50c07f
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M payloads/libpayload/include/stdlib.h
M payloads/libpayload/libc/string.c
2 files changed, 26 insertions(+), 40 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/32086/1
diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h
index aaacc87..d4a7844 100644
--- a/payloads/libpayload/include/stdlib.h
+++ b/payloads/libpayload/include/stdlib.h
@@ -196,6 +196,7 @@
* @{
*/
long int strtol(const char *s, char **nptr, int base);
+long long int strtoll(const char *s, char **nptr, int base);
unsigned long int strtoul(const char *s, char **nptr, int base);
unsigned long long int strtoull(const char *s, char **nptr, int base);
long atol(const char *nptr);
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c
index f563f63..6c257cb 100644
--- a/payloads/libpayload/libc/string.c
+++ b/payloads/libpayload/libc/string.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
+#include <limits.h>
#include <errno.h>
/**
@@ -419,59 +420,43 @@
* @return A signed integer representation of the string
*/
-long int strtol(const char *ptr, char **endptr, int base)
+long long int strtoll(const char *orig_ptr, char **endptr, int base)
{
- int ret = 0;
- int negative = 1;
-
- if (endptr != NULL)
- *endptr = (char *) ptr;
+ const char *ptr = orig_ptr;
+ int is_negative = 0;
/* Purge whitespace */
for( ; *ptr && isspace(*ptr); ptr++);
if (ptr[0] == '-') {
- negative = -1;
+ is_negative = 1;
ptr++;
}
- if (!*ptr)
- return 0;
+ unsigned long long uval = strtoull(ptr, endptr, base);
- /* Determine the base */
+ /* If the whole string is unparseable, endptr should point to start. */
+ if (endptr && *endptr == ptr)
+ *endptr = (char *)orig_ptr;
- if (base == 0) {
- if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
- base = 16;
- else if (ptr[0] == '0') {
- base = 8;
- ptr++;
- }
- else
- base = 10;
- }
+ if (uval > (unsigned long long)LLONG_MAX + !!is_negative)
+ uval = (unsigned long long)LLONG_MAX + !!is_negative;
- /* Base 16 allows the 0x on front - so skip over it */
+ if (is_negative)
+ return -uval;
+ else
+ return uval;
+}
- if (base == 16) {
- if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
- ptr += 2;
- }
-
- /* If the first character isn't valid, then don't
- * bother */
-
- if (!*ptr || !_valid(*ptr, base))
- return 0;
-
- for( ; *ptr && _valid(*ptr, base); ptr++)
- ret = (ret * base) + _offset(*ptr, base);
-
- if (endptr != NULL)
- *endptr = (char *) ptr;
-
- return ret * negative;
+long int strtol(const char *ptr, char **endptr, int base)
+{
+ long long int val = strtoll(ptr, endptr, base);
+ if (val > LONG_MAX)
+ return LONG_MAX;
+ if (val < LONG_MIN)
+ return LONG_MIN;
+ return val;
}
long atol(const char *nptr)
@@ -534,7 +519,7 @@
unsigned long int strtoul(const char *ptr, char **endptr, int base)
{
unsigned long long val = strtoull(ptr, endptr, base);
- if (val > UINT32_MAX) return UINT32_MAX;
+ if (val > ULONG_MAX) return ULONG_MAX;
return val;
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/32086
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I919c65a773cecdb11739c3f22dd0d182ed50c07f
Gerrit-Change-Number: 32086
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/32085
to review the following change.
Change subject: libpayload: limits.h: Provide reliable definitions for all XXX_MAX/MIN
......................................................................
libpayload: limits.h: Provide reliable definitions for all XXX_MAX/MIN
Our current limits.h only provides (U)INT_MAX constants. This patch adds
most others expected by POSIX. Since some of these may be different
depending on architecture (e.g. 'long' is 32-bit on x86 and 64-bit on
arm64), provide a definition that will automatically figure out the
right value for the data model the compiler is using (as long as it's
using two's complement for signed integers, which I think we can assume
these days).
Change-Id: I1124a41279abd4f53d208270e392e590ca8eaada
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M payloads/libpayload/include/limits.h
1 file changed, 15 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/85/32085/1
diff --git a/payloads/libpayload/include/limits.h b/payloads/libpayload/include/limits.h
index 2fecf23..4238e0e 100644
--- a/payloads/libpayload/include/limits.h
+++ b/payloads/libpayload/include/limits.h
@@ -40,7 +40,20 @@
# endif
#endif
-#define UINT_MAX (unsigned int)0xffffffff
-#define INT_MAX (unsigned int)0x7fffffff
+#define USHRT_MAX ((unsigned short int)~0U)
+#define SHRT_MIN ((short int)(USHRT_MAX & ~(USHRT_MAX >> 1)))
+#define SHRT_MAX ((short int)(USHRT_MAX >> 1))
+
+#define UINT_MAX ((unsigned int)~0U)
+#define INT_MIN ((int)(UINT_MAX & ~(UINT_MAX >> 1)))
+#define INT_MAX ((int)(UINT_MAX >> 1))
+
+#define ULONG_MAX ((unsigned long int)~0UL)
+#define LONG_MIN ((long int)(ULONG_MAX & ~(ULONG_MAX >> 1)))
+#define LONG_MAX ((long int)(ULONG_MAX >> 1))
+
+#define ULLONG_MAX ((unsigned long long int)~0UL)
+#define LLONG_MIN ((long long int)(ULLONG_MAX & ~(ULLONG_MAX >> 1)))
+#define LLONG_MAX ((long long int)(ULLONG_MAX >> 1))
#endif
--
To view, visit https://review.coreboot.org/c/coreboot/+/32085
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1124a41279abd4f53d208270e392e590ca8eaada
Gerrit-Change-Number: 32085
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
mikeb mikeb has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/23856 )
Change subject: tint: introduce the new tint build system with checksum verification
......................................................................
Patch Set 12: Code-Review+1
> Patch Set 12:
>
> Luckily ./util/crossgcc/buildgcc script is quite stable - no major changes at its' core functions for at least half year - so the minor maintenance for my tint build system is rarely needed. ;-) I'm rebasing it sometimes to show that I tested it recently and its still working good.
This change is important because it adds the checksum verification for tint archive that's downloaded from FSF mirror. I trust FSF, but what if their server is hacked and tint archive replaced with something malicious? If we are the only people who are getting tint from them, such a change - without the checksum verification - could be unnoticed. Or maybe a MitM attack (replace the archive only for one person)
--
To view, visit https://review.coreboot.org/c/coreboot/+/23856
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1d24f222d1b92030b81bba3951e243a2a9f37290
Gerrit-Change-Number: 23856
Gerrit-PatchSet: 12
Gerrit-Owner: mikeb mikeb <mikebdp2(a)gmail.com>
Gerrit-Reviewer: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Gerrit-Reviewer: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: mikeb mikeb <mikebdp2(a)gmail.com>
Gerrit-Comment-Date: Wed, 10 Apr 2019 08:28:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
mikeb mikeb has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/23856 )
Change subject: tint: introduce the new tint build system with checksum verification
......................................................................
Patch Set 12:
Luckily ./util/crossgcc/buildgcc script is quite stable - no major changes at its' core functions for at least half year - so the minor maintenance for my tint build system is rarely needed. ;-) I'm rebasing it sometimes to show that I tested it recently and its still working good.
--
To view, visit https://review.coreboot.org/c/coreboot/+/23856
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1d24f222d1b92030b81bba3951e243a2a9f37290
Gerrit-Change-Number: 23856
Gerrit-PatchSet: 12
Gerrit-Owner: mikeb mikeb <mikebdp2(a)gmail.com>
Gerrit-Reviewer: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: mikeb mikeb <mikebdp2(a)gmail.com>
Gerrit-Comment-Date: Wed, 10 Apr 2019 08:19:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/14921 )
Change subject: libpayload: Fix CONFIG_LP_DEBUG_MALLOC for 64-bit archs
......................................................................
Patch Set 6: Code-Review+2
Yes I do. Let's get this merged.
--
To view, visit https://review.coreboot.org/c/coreboot/+/14921
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ib54ebc3cfba99f372690365b78c7ceb372c0bd45
Gerrit-Change-Number: 14921
Gerrit-PatchSet: 6
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-Reviewer: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Philippe Mathieu-Daudé <f4bug(a)amsat.org>
Gerrit-Reviewer: Uwe Hermann <uwe(a)hermann-uwe.de>
Gerrit-Reviewer: You-Cheng Syu <youcheng(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Wed, 10 Apr 2019 07:25:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Hello Patrick Rudolph, Subrata Banik, Philipp Deppenwiese, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32155
to look at the new patch set (#2).
Change subject: src/drivers/intel/fsp2_0: Added FSP_S component to VBOOT Stage Verification. FSP_S component will be verified in RAMSTAGE.
......................................................................
src/drivers/intel/fsp2_0: Added FSP_S component to VBOOT Stage Verification.
FSP_S component will be verified in RAMSTAGE.
When VBOOT Stage Verification is enabled, FSP_S component needs
to be verified. This logic has been added.
TEST=Create a coreboot.rom image by enabling CONFIG_VBOOT and
CONFIG_VBOOT_STAGE_VERIFICATION. Verify that the image boots
to authenticated payload and graphics is displayed via HDMI
and Display Port.
Change-Id: Ifefad96b54388143fecb56f0402c3b627ae6350d
Signed-off-by: Sukerkar, Amol N <amol.n.sukerkar(a)intel.com>
---
M src/drivers/intel/fsp2_0/silicon_init.c
1 file changed, 35 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/32155/2
--
To view, visit https://review.coreboot.org/c/coreboot/+/32155
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ifefad96b54388143fecb56f0402c3b627ae6350d
Gerrit-Change-Number: 32155
Gerrit-PatchSet: 2
Gerrit-Owner: Amol N Sukerkar <amol.n.sukerkar(a)intel.com>
Gerrit-Reviewer: Amol N Sukerkar <amol.n.sukerkar(a)intel.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki(a)gmail.com>
Gerrit-Reviewer: Subrata Banik <subrata.banik(a)intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: newpatchset
Hello Subrata Banik, Philipp Deppenwiese, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32154
to look at the new patch set (#2).
Change subject: src/lib: Changed the syntax of verify_stage_if_required to accommodate name of the component and added config flags to select them conditionally
......................................................................
src/lib: Changed the syntax of verify_stage_if_required to accommodate
name of the component and added config flags to select them
conditionally
When VBOOT Stage Verification is enabled, the components are verified
after they are loaded into DRAM. This requires identifying them by their
name so they can be selectively verified as required.
TEST=Create a coreboot.rom image by enabling CONFIG_VBOOT and
CONFIG_VBOOT_STAGE_VERIFICATION. Verify that the image boots
to authenticated payload and graphics is displayed via HDMI
and Display Port.
Change-Id: I8184a432a32338d1c0aaa362d34de5306ec08eb9
Signed-off-by: Sukerkar, Amol N <amol.n.sukerkar(a)intel.com>
---
M src/include/cbfs.h
M src/lib/Kconfig
M src/lib/cbfs.c
M src/lib/selfboot.c
4 files changed, 24 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/32154/2
--
To view, visit https://review.coreboot.org/c/coreboot/+/32154
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I8184a432a32338d1c0aaa362d34de5306ec08eb9
Gerrit-Change-Number: 32154
Gerrit-PatchSet: 2
Gerrit-Owner: Amol N Sukerkar <amol.n.sukerkar(a)intel.com>
Gerrit-Reviewer: Amol N Sukerkar <amol.n.sukerkar(a)intel.com>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki(a)gmail.com>
Gerrit-Reviewer: Subrata Banik <subrata.banik(a)intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: newpatchset
Peter Lemenkov has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/11791 )
Change subject: [WIP]mainboard/lenovo/t410: Add new port
......................................................................
Patch Set 13:
> Any new progress on this? Seems like a very interesting port
> potential.
Please try latest patch. I've just updated it to compile against current master.
UNTESTED!!!! BEWARE!!!
--
To view, visit https://review.coreboot.org/c/coreboot/+/11791
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Id9d872e643dd242e925bfb46d18076e6ad100995
Gerrit-Change-Number: 11791
Gerrit-PatchSet: 13
Gerrit-Owner: Nicolas Reinecke <nr(a)das-labor.org>
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Nicolas Reinecke <nr(a)das-labor.org>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Eloy
Gerrit-CC: HAOUAS Elyes <ehaouas(a)noos.fr>
Gerrit-CC: Okashi Odayakana <brianblevins316(a)gmail.com>
Gerrit-CC: Peter Lemenkov <lemenkov(a)gmail.com>
Gerrit-Comment-Date: Tue, 09 Apr 2019 18:05:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment