From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21652C76192 for ; Thu, 18 Jul 2019 00:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE83821849 for ; Thu, 18 Jul 2019 00:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563410840; bh=xdUPLnhzHIdZRYZi8AUKI9yOcgq9hjqy1SmitBqoN1k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=fIGoFQwydkaOIenYr72hzQXEVKNXHa/CPuGJfEShHhglWmBH+sp21S3Y6+U9erl/0 KUujoD6jgwwR3lirq+AMiZ859EdEBEu5sDGzITNtbW3kriYTn4L4jbHzxEP5G8LFj6 bvfvP2U9J/itnd3t/yUte1Mj3HsgLaPvT9YQdLaE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732032AbfGRArT (ORCPT ); Wed, 17 Jul 2019 20:47:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:53264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbfGRArS (ORCPT ); Wed, 17 Jul 2019 20:47:18 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D5B4217F4; Thu, 18 Jul 2019 00:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563410837; bh=xdUPLnhzHIdZRYZi8AUKI9yOcgq9hjqy1SmitBqoN1k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=moALQlLXZ2zUwy7M4eJ872ZP8pni0uVTPRs5iRtREQbZLbfB6Junpc+piQ0kFklt/ x/Rhw75/MByDS0k0J4Zb1HEinxnFXFscat18Bve55q5AwQRk0q1cnFZNm4T52Ezd8/ HPAsizUyafk7GSk5dYymd2CQ2YIaBn14f2lk+gbY= Date: Thu, 18 Jul 2019 09:47:15 +0900 From: Greg KH To: Vaibhav Rustagi Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Vivek Goyal , Nick Desaulniers , stable@vger.kernel.org, Manoj Gupta , Alistair Delva Subject: Re: [PATCH 2/2] x86/purgatory: do not use __builtin_memcpy and __builtin_memset. Message-ID: <20190718004715.GB31085@kroah.com> References: <20190718000206.121392-1-vaibhavrustagi@google.com> <20190718000206.121392-3-vaibhavrustagi@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190718000206.121392-3-vaibhavrustagi@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 17, 2019 at 05:02:06PM -0700, Vaibhav Rustagi wrote: > From: Nick Desaulniers > > Implementing memcpy and memset in terms of __builtin_memcpy and > __builtin_memset is problematic. > > GCC at -O2 will replace calls to the builtins with calls to memcpy and > memset (but will generate an inline implementation at -Os). Clang will > replace the builtins with these calls regardless of optimization level. > > $ llvm-objdump -dr arch/x86/purgatory/string.o | tail > > 0000000000000339 memcpy: > 339: 48 b8 00 00 00 00 00 00 00 00 movabsq $0, %rax > 000000000000033b: R_X86_64_64 memcpy > 343: ff e0 jmpq *%rax > > 0000000000000345 memset: > 345: 48 b8 00 00 00 00 00 00 00 00 movabsq $0, %rax > 0000000000000347: R_X86_64_64 memset > 34f: ff e0 > > Such code results in infinite recursion at runtime. This is observed > when doing kexec. > > Instead, reuse an implementation from arch/x86/boot/compressed/string.c > if we define warn as a symbol. > > Link: https://bugs.chromium.org/p/chromium/issues/detail?id=984056 > Reported-by: Vaibhav Rustagi > Tested-by: Vaibhav Rustagi > Debugged-by: Vaibhav Rustagi > Debugged-by: Manoj Gupta > Suggested-by: Alistair Delva > Signed-off-by: Vaibhav Rustagi > Signed-off-by: Nick Desaulniers > --- > arch/x86/purgatory/Makefile | 3 +++ > arch/x86/purgatory/purgatory.c | 6 ++++++ > arch/x86/purgatory/string.c | 23 ----------------------- > 3 files changed, 9 insertions(+), 23 deletions(-) > delete mode 100644 arch/x86/purgatory/string.c This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.