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=-15.1 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=no 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 0F49DC2BC84 for ; Thu, 3 Sep 2020 22:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D43F220716 for ; Thu, 3 Sep 2020 22:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bCIKEXnT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729036AbgICWML (ORCPT ); Thu, 3 Sep 2020 18:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgICWMH (ORCPT ); Thu, 3 Sep 2020 18:12:07 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69501C061244 for ; Thu, 3 Sep 2020 15:12:07 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id a26so6015983ejc.2 for ; Thu, 03 Sep 2020 15:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BwuEtmyXe7F2cR0q4/BzPn1A0ke23BiGgvDQhdo0WMU=; b=bCIKEXnTf0ca1JmAwAE+LZOTcE2dN/TiK90vOBcdOhHh/Eb1NLoFw7SGFvV4u1q4yd NSCanRXVgtM0tLCAM/3prxemS1L+tmFwrVZgjePvUDD44B5oCHIVMnvMHwsYfaBSh/Yc ffmoIuI333/SJsY+DmYpMd9pJN4WUM6UZUH4iyAU5CMWkI/ub98PWyrdm/IgFhN66cyb KAJCdgJvjtjPtzH0nHOK8Q44XszFzrAF+OGkeCpJsCVm4vUIQ5GYCIXnLOQe2wb/sK6A t28MQcHuz/Eyk+V8/eVV05WMiL8r79f3UOiZYAKgfKK5uep6TWKRy9tUGQI9YxjCiAu1 jxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BwuEtmyXe7F2cR0q4/BzPn1A0ke23BiGgvDQhdo0WMU=; b=hCOAxpbYAtEG7kB8h5+lo1mAMoAboplkf2VGHkEQqdc468vuRKFrG4HuOt83agaAX3 D+/lO8dAUz1ai4WX8TybsBb2nEsj0iGLaKg3kcEs1CLjSJr0lF+8rmikHsejaI8vOf2u mxzl3hQb9gLoPmw2OdYmC6/Zj+9jXMh5DiiY80gMAr0gGzhw1/WjuTFFbEJALjzCvoEa GVC32Zyq7SngQwjgDxy8j/Q5nSqePnN3jVilb4RtL75uu5FSpDJBknCR3h5eSn8m2FMr 5okF4GwdgUnQIVaD9VutaGls05IEmSV6ZbOzcCXgh9Eo1tFyAcLRyli6+yAs4aAwxKnr iYkA== X-Gm-Message-State: AOAM532752tKkTxQ8ciKqvadNShVofAPbApCqXZdAIYJaQVBDL5nZnPz nbnah9Ya1d04L1NAwIktQCC/YeZBJxFnNgebZREv7w== X-Google-Smtp-Source: ABdhPJzTTihf74kYnNBBzSlXexZpmKM7vZMRAKfIQLzvqwFNAx6uvnwDBIQzEJ98cMtCA2J/JaapvP+XgOC8JK4Jyhw= X-Received: by 2002:a17:906:7492:: with SMTP id e18mr4301672ejl.375.1599171125797; Thu, 03 Sep 2020 15:12:05 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-9-samitolvanen@google.com> <202009031456.C058EC4@keescook> In-Reply-To: <202009031456.C058EC4@keescook> From: Sami Tolvanen Date: Thu, 3 Sep 2020 15:11:54 -0700 Message-ID: Subject: Re: [PATCH v2 08/28] x86, build: use objtool mcount To: Kees Cook Cc: Masahiro Yamada , Will Deacon , Peter Zijlstra , Steven Rostedt , Greg Kroah-Hartman , "Paul E. McKenney" , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , linux-pci@vger.kernel.org, X86 ML Content-Type: text/plain; charset="UTF-8" Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Sep 3, 2020 at 2:58 PM Kees Cook wrote: > > On Thu, Sep 03, 2020 at 01:30:33PM -0700, Sami Tolvanen wrote: > > Select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION is selected to use > > objtool to generate __mcount_loc sections for dynamic ftrace with > > Clang and gcc <5. > > > > Signed-off-by: Sami Tolvanen > > Am I right to understand that this fixes mcount for Clang generally > (i.e. it's not _strictly_ related to LTO, though LTO depends on this > change)? No, this works fine with Clang when LTO is disabled, because recordmcount ignores files named "ftrace.o". However, with LTO, we process vmlinux.o instead, so we need a different method of ignoring __fentry__ relocations that are not calls. In v1, I used a function attribute to whitelist functions that refer to __fentry__, but as Peter pointed out back then, objtool already knows where the call sites are, so using it to generate __mcount_loc is cleaner. > And does this mean mcount was working for gcc < 5? Yes. I should have been clearer in the commit message. The reason I mentioned gcc <5 is that later gcc versions support -mrecord-mcount, which means they don't need an external tool for generating __mcount_loc anymore. Sami