Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp938355ybh; Mon, 13 Jul 2020 05:23:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR8guvpLzTDOt9/Qkp6TMOrLw2cotp5kxW1hiQBacs/SBmJ44/6nMroyMI/GZ97u8HDcVB X-Received: by 2002:a17:906:2b0e:: with SMTP id a14mr46096756ejg.459.1594642988726; Mon, 13 Jul 2020 05:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594642988; cv=none; d=google.com; s=arc-20160816; b=JvgmwpZFaCaCIvUpSSkG3c+mET7gHq/Wp9QDBjuyenl2gKhqwVeq/cROKZthQ1Pg09 azlmw2DQn86G4J8lRSdQZomIFwF5npopYeC+O48xKBLtQ2EDfSWaUtImEg1PxHget9rM /nQ3YneGlhDYkChN6VdoZ6DuVKFM+rb2gLFDEd0yB1o65p+pxAiYvrEa3khXGOUMA7Lr JwKZkeUxWecF1mD+q8g0L+7cBhOMZjYhEyFEU2gc9M/43AzJ8JXKb9rg7Ch7CDNoq4s8 Pp3XZFji/7VDR8Qy8plmFl2atVmqI/NuNbdLarSR06Rrbh6dDwn4lvDkfQq+5U/USnns Ycsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8YoZfS6Ec0trQxulK3DBYECrFf+oRtRr9nCx9IJyqvA=; b=iSBspPFwnxeRhvBsQVtCnN1tprj3/wjcBNYXFiecPZq91EUqT1/kSkEwCaeIuc4k2z ICNz4Eikie5U40czpSGlSuZjsDLxspAYNaDxu2aMK5C3YE/MlNJgmSWHrVSU4aZm8ZrG WQy728InXDTNZijGMsABrnO5yKJfumSaLhJYrljuQGfWAoJtd8r9mqq+aP7KRoRdhprq h2Kz12QqyWsezljasHMPSgOqOk9lcGUKabgECspxfGNzmeFuDv23tyqg7pRZ79mcz7Hk BFAPgzDzxF+JUx2vAXn/JuG36IGIL5T3/KqsT4sglCZ3RB/Ag6yaemjUM1QiaEof350M N2oA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si9071890edr.292.2020.07.13.05.22.45; Mon, 13 Jul 2020 05:23: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729754AbgGMMV5 (ORCPT + 99 others); Mon, 13 Jul 2020 08:21:57 -0400 Received: from foss.arm.com ([217.140.110.172]:59286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgGMMV4 (ORCPT ); Mon, 13 Jul 2020 08:21:56 -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 3E83530E; Mon, 13 Jul 2020 05:21:56 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA0163F887; Mon, 13 Jul 2020 05:21:54 -0700 (PDT) Date: Mon, 13 Jul 2020 13:21:48 +0100 From: Mark Rutland To: Christoph Hellwig , Geert Uytterhoeven Cc: Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Andrew Morton , Linus Torvalds , linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/6] uaccess: add force_uaccess_{begin,end} helpers Message-ID: <20200713122148.GA51007@lakrids.cambridge.arm.com> References: <20200710135706.537715-1-hch@lst.de> <20200710135706.537715-6-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710135706.537715-6-hch@lst.de> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 10, 2020 at 03:57:05PM +0200, Christoph Hellwig wrote: > Add helpers to wraper the get_fs/set_fs magic for undoing any damange > done by set_fs(KERNEL_DS). There is no real functional benefit, but this > documents the intent of these calls better, and will allow stubbing the > functions out easily for kernels builds that do not allow address space > overrides in the future. > diff --git a/arch/m68k/include/asm/tlbflush.h b/arch/m68k/include/asm/tlbflush.h > index 191e75a6bb249e..30471549e1e224 100644 > --- a/arch/m68k/include/asm/tlbflush.h > +++ b/arch/m68k/include/asm/tlbflush.h > @@ -13,13 +13,13 @@ static inline void flush_tlb_kernel_page(void *addr) > if (CPU_IS_COLDFIRE) { > mmu_write(MMUOR, MMUOR_CNL); > } else if (CPU_IS_040_OR_060) { > - mm_segment_t old_fs = get_fs(); > - set_fs(KERNEL_DS); > + mm_segment_t old_fs = force_uaccess_begin(); > + This used to set KERNEL_DS, and now it sets USER_DS, which looks wrong superficially. If the new behaviour is fine it suggests that the old behaviour was wrong, or that this is superfluous and could go entirely. Geert? Mark. > __asm__ __volatile__(".chip 68040\n\t" > "pflush (%0)\n\t" > ".chip 68k" > : : "a" (addr)); > - set_fs(old_fs); > + force_uaccess_end(old_fs); > } else if (CPU_IS_020_OR_030) > __asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr)); > +/* > + * Force the uaccess routines to be wired up for actual userspace access, > + * overriding any possible set_fs(KERNEL_DS) still lingering around. Undone > + * using force_uaccess_end below. > + */ > +static inline mm_segment_t force_uaccess_begin(void) > +{ > + mm_segment_t fs = get_fs(); > + > + set_fs(USER_DS); > + return fs; > +} > + > +static inline void force_uaccess_end(mm_segment_t oldfs) > +{ > + set_fs(oldfs); > +}