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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D84F8C433F5 for ; Wed, 22 Dec 2021 13:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=/BXgYtT9h0OeM8vbBl41sGuKCb9zYgRxqyl53odZjjI=; b=olgRWoukGNwfMY 04aUnjMquqQBVjVkpfUci+gzYVNcEmLg7wzFcazJSGPWxnFESC25dG/sD93aKhfg/XaedQiRIl92s lUEz6B5bejWaDrSBzWq50EgquE9sWMR6muse3ok95dpaCZx+xOBDJ0irCxdtNtprhXte2TymYAbJQ E7a7uGw5MEm+M9JvUXyaD3CAnWEJM7YN+ZpAnrGMoe/GhXSGF3EKwA/gj39D+l5pShBTXWFchbcXC qmet84dZrDHY/s/gmR9qwwPVB5szAk/T912iaX/Jf+58EpOC5NgUpt5FQmcdCM4bb2QamaeB/JQuI lmzDHTBzBMSS3zOFDYZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n01Da-00AN1Q-SK; Wed, 22 Dec 2021 12:59:42 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n01DX-00AN0K-5V for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 12:59:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7C6261A82; Wed, 22 Dec 2021 12:59:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5709C36AE8; Wed, 22 Dec 2021 12:59:35 +0000 (UTC) Date: Wed, 22 Dec 2021 12:59:32 +0000 From: Catalin Marinas To: Pingfan Liu Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Mark Rutland , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann Subject: Re: [PATCH 1/2] arm64: uaccess: disable preempt during uaccess through ttbr0 Message-ID: References: <20211221134242.98877-1-kernelfans@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211221134242.98877-1-kernelfans@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_045939_294293_FD052F4D X-CRM114-Status: GOOD ( 20.64 ) 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 Tue, Dec 21, 2021 at 09:42:41PM +0800, Pingfan Liu wrote: > If using software PAN, the ttbr0 should keep unchanged, otherwise, > considering the following scenario: > task1 > __uaccess_ttbr0_enable() > switch_mm(this,next,tsk), which resets ttbr0 to __pa_symbol(reserved_pg_dir) > switch_mm(prev,this,tsk), which can not re-install the user page table automatically Have you found a real problem with this in practice or just by code inspection? The assumption is that during uaccess_ttbr0_enable/disable regions, the only way to get into switch_mm() is as a result of a page fault or interrupt. The __swpan_{entry,exit}_el1 functions should take care of restoring ttbr0 when returning to the interrupted context. > Tackle this issue by disabling preemption. > > Signed-off-by: Pingfan Liu > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: Vincenzo Frascino > Cc: Andrey Konovalov > Cc: Arnd Bergmann > To: linux-arm-kernel@lists.infradead.org > --- > arch/arm64/include/asm/uaccess.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 3a5ff5e20586..406888877bbd 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -121,6 +121,7 @@ static inline bool uaccess_ttbr0_disable(void) > if (!system_uses_ttbr0_pan()) > return false; > __uaccess_ttbr0_disable(); > + preempt_enable(); > return true; > } > > @@ -128,6 +129,7 @@ static inline bool uaccess_ttbr0_enable(void) > { > if (!system_uses_ttbr0_pan()) > return false; > + preempt_disable(); > __uaccess_ttbr0_enable(); > return true; > } preempt_disable() won't help much here if, for example, the subsequent uaccess gets a fault and need to sleep until the accessed page gets available. I suspect you'd get some sleeping in atomic warning as well with the right debug options enabled. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel