From patchwork Tue Apr 3 11:09:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 132723 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3666188ljb; Tue, 3 Apr 2018 04:10:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ECA2jXSIpDoidSiA64taWaA1SJGp0DjK0E6bPk8ZuNrDs/SOMrHQ6PLkRi4Mi21QDPrIk X-Received: by 10.98.153.204 with SMTP id t73mr10249288pfk.121.1522753823083; Tue, 03 Apr 2018 04:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522753823; cv=none; d=google.com; s=arc-20160816; b=wtffT5G4q6CCnyeg7d1323I4Voc5+OcsDZD0D4JZ/YKLKYbNJ0Ez5cQsofSMGsjG/5 o0ltcSruK/2yru4y3IMS53AzFEkEaKf0Ld/GcI/USZnNsijO6ejtZeKlI0tXY5EadXso u6nClL57wJmeGWYKkD6Mtc998r7IOrJJdrhq5fDncxlH/Oy+IcCSziZpkSBkqyPI7r0X cEU1IJfBD+jiFIn4gl7kD3Xcr4s4vCov0cKWwAJw+4fNB0iEJe09Ee335xhfyK7nMi7P ak2adNLh+5VtXOmct/PFbNEL5KEMrgm4ssMKMinctu8CpTfIuOzKRUR1UK7W8ET7IWOA fooA== 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:arc-authentication-results; bh=hlGzOL1YZh7B9yHlRhiKlYg5+B+uUsT2UQFiB5bUwBA=; b=U9vO8pSQFyv2XYgeeBm0WywH4nD+fdXjGi1LQ8PCWWvjSlahPqj8DJAoRgv5syaowL jqfxiWKTLPq0I+twlKuzjjEC5BRC0LNBfg5CIK1+ZQtB7xgjKb5+QTE4SZA0UNHxKimw jX9oSpeSkXYz7fBU523IXE5VzZhkb6WhupqPApBu60NPPZl+hSFSx610UHtjdfz8+Dnv 2TkSBTax3PaPBYOi2jGj600Hht8K3Fkd7uO0vEzoibciTxCUortoJ0mMUFjTzdePeDF5 hAe4xU0P4UfZMGE/4zEuzFQRZkkJJ7iTE8WohMA2Ags6kWlxs6xCT+/pSxPTVKC5GxxU Tfkg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l91-v6si306341plb.301.2018.04.03.04.10.22; Tue, 03 Apr 2018 04:10:23 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755308AbeDCLKV (ORCPT + 11 others); Tue, 3 Apr 2018 07:10:21 -0400 Received: from foss.arm.com ([217.140.101.70]:59344 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755487AbeDCLKK (ORCPT ); Tue, 3 Apr 2018 07:10:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15D041435; Tue, 3 Apr 2018 04:10:10 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D95583F587; Tue, 3 Apr 2018 04:10:08 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com Subject: [PATCH v4.9.y 12/27] arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks Date: Tue, 3 Apr 2018 12:09:08 +0100 Message-Id: <20180403110923.43575-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403110923.43575-1-mark.rutland@arm.com> References: <20180403110923.43575-1-mark.rutland@arm.com> 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 [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm64/kernel/process.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 0e7394915c70..0972ce58316d 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 */