From patchwork Mon Jan 23 22:56:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 13113130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C020C25B50 for ; Mon, 23 Jan 2023 22:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233422AbjAWW5a (ORCPT ); Mon, 23 Jan 2023 17:57:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjAWW52 (ORCPT ); Mon, 23 Jan 2023 17:57:28 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2046.outbound.protection.outlook.com [40.107.101.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79DBE14484; Mon, 23 Jan 2023 14:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgMqh7j3OXmfjSepdwgV/Y/n4cCGH0BLUlSmMHudZOyu0a5dLOn4uS2qXYOqeOD/5QMQnf01eUQcekRoHhqkE+A5Ll9noeZozNsN/cwYotoeeGYKY4LZC9wfoqSdQ2lGoYrshf4Hn4QCwVEtjyh7W5ZRcuoqC8g+bO36vyTJMJ3pV4B600YjiB0veNZ3oUxgi01BeAZGb7gsIkhYCqMwBclJxe6YsVjinyYcr95vGfGFz1t8BoirCHJuXzpLilkPmqTWltQfS7JJd5qcmtxk0ASJu6E7BecfK60Da+U268vC1KEUkvVpMl0YNQ6zPX0cfaTNW/fdANh9jXku/ogkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3GAUq2qG6c/SnAW0J4ARLzMQs7G6rvaXWnTEdfazk/8=; b=NbOtXBYhrqqS82JvdAu5WPykca22oAu2h+Xa3mVDBwA0G+WDT/91aAivx3Q9dS7nzTfLizYw7AFy0H/Qmkk3Hl1zZxFdt0qWfbCsaC9DYy4q8K46BG/H01r3KlwCNAqnpqnqDZwrwMj/wrxXNuOK/1fiXD6oaBC/3eeD+wr4dDCMCC1Bs1MA4uwlSBmgBr+ObYmU0rdsY9S49APX+pkDqIxcCMkh/tBwYx4j2/GT77UWETdHfKR4OAbwM6EgIRcC6mH/X8Shn/wnskHIU2JRudaQNMxWyPdH2QbvX3RGipfqH/szHrng1wJiYwvQdVIfoMhD1EKLz2BY7+Pofk8SRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3GAUq2qG6c/SnAW0J4ARLzMQs7G6rvaXWnTEdfazk/8=; b=a7dWmsIG6FGOTxy/nDdAd47tOIhpnYPk51cX0KP+8iucE6WYm1kEUc1VUPEyW+XhWLGDVYF7nsv4ly3Q+6JQOZt8aIjrvAhcW2aPI3fzwRmqeGcpO7NtOHXc8jcTEC4C2amlLVMV579H0WIcuWa9Lb+boS7tEvb+EYUYUhyuAgE= Received: from BN9PR03CA0257.namprd03.prod.outlook.com (2603:10b6:408:ff::22) by CH3PR12MB7739.namprd12.prod.outlook.com (2603:10b6:610:151::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:57:24 +0000 Received: from BN8NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::94) by BN9PR03CA0257.outlook.office365.com (2603:10b6:408:ff::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:57:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT070.mail.protection.outlook.com (10.13.177.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:57:23 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:57:21 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 1/8] x86/cpu, kvm: Add support for CPUID_80000021_EAX Date: Mon, 23 Jan 2023 16:56:53 -0600 Message-ID: <20230123225700.2224063-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT070:EE_|CH3PR12MB7739:EE_ X-MS-Office365-Filtering-Correlation-Id: 38bd5bee-bcd5-40ab-21f3-08dafd9530ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PLk9qnZ9LMEGhm9CEuYwv3z3XsC8JgPlUG30yD0ePazpMbEF96V8T2DQudPDpRLe7czrFCklQyZs8iBZw4EKWsvexILNhcfXQWDWjEZL1Tc8mmec4dvQuszHXyTQi5DdOs2a7TPrPUo0OJ6j/f0taDHKkTniBuU1c6Sj7CAdhW/kkguw4Kyngno4gks6MC74sx7dF6Fk1tLdvEXzY/NnU97zipAmuWSFHg5O9SWcJa/iOIwh6zwFxsBpCwG0cTGx1I1Pe/BV/ntY9QYom6CUTdoWntOmc22BScf/ayGgbP7es2AtH4ZCdGNc/8PhMLRlwlbvrzhKlD+iQaWzjM/81LliV4TsJhLGuVtVR0fSKCBiZ7NUwcXHFllqGzFZjFpCAZhCdrPSygRRRXTEvBiHpwABBYvHHKuWEtjTNTTfCs//2qeypSmzpIGa+1Z/iQRu7XnD4LGXsSPsdsnOlDII56I6Hvd2/PxFmzU6V02MnazBfrzPur7hnaDjzMXn0DhPw9oFAE8M9QZ4yPCtLx77d9DJ8pYkveA7WppfXOGtvZPVtxNpNvLyxecR2+uIaHfJwhtOZJQfI7LhUy0dzJHja8RS9V5bGYQJu5xlRx4fOcNd31MA2o4gFHsG8BU+a/oQCmk2mfhetALislTFHucPx40xR5o6Jk0O4ZgblG5FabvuJeNVGgOdR/7qDwe1dmg6rFqw33PdYj5eWI726ZORiJPgAp+/z+ZDvMDNaYOeySk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199015)(46966006)(40470700004)(36840700001)(81166007)(82740400003)(40460700003)(36756003)(356005)(40480700001)(82310400005)(86362001)(316002)(336012)(478600001)(54906003)(8676002)(70206006)(70586007)(6916009)(4326008)(426003)(47076005)(2616005)(7696005)(1076003)(2906002)(8936002)(186003)(41300700001)(26005)(36860700001)(83380400001)(6666004)(16526019)(44832011)(7416002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:57:23.8679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38bd5bee-bcd5-40ab-21f3-08dafd9530ed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7739 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add support for CPUID leaf 80000021, EAX. The majority of the features will be used in the kernel and thus a separate leaf is appropriate. Include KVM's reverse_cpuid entry because features are used by VM guests, too. [ bp: Massage commit message. ] Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeature.h | 7 +++++-- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/include/asm/disabled-features.h | 3 ++- arch/x86/include/asm/required-features.h | 3 ++- arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kvm/reverse_cpuid.h | 1 + 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 1a85e1fb0922..ce0c8f7d3218 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -32,6 +32,7 @@ enum cpuid_leafs CPUID_8000_0007_EBX, CPUID_7_EDX, CPUID_8000_001F_EAX, + CPUID_8000_0021_EAX, }; #define X86_CAP_FMT_NUM "%d:%d" @@ -94,8 +95,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 20, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 21)) #define DISABLED_MASK_BIT_SET(feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \ @@ -118,8 +120,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 20, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 21)) #define cpu_has(c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 6cfa7143c316..a84536876794 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -13,7 +13,7 @@ /* * Defines x86 CPU feature bits */ -#define NCAPINTS 20 /* N 32-bit words worth of info */ +#define NCAPINTS 21 /* N 32-bit words worth of info */ #define NBUGINTS 1 /* N 32-bit bug flags */ /* diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index c44b56f7ffba..5dfa4fb76f4b 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -124,6 +124,7 @@ #define DISABLED_MASK17 0 #define DISABLED_MASK18 0 #define DISABLED_MASK19 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define DISABLED_MASK20 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) #endif /* _ASM_X86_DISABLED_FEATURES_H */ diff --git a/arch/x86/include/asm/required-features.h b/arch/x86/include/asm/required-features.h index aff774775c67..7ba1726b71c7 100644 --- a/arch/x86/include/asm/required-features.h +++ b/arch/x86/include/asm/required-features.h @@ -98,6 +98,7 @@ #define REQUIRED_MASK17 0 #define REQUIRED_MASK18 0 #define REQUIRED_MASK19 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define REQUIRED_MASK20 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) #endif /* _ASM_X86_REQUIRED_FEATURES_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 5fe56f0ec9d7..094dbcd63f2a 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1093,6 +1093,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c) if (c->extended_cpuid_level >= 0x8000001f) c->x86_capability[CPUID_8000_001F_EAX] = cpuid_eax(0x8000001f); + if (c->extended_cpuid_level >= 0x80000021) + c->x86_capability[CPUID_8000_0021_EAX] = cpuid_eax(0x80000021); + init_scattered_cpuid_features(c); init_speculation_control(c); diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 042d0aca3c92..81f4e9ce0c77 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -68,6 +68,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, [CPUID_7_1_EDX] = { 7, 1, CPUID_EDX}, + [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX}, }; /*