linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Masahiro Yamada <masahiroy@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>
Cc: "Michal Marek" <michal.lkml@markovi.net>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Kees Cook" <keescook@chromium.org>,
	"Tony Luck" <tony.luck@intel.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Joe Perches" <joe@perches.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Daniel Axtens" <dja@axtens.net>,
	"Arvind Sankar" <nivedita@alum.mit.edu>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Alexandru Ardelean" <alexandru.ardelean@analog.com>,
	"Yury Norov" <yury.norov@gmail.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	"Daniel Kiper" <daniel.kiper@oracle.com>,
	"Bruce Ashfield" <bruce.ashfield@gmail.com>,
	"Marco Elver" <elver@google.com>,
	"Vamshi K Sthambamkadi" <vamshi.k.sthambamkadi@gmail.com>,
	"Andi Kleen" <ak@suse.de>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Dávid Bolvanský" <david.bolvansky@gmail.com>,
	"Eli Friedman" <efriedma@quicinc.com>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Subject: [PATCH v2 4/5] x86/boot: use -fno-builtin-bcmp
Date: Wed, 19 Aug 2020 12:16:53 -0700	[thread overview]
Message-ID: <20200819191654.1130563-5-ndesaulniers@google.com> (raw)
In-Reply-To: <20200819191654.1130563-1-ndesaulniers@google.com>

We're reverting
commit 5f074f3e192f ("lib/string.c: implement a basic bcmp")
in favor of -fno-builtin-bcmp. Remove the additional definition here,
too.

arch/x86/purgatory/Makefile uses -ffreestanding, so there's no risk of
this libcall optimization occurring for arch/x86/boot/purgatory.ro.

arch/x86/boot/Makefile resets KBUILD_CFLAGS, so make sure to reset this
flag that was set for the top level Makefile.

Fixes: 4ce97317f41d ("x86/purgatory: Do not use __builtin_memcpy and __builtin_memset")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/x86/boot/Makefile | 1 +
 arch/x86/boot/string.c | 8 --------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index fe605205b4ce..ef7f15bfceab 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -70,6 +70,7 @@ KBUILD_CFLAGS	:= $(REALMODE_CFLAGS) -D_SETUP
 KBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
 KBUILD_CFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
 KBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
+KBUILD_CFLAGS	+= -fno-builtin-bcmp
 GCOV_PROFILE := n
 UBSAN_SANITIZE := n
 
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 8a3fff9128bb..23d91aa7691e 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -37,14 +37,6 @@ int memcmp(const void *s1, const void *s2, size_t len)
 	return diff;
 }
 
-/*
- * Clang may lower `memcmp == 0` to `bcmp == 0`.
- */
-int bcmp(const void *s1, const void *s2, size_t len)
-{
-	return memcmp(s1, s2, len);
-}
-
 int strcmp(const char *str1, const char *str2)
 {
 	const unsigned char *s1 = (const unsigned char *)str1;
-- 
2.28.0.297.g1956fa8f8d-goog


  parent reply	other threads:[~2020-08-19 19:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 19:16 [PATCH v2 0/5] -ffreestanding/-fno-builtin-* patches Nick Desaulniers
2020-08-19 19:16 ` [PATCH v2 1/5] Makefile: add -fno-builtin-stpcpy Nick Desaulniers
2020-08-20  3:33   ` Nathan Chancellor
2020-08-19 19:16 ` [PATCH v2 2/5] Makefile: add -fno-builtin-bcmp Nick Desaulniers
2020-08-20  3:33   ` Nathan Chancellor
2020-08-19 19:16 ` [PATCH v2 3/5] Revert "lib/string.c: implement a basic bcmp" Nick Desaulniers
2020-08-20  3:34   ` Nathan Chancellor
2020-08-19 19:16 ` Nick Desaulniers [this message]
2020-08-19 19:29   ` [PATCH v2 4/5] x86/boot: use -fno-builtin-bcmp Arvind Sankar
2020-08-19 20:11     ` Nick Desaulniers
2020-08-19 19:16 ` [PATCH v2 5/5] x86: don't build CONFIG_X86_32 as -ffreestanding Nick Desaulniers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200819191654.1130563-5-ndesaulniers@google.com \
    --to=ndesaulniers@google.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alexandru.ardelean@analog.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=bruce.ashfield@gmail.com \
    --cc=daniel.kiper@oracle.com \
    --cc=david.bolvansky@gmail.com \
    --cc=dja@axtens.net \
    --cc=dvyukov@google.com \
    --cc=efriedma@quicinc.com \
    --cc=elver@google.com \
    --cc=hpa@zytor.com \
    --cc=joe@perches.com \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=nivedita@alum.mit.edu \
    --cc=paulmck@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vamshi.k.sthambamkadi@gmail.com \
    --cc=x86@kernel.org \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).