Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp698408pxa; Wed, 19 Aug 2020 12:19:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr7idFW7RLefW1HUDH6V8CKRDbfe6dA1dxI8BJcyAUTt+hbwYZ0pfdJ5uD1ufIWhkh/1s3 X-Received: by 2002:a50:bf01:: with SMTP id f1mr4057959edk.369.1597864788403; Wed, 19 Aug 2020 12:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597864788; cv=none; d=google.com; s=arc-20160816; b=B7TbPDbWrKL1WNDFpTXkElZILHv6uq5rtXV9IDrv3c96ndxLidKer5UC2VkKV2R5cr D2TGBQsi54ioBLzEAho6vJ/uqstbqELZbJ+2ar9uO+dKg4J/XZQ8eL/RBkR2H+XK4lMq FdTEEs6HznthAGsTMsp5BBiYTvY1Bn6o/zjP19OyzfEyfyRvU7gmjiSWaDv1garYZUJj DKB5B3wMPweM5tXuz/k5a/ySFd4ungVIXv+C27DqtYzW3p8DK6ImxhBsoa5xVX72RtRZ LvD4yxo7f8B8ATpdPgejYmB51dSHbCeVPMBxdskjT234aCAHO+dH540BHo/ZsAuiY0wg ahZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=/urKDqIkN4zGAhl6LxHMUbH10s5ZvVFc504ba3S5u7E=; b=S7suxE1HsKy1PeNucwegLHELto5NEDs0aVc7S2jAMsLU29xXLhriGT84DVraux904U yg4aC88Qnval2ONk4S7QwNVo6h+fqsuFvIjwm946bOUd0COzZ1p3ZqwX3+mBbrYWZCL/ qcDeuuH8erefTrcCIq7W+uHw4ax6wF+ldRUcOuCGJvZeOQbYBkdm5v7NUbdtABAHBapH eJHT7pa6scHEI78WIJnD32E7EaY+S7hOTV/PKoLrEZzGcXrtDNcMWVpoKz8aB0vzf/Z8 Tw8bAZ85RMJZPQN+1QRSr2CS6WS8e2iXQa+c2DJO1EPtPt6TI23RgOMReJOXD5P+uWQT NWrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RqgI8CJy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si15741150ejs.554.2020.08.19.12.19.24; Wed, 19 Aug 2020 12:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RqgI8CJy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbgHSTRn (ORCPT + 99 others); Wed, 19 Aug 2020 15:17:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgHSTRX (ORCPT ); Wed, 19 Aug 2020 15:17:23 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F92C061383 for ; Wed, 19 Aug 2020 12:17:23 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w11so26839131ybi.23 for ; Wed, 19 Aug 2020 12:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/urKDqIkN4zGAhl6LxHMUbH10s5ZvVFc504ba3S5u7E=; b=RqgI8CJyXmWUn6Vo8lcLGmL7Sryn+W/FkZ33sxWqlgyz8meu39k4+6oomx7QFIBp3x Gg+82ihdMho3l7JJ+S2CfjEP3vQubdhyeoQjj85loSSZleZOVl/jOK3cGE8XEH01Ej2N AbQ/Vy7C7JnBDZKmbQ+iklaXV4MNxz3nqNMJxtOowSWnBqpDLp9YXD8p4zPXjqRgGid9 DF9aV54NmI8wKPj4ZWIE4q6Hj/KIDGSRh80b9cn08g+O8nK8QAGEuQ1iYxBDUmPybqOx 5zO6eUDXW1sIoB9BFjqIqf3ncr2pKUn9kYElgbeTJbWgIVBEyg7Xn7mdJSFdCsmpBLdU DioQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/urKDqIkN4zGAhl6LxHMUbH10s5ZvVFc504ba3S5u7E=; b=OIGyrb63RCfDt3k+SqvizN94nLw1b1d7+ZhY9fGddu3lrXx4yt6XtC7Dnpf2dK1Ako py36mmhHmDyWJOdXgz+Ar4T48npZeFuTBRRtfm6yLIytag6DHGfMUIpjVsTXng4kR9/7 ncVPDKyZRvp4EDCz2S71re2qz7UuCRnZvX6djNga1owKQWNdEB7ATQoc7CoyVQzdWPAk /B+lI3fXruaEfF6kSz33QTZ7DNDqq7ANZk2hMgDDiCJDyUKxCk2HsdyWkJxNF3m9X9vT nc0h2ykz1i6PRZNAP3v2D94vr1V60/t77iuw6sExZC+pkXg4AWK+GKYU2Gl7DYMAw+si m5ww== X-Gm-Message-State: AOAM532HRCAR7vkZc4Iuf4y5WgqrDNZWC80nQ70+BtldQIT+TCE6Y8LL QRLox7yzMzA/PUiFcYNL+phRLQ3mPhMlI4b63W0= X-Received: by 2002:a25:c2c7:: with SMTP id s190mr34810966ybf.161.1597864642671; Wed, 19 Aug 2020 12:17:22 -0700 (PDT) Date: Wed, 19 Aug 2020 12:16:53 -0700 In-Reply-To: <20200819191654.1130563-1-ndesaulniers@google.com> Message-Id: <20200819191654.1130563-5-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200819191654.1130563-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH v2 4/5] x86/boot: use -fno-builtin-bcmp From: Nick Desaulniers To: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Arvind Sankar , Andy Shevchenko , Alexandru Ardelean , Yury Norov , x86@kernel.org, "H . Peter Anvin" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi , Andi Kleen , Linus Torvalds , "=?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?=" , Eli Friedman , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Nick Desaulniers --- 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