Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4467361ybx; Mon, 4 Nov 2019 13:55:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyiw0KEUDzWbXYlt5oEqv0u926qq756MLqD6ZH8M20tI9WL2gTiLH52vstrm2HeMHmIFsvA X-Received: by 2002:a50:8a88:: with SMTP id j8mr33003228edj.35.1572904538872; Mon, 04 Nov 2019 13:55:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572904538; cv=none; d=google.com; s=arc-20160816; b=ebRPLJOf4m5XsdLsXeY9YyoyWuXsUYLU4SPBB9EAQOuCSBxZ8FZXJJ7SAnXk8pJApK OcCKwlTCwOv14nQdWHb9/sUlLSdAHnhPJcdxLnjZSX+gKUuADYw+fZ6vYKIhLyokbbsF gwOJ+3DWmVZaiPd3M1xDN5PwgBuZXEA2Is0SytcCyy2b4Ol2s/mm/fmokcUjDuYGH5w2 bB1Dbcf4sywsODEr0l/goJiLO3AzpcFUT9SzwvKaQxifmbm/FiMK3gAT2z+gURkMe/rU D9Hd2xHP0eDKCsbx9aUEyrBLnCNcPUzoHNxN+Ed4/pyOZCCwLCP/HE1UCoNkrbJntkaG 1QYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CeZUZ/CqLU7EHs/5THJPxIy9564NauE54iEGN6Egm9U=; b=KyV6gtjUqojUrKChdZUU1/TI6WyVR/6LNxC7qFewXaW1I4R6bNHtiNS9lrauBg1MR+ xVrYXJfwwWfWDYCKG2jASDT2ZmCUSF4Td1dvapUxe6kdFuxYLwMGxey8v4F1zphIPn8+ u652fnnAD6SUgnt9azsjb7tlf6VRQLIFaLeZbeLULn6NFA/A9cYeKwvBbRDO+AHnQ/V2 kZNaelaq5595AjbSyLEoExOm1Tr+OyikmW5vxY25uihN4XgN1Cc1Zfs6oEYxGAY1H6Q4 PQpdgQ2KmndN8/nEtXG2G3vAePOp8cau0U/ZDeMxMaR9pFW/uA38x9P69A01ZpcFv7J/ DeeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uyhmQf5e; 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 m4si1802747ejr.90.2019.11.04.13.55.15; Mon, 04 Nov 2019 13:55:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=uyhmQf5e; 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 S1731005AbfKDVxc (ORCPT + 99 others); Mon, 4 Nov 2019 16:53:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730987AbfKDVx3 (ORCPT ); Mon, 4 Nov 2019 16:53:29 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0409621850; Mon, 4 Nov 2019 21:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904408; bh=XT+45AHELqelbvkdANKgn/zccoTA/gMFB6V49Z8j63s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uyhmQf5eKwBgSOqOigg+ICvuudyPnsXmdnDm8sgu4r3rIr8csXIznunRxUOmAegz1 mLSy1YitOVhnu2HlOhDOfbBf6GxSQDiNj5aJSmzSNlMFwApPy/oxX0EDN/q+/RiCnv b5GAZPJfm2tVNE9zjevbrd+Bu0tTmLOIwxkeXdDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Will Deacon , Sasha Levin Subject: [PATCH 4.14 35/95] arm64: ftrace: Ensure synchronisation in PLT setup for Neoverse-N1 #1542419 Date: Mon, 4 Nov 2019 22:44:33 +0100 Message-Id: <20191104212100.174262863@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212038.056365853@linuxfoundation.org> References: <20191104212038.056365853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Morse [ Upstream commit dd8a1f13488438c6c220b7cafa500baaf21a6e53 ] CPUs affected by Neoverse-N1 #1542419 may execute a stale instruction if it was recently modified. The affected sequence requires freshly written instructions to be executable before a branch to them is updated. There are very few places in the kernel that modify executable text, all but one come with sufficient synchronisation: * The module loader's flush_module_icache() calls flush_icache_range(), which does a kick_all_cpus_sync() * bpf_int_jit_compile() calls flush_icache_range(). * Kprobes calls aarch64_insn_patch_text(), which does its work in stop_machine(). * static keys and ftrace both patch between nops and branches to existing kernel code (not generated code). The affected sequence is the interaction between ftrace and modules. The module PLT is cleaned using __flush_icache_range() as the trampoline shouldn't be executable until we update the branch to it. Drop the double-underscore so that this path runs kick_all_cpus_sync() too. Signed-off-by: James Morse Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/ftrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index fac79d75d1d9d..6eefd5873aef4 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -119,7 +119,13 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) /* * Ensure updated trampoline is visible to instruction - * fetch before we patch in the branch. + * fetch before we patch in the branch. Although the + * architecture doesn't require an IPI in this case, + * Neoverse-N1 erratum #1542419 does require one + * if the TLB maintenance in module_enable_ro() is + * skipped due to rodata_enabled. It doesn't seem worth + * it to make it conditional given that this is + * certainly not a fast-path. */ flush_icache_range((unsigned long)&dst[0], (unsigned long)&dst[1]); -- 2.20.1