Received: by 10.223.185.116 with SMTP id b49csp553736wrg; Fri, 16 Feb 2018 03:28:35 -0800 (PST) X-Google-Smtp-Source: AH8x226Q6lSQ38lhfqbdBoHDwZZBalQ9c5KefaBgpQbs3Y/cQZ8g9lIMmzoKyuTxQCexy1QSX0hA X-Received: by 2002:a17:902:b109:: with SMTP id q9-v6mr5696358plr.340.1518780515027; Fri, 16 Feb 2018 03:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518780514; cv=none; d=google.com; s=arc-20160816; b=eprELQygV8BwU9B+J1yGUMZm3TLL0X6/GKuLKcEm3kzVXWpQssxhOnsD7KnAXd/Wfw U5yAQvBovbriTrYxgLOshJQwDhe1ijxBMTnzolZdZ6wABAObGrqHdZSr3znHIiOwqiRI TDZgL8EVpH/sXv46SBSF71IQh607hplwPkCpbJaAHSMa31nZRCnlt6rMrzJvDhcLY25u /DWUv8jCmReYEPUGDREaNcNPrsdRQ9yc6YlUuVEu+toA6MJ9x70BpiQC+y1keF3+5kvG U2BYUHC+zVN8czWgqGPq8TplqeFwklvVSaOZGZ3ayLAvtH5+tWtLEnqvftsT62VbiLSZ lRdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LZ3VeFe4ZfthCBi9nGB7UyZ7WcFJG2iDc40RsJxQ2IM=; b=wUux9vIKU7U4lAC4lMSlw5Y6Fd0W05zvSJi1dyYZM/7hXsMaBJW+fdqWl6CWrCsER8 UcVwUejDqPIjz9pODiS7LHNHx1ynybeEQ+If5GjuuIetIVkXWELIwVdcfi0gTVtZekEy 0E/bUf/z1aPTaWIII3uHDHIVA2VxPJ9oNCrEAcnHVw6CMrh7Fdn2xt2ZbooRQJNHWodB RZLueaiBCMn57JUa5PK8ZtcXNI2qo80pE4L/FINaD4RmdSKB/OsyJKLMpfR/+zlEOaeA d4khDyntTyPUdsFFGbE/Yl2wqqxzq6EaiSg8+0YWgO5jvPVMNHaYT8CRjh/lxL6tFAqN jR9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e91-v6si2915953plb.177.2018.02.16.03.28.19; Fri, 16 Feb 2018 03:28:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427387AbeBORsP (ORCPT + 99 others); Thu, 15 Feb 2018 12:48:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55382 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164370AbeBOPbP (ORCPT ); Thu, 15 Feb 2018 10:31:15 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AA3EC114C; Thu, 15 Feb 2018 15:31:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon , Ard Biesheuvel Subject: [PATCH 4.14 038/195] [Variant 3/Meltdown] arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks Date: Thu, 15 Feb 2018 16:15:29 +0100 Message-Id: <20180215151707.637473541@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/process.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -314,16 +314,14 @@ void tls_preserve_current_state(void) static void tls_thread_switch(struct task_struct *next) { - unsigned long tpidr, tpidrro; - tls_preserve_current_state(); - 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 */