Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553AbdCEAPD (ORCPT ); Sat, 4 Mar 2017 19:15:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:33610 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbdCEAPC (ORCPT ); Sat, 4 Mar 2017 19:15:02 -0500 Date: Sun, 5 Mar 2017 01:14:47 +0100 From: Borislav Petkov To: hpa@zytor.com Cc: Logan Gunthorpe , Thomas Gleixner , Ingo Molnar , Tony Luck , Al Viro , the arch/x86 maintainers , Linux Kernel Mailing List Subject: Re: Question Regarding ERMS memcpy Message-ID: <20170305001447.kcxignj3nsq35vci@pd.tnic> References: <20170304224341.zfp4fl37ypt57amg@pd.tnic> <5CCEF10D-5647-4503-A398-0681DF2C8847@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5CCEF10D-5647-4503-A398-0681DF2C8847@zytor.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1366 Lines: 42 On Sat, Mar 04, 2017 at 03:55:27PM -0800, hpa@zytor.com wrote: > For newer processors, as determined by -mtune=, it is actually the > best option for an arbitrary copy. So his doesn't have ERMS - it is a SNB - so if for SNB REP_GOOD is the best option for memcpy, then we should probably build with -fno-builtin-memcpy unconditionally. Otherwise gcc apparently inserts its own memcpy variant. And this is probably wrong because we do the detection at boot time and not at build time. For example here it generates REP; MOVSL for the call in drivers/firmware/dmi_scan.c::dmi_scan_machine() which looks wrong to me. Length is 32 so it could just as well do REP; MOVSQ. IOW, we could do something like this: --- diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 2d449337a360..c1b68d147b8d 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -142,10 +142,7 @@ ifdef CONFIG_X86_X32 endif export CONFIG_X86_X32_ABI -# Don't unroll struct assignments with kmemcheck enabled -ifeq ($(CONFIG_KMEMCHECK),y) - KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy) -endif +KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy) # Stackpointer is addressed different for 32 bit and 64 bit x86 sp-$(CONFIG_X86_32) := esp -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --