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: 129897 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp568275lja; Tue, 27 Feb 2018 19:59:14 -0800 (PST) X-Google-Smtp-Source: AG47ELtIT+iOXswgyOfglADpLBdckRu1nbCPT0NSUpkEkzD8nVgh3qeh3IpEUeEzHfJ2FhBUc6Ak X-Received: by 10.99.168.8 with SMTP id o8mr7018845pgf.246.1519790354805; Tue, 27 Feb 2018 19:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519790354; cv=none; d=google.com; s=arc-20160816; b=lfXgnkbtb0uK0JGeDS+f9UWdHkS7PFeXrvaPUfHhGIPQrKvzmJjUUUEzks2M/Bg2p3 K/INLa4PT+4FbCgDc5XbH6If/3VL5+W7Q5D2TsqzNrk9zV26VkjaUpcy9YuBpdt0f7RD 5T/5mulNgmO0KbZ/LWFDH86NAe4v7e7mKYUHTvwxP9bNqQZohJY79+JC3Mb7gt3l0zfD luNVc1pTdZxVWcmDkf3TOACHXxJzNcgY32AadXi0fWKQ+aBiERs0ajCfDQsPm2lW3oQm xMWJfEOEjm1ElfBDvCIUeYwUC96h/acsgCdlOEKOx18ZN+u2T5nSB8mbcaU43wv1xIY8 XQBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pUvcFHZB0gmxXIk6KYrb0J8r+/ie6VTOJuvKP5z63GU=; b=x2gGWL1FP3okZKpo2UsQzppwA49MK7FOli9DSNrAcxrqAiJHWcongFYi0KrfSlik1E YkyMtv0YzILGn0yFEsQrLnUct1YN2+lnrBZK6NPcsG1wZOjX5gi6lsZ55YS9VhghIJ83 ERecvOaXzPR4p2nWndj7g/ZLDR5v9wzTiFo1rsynWuRj10s85L95GfktpFjtlG9U+GY0 ClXexjA/emRQYqVntQo1YiSEKkE7Lh8uJtJOu8PI7saXNeCbUInRjVIN///fnkTsyLPg ssEcrCP/vv2rCXkZx3CPdPFYicp+BZrT+wrzZTcEB956yd+OIaKQWdMSp3NHuetxF8s8 KVbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TSxrL4HE; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si603010plr.334.2018.02.27.19.59.14; Tue, 27 Feb 2018 19:59:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TSxrL4HE; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752254AbeB1D7L (ORCPT + 10 others); Tue, 27 Feb 2018 22:59:11 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36249 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbeB1D7J (ORCPT ); Tue, 27 Feb 2018 22:59:09 -0500 Received: by mail-pg0-f65.google.com with SMTP id i14so487954pgv.3 for ; Tue, 27 Feb 2018 19:59:09 -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=BcVP9n7OP6GQ13sPdmOt8/vPkG00b0tBH4ZMkqJrfQ10d/fAP2QODOeaJwct3uilrz Tmr83SY9D+xOP/8/Wx3QWtVZVKVbgmQl1MD5VeFh96zChby8AyOiLnzbJ0RlXCouAvE/ Xr9la41I3zO61Z741SSFmY0qXRp2MQr/sbWakbzcb3IQuDEi3E9rDOtimBEuyBIxpK8v Td2yy0H+tOyXcBGMegtxffOur5uBMwJ6Ych5cR1w9VThjadCqi0luvpcbyNQNYNRcQ8f bKvs3VbW+pGBf9vI5Za72q4Op1s+JBBKdHi4obVlIq3iIlfJQAM20bxMUX59BYMM7z53 N4uQ== X-Gm-Message-State: APf1xPBWGmoanC9bzYrOKEs2H4tnQt7/uTkqyEsC4MJVhDZ90hdEUdKw m8dYJ6Zok4AmleuMlz+yegKaGg== 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 Cc: Alex Shi 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> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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(-) -- 2.7.4 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 */