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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A9886C433C1 for ; Thu, 25 Mar 2021 10:19:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16B2460C3E for ; Thu, 25 Mar 2021 10:19:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16B2460C3E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HBgQzwlegE2B1DvPHDxPAivqG7GNcnrfI1Z2YKWOGbE=; b=LYbCE2fZhAU2p+wAu7iOq54y+ zuAaOaxrzHGHINAwEdJaxc/VbGoVuHoBdoIYCJbGPR1RDDlcdOL62G6FTI7GolvEZjuqQtHgtvQAx FHiE8wi6P4TuuCSlW+D7c1jAl6i+VJmf5MyB7OkvzF9hv04i0r4ov7uUnG5E673hmfSwtnu+USZGm Il7YZdfXvNYlhlerlMpmiPnh+obRK88lFqwWfGBha29mXa5TfV8UOw66KX/kZK55+WB7o4dObba9j bGF4vI5rvmLLeX6n21OrjXh9LSeBcZja+gbyO5YyLN8wQQyJOcQVxDSncG8/MB1t5p0tPMNv+cvbj 9dYg8Roog==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPN37-001CJj-L3; Thu, 25 Mar 2021 10:17:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPN32-001CIm-75 for linux-arm-kernel@lists.infradead.org; Thu, 25 Mar 2021 10:17:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6609613A1; Thu, 25 Mar 2021 03:17:02 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2EB263F718; Thu, 25 Mar 2021 03:16:57 -0700 (PDT) Date: Thu, 25 Mar 2021 10:16:55 +0000 From: Mark Rutland To: Sami Tolvanen 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 Subject: Re: [PATCH v3 03/17] mm: add generic __va_function and __pa_function macros Message-ID: <20210325101655.GB36570@C02TD0UTHF1T.local> References: <20210323203946.2159693-1-samitolvanen@google.com> <20210323203946.2159693-4-samitolvanen@google.com> <20210324071357.GB2639075@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210325_101704_561297_AB11F4F9 X-CRM114-Status: GOOD ( 24.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel