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 134FB1B6CFF for ; Mon, 13 Jan 2025 21:11:09 +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=1736802671; cv=none; b=HRhW1gpnsZnaOvUF9+meR3js9V74qt+JJvTMVMjsuefgEqUr3bZdam52jW3EgLM1mmUO+CPrj1+hHU/G/a9cajsAavLG6aILbtonyPSk3EqRcQBlMP1nYvyoXkrkUZ6p/3fVgfXCj2/XpdJGXdt4PwHDazfMbAKLCjhmJjrpHqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736802671; c=relaxed/simple; bh=LTzPl4djjIdWFnlUDp4J4US04fOE5Nljrgdv3Q6o6G4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=UXPWoptlw6z6qwOTYhP64L5d94+LGjbjjVFYiVv7wGsaLbcid/Ht9sv8weSxTdyYd+hrZbWUAKyZ+IERTm2AGltiQhZnrsNmmXkKx698/T44Zr27FvzaTqYt+p4Xs0jeJr6mipNPo9hC8ErtFyua5iaHDJv4ohhW9aHeYHR/ka8= 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 1tXRfx-000000008Eo-1N6a; Mon, 13 Jan 2025 16:08:45 -0500 Message-ID: Subject: Re: [PATCH v4 04/12] x86/mm: get INVLPGB count max from CPUID From: Rik van Riel To: Jann Horn , thomas.lendacky@amd.com Cc: x86@kernel.org, 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 Date: Mon, 13 Jan 2025 16:08:45 -0500 In-Reply-To: References: <20250112155453.1104139-1-riel@surriel.com> <20250112155453.1104139-5-riel@surriel.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 16:50 +0100, Jann Horn wrote: > On Sun, Jan 12, 2025 at 4:55=E2=80=AFPM Rik van Riel > wrote: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Max number of pages INVLPGB ca= n invalidate in one shot > > */ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (boot_cpu_has(X86_FEATURE_INVL= PGB)) { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 cpuid(0x80000008, &eax, &ebx, &ecx, &edx); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 invlpgb_count_max =3D (edx & 0xffff) + 1; >=20 > I assume the +1 is just a weird undocumented (or weirdly documented) > encoding? > https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/prog= rammer-references/24594.pdf > says that field InvlpgbCountMax contains the "Maximum page count for > INVLPGB instruction" and doesn't mention having to add 1 from what I > can tell. >=20 The way I read the documentation, the number passed in to invlpgb (and retrieved from cpuid) corresponds to the number of extra pages invalidated beyond the first page at the specified address. Things have not exploded on me invalidating multiple pages at once in larger ranges, so I=20 suspect my reading is right, but it would be nice for one of the AMD people to confirm :) --=20 All Rights Reversed.