Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp251329pxf; Thu, 25 Mar 2021 03:18:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYJvK6P7DymePBg+uTSYKpkAY6hktKlAvn6sSwrqmbB8ttuKv9JwUzJ7GiBE3uFt64H6yN X-Received: by 2002:a17:906:1c98:: with SMTP id g24mr8578742ejh.51.1616667520514; Thu, 25 Mar 2021 03:18:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616667520; cv=none; d=google.com; s=arc-20160816; b=TtlK1fGRa4damMeDZfF7TmWoFWYm6iySwmY96OBycXfjYyeZYFSwI2tHqU3SsB1yAa Svk9UKoYCpjgSsEZCZV9/7hsKOa+R8KDtqWVXfV6yF2P8lRfB8OYM0p2AE+cmfAkJkNz 951i2HY51Di228V9R/BvqAw+noWAMdLejATvWITGs9xX/WNTjWIpOlbrDaYTKAecYLsT 6Zhy20949qPvg/81nWIGyQGLeheXg4oQG2MhSEEGBJykozB3VAEr01ooz3iaVPKPDgD0 7aPTgCMzQlFeKkNuD/mKcUBMXxvePXcI23NQk1DTboIWlrR91SjqIHqgdqm6szc8tJIH H4Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=VIfyQMCxLiN1Z2QqbOSnS6Yxk3ab16GB2GO/1+6uYtk=; b=I3fJ7MKd+BPsIzkkLt6cLkwO3iUZZQGCS7kDxzy8nNZj6MlwUlOCHXXYvV0isOYA4u ecrnVoSN6U/YhO+aXjEbUyWqvbuCFgAKBl1zBUS4MgG5pQNl3fD44schSwlgSBVpb3Pl WYnazo2PkrEbH0VYlwenTyom4EC9zxpryHPm+B2BdMHHWVqy3DKD+7Ejg1gHEqY4Pv9r LCsJK+K3eEGJ0U9B5QEENVK20iCEfxNqM5NQNPqpkW1qIO9wzqJTnpy1er7QuzvSwzVd HjmUbXPWqNrPn4RCiG04Dqqv/wkVlTFDX371+EytOBfEZyJAAcUb9D1l/Z9BgNa8Ws8/ c53w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si4293085edn.523.2021.03.25.03.18.17; Thu, 25 Mar 2021 03:18:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbhCYKRP (ORCPT + 99 others); Thu, 25 Mar 2021 06:17:15 -0400 Received: from foss.arm.com ([217.140.110.172]:45880 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230007AbhCYKRD (ORCPT ); Thu, 25 Mar 2021 06:17:03 -0400 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.