Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1566298ybi; Wed, 17 Jul 2019 17:49:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqw79MzP7S+e4Fmtg9xZRXaYMrdnGzKTvuposA2SUy9tP90jKIv5Es6+CFD9pF3DxCUPSRSu X-Received: by 2002:a63:ce45:: with SMTP id r5mr20015813pgi.435.1563410944580; Wed, 17 Jul 2019 17:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563410944; cv=none; d=google.com; s=arc-20160816; b=WhnCeaAY+pR3ZdXDGdWhDYWMSKOCHc0bRxdd8Wzslom/E/fHf7hhVZQ/hE5/1XWEqK YHKlfziMMC3tGrcXDdehx+xpxhJj4Y26pRms3PNJB/8Byo0soeeLbyX6eAjwRo9YTrUL 4Z/DQj17T+GUvB5P54v6xNSmrQLmT7wkpWxc9BEweN1t2xg4p0atpjmStl0oRFR3RwP5 TAj2iqmy+hnCwHnlaWgjWX1IEV1u3CAQCjlrcFJGDlp8r2o2ErzEGOTWKLWdwSYi6gvS v8b19/8vDaGY+ZcPZ+fFse1fhSyj1Jh9OaxujR3Jbho+2TO0C49zL49yrU+56C5Jimuz eujg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dczQDVue2ywrYxnl2pRFV0haOoi+uFxq0/WRrkbMcHI=; b=s0RQNVIinGvNYdGpfa8MoK31us0HddQDKQBkaDvkpJDC4XtioyuelW/53fCjCNuUM+ PKtxFInYKxoJxMnHA6gWdTKgPM1HIgZxYvbAJLsB/yElkzawGbO6nFUgcOm4KAM90kLG Z4Gzctge4bm+JdFAY0woWMoODTD1E+ygPdpWVxd95TUI4pMapzAIDAuwt0p/KjnTNF6O 2t/BiDsGTUj/uQjuRCblsk7DG4YN3UP1BWkbY1VPiU26McACUlUrmvj3bAPF9oOx6BY8 f7gNRAFifbgt4cBIB52PtW+AJybcjWmoM6V9Xq4iing5eDJN/nhOQ+SZrD2GORdZ4myY v48Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=moALQlLX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i68si25651486pfc.153.2019.07.17.17.48.48; Wed, 17 Jul 2019 17:49:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=moALQlLX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731973AbfGRArT (ORCPT + 99 others); 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.