From patchwork Thu Feb 29 23:21:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13577706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29205C48BF6 for ; Thu, 29 Feb 2024 23:22:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAA066B007B; Thu, 29 Feb 2024 18:22:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0B516B007D; Thu, 29 Feb 2024 18:22:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D29E6B0093; Thu, 29 Feb 2024 18:22:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7E52E6B007B for ; Thu, 29 Feb 2024 18:22:17 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4B23AA0146 for ; Thu, 29 Feb 2024 23:22:17 +0000 (UTC) X-FDA: 81846417114.10.3BA47DE Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf02.hostedemail.com (Postfix) with ESMTP id 5A7B280013 for ; Thu, 29 Feb 2024 23:22:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=PD7l2PYV; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf02.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709248935; a=rsa-sha256; cv=none; b=ydGvNHII7AZeFGcOAcwXYnUM/sxl0arTvZ+4uGupoLqF6OGqLxCosPz9ZO+K98OY8b2vAk fwYwETh3nurwZtIihIEkKekWZ3RL7Yf3YcRCanQg9v/p1qrtqY3laWeBOn1Zw3RlnYoNIA V5nEyYCy7pMNZtW189xp1yNjC+p46N0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=PD7l2PYV; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf02.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709248935; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=O37VWqG4iCvkiZDgqVtP8oElF9rd1vMtEBQWx77Nmx0=; b=vw3QqKvBzu3aWXgPjrOZ7G2Tqhs5r7NL8gYZOuxroegpLzJP3NzrYDPiJrm2cbXyAs0T67 fWjG2dC1aashucTK7klEFm/AIATRUMYYAE26KWAhEXaXmOzjBGbI6nrFrlWLp8t6wBKf0k wVW8/mZiYvQhnLL8hn47dsP58m9YlWk= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e4d869b019so891361b3a.0 for ; Thu, 29 Feb 2024 15:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709248934; x=1709853734; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O37VWqG4iCvkiZDgqVtP8oElF9rd1vMtEBQWx77Nmx0=; b=PD7l2PYVhQ3tViG6/elpYCYHfP/99+Jej+cUZ0exa7T/3q/V9AF0mYtLXoDTgreGtQ zZQ89ilD3Cy1atLNRvvrksCyutMSf6/xKFF6r1k/wriPwWq7wynVFDfkSy4Z/m6vuu6U a4EIGqkBRLxrElOP8MTfPolwBcR9B1fHy4XlPKjR00mvvt0Mkj2frqzz0L1m2hgHgS6n fMMJdaLm86HBegm5gEeBTygsumbfHIEL5iXg6FjfEbIHdZp2NRq36wPLWyOCmVJfmhOc uD18GZoc/uAsRpll9EN1Tm/4vncWFJNFFcBtSXqgEdU62A3fOj/SC3RIQ43+23cb1BV4 BWOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709248934; x=1709853734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O37VWqG4iCvkiZDgqVtP8oElF9rd1vMtEBQWx77Nmx0=; b=F7Ij477bjX8xampWAkTaQqM69v6/bIqPsLJLEmO6K5oh34+IAKp5D3bQoqWKey0OX4 KyPQCGdtTAKp0OLkukUqH61Z67mxADXP0o8epU6B7YveOsE3C5XnyilveV6Tw2sm2XVb Sfx8hfwiFRo9FkldLbt/RgjCpWJfJWusESbSEfMuOlyFdgIoi2BRBhDuHDs1EcBhGXRK oipgbzW2JScoq58nji1NSI3EUL/RQLruPIEjmvexYPYnURM7LuMJr7PxkH9h2kVf9D0e 7vArQDnJNyiRmcpbEYBC+7TViNR7PC13VCL0AvRwT+2aOflV9QfbQZJq/rhxdULdXFQW 9P1w== X-Forwarded-Encrypted: i=1; AJvYcCV11ooT0IHdMxbYjd03QPHiJ5GF7C0jcxpOwcrbyZ24W+0hb1SVmNAnkJeXlan5YwkaqZoSC2inY+WyuLEnBW/I1Ro= X-Gm-Message-State: AOJu0YzlLVlf8gXFfPP+m6gX3n0NoNrI1eEycljwf/gVW2uUhNtmTrPO gEAaJy4Mlm/XOVS81R7Zi7klz3R4bGblESIMfdUyHU5SdzMdTZJmyT0dRHfbZnRMEDP+eGgIGMc n X-Google-Smtp-Source: AGHT+IEXcsW9CGPGmNlysP87xM+KqyMeGQDT/2i2zpW2/RfnrP1VyWuH3lyJldn2H0bz6i0E+Cfqiw== X-Received: by 2002:a05:6a00:2d1c:b0:6e3:fa52:2f26 with SMTP id fa28-20020a056a002d1c00b006e3fa522f26mr168419pfb.8.1709248934208; Thu, 29 Feb 2024 15:22:14 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id c6-20020aa78806000000b006e55aa75d6csm1779719pfo.122.2024.02.29.15.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 15:22:13 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui , Samuel Holland Subject: [PATCH v5 01/13] riscv: Flush the instruction cache during SMP bringup Date: Thu, 29 Feb 2024 15:21:42 -0800 Message-ID: <20240229232211.161961-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240229232211.161961-1-samuel.holland@sifive.com> References: <20240229232211.161961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5A7B280013 X-Stat-Signature: w1p7ac9uhtn1dku3q7a3y7ccmsc13dh9 X-HE-Tag: 1709248935-975649 X-HE-Meta: U2FsdGVkX1801hhbEiC5/ay3C2ubil9PY9AEOCR4zxo8Gujj4/m6InvYoClFeJP+dqedeNW0RBB9UEiZGRJUGjOZZ2S3EqDZy+zvYFeqvjUG9VK+9p6llZ4z32DU39MHSWjbOzHcxXfqzWfFRSOySsqH536w3gTM0QAyJGCYTAoTqwzfLNYFU/9J+uq6UZuPpsyM0qUw8oKvY5rJvm4sc3xb7CzXDXpfvW4jCLtqy1U0Iz3AqoBE7iDW2OSvy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L59u3H5iVA6wQk6ECSBPdQowNG/8eCYpC87r/Ph2NOCYspbEe1uAV8J+gf0jOoR/RNqsrAqc5hT+xDDc71Hl5UkGdicpIOPQknvAjppB58igOGw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Instruction cache flush IPIs are sent only to CPUs in cpu_online_mask, so they will not target a CPU until it calls set_cpu_online() earlier in smp_callin(). As a result, if instruction memory is modified between the CPU coming out of reset and that point, then its instruction cache may contain stale data. Therefore, the instruction cache must be flushed after the set_cpu_online() synchronization point. Fixes: 08f051eda33b ("RISC-V: Flush I$ when making a dirty page executable") Reviewed-by: Alexandre Ghiti Signed-off-by: Samuel Holland --- (no changes since v4) Changes in v4: - New patch for v4 arch/riscv/kernel/smpboot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index cfbe4b840d42..e1b612f37dd9 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -238,9 +238,10 @@ asmlinkage __visible void smp_callin(void) riscv_user_isa_enable(); /* - * Remote TLB flushes are ignored while the CPU is offline, so emit - * a local TLB flush right now just in case. + * Remote cache and TLB flushes are ignored while the CPU is offline, + * so flush them both right now just in case. */ + local_flush_icache_all(); local_flush_tlb_all(); complete(&cpu_running); /*