Received: by 10.223.185.116 with SMTP id b49csp534689wrg; Fri, 16 Feb 2018 03:09:14 -0800 (PST) X-Google-Smtp-Source: AH8x2272Y2fY7VyC0MhdG6HWXXVnUi7ltefHqoDLzlX3qDhCWo752PIth9woJHaxVtC2ia7lIC0Z X-Received: by 10.101.82.130 with SMTP id y2mr4897477pgp.68.1518779354887; Fri, 16 Feb 2018 03:09:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518779354; cv=none; d=google.com; s=arc-20160816; b=ctmv0LDXhtdwHrY6PHH2w4+VIHuviouOHy6mE8p2IUtuq2n3eYQjwLrwyRI2T+iFTi 5wy84PtEZ62j40hHvdkoTzn3owuQuqkWJf6VprcwjSPIUpIbXGwKqi25yBnQS2F6PpRu DNzvyMuFFdzimWU/1Bchr+3wnoWReefoOlRLOGO78GDSaJvcX5qWYJGGoa+YAWgwu3VS yGe5tThXle3iz5wOowA6FohAZbUhJsv6uQXLyhbiT96n7zlkG3fv91gr4fWUli/5aKBf JMGafsf1ZbPtxpT3mAeswo/YmN6aU3Gao4BpP7UwyV6BK3v2v50ivwnYBPAAUDbPlpXT tCNA== 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=SZMHYkhOEyQ6kUwX7CSkH1jZP9P5OA4YJHyPqocepWI=; b=neqP5ybj29fwKOwueI3SKGVIm5cGCBEkn8MTlAmHD1heGiw2lEBJOt1ogaVTgmg+q0 +BaQqToTsXhTDAEfjY0EdjFnw9lQ146fdl7wP8TNG+DA86sfY6m73HTMNV9Cjx6lHfYw ooNiAj6SRF2GgEfj6M3UGQUXtVlYcFNR9xzptgvoo298LPgVqjpCHnKEOy8xgPpxVqwi zuDs7EUDPBiHqbGk7RjUC0D/GLdAriE+MjJwDC7RsuSXqbk5hbTQmyS9F7iC7Aop9UeN o6qUJUaImA1jj+kR929fWZn9XGoPtcaCB6T+yw9/ejd8Q2LV1dr2Dt+J7+2KMjXDcyOq l/dA== 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 u85si1145803pfi.5.2018.02.16.03.09.00; Fri, 16 Feb 2018 03:09:14 -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 S1427562AbeBORkr (ORCPT + 99 others); Thu, 15 Feb 2018 12:40:47 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56474 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164646AbeBOPcg (ORCPT ); Thu, 15 Feb 2018 10:32:36 -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 05C4AFF8; Thu, 15 Feb 2018 15:32:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.14 069/195] [Variant 2/Spectre-v2] arm64: Move post_ttbr_update_workaround to C code Date: Thu, 15 Feb 2018 16:16:00 +0100 Message-Id: <20180215151709.160256379@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: Marc Zyngier Commit 95e3de3590e3 upstream. We will soon need to invoke a CPU-specific function pointer after changing page tables, so move post_ttbr_update_workaround out into C code to make this possible. Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/assembler.h | 13 ------------- arch/arm64/kernel/entry.S | 2 +- arch/arm64/mm/context.c | 9 +++++++++ arch/arm64/mm/proc.S | 3 +-- 4 files changed, 11 insertions(+), 16 deletions(-) --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -481,19 +481,6 @@ alternative_endif mrs \rd, sp_el0 .endm -/* - * Errata workaround post TTBRx_EL1 update. - */ - .macro post_ttbr_update_workaround -#ifdef CONFIG_CAVIUM_ERRATUM_27456 -alternative_if ARM64_WORKAROUND_CAVIUM_27456 - ic iallu - dsb nsh - isb -alternative_else_nop_endif -#endif - .endm - /** * Errata workaround prior to disable MMU. Insert an ISB immediately prior * to executing the MSR that will change SCTLR_ELn[M] from a value of 1 to 0. --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -275,7 +275,7 @@ alternative_else_nop_endif * Cavium erratum 27456 (broadcast TLBI instructions may cause I-cache * corruption). */ - post_ttbr_update_workaround + bl post_ttbr_update_workaround .endif 1: .if \el != 0 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -235,6 +235,15 @@ switch_mm_fastpath: cpu_switch_mm(mm->pgd, mm); } +/* Errata workaround post TTBRx_EL1 update. */ +asmlinkage void post_ttbr_update_workaround(void) +{ + asm(ALTERNATIVE("nop; nop; nop", + "ic iallu; dsb nsh; isb", + ARM64_WORKAROUND_CAVIUM_27456, + CONFIG_CAVIUM_ERRATUM_27456)); +} + static int asids_init(void) { asid_bits = get_cpu_asid_bits(); --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -148,8 +148,7 @@ ENTRY(cpu_do_switch_mm) isb msr ttbr0_el1, x0 // now update TTBR0 isb - post_ttbr_update_workaround - ret + b post_ttbr_update_workaround // Back to C code... ENDPROC(cpu_do_switch_mm) .pushsection ".idmap.text", "awx"