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 F221F1CEEA0 for ; Mon, 13 Jan 2025 21:11:07 +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=1736802670; cv=none; b=eLhVmLOLAq+J3J85Do/vs7r+QtmyYhFfITZcnNgu9Io6xKbP98bs8aB6WEIT0pfNef64etdhaVpZN7cF4U7I8SxYJ+CnapJZGK0moN0PjN/la/2q/lMGcOg/5dTlQA/x+PMA3xmj1H7j3MXxviGnYguqepMzx7+oLF1a19WFPBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736802670; c=relaxed/simple; bh=JWnvJNwnAEgeDYP0fQFpbD9j7j8Qwz/eZpT1jdwOjow=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=OuDc6l+cCPQ5XjlqWiJl/qNTb4LYCRdNtkRmyG6++veMCZjwVM3t0TgRE6YK/hMFmW6LwvzJ8q52eAOjLFJXYVXh0dSWiK9B1WWRO0bggH5//ssW7Ar1RAuqSU2T2o4qhCCt3X5EcmgoF2D8Guwh+o9VSxotmA7pxQe664/WcLk= 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 1tXRhp-000000008HJ-0Lgp; Mon, 13 Jan 2025 16:10:41 -0500 Message-ID: <7045d1666ac5722820a43fffa7f2e6fb3c2eb485.camel@surriel.com> Subject: Re: [PATCH v4 05/12] x86/mm: add INVLPGB support code From: Rik van Riel To: Tom Lendacky , 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: Mon, 13 Jan 2025 16:10:41 -0500 In-Reply-To: <685632f2-44a4-a7fd-063b-1d426896f297@amd.com> References: <20250112155453.1104139-1-riel@surriel.com> <20250112155453.1104139-6-riel@surriel.com> <685632f2-44a4-a7fd-063b-1d426896f297@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 Mon, 2025-01-13 at 08:21 -0600, Tom Lendacky wrote: > On 1/12/25 09:53, Rik van Riel wrote: > >=20 > > +static inline void __invlpgb(unsigned long asid, unsigned long > > pcid, unsigned long addr, > > + =C2=A0=C2=A0=C2=A0 int extra_count, bool pmd_stride, > > unsigned long flags) > > +{ > > + u32 edx =3D (pcid << 16) | asid; > > + u32 ecx =3D (pmd_stride << 31); > > + u64 rax =3D addr | flags; > > + > > + /* Protect against negative numbers. */ > > + extra_count =3D max(extra_count, 0); > > + ecx |=3D extra_count; >=20 > A bad ECX value (ECX[15:0] > invlpgb_count_max) will result in a #GP, > is > that ok? The calling code ensures we do not call this code with more than invlpgb_count_max pages at a time. 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. --=20 All Rights Reversed.