From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 773AA3596B for ; Tue, 14 Jan 2025 15:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.67.55.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869664; cv=none; b=TV0wS+qwnry6KvtSyrbR52QMDyLCfyyOWLRcQiKGoe7ATqG2B5hIGo9hznsmHrykduhhUaRiJucdI65nuBCUvDS8+L+q5fKKw24ZJLl7D2H7n8o32eWN/tzX7c5+21cIcFdGeKJduaBdjYv4TdltwszDXwrq6/wTF0gO/Uxom/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869664; c=relaxed/simple; bh=sDQbItROZoohmC1cGQMudoCGxaGU0U41JrCb29GQJJ4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=k6p1+hqZrTl7EzfSHjm+peU8bOcG3FzHbw/Od2aDiXf5Mi9jsTyWyJxPTCrgtrllHEsyPRn0lIBPVu/W0/7NiuHMv7nLhF+3sT1LMcBGoE2a066F03nWAxw0sjdCxO4YLxYfsYmQpeXd4jnEpPiCPpRHAiv2P6WFYSXEyWUWSGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com; spf=pass smtp.mailfrom=shelob.surriel.com; arc=none smtp.client-ip=96.67.55.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shelob.surriel.com Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1tXj8U-000000007Ta-0EtC; Tue, 14 Jan 2025 10:47:22 -0500 Message-ID: Subject: Re: [PATCH v4 05/12] x86/mm: add INVLPGB support code From: Rik van Riel To: Tom Lendacky , Dave Hansen , x86@kernel.org Cc: linux-kernel@vger.kernel.org, bp@alien8.de, peterz@infradead.org, dave.hansen@linux.intel.com, zhengqi.arch@bytedance.com, nadav.amit@gmail.com, kernel-team@meta.com, linux-mm@kvack.org, akpm@linux-foundation.org, jannh@google.com Date: Tue, 14 Jan 2025 10:47:22 -0500 In-Reply-To: <0e20a86c-bc4f-2774-3cf7-4424af7becad@amd.com> References: <20250112155453.1104139-1-riel@surriel.com> <20250112155453.1104139-6-riel@surriel.com> <685632f2-44a4-a7fd-063b-1d426896f297@amd.com> <7045d1666ac5722820a43fffa7f2e6fb3c2eb485.camel@surriel.com> <5085e0aa-5921-40c2-c018-c947b98f5152@amd.com> <6737e3d6-65fa-46b3-9413-e26f4ba8efdd@intel.com> <0e20a86c-bc4f-2774-3cf7-4424af7becad@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.1 (3.54.1-1.fc41) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: riel@surriel.com On Tue, 2025-01-14 at 09:23 -0600, Tom Lendacky wrote: > On 1/14/25 09:05, Dave Hansen wrote: > > On 1/14/25 06:29, Tom Lendacky wrote: > > > > Given the choice between "a bug in the calling code > > > > crashes the kernel" and "a bug in the calling code > > > > results in a missed TLB flush", I'm guessing the > > > > crash is probably better. > > > So instead of the negative number protection, shouldn't this just > > > use an > > > unsigned int for extra_count and panic() if the value is greater > > > than > > > invlpgb_count_max? The caller has some sort of logic problem and > > > it > > > could possibly result in missed TLB flushes. Or if a panic() is > > > out of > > > the question, maybe a WARN() and a full TLB flush to be safe? > >=20 > > The current implementation will panic in the #GP handler though. It > > should be pretty easy to figure out that INVLPGB is involved with > > RIP or > > the Code: snippet. From there, you'd need to figure out what caused > > the #GP. >=20 > Hmmm, maybe I'm missing something. IIUC, when a negative number is > supplied, the extra_count field will be set to 0 (via the max() > function) and allow the INVLPGB to continue. 0 is valid in ECX[15:0] > and > so the instruction won't #GP. I added that at the request of somebody else :) Let me remove it again, now that we seem to have a consensus that a panic is preferable to a wrong TLB flush. --=20 All Rights Reversed.