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 16F79748A for ; Sun, 22 Dec 2024 04:07:51 +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=1734840474; cv=none; b=UUNYePFeZxNZMpBeoPEeK2ZuNCYdo50v03qznuuYwqA2FUL4CHQbNxDQl0Rpy2DWRBSEiVG9ChApFG7ajjJFMam52sbAL9bVKx5Xqsza2LyXrDww59Ay/dr9Wn6fDWqNlOcmxxSkcWGusnzps75FCybwPvSnBWtg3QwcTbg3ffE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734840474; c=relaxed/simple; bh=6FqzAc/mjlt0mXwcLqLRzxSexVZmKRc41mQ3z5b7S1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I1xa0Q8bf1xf8Ewai8LieoAjN5s8itcXcUZcoX3RjPXqPrYBCy3gAHB9RPubnTDfCzwJP3DcycTHnR1yYd2oU8uBmGAGa77wlrYz7r6fQMI87fZFqE8lHUYBaMg/tXtRoAoTpGAh1RPQiN/nogeM0hHMYBTzEo9xkSvMHOvf74c= 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 1tPDFT-000000000V0-0y0L; Sat, 21 Dec 2024 23:07:23 -0500 From: Rik van Riel To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, akpm@linux-foundation.org, Rik van Riel Subject: [PATCH 02/10] x86,tlb: get INVLPGB count max from CPUID Date: Sat, 21 Dec 2024 23:06:34 -0500 Message-ID: <20241222040717.3096835-3-riel@surriel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241222040717.3096835-1-riel@surriel.com> References: <20241222040717.3096835-1-riel@surriel.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 Sender: riel@surriel.com The CPU advertises the maximum number of pages that can be shot down with one INVLPGB instruction in the CPUID data. Save that information for later use. Signed-off-by: Rik van Riel --- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/cpu/amd.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 20e6009381ed..dd32a75d5da8 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -185,6 +185,8 @@ struct cpuinfo_x86 { u16 booted_cores; /* Index into per_cpu list: */ u16 cpu_index; + /* Max number of pages invalidated with one INVLPGB */ + u16 invlpgb_count_max; /* Is SMT active on this core? */ bool smt_active; u32 microcode; diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 79d2e17f6582..6a6adbe9ae54 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -1135,6 +1135,14 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) tlb_lli_2m[ENTRIES] = eax & mask; tlb_lli_4m[ENTRIES] = tlb_lli_2m[ENTRIES] >> 1; + + if (c->extended_cpuid_level < 0x80000008) + return; + + cpuid(0x80000008, &eax, &ebx, &ecx, &edx); + + /* Max number of pages INVLPGB can invalidate in one shot */ + c->invlpgb_count_max = (edx & 0xffff) + 1; } static const struct cpu_dev amd_cpu_dev = { -- 2.47.1