From patchwork Wed Feb 28 03:56:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10246759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F4F260362 for ; Wed, 28 Feb 2018 04:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E11E28A82 for ; Wed, 28 Feb 2018 04:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32F0A28A89; Wed, 28 Feb 2018 04:11:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2C1028A82 for ; Wed, 28 Feb 2018 04:11:39 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7OKSPdvba7eRQWbfmMGk+61B4Yd6xtDQxzAhM6Qolxo=; b=JFEJ5jmjQUqmvQdEIVg3941WJ4 V32dEqdH6i3zLi6IXIEAjjt9gO7V7EhlIL/C45Q4kKjuIQu1mJyXKHjB5eu08iuiWbWNMA9L8W8oO bdvBlEwtLAjn5uEQfow3YNjc9yKaCxswby3lrgEO0aXThHm1+EQ2KuOyux6Lk3mO7Gyj+ju44VMZ9 Df+oUusgH+PeKcTaQaDXfaJo60Zdrrk0XXmsVCPfjIwzVdZDBNhrGIVVoVcpM/vsL9oSJf4Zj4XaS lTxFZujPfyd0rIWS6twdCJTp90XPZupSkTQaDmDeGbaZjXvTIyx8L92P7qEXQ7G/zbZSkqor3/N6O vA0xww0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqt5Y-0000dD-8k; Wed, 28 Feb 2018 04:11:32 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqstk-0007VT-SR for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 04:00:10 +0000 Received: by mail-pg0-x242.google.com with SMTP id q27so478867pgn.8 for ; Tue, 27 Feb 2018 19:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pUvcFHZB0gmxXIk6KYrb0J8r+/ie6VTOJuvKP5z63GU=; b=TSxrL4HEX6qHL5OZctrCfHUc8hJC4pV6aomyCHyljm+Hv3cGgvhKfDvdiWrkJcfEAI wbyA6qlhwkXQ4XsdI1jnqyM2aGCBYHIbxO53Gv5BZ2HgzOrYJsWJ7KNTdPVduAEsyr3a h9JFV0gnHXZQgDk8nq+wG3nZuEfZrmDu2UtpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pUvcFHZB0gmxXIk6KYrb0J8r+/ie6VTOJuvKP5z63GU=; b=GWiaSzlIeZt293GlaK3F5apEUGYT91uOMlhkO/x2Zr3Nkn7p0A36C0IhZt36sPoe2T LNgZKywGzGdIXMnWsjF6fq/bpqBlei9/eZ0jYy3W1avPBS59rE/6aPVwQsS2vkfdT45P 7gENJghhlsUk4Gq4Y5WV6IFs1ytFNH6fatd7UrbvDK47Js3Z8UX/vTsG/7Wppq7hsguV g8tsQLR+tqBTD2Q6JW0S/Frf4zkRLUqq6tE8zZV5f+3FynUNdEOL9kZb79jQs89UEOLt 2oMZ5OR7jznTe564U68xh72+7cnk+gzRaEDRUCYMbQIvAEdbSVLkhS3FEYNU6lAz8R3t 5UyA== X-Gm-Message-State: APf1xPBkW8P9b9Rt7WzHxVfgG4hELSr0qg5u854XF93MBjpVbufZkVnq KH6CDmHIAH6g7HxukMLb3r7qaWqXn84= X-Google-Smtp-Source: AH8x227FTjYlIlGZG+/GmZtgoxqLjJhRMcRqc4G1Pq8cN6Wkx9vS+CDp5b5WvdEF6EueOVgXMGAyEw== X-Received: by 10.101.98.85 with SMTP id q21mr12848320pgv.182.1519790349384; Tue, 27 Feb 2018 19:59:09 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id q17sm739911pgt.7.2018.02.27.19.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 19:59:08 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/29] arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks Date: Wed, 28 Feb 2018 11:56:35 +0800 Message-Id: <1519790211-16582-14-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> References: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_195921_780279_035E36E2 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Will Deacon commit 18011eac28c7 upstream. When unmapping the kernel at EL0, we use tpidrro_el0 as a scratch register during exception entry from native tasks and subsequently zero it in the kernel_ventry macro. We can therefore avoid zeroing tpidrro_el0 in the context-switch path for native tasks using the entry trampoline. Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Alex Shi Conflicts: fold tls_preserve_current_state() in arch/arm64/kernel/process.c --- arch/arm64/kernel/process.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 0e73949..0972ce5 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -306,17 +306,17 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, static void tls_thread_switch(struct task_struct *next) { - unsigned long tpidr, tpidrro; + unsigned long tpidr; tpidr = read_sysreg(tpidr_el0); *task_user_tls(current) = tpidr; - tpidr = *task_user_tls(next); - tpidrro = is_compat_thread(task_thread_info(next)) ? - next->thread.tp_value : 0; + if (is_compat_thread(task_thread_info(next))) + write_sysreg(next->thread.tp_value, tpidrro_el0); + else if (!arm64_kernel_unmapped_at_el0()) + write_sysreg(0, tpidrro_el0); - write_sysreg(tpidr, tpidr_el0); - write_sysreg(tpidrro, tpidrro_el0); + write_sysreg(*task_user_tls(next), tpidr_el0); } /* Restore the UAO state depending on next's addr_limit */