From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA08F443A83 for ; Mon, 10 Aug 2026 19:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786390826; cv=none; b=h1/ZoXwmFbq7Dv5AsVbVhjKWEEkiy6u9cry5K77Ndhybym8mUn4gr6u+iag4VV8erq4uneqDLjwp2UHZX9IFvVnJ+vtvr0gva8RTIgKSpN+6EODBDeft9jOrNFIIIPayevIqwi3+RVqC3amA9l66R2sHQ2V9zWn7Ow2jQRE2xyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786390826; c=relaxed/simple; bh=2LEh4N21WEQPtgsS/wklt177lc/JUP+Si+EuLT16XJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s14h3tUmU2k7L18+q8ZZQTqe6hhVHHO1YUWZBtiakRUjrlXFa5mpefYgKWUCbbRku958dH+IB5Ozv/ivxvc/dlmWQujTF3/8rQKtnagRBc/RBAnLon+gc+3FbphAM43lDBnHC6ivoked4ysDCNF7L1raOj1LOK3OfmnY0bJRfFI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jgRp7vRO; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jgRp7vRO" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c2055f5a993so215595866b.2 for ; Mon, 10 Aug 2026 12:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786390815; x=1786995615; darn=vger.kernel.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:content-type; bh=gRKEDfsj3neRvHaPQAcC4yHGhjyN32qyFm0f+mmrXno=; b=jgRp7vROUkEtxTU2BcrmcGFPcb2nJO4t6WhS3WZ3yyXJ3YAPaDV4Qq/c+7YjH1jz9/ CZzds5tkjddT0Eer5/kg+M7+79At1xF0azUA8XLTNGaCai2rz/I8bVYYRj7F5nN0w3el MImIiBuuklKGmmjg4z+EHwfHgSOn6lMf1A43r4OGGLmgjmv9apGJfy+ImpQGB1x++xfp t3WXUplrMtShwMeFcD8FscrgU6Lhl4BCqRoLP7xpIAf0+F22QVUozoNg91XWROLA3NYV S9qJDqkNmP/ywAu6uARxtKNE4HoD4UL3d+CCzdVAABdnIVE5Da82NywHdsE7DYl3Ywq+ calg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786390815; x=1786995615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gRKEDfsj3neRvHaPQAcC4yHGhjyN32qyFm0f+mmrXno=; b=F+ChMQ79Z9UrNUrawAzI1ofuZPRzjc1p42nuN7Unno/4UjiEpQ0gB9XR55EghMSm3t 4sRuOqrhbADcrW42Dsmx8rUntcB1pGXQ3/pOp7qUkKboti7JLIMYx8Im2CGBdvJo/0Ks OthhHSo1/jr7144TLmMEdLW3PYE+TjrTgISSS1gbaAkJBGH8mmFpfRYrOWiMLif7YZM9 zSkbejqHgfbVS4hSP9k9E9ebMxudMoO315EkSC5E+qlCEpB8vRY/e2TuQx1k0gDtYE1W WJic6sMn3DuFjkPQlZw+Vko8Rg9FB02HV+d0/cdVjzuEf7M47qqFz+898+tIAkgPDBI/ SWYg== X-Forwarded-Encrypted: i=1; AHgh+Ro6NGwXMZQvX8uUPEeTYUwtZC2WAqTChKMDwxcsHvDKltkpgDWKC7PAbvLH4EDFPisU2CEDVoVqDd/OSds=@vger.kernel.org X-Gm-Message-State: AOJu0YynsodaNTulU4snbTBcf1G6nTcwcZr9gHsLEmYam++VOZ9t4A9Q gTSUsXb4OA8h7nQHjNlodXCCp2mCBe8VRl3a01PY3MiHTwe4aoLKi6nx X-Gm-Gg: AR+sD13x6x9lVIY+Qz+c1DYNu+P0+H28wU6kZg7yjvqrAsRZcofpnJ/140wYSi5PBHx h8gGbgETTThRSsErC+edMjtQgqXGG14OCQXxFGz50tj+4/+cWfT837fJ3QgIqbMm8GQuU06EKOd kzF06/QOQ271XGCWFTKFRtfgtI3pm43aoVPv8HdoCFcf/23vPrfu/2Eaxxdtwq1XonHZY7K3eas jVXKJ8L668fkI5HY6gb9k1TPx/a4hTcMwprduvEi36ipybLeW+V+4tTnWfEf0AshiADwVgv9Nz/ V2J9cF2Xd4oZYjzDTLaQntVpbtf9nNH+cLX4YvKkSCFGiMTMi5ea4bSH8sXEuFSvqB5PQCD+xaI II0LrPmkZ5u7fNX1PYznnJJBMyRZMoVA0wI5VpEM3FIndCGWqM/Ygvb3G6ZXHMXR2kk8hjOAws0 zBKPf4j3fr+cl68r5GH9SoNz//bOLL9YvxVH79gaDVy9QI+tOwwTP11tVvhUlyN5RJTBfXxBjDX eaJI0fc+gsXG4RWZzi4AxWW/ZcWEu8qMr8Osm4STQ== X-Received: by 2002:a17:907:5cd:b0:c1c:3b06:ed24 with SMTP id a640c23a62f3a-c207ed5cd1dmr1368830166b.28.1786390814821; Mon, 10 Aug 2026 12:40:14 -0700 (PDT) Received: from buildhost.darklands.se ([2001:9b1:ff:d701:51eb:176f:63d9:53f8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2080a29a84sm449928966b.3.2026.08.10.12.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 12:40:14 -0700 (PDT) From: Magnus Lindholm To: richard.henderson@linaro.org, mattst88@gmail.com, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org Cc: glaubitz@physik.fu-berlin.de, mcree@orcon.net.nz, ink@unseen.parts, macro@orcam.me.uk, Magnus Lindholm , stable@vger.kernel.org Subject: [PATCH v2 2/7] alpha: only use a targeted tbi() when the target mm is really current Date: Mon, 10 Aug 2026 21:34:53 +0200 Message-ID: <20260810193902.3286353-3-linmag7@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260810193902.3286353-1-linmag7@gmail.com> References: <20260810193902.3286353-1-linmag7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ipi_flush_tlb_page() gates a targeted tbi() on current->active_mm. tbi() acts on the address space context currently loaded on the CPU, so it reaches an mm's translations only when a thread of that mm is running there. current->active_mm is not sufficient: under lazy TLB an idle or kernel task keeps an mm as its active_mm while a different ASN is loaded, so the invalidate hits the wrong context and the stale entry survives. Nothing retires the old ASN afterwards either, mm->context[cpu] still being valid, so the resuming thread can reuse it. Test current->mm instead and otherwise fall back to flush_tlb_other(), which clears mm->context[cpu] and forces a fresh ASN at the next switch whatever is loaded now. current->mm can be set while the mm's context is not loaded: a task that borrowed an mm through kthread_use_mm() has current->mm set, but ev5_switch_mm() only prepared the PCB and the asn_lock it set is still held, as described in the previous patch. The !asn_locked() test keeps this path conservative for the whole of that window. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Magnus Lindholm --- arch/alpha/kernel/smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index ed06367ece57..1ad448105201 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -669,7 +669,8 @@ ipi_flush_tlb_page(void *x) struct flush_tlb_page_struct *data = x; struct mm_struct * mm = data->mm; - if (mm == current->active_mm && !asn_locked()) + /* A targeted tbi() needs a thread of MM to be current. */ + if (mm == current->mm && !asn_locked()) flush_tlb_current_page(mm, data->vma, data->addr); else flush_tlb_other(mm); -- 2.53.0