Re: Heads up: gcc miscompiling initramfs zlib decompression code at -O3
On Mon, May 03, 2021 at 10:41:45AM -0700, Linus Torvalds wrote: > It would be lovely if somebody also took a look at some of the other > zlib code, like inflate.c itself. But some of that code has rather > subtle changes for things like s390 hardware support, and we have > thihngs like our fallthrough rules etc, so it gets a bit hairier. > > Which is why I did just this fairly minimal part. > > Note that the commit message has a "Not-yet-signed-off-by:" from me. > That's purely because I wanted it to be obvious that this needs a lot > more testing - I'm not comfy with this patch unless somebody takes it > upon themselves to actually test it under different loads (and > different architectures). The patch below is required on top of your patch to make it compile for s390 as well. Tested with kernel image decompression, and also btrfs with file compression; both software and hardware compression. Everything seems to work. diff --git a/lib/zlib_dfltcc/dfltcc_inflate.c b/lib/zlib_dfltcc/dfltcc_inflate.c index fb60b5a6a1cb..3bb3e431b79f 100644 --- a/lib/zlib_dfltcc/dfltcc_inflate.c +++ b/lib/zlib_dfltcc/dfltcc_inflate.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: Zlib +#include +#include "../zlib_inflate/inftrees.h" #include "../zlib_inflate/inflate.h" #include "dfltcc_util.h" #include "dfltcc.h" @@ -122,7 +124,7 @@ dfltcc_inflate_action dfltcc_inflate( param->cvt = CVT_ADLER32; param->sbb = state->bits; param->hl = state->whave; /* Software and hardware history formats match */ -param->ho = (state->write - state->whave) & ((1 << HB_BITS) - 1); +param->ho = (state->wnext - state->whave) & ((1 << HB_BITS) - 1); if (param->hl) param->nt = 0; /* Honor history for the first block */ param->cv = state->check; @@ -137,7 +139,7 @@ dfltcc_inflate_action dfltcc_inflate( state->last = cc == DFLTCC_CC_OK; state->bits = param->sbb; state->whave = param->hl; -state->write = (param->ho + param->hl) & ((1 << HB_BITS) - 1); +state->wnext = (param->ho + param->hl) & ((1 << HB_BITS) - 1); state->check = param->cv; if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { /* Report an error if stream is corrupted */ diff --git a/lib/zlib_inflate/inflate.h b/lib/zlib_inflate/inflate.h index 6ece8efd879b..52314b8b28ea 100644 --- a/lib/zlib_inflate/inflate.h +++ b/lib/zlib_inflate/inflate.h @@ -1,3 +1,6 @@ +#ifndef __ZLIB_INFLATE_INFLATE_H +#define __ZLIB_INFLATE_INFLATE_H + /* inflate.h -- internal inflate state definition * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -123,3 +126,5 @@ struct inflate_state { int back; /* bits back of last unprocessed length/lit */ unsigned was; /* initial length of match */ }; + +#endif /* __ZLIB_INFLATE_INFLATE_H */ diff --git a/lib/zlib_inflate/inftrees.h b/lib/zlib_inflate/inftrees.h index fe4307fcfbe3..39d5d90d1258 100644 --- a/lib/zlib_inflate/inftrees.h +++ b/lib/zlib_inflate/inftrees.h @@ -1,3 +1,6 @@ +#ifndef __ZLIB_INFLATE_INFTREES_H +#define __ZLIB_INFLATE_INFTREES_H + /* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2005, 2010 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h @@ -60,3 +63,5 @@ typedef enum { int zlib_inflate_table (codetype type, unsigned short *lens, unsigned codes, code **table, unsigned *bits, unsigned short *work); + +#endif /* __ZLIB_INFLATE_INFTREES_H */ ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] Recognize arc64
On Wed, Apr 21, 2021 at 12:51:18PM -0700, Vineet Gupta wrote: > This paves way for setting up arc64 software ecosystem. > > $ make check > cd testsuite && bash config-guess.sh && rm uname > PASS: config.guess checks (135 tests) > cd testsuite && bash config-sub.sh > PASS: config.sub checks (852 tests) > PASS: config.sub idempotency checks (789 tests) > PASS: config.sub canonicalise each config.guess testcase (135 tests) > > * config.guess (arc64:Linux:*:*): Recognize. > * config.sub (arc64): Likewise. > * doc/config.guess.1: Regenerate. > * doc/config.sub.1: Likewise. > * testsuite/config-guess.data: Add test cases for arc64. > * testsuite/config-sub.data (arc64, arc*-elf): Add test cases. > > Signed-off-by: Vineet Gupta > --- > config.guess| 4 ++-- > config.sub | 4 ++-- > doc/config.guess.1 | 2 +- > doc/config.sub.1| 2 +- > testsuite/config-guess.data | 1 + > testsuite/config-sub.data | 5 + > 6 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/config.guess b/config.guess > index 1972fda8eb05..a6646ed28258 100755 > --- a/config.guess > +++ b/config.guess > @@ -2,7 +2,7 @@ > # Attempt to guess a canonical system name. > # Copyright 1992-2021 Free Software Foundation, Inc. > > -timestamp='2021-01-25' > +timestamp='2021-04-21' > > # This file is free software; you can redistribute it and/or modify it > # under the terms of the GNU General Public License as published by > @@ -949,7 +949,7 @@ EOF > if test "$?" = 0 ; then LIBC=gnulibc1 ; fi > echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" > exit ;; > -arc:Linux:*:* | arceb:Linux:*:*) > +arc:Linux:*:* | arceb:Linux:*:* | arc64:Linux:*:*) > echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" > exit ;; > arm*:Linux:*:*) > diff --git a/config.sub b/config.sub > index 7f7d0b055ac5..d70247c08d12 100755 > --- a/config.sub > +++ b/config.sub > @@ -2,7 +2,7 @@ > # Configuration validation subroutine script. > # Copyright 1992-2021 Free Software Foundation, Inc. > > -timestamp='2021-03-10' > +timestamp='2021-04-21' > > # This file is free software; you can redistribute it and/or modify it > # under the terms of the GNU General Public License as published by > @@ -1165,7 +1165,7 @@ case $cpu-$vendor in > | alphapca5[67] | alpha64pca5[67] \ > | am33_2.0 \ > | amdgcn \ > - | arc | arceb \ > + | arc | arceb | arc64 \ > | arm | arm[lb]e | arme[lb] | armv* \ > | avr | avr32 \ > | asmjs \ > diff --git a/doc/config.guess.1 b/doc/config.guess.1 > index 75fbb236fd68..f79f1c5f10c5 100644 > --- a/doc/config.guess.1 > +++ b/doc/config.guess.1 > @@ -1,5 +1,5 @@ > .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. > -.TH CONFIG.GUESS "1" "January 2021" "GNU config.guess (2021-01-25)" "User > Commands" > +.TH CONFIG.GUESS "1" "January 2021" "GNU config.guess (2021-04-21)" "User > Commands" > .SH NAME > config.guess \- guess the build system triplet > .SH SYNOPSIS > diff --git a/doc/config.sub.1 b/doc/config.sub.1 > index 317c8c47a180..9d52cebf58d0 100644 > --- a/doc/config.sub.1 > +++ b/doc/config.sub.1 > @@ -1,5 +1,5 @@ > .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16. > -.TH CONFIG.SUB "1" "March 2021" "GNU config.sub (2021-03-10)" "User Commands" > +.TH CONFIG.SUB "1" "March 2021" "GNU config.sub (2021-04-21)" "User Commands" > .SH NAME > config.sub \- validate and canonicalize a configuration triplet > .SH SYNOPSIS > diff --git a/testsuite/config-guess.data b/testsuite/config-guess.data > index f240e9ce61df..73908abb4e06 100644 > --- a/testsuite/config-guess.data > +++ b/testsuite/config-guess.data > @@ -35,6 +35,7 @@ amd64 | 7.0_RC1 | NetBSD | ignored | x86_64 | > x86_64-unknown-netbsd7.0 > amd64 | 7.2.1 | Isilon OneFS | ignored | ignored | x86_64-unknown-onefs > arc | ignored | Linux | ignored | ignored | arc-unknown-linux-gnu > arceb | ignored | Linux | ignored | ignored | arceb-unknown-linux-gnu > +arc64 | ignored | Linux | ignored | ignored | arc64-unknown-linux-gnu > arm | 12.0 | FreeBSD | ignored | armv6 | armv6-unknown-freebsd12.0-gnueabihf > arm | 12.0 | FreeBSD | ignored | armv7 | armv7-unknown-freebsd12.0-gnueabihf > arm | 12.1 | AROS | ignored | armv7 | arm-unknown-aros > diff --git a/testsuite/config-sub.data b/testsuite/config-sub.data > index 101a4c45ec39..0a59eaf1cec7 100644 > --- a/testsuite/config-sub.data > +++ b/testsuite/config-sub.data > @@ -59,9 +59,14 @@ amix > m68k-unknown-sysv4 > apollo68 m68k-apollo-sysv > apollo68bsd m68k-apollo-bsd > arc arc-unknown-none > +arc-elf arc-unknown-elf > arc-linux
[PATCH 0/3] Buildroot updates for ARC, LMBench
Hi, Please apply the assorted fixes. Thx, -Vineet Vineet Gupta (3): ARC: config: explicit'ify -mcpu for cpu selection lmbench: increase memsize delay for slow FPGAs lmbench: emulate --prefix to avoid scattering binaries all over arch/Config.in.arc| 8 +++--- ...c-to-prevent-memsize-from-timingout-.patch | 28 +++ package/lmbench/lmbench.mk| 9 +- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 package/lmbench/0003-TOO_LONG-100-usec-to-prevent-memsize-from-timingout-.patch -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH 2/3] lmbench: increase memsize delay for slow FPGAs
Signed-off-by: Vineet Gupta --- ...c-to-prevent-memsize-from-timingout-.patch | 28 +++ 1 file changed, 28 insertions(+) create mode 100644 package/lmbench/0003-TOO_LONG-100-usec-to-prevent-memsize-from-timingout-.patch diff --git a/package/lmbench/0003-TOO_LONG-100-usec-to-prevent-memsize-from-timingout-.patch b/package/lmbench/0003-TOO_LONG-100-usec-to-prevent-memsize-from-timingout-.patch new file mode 100644 index ..6c3e7370e11b --- /dev/null +++ b/package/lmbench/0003-TOO_LONG-100-usec-to-prevent-memsize-from-timingout-.patch @@ -0,0 +1,28 @@ +From d85b61666aa2728f68b69d02bfb162c432df709f Mon Sep 17 00:00:00 2001 +From: vgupta +Date: Sat, 3 Mar 2012 10:02:24 + +Subject: [PATCH] TOO_LONG 100 usec to prevent memsize from timingout @80Mhz + +git-svn-id: http://sjvm-subversion02.internal.synopsys.com/svn/OSS/ARC_Linux/tests/lmbench-3.0-a9@157318 4eed8e25-bc12-0410-818a-f70ee6866280 + +Signed-off-by: Vineet Gupta +--- + src/memsize.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/memsize.c b/src/memsize.c +index eb25a0924872..b333cf8cbd32 100644 +--- a/src/memsize.c b/src/memsize.c +@@ -15,7 +15,7 @@ char *id = "$Id$\n"; + #define CHK(x) if ((x) == -1) { perror("x"); exit(1); } + + #ifndef TOO_LONG +-#define TOO_LONG10 /* usecs */ ++#define TOO_LONG100 /* usecs */ + #endif + + int alarm_triggered = 0; +-- +2.25.1 + -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH 1/3] ARC: config: explicit'ify -mcpu for cpu selection
Signed-off-by: Vineet Gupta --- arch/Config.in.arc | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/Config.in.arc b/arch/Config.in.arc index f7a6d920b50d..f84dfab38ae9 100644 --- a/arch/Config.in.arc +++ b/arch/Config.in.arc @@ -12,14 +12,14 @@ config BR2_arc770d bool "ARC 770D" config BR2_archs38 - bool "ARC HS38" + bool "ARC HS38 (-mcpu=archs)" help Generic ARC HS capable of running Linux, i.e. with MMU, caches and 32-bit multiplier. Also it corresponds to the default configuration in older GNU toolchain versions. config BR2_archs38_64mpy - bool "ARC HS38 with 64-bit mpy" + bool "ARC HS38 with 64-bit mpy (-mcpu=hs38)" help Fully featured ARC HS capable of running Linux, i.e. with MMU, caches and 64-bit multiplier. @@ -28,7 +28,7 @@ config BR2_archs38_64mpy for use this one. config BR2_archs38_full - bool "ARC HS38 with Quad MAC & FPU" + bool "ARC HS38 with Quad MAC & FPU (-mcpu=hs38_linux)" help Fully featured ARC HS with additional support for - Dual- and quad multiply and MC oprations @@ -43,7 +43,7 @@ config BR2_archs4x_rel31 Build for HS48 release 3.1 config BR2_archs4x - bool "ARC HS48" + bool "ARC HS48 (-mcpu=hs4x)" help Latest release of HS48 processor - Dual and Quad multiply and MAC operations -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH 3/3] lmbench: emulate --prefix to avoid scattering binaries all over
- moves all lmbench binaries to /lmbench/bin/ - scripts copied to /lmbench/scripts - scripts/os overwritten to setup "OS" as expected by LMBench runtime scripts Signed-off-by: Vineet Gupta --- package/lmbench/lmbench.mk | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package/lmbench/lmbench.mk b/package/lmbench/lmbench.mk index 2f3b19b5f820..be6b3170099a 100644 --- a/package/lmbench/lmbench.mk +++ b/package/lmbench/lmbench.mk @@ -36,7 +36,14 @@ define LMBENCH_BUILD_CMDS endef define LMBENCH_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE) CFLAGS="$(TARGET_CFLAGS)" OS=$(ARCH) CC="$(TARGET_CC)" BASE=$(TARGET_DIR)/usr -C $(@D)/src install + mkdir -p $(TARGET_DIR)/lmbench/tmp + mkdir -p $(TARGET_DIR)/lmbench/scripts + $(TARGET_MAKE_ENV) $(MAKE) CFLAGS="$(TARGET_CFLAGS)" OS=$(ARCH) CC="$(TARGET_CC)" BASE=$(TARGET_DIR)/lmbench/tmp -C $(@D)/src install + mkdir -p $(TARGET_DIR)/lmbench/bin/$(ARCH) + mv $(TARGET_DIR)/lmbench/tmp/bin/* $(TARGET_DIR)/lmbench/bin/$(ARCH) + rm -rf $(TARGET_DIR)/lmbench/tmp/ + cp -rfd $(@D)/scripts/ $(TARGET_DIR)/lmbench/. + echo "export OS=${ARCH}" > $(TARGET_DIR)/lmbench/scripts/os endef $(eval $(generic-package)) -- 2.25.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc