Julius Werner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80254?usp=email )
Change subject: commonlib: Add assembly optimization for ipchksum() on arm64
......................................................................
commonlib: Add assembly optimization for ipchksum() on arm64
This patch adds a bit of optimized assembly code to the ipchksum()
algorithm for arm64 targets in order to take advantage of larger load
sizes and the add-with-carry instruction. This improves execution speed
on a Cortex-A75 by more than 20x.
Change-Id: I9c7bbc9d7a1cd083ced62fe9222592243a796077
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M src/commonlib/bsd/ipchksum.c
1 file changed, 25 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/80254/1
diff --git a/src/commonlib/bsd/ipchksum.c b/src/commonlib/bsd/ipchksum.c
index a40b86c..89d261f 100644
--- a/src/commonlib/bsd/ipchksum.c
+++ b/src/commonlib/bsd/ipchksum.c
@@ -11,6 +11,31 @@
uint32_t sum = 0;
size_t i = 0;
+#if defined(__aarch64__)
+ size_t size16 = size / 16;
+ const uint64_t *p8 = data;
+ if (size16) {
+ unsigned long tmp1, tmp2;
+ i = size16 * 16;
+ asm (
+ "adds xzr, xzr, xzr\n\t" /* init carry flag for addition */
+ "1:\n\t"
+ "ldp %[v1], %[v2], [%[p8]], #16\n\t"
+ "adcs %[wsum], %[wsum], %[v1]\n\t"
+ "adcs %[wsum], %[wsum], %[v2]\n\t"
+ "sub %[size16], %[size16], #1\n\t"
+ "cbnz %[size16], 1b\n\t"
+ "adcs %[wsum], %[wsum], xzr\n\t" /* use up last carry */
+ : [v1] "=r" (tmp1),
+ [v2] "=r" (tmp2),
+ [wsum] "+r" (wide_sum),
+ [p8] "+r" (p8),
+ [size16] "+r" (size16)
+ :: "cc"
+ );
+ }
+#endif
+
while (wide_sum) {
sum += wide_sum & 0xFFFF;
wide_sum >>= 16;
--
To view, visit https://review.coreboot.org/c/coreboot/+/80254?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: I9c7bbc9d7a1cd083ced62fe9222592243a796077
Gerrit-Change-Number: 80254
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-MessageType: newchange
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