From patchwork Mon Jan 16 23:01: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: 44345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1444997wrn; Mon, 16 Jan 2023 15:05:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuTW64iikbkptMnz6Fdp1tr/mQzhM6lVi4v5rlqm45vx18kEcv7T7ZbpV3ovLjoRqx71Abo X-Received: by 2002:a17:907:9623:b0:869:236c:ac40 with SMTP id gb35-20020a170907962300b00869236cac40mr790983ejc.31.1673910339538; Mon, 16 Jan 2023 15:05:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673910339; cv=pass; d=google.com; s=arc-20160816; b=QU6RXLPeesCvpsywIHDpPZRLzxZm3S8PCIbCd8mRMvJNUL29q5tgSiqlvHHD9J6yEl OJmKKtJbURVs7tbRuqa/2W4auyldGdWukySKrweu3JJH3bPU4xPdHHRMPfEIGK/1q7Sn txu3eiBE8WOceQDk/8kxfBLUaI7LaDOiZZNDqZMu3Fochm59Yz4fZn1VXmzvxTbvOB79 jR3x3VDPSGkFgwxdFxbaoG6ig9DaXhb1AN6CJkC6MHKSpP5MXqJL2ntmuUY8J+kcH29D XzgQpgOq5JiYPPggklnBh3s2VBvOU8UDWFis2h7Zo88SBBEmA8TSNOudIy4/yG1dqz6U 88jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zVj1u6FX2kvhAleMYQ5nA22ItaXi/ySC1bOpTHGs7dY=; b=ehXzAxFQhD8IWtFfBqmcSueIbST2xu0okBvaSnRtxVFnaTc86YflSXQZOnq8Oeo/fD sf8qkOI7Xia3gf8DCVIjWT5Bn5QBFO+z6M479TZSH+X4Mkxsykbv8pZbHDWSmwM2pxMK 5QHPnfzPg3igki2EGli3o2GcJmluFfk3h+LTXE9YEvJ9d0z3pjSavUQMjRBvUz5v4bIT gKWeibN6DlYGoz3ujdltnJ90dzxr7GBJ9sl+9BfZOmSzXHgHCyuKAC51isYMmpkEu7mr sL7my/3U0jBHbkBjlKmWjOHjaKcE+b0/wOoAAVUwuhD5i+qFNO87wLDB6NN/dxJo/Ha7 jsNQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gdAPJvEN; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt12-20020a170907728c00b007c110cdf37bsi21033610ejc.529.2023.01.16.15.05.15; Mon, 16 Jan 2023 15:05:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gdAPJvEN; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235135AbjAPXCt (ORCPT + 99 others); Mon, 16 Jan 2023 18:02:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235165AbjAPXCd (ORCPT ); Mon, 16 Jan 2023 18:02:33 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F387A2A16E; Mon, 16 Jan 2023 15:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U6SJK4wjJ20vQuqpNBYcUgW5KM5QBkCRPDd2lU7pO4AKH0oNmi7EnLJyjoDeV2hwQtarC6uHPMbpPHC6vUR9BG9399/NYdMLCUtDpR9x7kEi4RwuTqWOY0KzkKt0UPgkDGVNo18XNSpN96TZyDcJrZ9HS2fD8JulDgYaPZuvoGvFzt8p8lIdze5Im9hM2HgS2IsjC2pzNyh5lNCf+/Ae523cyW/3En8tIqqnIX+HAII/O4pRYhtqR856R7uryxwOk2jdryA/oOYp2TpMOkDAh0UWgC8V6nqXMlMgo5vZchaTChiB3fuPzRMdPtNSjRVQMHO/IPb599iCkEJoQDDjhw== 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=zVj1u6FX2kvhAleMYQ5nA22ItaXi/ySC1bOpTHGs7dY=; b=d6xzlFPWrhdVka6cpbqmvWHmfsc1QrJwdnMLGjLHDS/sDvjLLM5A77oQnT++iiFJ+p+yIA9iF0K52sBRMt5KZtKpjMjMjaZLWiRgnAkW56tehkATijCuTpDW8RBzv4L5RYDngqNFg/z6KQK6AtSGdDLq8WHg7upXvATvcr5bBTrEsx4bD1wPSJFzuWja17F7uEHCryORMvOuPr15y/FBQFvnCmKIYFhL/d6XpV+qS9q4izZNmQze5ksPhvHFG3N+lkQtxrpBJsXKPh5WpV4W9uCngXpDsTDxByRtA9F49poqNSfGThSckbfhMkBg/Dd3HOPMsrxjDWDhcUL3q8vtYg== 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=zVj1u6FX2kvhAleMYQ5nA22ItaXi/ySC1bOpTHGs7dY=; b=gdAPJvENMuy5jYx0a2eMlBLhRn+sE2U8G43MS2epgEy4WeNa+pTJ0tJrR+P7TiWuvVd5TRICwopWYRO3FirDF82QiAil1tlLkKT5jqackFIcuIOrcMbFpKRTriIVSU1lFrF6xv2/eZaToq1RaqOqo/njmLlj/YtAyAqQjhzhWg4= Received: from DM6PR02CA0112.namprd02.prod.outlook.com (2603:10b6:5:1b4::14) by PH0PR12MB5433.namprd12.prod.outlook.com (2603:10b6:510:e1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Mon, 16 Jan 2023 23:02:22 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:5:1b4:cafe::71) by DM6PR02CA0112.outlook.office365.com (2603:10b6:5:1b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Mon, 16 Jan 2023 23:02:21 +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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.11 via Frontend Transport; Mon, 16 Jan 2023 23:02:20 +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, 16 Jan 2023 17:02:18 -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 v7 1/7] x86/cpu, kvm: Add support for cpuid leaf 80000021/EAX (FeatureExt2Eax) Date: Mon, 16 Jan 2023 17:01:53 -0600 Message-ID: <20230116230159.1511393-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116230159.1511393-1-kim.phillips@amd.com> References: <20230116230159.1511393-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: DS1PEPF0000B074:EE_|PH0PR12MB5433:EE_ X-MS-Office365-Filtering-Correlation-Id: 37b6511d-9a2c-42b2-576c-08daf815b8b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AUpvgUHrU/2X2k4HKWHW3baiNlnOMuDp0tD85HxeHvO1eEiK7qRdlx+dTUZH39bPWLVoEdchO8Oh6IJna5XWkNrdqCHwgkR8Nx9nVnM+4Ku1rV464DZG9Au37hybyc4GcqRHCv1Nxqgu+21gPP0PrwnqLONbz/GDCYWSUvL99YIOsqM7ARYbahdBqHQaqNqK1apOqaO2BP5EUwjglnhY+Xr4NGXYS6wRIWcxXbMAAeB8mM7bYj8eL6eaXbMzOaQk2ETNh7FxpuhmgBh75YWoCsCYdE5tD3Vxy2SPfNYtaiv1W5M6UwagiKxN6wObbKMQj9XKwg7Nvx0D+NALsw5VfkodKfRrIH9DJWcZiWTKcf8ks60BCSTezT8e7aY5tJltykon0IdUIlGh5u6IbB66l4KsGnp13JLlPwWtrsvzOrj/S7k2+k+HyssJhN0bElEP/sGfEISJEopCKVpoxj+uAFjXoBsqoBVzfiqMq/Q8IghuoS7FBusPb08HYQGNeE59dtkTK3xAFPNhM5WwZXvO65be0meYBvF4Ybt1/ss7zQ7/Oienl/YwaHMpqye28SdFw0x5tsEGF/KU00jeX8FpIv2azFL7NX1hi4BTugQXTt3X6OF2BUlFLw1YMXD6RKJdvK+61jTyJNdPUtTuo2lZichfRudo9U8Q33+882fxdtXZGi15YzraGQy2BWnIdlt5bPIXreqyZ+mzyB2i62Q/JB8mFa8k/We2ihB/1peFSCE= 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)(346002)(136003)(376002)(39860400002)(396003)(451199015)(46966006)(36840700001)(40470700004)(81166007)(83380400001)(36860700001)(82740400003)(86362001)(356005)(5660300002)(70586007)(4326008)(2906002)(7416002)(44832011)(6916009)(8936002)(8676002)(70206006)(41300700001)(82310400005)(40480700001)(2616005)(186003)(26005)(16526019)(336012)(1076003)(426003)(47076005)(6666004)(316002)(54906003)(7696005)(40460700003)(478600001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2023 23:02:20.2131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37b6511d-9a2c-42b2-576c-08daf815b8b0 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5433 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755222207813703752?= X-GMAIL-MSGID: =?utf-8?q?1755222207813703752?= Add the 80000021/EAX leaf that advertises features in later Zen processors. 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. 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 ce40e7caa555..d762654d16a0 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}, }; /*