Julius Werner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80253?usp=email )
Change subject: libpayload: Switch to commonlib ipchksum() algorithm
......................................................................
libpayload: Switch to commonlib ipchksum() algorithm
This patch moves libpayload over to the commonlib implementation for
calculating the IP checksum.
Change-Id: Ie8d323ce9f8d946758619761b4b22d54bce222b6
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M payloads/libpayload/include/coreboot_tables.h
D payloads/libpayload/include/ipchksum.h
M payloads/libpayload/include/libpayload.h
M payloads/libpayload/libc/Makefile.mk
D payloads/libpayload/libc/ipchecksum.c
5 files changed, 4 insertions(+), 94 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/53/80253/1
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index 5c3f0c4..5b19ca8 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -30,7 +30,7 @@
#define _COREBOOT_TABLES_H
#include <arch/types.h>
-#include <ipchksum.h>
+#include <commonlib/bsd/ipchksum.h>
#include <stdint.h>
enum {
diff --git a/payloads/libpayload/include/ipchksum.h b/payloads/libpayload/include/ipchksum.h
deleted file mode 100644
index 391fefb..0000000
--- a/payloads/libpayload/include/ipchksum.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Copyright (c) 2012 The ChromiumOS Authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef __IPCHKSUM_H__
-#define __IPCHKSUM_H__
-
-/**
- * @defgroup ipchecksum IP checksum functions
- * @{
- */
-unsigned short ipchksum(const void *ptr, unsigned long nbytes);
-/** @} */
-
-#endif
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 06c6de4..6da4564 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -48,12 +48,12 @@
#include <commonlib/bsd/elog.h>
#include <commonlib/bsd/fmap_serialized.h>
#include <commonlib/bsd/helpers.h>
+#include <commonlib/bsd/ipchksum.h>
#include <commonlib/bsd/mem_chip_info.h>
#include <ctype.h>
#include <die.h>
#include <endian.h>
#include <fmap.h>
-#include <ipchksum.h>
#include <kconfig.h>
#include <stddef.h>
#include <stdio.h>
diff --git a/payloads/libpayload/libc/Makefile.mk b/payloads/libpayload/libc/Makefile.mk
index 2d277da..306bebf 100644
--- a/payloads/libpayload/libc/Makefile.mk
+++ b/payloads/libpayload/libc/Makefile.mk
@@ -28,7 +28,7 @@
##
libc-$(CONFIG_LP_LIBC) += malloc.c printf.c console.c string.c
-libc-$(CONFIG_LP_LIBC) += memory.c ctype.c ipchecksum.c lib.c libgcc.c
+libc-$(CONFIG_LP_LIBC) += memory.c ctype.c lib.c libgcc.c
libc-$(CONFIG_LP_LIBC) += rand.c time.c exec.c
libc-$(CONFIG_LP_LIBC) += readline.c getopt_long.c sysinfo.c
libc-$(CONFIG_LP_LIBC) += args.c
@@ -47,4 +47,5 @@
ifeq ($(CONFIG_LP_LIBC),y)
libc-srcs += $(coreboottop)/src/commonlib/bsd/elog.c
libc-srcs += $(coreboottop)/src/commonlib/bsd/gcd.c
+libc-srcs += $(coreboottop)/src/commonlib/bsd/ipchksum.c
endif
diff --git a/payloads/libpayload/libc/ipchecksum.c b/payloads/libpayload/libc/ipchecksum.c
deleted file mode 100644
index 118a694..0000000
--- a/payloads/libpayload/libc/ipchecksum.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * It has originally been taken from the FreeBSD project.
- *
- * Copyright (c) 2001 Charles Mott <cm(a)linktel.net>
- * Copyright (c) 2008 coresystems GmbH
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <libpayload.h>
-
-unsigned short ipchksum(const void *vptr, unsigned long nbytes)
-{
- int sum, oddbyte;
- const unsigned short *ptr = vptr;
-
- sum = 0;
- while (nbytes > 1) {
- sum += *ptr++;
- nbytes -= 2;
- }
- if (nbytes == 1) {
- oddbyte = 0;
- ((u8 *) & oddbyte)[0] = *(u8 *) ptr;
- ((u8 *) & oddbyte)[1] = 0;
- sum += oddbyte;
- }
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- return (~sum);
-}
--
To view, visit https://review.coreboot.org/c/coreboot/+/80253?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ie8d323ce9f8d946758619761b4b22d54bce222b6
Gerrit-Change-Number: 80253
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Jakub Czapiga.
Julius Werner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80252?usp=email )
Change subject: tests: Add some more ipchksum() test cases
......................................................................
tests: Add some more ipchksum() test cases
This patch adds a few more test cases for the IP checksum algorithm to
catch more possible corner cases (large data with more than 64K carries,
unaligned data, checksum addition with offset, etc.).
Change-Id: I39b4d3f1bb833894985649872329eec88a02a22c
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M tests/commonlib/bsd/ipchksum-test.c
1 file changed, 30 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/52/80252/1
diff --git a/tests/commonlib/bsd/ipchksum-test.c b/tests/commonlib/bsd/ipchksum-test.c
index 2aed94c..3231e21 100644
--- a/tests/commonlib/bsd/ipchksum-test.c
+++ b/tests/commonlib/bsd/ipchksum-test.c
@@ -63,6 +63,23 @@
free(helper_buffer);
}
+static void test_ipchksum_80kff(void **state)
+{
+ /* 64K is an important boundary since naive 32-bit sum implementations that accumulate
+ carries may run over after that point. */
+ size_t buffer_sz = 80 * 1024;
+ char *buffer = malloc(buffer_sz);
+
+ memset(buffer, 0xff, buffer_sz);
+ assert_int_equal(ipchksum(buffer, buffer_sz), 0);
+
+ /* Make things a bit more interesting... */
+ memcpy(buffer + 0x6789, test_data_simple, test_data_simple_sz);
+ assert_int_equal(ipchksum(buffer, buffer_sz), 0x6742);
+
+ free(buffer);
+}
+
static void test_ipchksum_add_empty_values(void **state)
{
uint16_t res;
@@ -81,7 +98,19 @@
test_data_simple_sz / 2);
uint16_t res_sum = ipchksum_add(test_data_simple_sz / 2, res_1, res_2);
+ assert_int_equal(0xb62e, res_1);
+ assert_int_equal(0x8c38, res_2);
assert_int_equal(test_data_simple_checksum, res_sum);
+
+ /* Test some unaligned sums */
+ res_1 = ipchksum(test_data_simple, 17);
+ res_2 = ipchksum(test_data_simple + 17, test_data_simple_sz - 17);
+ res_sum = ipchksum_add(17, res_1, res_2);
+
+ assert_int_equal(0x2198, res_1);
+ assert_int_equal(0xcf20, res_2);
+ assert_int_equal(test_data_simple_checksum, res_sum);
+
}
int main(void)
@@ -90,6 +119,7 @@
cmocka_unit_test(test_ipchksum_zero_length),
cmocka_unit_test(test_ipchksum_zero_buffer),
cmocka_unit_test(test_ipchksum_simple_data),
+ cmocka_unit_test(test_ipchksum_80kff),
cmocka_unit_test(test_ipchksum_add_empty_values),
cmocka_unit_test(test_ipchksum_add),
--
To view, visit https://review.coreboot.org/c/coreboot/+/80252?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I39b4d3f1bb833894985649872329eec88a02a22c
Gerrit-Change-Number: 80252
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Jakub Czapiga <czapiga(a)google.com>
Gerrit-Attention: Jakub Czapiga <czapiga(a)google.com>
Gerrit-MessageType: newchange
Attention is currently required from: Arthur Heymans, Felix Held, Felix Singer, Patrick Rudolph, Paul Menzel, Shuo Liu.
Lean Sheng Tan has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/80240?usp=email )
Change subject: MAINTAINERS: Update maintainers list for Xeon SP
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
Commit Message:
https://review.coreboot.org/c/coreboot/+/80240/comment/dd9d6045_e47e1626 :
PS2, Line 7: Update maintainers list for Xeon SP
:
> The title is not appropriate for the names. please use the commit summary instead.
it is always this way as Paul suggested:
https://review.coreboot.org/c/coreboot/+/78989
--
To view, visit https://review.coreboot.org/c/coreboot/+/80240?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ide3aa87fca69be6b0f1ffe0b18d7ffb410e5c563
Gerrit-Change-Number: 80240
Gerrit-PatchSet: 2
Gerrit-Owner: Shuo Liu <shuo.liu(a)intel.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Felix Singer <service+coreboot-gerrit(a)felixsinger.de>
Gerrit-Reviewer: Lean Sheng Tan <sheng.tan(a)9elements.com>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <service+coreboot-gerrit(a)felixsinger.de>
Gerrit-Attention: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Attention: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Shuo Liu <shuo.liu(a)intel.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Tue, 30 Jan 2024 17:56:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Felix Singer <service+coreboot-gerrit(a)felixsinger.de>
Comment-In-Reply-To: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: comment
Attention is currently required from: Arthur Heymans, Felix Held, Patrick Rudolph, Paul Menzel, Shuo Liu.
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/80240?usp=email )
Change subject: MAINTAINERS: Update maintainers list for Xeon SP
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://review.coreboot.org/c/coreboot/+/80240/comment/8cefb1b8_72b6ed24 :
PS2, Line 7: Update maintainers list for Xeon SP
:
> Please be more specific. Maybe: […]
The title is not appropriate for the names. please use the commit summary instead.
--
To view, visit https://review.coreboot.org/c/coreboot/+/80240?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ide3aa87fca69be6b0f1ffe0b18d7ffb410e5c563
Gerrit-Change-Number: 80240
Gerrit-PatchSet: 2
Gerrit-Owner: Shuo Liu <shuo.liu(a)intel.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Felix Singer <service+coreboot-gerrit(a)felixsinger.de>
Gerrit-Reviewer: Lean Sheng Tan <sheng.tan(a)9elements.com>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Attention: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Shuo Liu <shuo.liu(a)intel.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Comment-Date: Tue, 30 Jan 2024 17:50:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: comment
Attention is currently required from: Arthur Heymans, Jérémy Compostella, Paul Menzel, Subrata Banik, Wonkyu Kim.
Ashish Kumar Mishra has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/80088?usp=email )
Change subject: cpu/x86: Add 1GiB pages for memory access up to 512GiB
......................................................................
Patch Set 6:
(1 comment)
Patchset:
PS5:
> This assumes a physical address space of 41 bits which is not always the case on all hardware suppor […]
This patch is for access upto 512GB only and verified on 64bit mode with 38-bit and 42-bit hardware. Are you using any different mode?
--
To view, visit https://review.coreboot.org/c/coreboot/+/80088?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Id569ae5b50abf5b72e4db33b5e4cd802399e76ec
Gerrit-Change-Number: 80088
Gerrit-PatchSet: 6
Gerrit-Owner: Ashish Kumar Mishra <ashish.k.mishra(a)intel.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Jérémy Compostella <jeremy.compostella(a)intel.com>
Gerrit-Reviewer: Subrata Banik <subratabanik(a)google.com>
Gerrit-Reviewer: Wonkyu Kim <wonkyu.kim(a)intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Haribalaraman Ramasubramanian <haribalaraman.r(a)intel.com>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Wonkyu Kim <wonkyu.kim(a)intel.com>
Gerrit-Attention: Subrata Banik <subratabanik(a)google.com>
Gerrit-Attention: Jérémy Compostella <jeremy.compostella(a)intel.com>
Gerrit-Attention: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Comment-Date: Tue, 30 Jan 2024 17:24:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: comment
Attention is currently required from: Jakub Czapiga, Michał Żygowski, Subrata Banik.
Marek Maślanka has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/79909?usp=email )
Change subject: soc/intel/common/block: Add support for watchdog
......................................................................
Patch Set 13:
(8 comments)
File src/soc/intel/common/block/acpi/acpi.c:
https://review.coreboot.org/c/coreboot/+/79909/comment/41488cb1_b0fe0436 :
PS12, Line 395: wdat
> missed the NULL check in the code ?
I added checking against the NULL, just in case
https://review.coreboot.org/c/coreboot/+/79909/comment/cf3d2b27_f67f0ce3 :
PS12, Line 397: tcobase
> what if this address is zero like TCO is not enabled ?
Now, it's checked and handled
https://review.coreboot.org/c/coreboot/+/79909/comment/6018259d_b431745b :
PS12, Line 410: // write countdown
> ` […]
Done
https://review.coreboot.org/c/coreboot/+/79909/comment/826fd3e1_2829571b :
PS12, Line 461: 11
> what is the meaning of the hardcoded value ?
I replaced it with a function that takes the offset from a given field register definition to make it more clear and less error-prone.
https://review.coreboot.org/c/coreboot/+/79909/comment/3eb694a1_4b948f99 :
PS12, Line 468: entry->action = ACPI_WDAT_SET_RUNNING_STATE;
: entry->instruction = ACPI_WDAT_WRITE_VALUE | ACPI_WDAT_PRESERVE_REGISTER;
: entry->mask = 0x01;
: entry->register_region.space_id = ACPI_ADDRESS_SPACE_IO;
: entry->register_region.addrl = tcobase + TCO1_CNT;
: entry->register_region.access_size = ACPI_WDAT_ACCESS_SIZE_WORD;
: entry->register_region.bit_offset = 11;
> can this be a helper function like […]
I would prefer to keep it consistent with filling in other entries instead of creating separate functions for that.
File src/soc/intel/common/block/smbus/tco.c:
https://review.coreboot.org/c/coreboot/+/79909/comment/dfb2d8fd_f232529f :
PS12, Line 79: {
> single statement, don't need braces
Done
https://review.coreboot.org/c/coreboot/+/79909/comment/4501edc8_52629f8a :
PS12, Line 148: __weak
> why weak ?
right, needless
https://review.coreboot.org/c/coreboot/+/79909/comment/70de1e51_7a23ec02 :
PS12, Line 149: u32
> uint32_t
Done
--
To view, visit https://review.coreboot.org/c/coreboot/+/79909?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Iaf7971f8407920a553fd91d2ed04193c882e08f1
Gerrit-Change-Number: 79909
Gerrit-PatchSet: 13
Gerrit-Owner: Marek Maślanka <mmaslanka(a)google.com>
Gerrit-Reviewer: Jakub Czapiga <czapiga(a)google.com>
Gerrit-Reviewer: Subrata Banik <subratabanik(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Gerrit-Attention: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Gerrit-Attention: Subrata Banik <subratabanik(a)google.com>
Gerrit-Attention: Jakub Czapiga <czapiga(a)google.com>
Gerrit-Comment-Date: Tue, 30 Jan 2024 16:50:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Subrata Banik <subratabanik(a)google.com>
Gerrit-MessageType: comment