Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp867104pxf; Thu, 25 Mar 2021 16:20:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY92d87480M0RxSJ7XuQTU9w4ikHyKOGBPc9QFLXs5pMxVZ0b+ZYefzRt6iZKbMORM/dNM X-Received: by 2002:a17:906:5295:: with SMTP id c21mr12308831ejm.67.1616714408522; Thu, 25 Mar 2021 16:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616714408; cv=none; d=google.com; s=arc-20160816; b=O/ZaSIdoovLxBss+Z5CBmASApksnIYDM/iWNaWmKsWjnx8pRybm5VGBcfKrjOVnxKi 51RbeA+6+zZKdDyqFtbqETkGTAUglnAgnk59QncifHwDRkfPqcCpKtxFtTM0U68GYjUF 09IiJoOpix0qloPYX+8th/x6plKhGWt51IP5sHJVJUy0UcW4u9Px98NX99rhbSA2IXbk EyISfNfVrcIxgW6LdpLQOXHo90NdaXwt6NwRxzq9BjaDZyC7cAJgZgdZth6Yz0+EKDRA 5jsB9or6mDuBZIBWxxWi57yGskn1McQxt2r6vbtmC2O5WMokycHGiwRJkPjzxSkEAaKe J6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7Yk9NlOmGKofkdfMA6+3ywtQqOEAPVMOAz3hdr7uXvE=; b=NTDeSrxyAw2MBUYhAtHwjPeoFsymKKGIeuAznzVC7Ys6MKRJ/tL5zez/wMaw/8XCsJ 3p1gUJkJNxLHz5Irc4agiA5aa/llqQoyz9yS/oAfUJfZ8PXvAYk2Zdt7NCmvApUOJ3qp skz2ogbZgwmbOL6MKQCYpiyUjfAmazYN+mkZdgq2eUVMjKhzIod5wTIWPEhWzThrasNL sLGGLTSfD0t9WF68HnBs8A2VxPx/fhqibRRJ44pbcqJwSy9qNJ9++kZ8ePxaskQuuy94 OWP0EiS8pFXRFz9HO8Az7IO2wkxt8mSGfXlNadqzHY+NhySOLnMjYVWDCkdKZZ7jXNWV lg+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vA7OWbbK; 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 dn4si6122063ejc.709.2021.03.25.16.19.45; Thu, 25 Mar 2021 16:20:08 -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=vA7OWbbK; 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 S230486AbhCYXST (ORCPT + 99 others); Thu, 25 Mar 2021 19:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbhCYXSR (ORCPT ); Thu, 25 Mar 2021 19:18:17 -0400 Received: from mail-ua1-x935.google.com (mail-ua1-x935.google.com [IPv6:2607:f8b0:4864:20::935]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73C51C0613D7 for ; Thu, 25 Mar 2021 16:18:12 -0700 (PDT) Received: by mail-ua1-x935.google.com with SMTP id e1so1048521uaa.4 for ; Thu, 25 Mar 2021 16:18:12 -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=7Yk9NlOmGKofkdfMA6+3ywtQqOEAPVMOAz3hdr7uXvE=; b=vA7OWbbKWkumvZyucEZbcqeuCLfEdVpEWrKxOGx3P4tN9R3u/6w/09xaucaXo3fP1z MQIYpOTb4zLWU/hQWjL9CBjSTPJO+KxQfG7Dx96rt5gAiLXhhKoC7ABFmLukh4KXeZ9Z aRhWqpdYN7r23J9Vzze5A3lqpbSCfVHcu6YBrOLJtfWDQkdTihrZonOMBhhW48YWR/dn IhljM1ItzoydJs5ao4S1mTCZ7s+gfiMgil1ViPnShV6stP0PH7QJBHHaKatW8sJcx0wz u0NvJkbimko9Onpbq3gHaKn863Ymdx5cM9MeIfPQ4d7sEby86nkv+ILpbiaNaR5znvcq qbrg== 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=7Yk9NlOmGKofkdfMA6+3ywtQqOEAPVMOAz3hdr7uXvE=; b=miA7YYZp22fEX5ixEFBcv3R2RJZqPpWt69k8cALr+KuH69nvr/XzpniO4OmaPLuNg3 R3N/YlnBKBLUU9c/Y0w8aZ2q2lShGswd25WJuSpjDsuV4cHoJVISY/3ebuGnqe39iyPa K9m1x3Twc3l49dDUddaszBLLNJ2WcgPwUcVHJcJoe7jcYcPuxl7kP9DEgdOgQMFR6NWW eT1XfMEaBK4hFrOcSBhJ1Z5fIuzw74GiP+fGs0IwwPrsszg8Uj3sTKWiv0uV7G4o1c/z adBw51VvXwWjBF4J0/fpzirSErrKLZRUfp2w4OEZBg3QseB8QHtbQoauJX4zh0MILaX4 Q5BQ== X-Gm-Message-State: AOAM530blOCDl3gLVQ6AWUnvu5Z8NHrE+iPJE0bjm2rb2o4Jg+qM0ZDT DGUQgCreyJorNoq7Ofg6WWL/I9uxx+GQlbvAjFPb2w== X-Received: by 2002:ab0:b14:: with SMTP id b20mr6273790uak.52.1616714291094; Thu, 25 Mar 2021 16:18:11 -0700 (PDT) MIME-Version: 1.0 References: <20210323203946.2159693-1-samitolvanen@google.com> <20210323203946.2159693-4-samitolvanen@google.com> <20210324071357.GB2639075@infradead.org> <20210325101655.GB36570@C02TD0UTHF1T.local> In-Reply-To: <20210325101655.GB36570@C02TD0UTHF1T.local> From: Sami Tolvanen Date: Thu, 25 Mar 2021 16:17:59 -0700 Message-ID: Subject: Re: [PATCH v3 03/17] mm: add generic __va_function and __pa_function macros To: Mark Rutland Cc: Christoph Hellwig , Kees Cook , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Peter Zijlstra , bpf , linux-hardening@vger.kernel.org, linux-arch , linux-arm-kernel , linux-kbuild , PCI , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 3:17 AM Mark Rutland wrote: > > On Wed, Mar 24, 2021 at 08:54:18AM -0700, Sami Tolvanen wrote: > > On Wed, Mar 24, 2021 at 12:14 AM Christoph Hellwig wrote: > > > > > > On Tue, Mar 23, 2021 at 01:39:32PM -0700, Sami Tolvanen wrote: > > > > With CONFIG_CFI_CLANG, the compiler replaces function addresses > > > > in instrumented C code with jump table addresses. This means that > > > > __pa_symbol(function) returns the physical address of the jump table > > > > entry instead of the actual function, which may not work as the jump > > > > table code will immediately jump to a virtual address that may not be > > > > mapped. > > > > > > > > To avoid this address space confusion, this change adds generic > > > > definitions for __va_function and __pa_function, which architectures > > > > that support CFI can override. The typical implementation of the > > > > __va_function macro would use inline assembly to take the function > > > > address, which avoids compiler instrumentation. > > > > > > I think these helper are sensible, but shouldn't they have somewhat > > > less arcane names and proper documentation? > > > > Good point, I'll add comments in the next version. I thought > > __pa_function would be a fairly straightforward replacement for > > __pa_symbol, but I'm fine with renaming these. Any suggestions for > > less arcane names? > > I think dropping 'nocfi' into the name would be clear enough. I think > that given the usual fun with {symbol,module,virt}->phys conversions > it's not worth having the __pa_* form, and we can leave the phys > conversion to the caller that knows where the function lives. > > How about we just add `function_nocfi()` ? > > Callers can then do `__pa_symbol(function_nocfi(foo))` and similar. Sounds reasonable. I'll drop __pa_function() and rename __va_function() to function_nocfi() in the next version. Sami