Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp572602ybt; Wed, 17 Jun 2020 08:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQKUG8/g29gbVFkxgHlmSKwMAhXAjzGAnqcYZr3+3N273mM2tCJtFOxxdS8jpTj/vyrjV3 X-Received: by 2002:a17:906:4702:: with SMTP id y2mr7897338ejq.87.1592407503304; Wed, 17 Jun 2020 08:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592407503; cv=none; d=google.com; s=arc-20160816; b=liUPrDshAtaRIwH58ZnSZBS6C73lz8Hn1m6yVSlQoCxI82pdxLsUBYYxxqXJc4fA0V 9H8HI+y/e6u2/Mw9Z6LsAJqv7PMdMvk7RFS9twgECbAaaTi2ieFcx7C8Ppq4QH238yrn d/jvX8n0jBm2avDsKSSzwRa7bShaxyj2LtGS+KwdDj3xDYA87hUTlB6tPBGncFmN6lr4 c0ktSNr7ykJ2+NFym4jAAXKnTYloUwrL/Hlh5GV0TnzAwOf7yAHzsWSbeciOuoRQrjfV bGvgKZsKu1EGz2M36w06RWkfwSQJ61kfi55GbaXiFkM6pjVU0nb8SqExagmAv20B1A4l MnTw== 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=qQ975hNqevvgdpm9NCP0Rb6tLrxCJzAg5/lXYcYf+h8=; b=KJOdx7qvB+9g0KKUQd35dwDSXRAegWqX8HFVYfUzaMRsubr+hqvV5BXHPvM1jyTwkm Hyalqh7h1YNh9+GE+yLrHJ1G8CHLJgU8H7U1Hnpf3D7Q7/1/gV/L5R7D8/xLwtKtD4YK FAraakeBjm5l82YHj8fYgVUgisUf/quSzpxVjWEu3zdetUQ/5mBpq9Q51ZGq5MyH6fxj xtiKnkqVHyE5+Q/0Hiiyf3l2WUG1L+KnxZemVxXq48RBZprDAOw6FHl0iVMmw/41vqCP WjmE3PEIBs+RKzvPFSnyaORYHfX0oNP207gmijt8wVjqaVzs/0T3JPPIbiaytwd3HGU8 driw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KHJyeHZ1; 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 n15si216275edt.88.2020.06.17.08.24.40; Wed, 17 Jun 2020 08:25:03 -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=KHJyeHZ1; 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 S1726972AbgFQPUI (ORCPT + 99 others); Wed, 17 Jun 2020 11:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgFQPUH (ORCPT ); Wed, 17 Jun 2020 11:20:07 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4909EC06174E for ; Wed, 17 Jun 2020 08:20:07 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id f185so2429790wmf.3 for ; Wed, 17 Jun 2020 08:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qQ975hNqevvgdpm9NCP0Rb6tLrxCJzAg5/lXYcYf+h8=; b=KHJyeHZ10s41JrpZB5Pc/j1c0X6zwewzhIcG6+slF3BXsbLNgM68q19y6KINW6c6hy PCxOrAWwzVEhxy99/vLZbzGr7lFQM+sg/uZ4BV6KaCaq8NPT5UZzsLfn333MrMJBDWom FhoE3j3hY/XwZLX7TMKVRyDwBCTAhD+bxH4N6thblp8zewokqlW2IFGupUCSR4HF0m4l +5MG0QxTH9MdGya3P8+AfKe5RaBGHF5yqrpsgAyvykNXjWatfDv7xdSvPXqKxrEprDf2 XBhjLSJV3kAWfaAqmK5o8gGMeBy0WEY2c8rEhuB0GDRvmPAZc46/iEFVXhJQfpuAlxDL tJbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qQ975hNqevvgdpm9NCP0Rb6tLrxCJzAg5/lXYcYf+h8=; b=YUQamQKP+ikmIYpKkSS12lOUJFMg1VjA/GT1iFX6uy5OqwJKGxzYUMiu3k7HxeuQuf OZlDfecVijvDmCXuDEhbEEjqzJFRcJLm7gYyme87GcoE+WPgHuNgTyfOf3eRcLYOEcst N6+jYvx9iZD9X9xSbZHg32W0zvJAE6sqjwtAFi1UGknbVJTwvE90vY+kFWq/hYfPRIXT /Ppa/WCxk21yf+2qtmA3Ebs1vId9cxlb8yPrm2KeIOpoY5ssZB4G6uIesJPLm7yMFk5M 372n0hxbgkX5CwCWozrmXnP142/Gw+8pzev0w1sYV+Sf4dM8MjWhLmB6j65uTjwSjlw7 HU4g== X-Gm-Message-State: AOAM533SZMXOFkGSIqtS9YGVecF/D1CCR7Oc/H+lyT3PIc3mUW/pcF4L XuFhRBGCxqqN3Uj3z30md2CENA== X-Received: by 2002:a1c:5fd4:: with SMTP id t203mr8524133wmb.184.1592407205801; Wed, 17 Jun 2020 08:20:05 -0700 (PDT) Received: from elver.google.com ([100.105.32.75]) by smtp.gmail.com with ESMTPSA id y14sm76303wma.25.2020.06.17.08.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 08:20:05 -0700 (PDT) Date: Wed, 17 Jun 2020 17:19:59 +0200 From: Marco Elver To: Peter Zijlstra Cc: Dmitry Vyukov , Andrey Konovalov , Mark Rutland , Borislav Petkov , Thomas Gleixner , Ingo Molnar , clang-built-linux , "Paul E. McKenney" , Alexander Potapenko , kasan-dev , LKML , the arch/x86 maintainers , Andrew Morton , Josh Poimboeuf , ndesaulniers@google.com Subject: Re: [PATCH -tip v3 1/2] kcov: Make runtime functions noinstr-compatible Message-ID: <20200617151959.GB56208@elver.google.com> References: <20200612114900.GA187027@google.com> <20200615142949.GT2531@hirez.programming.kicks-ass.net> <20200615145336.GA220132@google.com> <20200615150327.GW2531@hirez.programming.kicks-ass.net> <20200615152056.GF2554@hirez.programming.kicks-ass.net> <20200617143208.GA56208@elver.google.com> <20200617144949.GA576905@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617144949.GA576905@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.13.2 (2019-12-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 04:49PM +0200, Peter Zijlstra wrote: > On Wed, Jun 17, 2020 at 04:32:08PM +0200, Marco Elver wrote: > > On Mon, Jun 15, 2020 at 05:20PM +0200, Peter Zijlstra wrote: > > > On Mon, Jun 15, 2020 at 05:03:27PM +0200, Peter Zijlstra wrote: > > > > > > > Yes, I think so. x86_64 needs lib/memcpy_64.S in .noinstr.text then. For > > > > i386 it's an __always_inline inline-asm thing. > > > > > > Bah, I tried writing it without memcpy, but clang inserts memcpy anyway > > > :/ > > > > Hmm, __builtin_memcpy() won't help either. > > > > Turns out, Clang 11 got __builtin_memcpy_inline(): https://reviews.llvm.org/D73543 > > > > The below works, no more crash on either KASAN or KCSAN with Clang. We > > can test if we have it with __has_feature(__builtin_memcpy_inline) > > (although that's currently not working as expected, trying to fix :-/). > > > > Would a memcpy_inline() be generally useful? It's not just Clang but > > also GCC that isn't entirely upfront about which memcpy is inlined and > > which isn't. If the compiler has __builtin_memcpy_inline(), we can use > > it, otherwise the arch likely has to provide the implementation. > > > > Thoughts? > > I had the below, except of course that yields another objtool > complaint, and I was still looking at that. > > Does GCC (8, as per the new KASAN thing) have that > __builtin_memcpy_inline() ? No, sadly it doesn't. Only Clang 11. :-/ But using a call to __memcpy() somehow breaks with Clang+KCSAN. Yet, it's not the memcpy that BUGs, but once again check_preemption_disabled (which is noinstr!). Just adding calls anywhere here seems to results in unpredictable behaviour. Are we running out of stack space? Thanks, -- Marco