From patchwork Tue Dec 21 13:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12696979 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 15762C433F5 for ; Tue, 21 Dec 2021 13:44:36 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mc/HrNAOuIGdW/VHvHlOcHM2+5N75zrppUTF1atkWMI=; b=v7PbPH6TU/IZ3w gbRLU9izsei9OQL61ZnR9SEw2J6/zefG2PgGiZw+ckC/wJ58BVCxwji3cC0u5Uj4PL1SsBVmSQ8AG ABvps8hj0PGWoGm6R/UXokMauNgaasuOcNcL35IHDyP/1y6CEKBP/0Rit+mRPPJGQftI9JE3znol0 M365CbzuhHOFi3Nm32K9eDPfHkcRqOVwW9GyIhA9kyfDCzfzczlzl8xETRIbzzqxudgp/IIytlmkS ddoJ0X9OLmk1PUR6HAWgOmGJgLp1P5RmAjOaX9nLLVVF8U3XSLWNkc1EZ36OcpAjGZ5OGb8aEkD/s z9aEv8X0buWBBLLpiCHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzfQ1-0070Qy-Ll; Tue, 21 Dec 2021 13:43:05 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzfPy-0070Q0-Kf for linux-arm-kernel@lists.infradead.org; Tue, 21 Dec 2021 13:43:03 +0000 Received: by mail-pj1-x1036.google.com with SMTP id k6-20020a17090a7f0600b001ad9d73b20bso3249463pjl.3 for ; Tue, 21 Dec 2021 05:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gRxAYTk6EoY+ZnlT2h2yFEnUdiK3IqlpulC9UoGiUp8=; b=hBbLXujgDN1DpeGbKSrCuQAJSMkc7ejQ7LJWCdEgw/8EFRFw4CQP4aOWTRf5sCEbr/ FqzKKMpDnhvbCTetc96OqZvC7y05rSZNcWHehXa4djqv9CCPowwC3dBre7JQYB1UemkV s6nnemOOpSnZgbthBUXBwSDmDzIl5QPpHwG4LrRFgY8bj+jjheWCVIkK+Q0uMVYWQnQ0 L+Ap+xtzPY5ZJ17HU5Uu3AJJG3kl7W2D5hu05IprrPFqHziJBaFkx2G0RWBdkEygDhyA +EUy/eItxpkZhNWkEuFYAGpexk6DgO1vbzbfAWPy0WcFpeh9nK+UYxbyiWqj/VQB/tFo en2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gRxAYTk6EoY+ZnlT2h2yFEnUdiK3IqlpulC9UoGiUp8=; b=q8RzWkEMPBC8QugMlvv8yHSwQP9qB98hCe+5ggB3C4Eby0DntX1Vk+xH6JAvrsnSI0 TIr7qfSsjWLlTxJ07KiQ2bqZZ2yCdg/KTIm56rB5EzaoUpDyK5AXrN22KI+3SayreJA9 xQT2pDztLrE8hPXL5eB6nPtB04YWsemFsuSuLh8OBzGYAmyFCWGtfqWVtTOuU2hTk12T XrSMqJJuh0FUqBxmUHx0iIxThAKZjITvZcEkZbm1TekDZwirBGp3PAYZP8WFfRpaLEgD 6bwxgs9iwtEujInZMXHQ4m5h34rG469mX2PEinadtiAEwSNKukoZlvEcse8pGd/Six3d KukA== X-Gm-Message-State: AOAM531i2SbGutjnlGJl5dVFmhR2PkQkBLuVw0mBds5JlBje8ghdzA6F w+wFjxvRX4cbOlIqhGrSIk9xw5iFuQ== X-Google-Smtp-Source: ABdhPJxvPt6wU7dU7jRSm8sPQ0shB7owQLzgpOLPRM5Ya2AaaOnA/+OjFzDYMAMJbg51LJQ7a6FquA== X-Received: by 2002:a17:90a:ba95:: with SMTP id t21mr4025598pjr.113.1640094178210; Tue, 21 Dec 2021 05:42:58 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e16sm4699143pfd.38.2021.12.21.05.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 05:42:57 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Mark Rutland , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann Subject: [PATCH 1/2] arm64: uaccess: disable preempt during uaccess through ttbr0 Date: Tue, 21 Dec 2021 21:42:41 +0800 Message-Id: <20211221134242.98877-1-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211221_054302_716441_5377EBFD X-CRM114-Status: GOOD ( 10.71 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 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; }