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=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 C8EDBC33C9E for ; Tue, 14 Jan 2020 18:14:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A4EE724672 for ; Tue, 14 Jan 2020 18:14:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dTv8P4CG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="lUYqmp9E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4EE724672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=CaaBoeFralbBc9moyfQCocLoTco4BKOMBTDKp0njyew=; b=dTv8P4CG8UfLUH R7k+ePSODHVWl1W4URSJZ0tGgjvlbK3jsOWGvcPHrE9AZ1oh7x3AGtMXT3WwayydSjzDhSJcwjeUm w/qVomA8h2/CdWtUyoHJxAdkm/YYByh+MlPoSfs+BI1s1VvcdZXQSYDwGNQ5M5u1/lN8taDdOHYnK OUt2WJ+9DSv9DKv+blut4vX9RPuwu9vYM0tPDaN/1rkCPcH3k92cmn8EeKPBVkd4+YIj3hHnxdlBX xbXassjhA58Po96vOfQUTEMLNQVyYqniLNNj4bRLk2pqfIZjUq0qXmK+v5fxQAZIGWVI2RoFUDcdU 5s9fEKNmIwrkzPokuBAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQiM-0000nK-FO; Tue, 14 Jan 2020 18:14:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irQiG-0000mD-Iy for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 18:14:53 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 618E8214AF; Tue, 14 Jan 2020 18:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579025688; bh=qMh1ery7M9FYKnGIXqR8RVhv5V7Xpyo6s7S1NGHlk/I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lUYqmp9E0IHaiBAQLWrMlx4ZGPSx81qOFkn+kt2E0saW/j73vmHShiwgKg0YzhZ7F oD++zjnW/suLGyOY9+rp/TuS1Tptv4QU2NAuBwIvQ//5O6dTagWDvZ7qb97H3BSgrh 54JZ+Cr+Iay9ktvSAb7op3V3/UQTZZDTFvibcHtw= Date: Tue, 14 Jan 2020 18:14:41 +0000 From: Will Deacon To: Pavel Tatashin Subject: Re: [PATCH v5 3/6] arm64: remove uaccess_ttbr0 asm macros from cache functions Message-ID: <20200114181440.GH2579@willie-the-truck> References: <20200102211357.8042-1-pasha.tatashin@soleen.com> <20200102211357.8042-4-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200102211357.8042-4-pasha.tatashin@soleen.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_101448_670740_218A3372 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, stefan@agner.ch, jmorris@namei.org, yamada.masahiro@socionext.com, boris.ostrovsky@oracle.com, sashal@kernel.org, sstabellini@kernel.org, maz@kernel.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, vladimir.murzin@arm.com, julien@xen.org, alexios.zavras@intel.com, tglx@linutronix.de, allison@lohutok.net, jgross@suse.com, steve.capper@arm.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, james.morse@arm.com, andrew.cooper3@citrix.com, info@metux.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jan 02, 2020 at 04:13:54PM -0500, Pavel Tatashin wrote: > We currently duplicate the logic to enable/disable uaccess via TTBR0, > with C functions and assembly macros. This is a maintenenace burden > and is liable to lead to subtle bugs, so let's get rid of the assembly > macros, and always use the C functions. This requires refactoring > some assembly functions to have a C wrapper. > > Signed-off-by: Pavel Tatashin > --- > arch/arm64/include/asm/asm-uaccess.h | 22 ---------------- > arch/arm64/include/asm/cacheflush.h | 39 +++++++++++++++++++++++++--- > arch/arm64/mm/cache.S | 36 ++++++++++--------------- > arch/arm64/mm/flush.c | 2 +- > 4 files changed, 50 insertions(+), 49 deletions(-) > > diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h > index f68a0e64482a..fba2a69f7fef 100644 > --- a/arch/arm64/include/asm/asm-uaccess.h > +++ b/arch/arm64/include/asm/asm-uaccess.h > @@ -34,28 +34,6 @@ > msr ttbr0_el1, \tmp1 // set the non-PAN TTBR0_EL1 > isb > .endm > - > - .macro uaccess_ttbr0_disable, tmp1, tmp2 > -alternative_if_not ARM64_HAS_PAN > - save_and_disable_irq \tmp2 // avoid preemption > - __uaccess_ttbr0_disable \tmp1 > - restore_irq \tmp2 > -alternative_else_nop_endif > - .endm > - > - .macro uaccess_ttbr0_enable, tmp1, tmp2, tmp3 > -alternative_if_not ARM64_HAS_PAN > - save_and_disable_irq \tmp3 // avoid preemption > - __uaccess_ttbr0_enable \tmp1, \tmp2 > - restore_irq \tmp3 > -alternative_else_nop_endif > - .endm > -#else > - .macro uaccess_ttbr0_disable, tmp1, tmp2 > - .endm > - > - .macro uaccess_ttbr0_enable, tmp1, tmp2, tmp3 > - .endm > #endif > > #endif > diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h > index 665c78e0665a..cb00c61e0bde 100644 > --- a/arch/arm64/include/asm/cacheflush.h > +++ b/arch/arm64/include/asm/cacheflush.h > @@ -61,16 +61,49 @@ > * - kaddr - page address > * - size - region size > */ > -extern void __flush_icache_range(unsigned long start, unsigned long end); > -extern int invalidate_icache_range(unsigned long start, unsigned long end); > +extern void __asm_flush_icache_range(unsigned long start, unsigned long end); > +extern long __asm_flush_cache_user_range(unsigned long start, > + unsigned long end); > +extern int __asm_invalidate_icache_range(unsigned long start, > + unsigned long end); > extern void __flush_dcache_area(void *addr, size_t len); > extern void __inval_dcache_area(void *addr, size_t len); > extern void __clean_dcache_area_poc(void *addr, size_t len); > extern void __clean_dcache_area_pop(void *addr, size_t len); > extern void __clean_dcache_area_pou(void *addr, size_t len); > -extern long __flush_cache_user_range(unsigned long start, unsigned long end); > extern void sync_icache_aliases(void *kaddr, unsigned long len); > > +static inline long __flush_cache_user_range(unsigned long start, > + unsigned long end) > +{ > + int ret; > + > + uaccess_ttbr0_enable(); > + ret = __asm_flush_cache_user_range(start, end); > + uaccess_ttbr0_disable(); > + > + return ret; > +} > + > +static inline void __flush_icache_range(unsigned long start, unsigned long end) > +{ > + uaccess_ttbr0_enable(); > + __asm_flush_icache_range(start, end); > + uaccess_ttbr0_disable(); > +} Interesting... I don't think we should be enabling uaccess here: the function has a void return type so we can't communicate failure back to the caller if we fault, so my feeling is that this should only ever be called on kernel addresses. > + > +static inline int invalidate_icache_range(unsigned long start, > + unsigned long end) > +{ > + int ret; > + > + uaccess_ttbr0_enable(); > + ret = __asm_invalidate_icache_range(start, end); > + uaccess_ttbr0_disable(); > + > + return ret; > +} Same here -- I don't think think this is ever called on user addresses. Can we make the return type void and drop the uaccess toggle? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel