From patchwork Wed Dec 9 00:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 340001 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp4145946jai; Tue, 8 Dec 2020 16:13:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJztwyALA0PzCNBudbumgJQLIHbA1Bx70ABHKw8tV6f/MN+Z4dcmijYqFkvWsT17IOeCtTDf X-Received: by 2002:a05:6402:1c90:: with SMTP id cy16mr426136edb.73.1607472783785; Tue, 08 Dec 2020 16:13:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607472783; cv=none; d=google.com; s=arc-20160816; b=jQhb167VcCMQpEecSgRXQA/wzUxMH2gqXDshWZXqubGVPCLqUlZYTt0VYlaj0BiX/C RsQoyveFEs4tmRqaTVgi4JydRX70pC3DuI+uCKcFtHLyCD8jsI8NUGHC7+Og8+CF7ygl dPwxHpc3YNPuQ7wUD9J6C1dwegz0op1TqJQ7D6jn0x6gQW2LbdaXAzs7KDD6rRKnTN2Y W1ItTHI7ZhlqdZnZbQ9MEOocs93/pqDEkwX8NKSucinfuSZsq+75cyzuU6Y6tVesAZzB YhDdxeku1H3p4pWqo3PMcX3mFp7j9HNH/DDgUWVgazfShzWPeV9Mt/CzcrMrD9XH/Xso 1L3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=3nKLFa8UfqviH+D7Xovpvn0xgKFhcHjy+Jh/lNndHZ0=; b=H5IK+gj+jMtQu49tU4HYJ2FqXfxVi58tp+tgCtN3g731G/NUAXpk4yknqoT2bRQl8b 5QM7lmQZopjZvb7bnoU7NvM0f/OgUfsRZ7W9MCGqePhnHTh+r0QM7vdKSZrK7573LIuc awDOPwKyzh8K2bnKKWN8l11bFu+cZl0WvvmgRvzpMpbshhHfNS4zH2RjYNYkrX7C5CdF m0LLK9ZObgRopmx8GOFcoUzpQwEA/w+Nx2Gf5rbhquIiNjwZaYJ2AAULCgjxXs1YRWrV HyMlnf6/dCTOvusI1qIlo+3qCVLGQ7gjXSR+r53VvXPO77bpJuD2ZdrbUhdNdsjQxYxp 90YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pokfDLHV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 y1si52849edm.279.2020.12.08.16.13.03; Tue, 08 Dec 2020 16:13:03 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=pokfDLHV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S1730421AbgLIANC (ORCPT + 14 others); Tue, 8 Dec 2020 19:13:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730241AbgLIANC (ORCPT ); Tue, 8 Dec 2020 19:13:02 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860A6C0613CF for ; Tue, 8 Dec 2020 16:12:16 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id v29so22675pgk.12 for ; Tue, 08 Dec 2020 16:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=3nKLFa8UfqviH+D7Xovpvn0xgKFhcHjy+Jh/lNndHZ0=; b=pokfDLHV/WTrlbcg4icOIlqyfUlltjxK3UoZXe6snWfG5wRbWw4Nfu2jkwrRnI5dIq kBjThcSYJKQvS21O3a6vYYQPDpIaGp8BcANZSvCNKVODjn9K60Tggd55ej1z0z7HDOSJ GKP9g5cJDVsm5VGiKeCc3EYMjjPqaXTRvpik4igfIOExMISNy+sbvfgKC6fNbmUeIhMK YDM6u2ocL4UE8xiVwdoGMXzvFSY2RhiDri17ttRFcmHHtIFpBlGJdzjLzwa8dIGLJuWi wxs20zZXFwRtNWwAri7H5tz3wJhQiGakUg79ucaAYqpatPEbJZF14RDNA3dojGNLqsio 8O1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=3nKLFa8UfqviH+D7Xovpvn0xgKFhcHjy+Jh/lNndHZ0=; b=ORKyLhx8WPGt8JD/6QgpvlilYkQOQKQTR+V+yPSb2sosWSDaCenllbU+bIiMoV0pP0 S5sZppzgSyOkraeiEXGNPfXDRs5zt6KSEjPqCFu/GtF1nD9aGI3KCQpVtd6D1ubfkEle k4zCZ3py4YJJaTWR1s7OFO2m2QpDFOHVsSWM7UaMGS7kDULVOMLJ4x4s+3yfwkTNJ5Su yZKd933eDy4mbC+5J8iNeHdecrmunQqltdwU4+HD3VWKzR3f0ZkCPD+wZoQDtiB6NPzF wGisexRSrksKN1eOFKtKz3w7KAe4ViwVB1q+tmFq3MXNomIwh/cwBUOBxzvm0qOF3Rwm 54/Q== X-Gm-Message-State: AOAM532MxIm2hAmm+63oWgJScpVH0VJWwDO2TjdhD1kMmiDIxFwDd1SS ejek2zuu5B1gex102QswvOhXgh67LJ/pVaveQsP09Q== X-Received: by 2002:a62:1896:0:b029:197:491c:be38 with SMTP id 144-20020a6218960000b0290197491cbe38mr385794pfy.15.1607472735704; Tue, 08 Dec 2020 16:12:15 -0800 (PST) MIME-Version: 1.0 From: Nick Desaulniers Date: Tue, 8 Dec 2020 16:12:02 -0800 Message-ID: Subject: 5.4 and 4.19 fix for LLVM_IAS/clang-12 To: Greg KH , Sasha Levin , Jiri Slaby Cc: stable , Jian Cai , Fangrui Song , Sami Tolvanen , Borislav Petkov , Nathan Chancellor , clang-built-linux Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Dear stable kernel maintainers, Please consider accepting the following backport to 5.4 and 4.19 of commit 4d6ffa27b8e5 ("x86/lib: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S"), attached. The patch to 5.4 had a conflict due to 5.4 missing upstream commit e9b9d020c487 ("x86/asm: Annotate aliases") which first landed in v5.5-rc1. The patch to 4.19 had a conflict due to 4.19 missing the above commit and ffedeeb780dc ("linkage: Introduce new macros for assembler symbols") which also first landed in v5.5-rc1 but was backported to linux-5.4.y as commit 840d8c9b3e5f ("linkage: Introduce new macros for assembler symbols") which shipped in v5.4.76. This patch fixes a build error from clang's assembler when building with Clang-12, which now errors when symbols are redeclared with different bindings. We're using clang's assembler in Android and ChromeOS for 4.19+. Jiri, would you mind reviewing the 4.19 patch (or both)? It simply open codes what the upstream macros would expand to; this can be and was observed from running: $ make ... arch/x86/lib/memmove_64.s (ie. lowercase s, to invoke the C preprocessor on the uppercase .S file) See also: https://github.com/ClangBuiltLinux/linux/issues/1190. -- Thanks, ~Nick Desaulniers >From fecddb0ab4ab58b69e29cb936b05336574cb029f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 2 Nov 2020 17:23:58 -0800 Subject: [PATCH] x86/lib: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S commit 4d6ffa27b8e5116c0abb318790fd01d4e12d75e6 upstream. Commit 393f203f5fd5 ("x86_64: kasan: add interceptors for memset/memmove/memcpy functions") added .weak directives to arch/x86/lib/mem*_64.S instead of changing the existing ENTRY macros to WEAK. This can lead to the assembly snippet .weak memcpy ... .globl memcpy which will produce a STB_WEAK memcpy with GNU as but STB_GLOBAL memcpy with LLVM's integrated assembler before LLVM 12. LLVM 12 (since https://reviews.llvm.org/D90108) will error on such an overridden symbol binding. Commit ef1e03152cb0 ("x86/asm: Make some functions local") changed ENTRY in arch/x86/lib/memcpy_64.S to SYM_FUNC_START_LOCAL, which was ineffective due to the preceding .weak directive. Use the appropriate SYM_FUNC_START_WEAK instead. Fixes: 393f203f5fd5 ("x86_64: kasan: add interceptors for memset/memmove/memcpy functions") Fixes: ef1e03152cb0 ("x86/asm: Make some functions local") Reported-by: Sami Tolvanen Signed-off-by: Fangrui Song Signed-off-by: Borislav Petkov Reviewed-by: Nick Desaulniers Tested-by: Nathan Chancellor Tested-by: Nick Desaulniers Cc: Link: https://lkml.kernel.org/r/20201103012358.168682-1-maskray@google.com [nd: backport due to missing commit e9b9d020c487 ("x86/asm: Annotate aliases")] Signed-off-by: Nick Desaulniers Reported-by: Sami Tolvanen Signed-off-by: Fangrui Song Signed-off-by: Borislav Petkov Reviewed-by: Nick Desaulniers Tested-by: Nathan Chancellor Tested-by: Nick Desaulniers Signed-off-by: Nick Desaulniers --- arch/x86/lib/memcpy_64.S | 6 ++---- arch/x86/lib/memmove_64.S | 6 ++---- arch/x86/lib/memset_64.S | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 92748660ba51..29f1eecffdfd 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -15,8 +15,6 @@ * to a jmp to memcpy_erms which does the REP; MOVSB mem copy. */ -.weak memcpy - /* * memcpy - Copy a memory block. * @@ -28,8 +26,8 @@ * Output: * rax original destination */ -ENTRY(__memcpy) -ENTRY(memcpy) +SYM_FUNC_START_ALIAS(__memcpy) +SYM_FUNC_START_WEAK(memcpy) ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \ "jmp memcpy_erms", X86_FEATURE_ERMS diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S index bbec69d8223b..f8deefb5a994 100644 --- a/arch/x86/lib/memmove_64.S +++ b/arch/x86/lib/memmove_64.S @@ -24,10 +24,8 @@ * Output: * rax: dest */ -.weak memmove - -ENTRY(memmove) -ENTRY(__memmove) +SYM_FUNC_START_WEAK(memmove) +SYM_FUNC_START(__memmove) /* Handle more 32 bytes in loop */ mov %rdi, %rax diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S index 9bc861c71e75..65837f7eeb32 100644 --- a/arch/x86/lib/memset_64.S +++ b/arch/x86/lib/memset_64.S @@ -6,8 +6,6 @@ #include #include -.weak memset - /* * ISO C memset - set a memory block to a byte value. This function uses fast * string to get better performance than the original function. The code is @@ -19,8 +17,8 @@ * * rax original destination */ -ENTRY(memset) -ENTRY(__memset) +SYM_FUNC_START_WEAK(memset) +SYM_FUNC_START(__memset) /* * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended * to use it when possible. If not available, use fast string instructions.