From patchwork Mon Dec 5 23:32:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529559wrr; Mon, 5 Dec 2022 15:35:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf6okyOc1esw1KVDGqSrDD7bQ3xaks9Rh5Jd0a9MKoCIXafrulXhoW5xCnVvx6D62tG4/TVg X-Received: by 2002:a17:90a:e648:b0:219:2567:dc1e with SMTP id ep8-20020a17090ae64800b002192567dc1emr47123387pjb.237.1670283314169; Mon, 05 Dec 2022 15:35:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283314; cv=pass; d=google.com; s=arc-20160816; b=DIOsWC+Ktm5ggViUbZEaOKGpO08yW+VJrn2FkMduj6cGzL7XhnfuY2S03MxzRqCwrH B7e+xiZiPYchY9ucpsftm9ELSzSxrNDz0mT7fUOmLNouZxrIOiSJp3APz/Tv5hQV3G55 M0Oh96CNFi+ftwpowzCyL7T1izRkb/aOW661o84DmbLdhibu8GhdzITBvcqfTZUB6qPU 7JgPEjKGe5O1WqWQ6hEJ71CRboipIO5T+TzhQkiKJ/KjcTKHbRvVn4C7nnEx3za4Iv0x 6IaE3cZmpswGzQvlqR5l/dwBvWT6pwpFXKWe1ZWmBgE3FadUOplg40p9X15aWHC1i53P MQMQ== 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=H87hsUKB9LkjnvkNIHk3GjV+tiR4ViJcfg5LYKiVPkw=; b=CLFUxSe+OcJ0KfOv3mJLh9gK0sw8dnPPv8radxX0zP2CiA6w/K9koQVNoJq2DjtJRw oDCPsSiCvl+XEO37tT7SvE/Ys6mdlXxKkP6HttUDorqp3/DSnXMqZ3tzuoJjxOO7U8eV 6FgroE98MOFz6XpPZWeJJlWKptpW0CFA4e3NqExbChNpq0IaBr3cL9Ls7/xqBqO7BxAC ejCAiYqq7f6jbC7Nj746lPvBArndgDLUN5ILlrS2YcbIh7o7RcUq1wanT5++W2QyldFu kgJIme7Sfmy6hYKfcTo0TrPcj+u83cd6JUgZvjEWQeMh1RmED9yD/HmPXgaOBKpnoYbA u3Og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Kpd+8oKW; 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 t6-20020a17090aba8600b00202c8fa5c54si18236300pjr.95.2022.12.05.15.35.00; Mon, 05 Dec 2022 15:35:14 -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=Kpd+8oKW; 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 S231497AbiLEXdn (ORCPT + 99 others); Mon, 5 Dec 2022 18:33:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbiLEXdM (ORCPT ); Mon, 5 Dec 2022 18:33:12 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB0ECDF41; Mon, 5 Dec 2022 15:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ikJxMhNYwWL3QqwTqRaucvOLafgDoIAvxGqjSWUqrzLeZby2YHII4358BXsK4hjwj8DFDopWLuD/Osukm2kaVuaU2q2BCBDe0il6sKu+gg7n+/5vkBElx5DbHA0ucRviiFMjdQuGLL5AWcvAqgtvZTs1tdZiBsPtGVnoOf1QTS0IhgRybe2FwZbId8yi9IeCShdxQG4szSdevuZr0LrkRzPgIkZkPX32YcVa28u37hDpEiUcjH4otUyP5xd/8JcVvv16M+vAf2DNsuPs1qBu2lv+gXTxOlmBw5M272xieoQW0Eo3dWUBwZveCzBnfS8nnsVL50Bga4v66zVzAr2+Tg== 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=H87hsUKB9LkjnvkNIHk3GjV+tiR4ViJcfg5LYKiVPkw=; b=HXahEg8LPGWbG6k41qAX8cwRdHzqqvYfUfqQjIFCp2bFuV+6iCj2yDW3kFcQrqt8vYqLr2MOb2rEQNyqRdX5ZdzqVpjCSe6F7w8FF/c2GGoUrepZh4qUEYV9t3DETO6ZoxSz8Np4n2Ipxf8CnIOAyIeNPFSpIzjkXRaHEWzPzjtXdj3bCa+ZMbeNjJn2+01E4G/Gv6VEOfF/8twKxey9aJOOHQVtK6fsZhhyRqG8XzVnOHhIR7sKwYDW26T6fJCGYW0NmjVsskjTtWrRy6uS0DraT0WjtkVSSBf3UoaktJJkg/T6uPE7VwGfcyZ3qDgfGAHlVZFdjt4pfE+5AX337w== 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=H87hsUKB9LkjnvkNIHk3GjV+tiR4ViJcfg5LYKiVPkw=; b=Kpd+8oKWXvewSxLEPScip+5dubW0CfevPI13FOYJtLzwiSZoRQIt/YwwpEmPqP1zGl7hMWiF1yB4tkkUyyA/0sSyGyQdXYakqoFi+1t9hzboIInP3/8qv3HJ6slAQlpZMaTF6y4akpk1dPGSM4jFTxwwVuPrF0NRNTYZ8VyeDkg= Received: from DM5PR07CA0102.namprd07.prod.outlook.com (2603:10b6:4:ae::31) by MN0PR12MB5907.namprd12.prod.outlook.com (2603:10b6:208:37b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 23:33:02 +0000 Received: from DS1PEPF0000E640.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::da) by DM5PR07CA0102.outlook.office365.com (2603:10b6:4:ae::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:33:02 +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 DS1PEPF0000E640.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:33:02 +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, 5 Dec 2022 17:33:00 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 1/7] x86/cpu: Define a scattered No Nested Data Breakpoints feature bit Date: Mon, 5 Dec 2022 17:32:29 -0600 Message-ID: <20221205233235.622491-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E640:EE_|MN0PR12MB5907:EE_ X-MS-Office365-Filtering-Correlation-Id: 863fdcb6-c80f-48a2-f5ed-08dad7190d24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lsnrWJoViUtZzKSTmF4RnLRq6BYJVBdNNrUHpQMQNQmm9ZJJRu+EQ6DYx5MwmajMFMg0E3jFyeThOGnWWAaEruaWdYodKC5/USoU8EEQUCM/piGszXNBt5y/cNWzKWbtdaJh5splW+iiBIZHhP9RQT7OUaeovtwGguug6TkO6E2ofu0Hxv+6v0opQPWR2r6ifis4WHCgzdYcv4s8Q6NGqZgAHv9rkNsSFto2rzHbP/72jBUm59w/zM2IBac1lnzxWXAdl0PAGz0pwtjl9tvS64dqmvkoxzy2TxjDpbg7JinxgkGV/4bY9JrdHTQlIvyS0SOVDCdwNFYuLCtKdIZ3A1JhVDqMV4/FcJMOfENNlkuTMuCTXetBxn0LgovP82rHPSTIe0oh9TpnaHxoUn0upYZNS/TEm6l6M0Q4Uw9DY/TKkR6tB+r+hbZ/l3IXakLn+Edvfbjyx2njeGS8A+AnKAMu1EBpn9yPDjgIAknBT+6WrXlnUIeKGokY51ICuLQGkJztE0k/9CIYm+sa2ZBKCUX/jMoZHOA5njgjAm0bE5Kucnl2pRj6Ny8Wce54bDyDFwgo2Z/GeYZmodDye6Rh3rgcSdLZu4I33mEUDMObliOda7PoHuj6ESgxbY6suogoipJEFGUfydi2wcQlXLpk18rzrzfwaJOpzyud3rY4KuH0OvPXQnBkc3yd68eBMLxogqJzWz5zDMc9ShvKMmOwUJM5Vag76xJAapMIJOALRl0= 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)(39860400002)(396003)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(40460700003)(40480700001)(4326008)(8676002)(2906002)(478600001)(16526019)(36756003)(2616005)(81166007)(26005)(36860700001)(70586007)(1076003)(70206006)(6666004)(356005)(7696005)(5660300002)(54906003)(8936002)(6916009)(426003)(336012)(86362001)(41300700001)(44832011)(316002)(186003)(82310400005)(82740400003)(7416002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:33:02.0245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 863fdcb6-c80f-48a2-f5ed-08dad7190d24 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: DS1PEPF0000E640.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5907 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?1751418996430947727?= X-GMAIL-MSGID: =?utf-8?q?1751418996430947727?= It's a part of the CPUID 0x80000021 leaf, and will be grouped with other feature bits to being propagated via kvm_set_cpu_caps() instead of open-coding them in __do_cpuid_func(). Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 11a0e06362e4..b16fdcedc2b5 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -307,6 +307,7 @@ #define X86_FEATURE_SGX_EDECCSSA (11*32+18) /* "" SGX EDECCSSA user leaf function */ #define X86_FEATURE_CALL_DEPTH (11*32+19) /* "" Call depth tracking for RSB stuffing */ #define X86_FEATURE_MSR_TSX_CTRL (11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */ +#define X86_FEATURE_NO_NESTED_DATA_BP (11*32+21) /* "" AMD No Nested Data Breakpoints */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index f53944fb8f7f..079e253e1049 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -45,6 +45,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, + { X86_FEATURE_NO_NESTED_DATA_BP,CPUID_EAX, 0, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { 0, 0, 0, 0, 0 } From patchwork Mon Dec 5 23:32:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529490wrr; Mon, 5 Dec 2022 15:35:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4g4F28dziu9FQX8k2xampQqadMCAADHf+WVRwwwR8FE/XNr1cIUn8ZVtU6mljK2qKR+vPw X-Received: by 2002:a63:314b:0:b0:478:b499:e789 with SMTP id x72-20020a63314b000000b00478b499e789mr7638207pgx.157.1670283301399; Mon, 05 Dec 2022 15:35:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283301; cv=pass; d=google.com; s=arc-20160816; b=PrdGkKW20gvd79HIHjtbkn85mcbxxnWgV0J2IVQkELEWTlglZVKDqVZTGiWfUyTEHZ iqUSb1pXRixYu0V6krdfKhUxbGEBOp8JU3sBDqaOMaPrw/UGVB8HGdNgLrV3F6x2aGEz Icdb1eXxOpJG+P2aK4Js3bWHyq4veXfu+NkRmtOSOOq5TWbwWQ+o44b1nvH69R0niDkB dcVFISjhIxGlA74hbKUjydhNeOQ0trHLlOK/TeFHf0QCYa1uXi7yjISwdiCKpE5TNW3q bqIBBpfAcXLp6vlRj+91iATYSsPoJ+gYlH3OWGxGNc5B09qFj3OHRBTIImbeQ1MMXa1i EW+Q== 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=Lrus1RgnPCTQ3ojDfAiukMVP1G9NWHKMVy8qkw1SQY0=; b=JA7Ljxv6UvVvTgqUfwrxO5eZFAs5AWv8mujGLabdybwze45DjfmyWJgdaV6Fh6aCOR mCT2BD//hEX0HoxojmT05PQNFb0eXdHgTaJj62S4dTuCerbt1mpdsBuiQOFzG6Y1Iyzp EnBsvlFl6wBJDP6T2efJ6wkLe+9nAttyrbYR87Jbz6TBKAGzvVqIWM3qccKVVhMt862M IOFjj3V2RCiWxYIIMhDDTSBkkPAn5p02YGWOM420n/J6eyXNmLhZ+D122x4qIQkz6vCE fucKj0TUyaDwU8R1g+LT8hJkLXqagt6GwI2PFah9VjTBQM22qvYkRvPzwNiBtgWDf60i 437A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gBbn1CLI; 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 iz4-20020a170902ef8400b00189c9f86942si6666643plb.379.2022.12.05.15.34.37; Mon, 05 Dec 2022 15:35:01 -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=gBbn1CLI; 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 S230381AbiLEXdg (ORCPT + 99 others); Mon, 5 Dec 2022 18:33:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbiLEXdT (ORCPT ); Mon, 5 Dec 2022 18:33:19 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F846D119; Mon, 5 Dec 2022 15:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6tlJMOv6OTzM1AJMYtYHFDnGt1fZsfawFrH9w4DqpwNygmsqO6OtE8uuGnYSOLUjFa427qjPxo6V+L7fgaovzQFFcbMtRtAc6Kr0esjEVe7sSWGWWWXXgu3uJnyFqhy07VYGPU89BSGM2j1gsS4KbV3BwYsrGscA6uQ0rIguf2zzP4BgoYaeUcel1YM8ML5EkZR2P+CgDINT6SmI6FABp+I3DX/XjBOFBCndXGeO4UEsomxx14EmqD5+R4rdv0LhyRZLlzfqSI5x2DQfmjL+ng8S9RMY7/AeKYbZzNFYg9XNzQQ4ihxseX0rt2T4C5Oz1/OlxcHjoXLVjuUov0PgA== 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=Lrus1RgnPCTQ3ojDfAiukMVP1G9NWHKMVy8qkw1SQY0=; b=n013d63F9fmkdIuBCbFiHuLtpnT6Z23uhvdh77VYhK5kXypSLLLQQhwyKW9TNUDvhm2/tps/0l6SofK5KA6xIRZOhjo2x5iFuvm0bb2I/vmJ6+WkYo4cyTj/z3qPqjefmgxusOlx/V+/yJJIBKk6IoxmMNeYWi9QvnS0m7otIU+nUe6MDunjtwfYMQ29KpOGEHd8EmOF6czDw7U4atj49RecODQyROnotlxiqnIv0DaijKQLzFq15Tg2FFKYLj2kLWErcGMwOqV1t46lmc0TkLffmwMuwz4qJ8mloO1okrWY7clPgD7RXBFXdTtZgvY5LrB+0NvsntMAtKwZa+gCZg== 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=Lrus1RgnPCTQ3ojDfAiukMVP1G9NWHKMVy8qkw1SQY0=; b=gBbn1CLIC35Hr2dWnyVoE9wZUvsQa/moEfeYYZXEcsc8nLFiwb9jwXy7sCbmneNQBCcSCQVyRU9LM5KhZZMTYLcMBfXoEqBPo0YvefiHyQCvDbfLBisNDFu3zSi8JcgT1Z23QaicrAqAEq6+QTxpe9L1apo6o1Fi48O6+pXHwBI= Received: from DM5PR07CA0119.namprd07.prod.outlook.com (2603:10b6:4:ae::48) by MN0PR12MB5930.namprd12.prod.outlook.com (2603:10b6:208:37d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 23:33:14 +0000 Received: from DS1PEPF0000E640.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::d6) by DM5PR07CA0119.outlook.office365.com (2603:10b6:4:ae::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:33:14 +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 DS1PEPF0000E640.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:33:13 +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, 5 Dec 2022 17:33:12 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 2/7] x86/cpu: Define a scattered Null Selector Clears Base feature bit Date: Mon, 5 Dec 2022 17:32:30 -0600 Message-ID: <20221205233235.622491-3-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E640:EE_|MN0PR12MB5930:EE_ X-MS-Office365-Filtering-Correlation-Id: fe547ce0-4faf-44e0-55ed-08dad719143b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZcAwyjji2IPh3DTUefz7h7sfAtNFgrcMY0rVara2zICBXV08sDJYzNAo0OpbyoKFZz1uo/Ruk+ubr/yX4qXxq0U6DRGhWiAMOZqR+uhP7p6TG60yVHORU2zknYi2Kgj8XHtGA8KVkxuLlzIlxVQeMm7m8/7I9AV8o3LjBjzeawBI5OyC7cnvcpuApG4S7XEV0r+FGuY3otp0hn+m4V1seJzcnGhFUM+SiTxhcGXqOia0N0JXZtNxu0SudpCAGU4kRqk0jIkPy7cXjaVcqwxRjnHB+pHeJvqgTcsAZPxhp5Q6BNVlxBD9pMWOdcon+sXAzBMEcNGI06/4ufFgjWdAS/TwcXhDiVRdHPqPx/6ZaBP5yJ2FwWYPdvWsMI2GN2nSCbyckUcu8iQ0APcDs3xKdPSSCsAOZ5PHJMJ+UpskdhvggVegvDWbIKQYAJI7feLOwV299RG71/jo9hmX6KCQ0NDNjYRlFIIIOPT9Wqq3aIyqETqIHc+r6ZCyS6KM2HAbFR4KqSaox8L/7FnzrejqPz670zp9n2hRd0GNyEiGML49urRAR7V7K7xttdCFUAA6gqlUl9IdoY5EQt6vpZcXgtKfSS6zDeMSVCBXx0PysDTF7lH8Se+fMyQHJ/RUwu3UObdTWfsQ02V2a7qI3HVHhZ3o5QLkfXl9kIS54AzBaysprX54D/Khpp6zfZxCVkEMgxTp6AOVnupLfaO341G9sQS+vRv/DSL39ba5V5AiJMY= 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)(376002)(396003)(39860400002)(136003)(451199015)(40470700004)(46966006)(36840700001)(5660300002)(44832011)(7416002)(356005)(2906002)(36756003)(40460700003)(82310400005)(40480700001)(86362001)(2616005)(16526019)(1076003)(82740400003)(26005)(186003)(7696005)(336012)(36860700001)(47076005)(83380400001)(426003)(316002)(54906003)(70206006)(478600001)(6916009)(8676002)(70586007)(4326008)(41300700001)(6666004)(8936002)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:33:13.8996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe547ce0-4faf-44e0-55ed-08dad719143b 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: DS1PEPF0000E640.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5930 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?1751418983341389710?= X-GMAIL-MSGID: =?utf-8?q?1751418983341389710?= It's a part of the CPUID 0x80000021 leaf, and will be grouped with other feature bits to being propagated via kvm_set_cpu_caps() instead of open-coding them in __do_cpuid_func(). Also use the feature bit definition in check_null_seg_clears_base() instead of open-coding it. Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/common.c | 3 +-- arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index b16fdcedc2b5..5ddde18c1ae8 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -308,6 +308,7 @@ #define X86_FEATURE_CALL_DEPTH (11*32+19) /* "" Call depth tracking for RSB stuffing */ #define X86_FEATURE_MSR_TSX_CTRL (11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */ #define X86_FEATURE_NO_NESTED_DATA_BP (11*32+21) /* "" AMD No Nested Data Breakpoints */ +#define X86_FEATURE_NULL_SEL_CLR_BASE (11*32+22) /* "" AMD Null Selector Clears Base */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 73cc546e024d..8d28cd7c9072 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1683,8 +1683,7 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c) return; /* Zen3 CPUs advertise Null Selector Clears Base in CPUID. */ - if (c->extended_cpuid_level >= 0x80000021 && - cpuid_eax(0x80000021) & BIT(6)) + if (cpu_has(c, X86_FEATURE_NULL_SEL_CLR_BASE)) return; /* diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 079e253e1049..d0734cc19d37 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -46,6 +46,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_NO_NESTED_DATA_BP,CPUID_EAX, 0, 0x80000021, 0 }, + { X86_FEATURE_NULL_SEL_CLR_BASE,CPUID_EAX, 6, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { 0, 0, 0, 0, 0 } From patchwork Mon Dec 5 23:32:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529934wrr; Mon, 5 Dec 2022 15:36:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7iKOnT6qCVYyTPOeK9eI7i/jHF6YcHhSsXLrBpNOteOB1MZFYLXVjvGH9NuaO31IaL5B7L X-Received: by 2002:a17:903:22c4:b0:171:5092:4d12 with SMTP id y4-20020a17090322c400b0017150924d12mr68731442plg.107.1670283374655; Mon, 05 Dec 2022 15:36:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283374; cv=pass; d=google.com; s=arc-20160816; b=ccvvBGcaCm/8sePpps48ba1/Kh1bIqatH3W5A3qXL9qOdXaVqF0pfHKo5LnZAwVPhT QDMZgP32Er4IcxLsS8mPeU5syKPKf2AqZElaArYhlyOWBQaWKh6jNqohNRgskzHdhZ0P fOxQ6BiJRXGlSeUHsm6Wj3PWrqm1MM1UV5ayipqqTR4F//4Ua7pOvCi3JW+vgbRzMCiC qN+r0d7eZcpalqBj2OSwoC7guEUPAWGxWdSOmqrkhQ2/7aoBaibqHivgg8HoR2gAiTrO WXq+Fl0EYntjIh9xRSzg+g1sS2+tv/QS/H+Aqmlvvwarm1fk0tx3NMeBGbKdniRCwb00 6hcQ== 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=D/PsyeRWEKYEJPwiKh3YYzfXYqYgLnYeN7PeRh5njPs=; b=tECNH07YUtdRNGnvAQJ0cranMYxMVLP6m/SpVoDHgh3hlFXUVPdUSSVTj4z1sthhxj Zu1EdBXwfGZLmQ0G93VHRxWLmAalyWDtjjwNtbFb0ZrqpJ326cBQhA5/i+Vwfly4z2Cu UQVlq6NgfUwgUShwqDi22Ks5jRT1Lpa9LK2lkausZpjlRqACw8c5cPJXnRH7ApKaIv9o WqMIlu5ORnjhZTO1VFY6/ASYn4XE7BBboO/bbWBy3K/oqxfhOV5U3e1asMbtoJGW0bm6 KzFza7HQxt9VXjw1Rc9J5d+KeALE3NN81fp8Yxq1rdxku2Dioggb+czDhSue4Z1Y+Drn 9p8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=NYbBPINU; 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 q14-20020a170902dace00b001893e9d712dsi16868949plx.557.2022.12.05.15.36.01; Mon, 05 Dec 2022 15:36:14 -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=NYbBPINU; 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 S232798AbiLEXds (ORCPT + 99 others); Mon, 5 Dec 2022 18:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbiLEXd3 (ORCPT ); Mon, 5 Dec 2022 18:33:29 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B73E06548; Mon, 5 Dec 2022 15:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FDxxQULwNYLPGXiJzKhQ4fcTLOmicpwgdT51Zf04tm8RoxnC2oj7ZhpirOn0u2E5hrTrNsxaaDTAREP80BrDFSdrU478KQe71nTc+WdhB0EzkKxXplHHyAddwpHvBel1VPIW6sSaej4BDxHbtc+2LgL4aW4f6Kj61XS7D0kbDPqdUUiHw+8r3jFDIkegvtJ20a3eT5539aBGexwjKBJCJOCvp26xJaJrWZNnjdjwyOPsmLHg8GqWKP4xmsSytIcLvLT+MbELYB6+y8gHfDmXilFWO62knhdjMx+28dCTQyLy0dm6rF9YzU1I+7GDnHvlO/Uz4sqEroOicXt/z5+oGg== 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=D/PsyeRWEKYEJPwiKh3YYzfXYqYgLnYeN7PeRh5njPs=; b=MiHSPb+BZyzY2BYy0c+q1NM5aRvCYtfFZmvkWCP1kWbG4+glP/Dx7tEywfshynnNlGqNeivADHmMoZd6vz/CceAeMF9WQbfN41ZP0khdDltoGqvPmVwDe7f6IQ1gka0W/aWAiRhotuA8ORF+V4lZ3sTYFSd0tZVd03LswIIXl+AvhpgKPshHAVXiS0Uv9zOau2zGs3iVr0Txs9Q5/r1Ot/PVN07oakylpJu1QQPTFFeo6KGyllAdA6UYwxhW8P00Mhz5aAQSnl59XCUa6FGY7J8FzrEXL3OnU9nUfXcTjv/EcTR0rntwil5JCQPXLyySfkp3fHa0WzSrWqc0Y5o9eQ== 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=D/PsyeRWEKYEJPwiKh3YYzfXYqYgLnYeN7PeRh5njPs=; b=NYbBPINUmTysOSsQ1SPMeeotiWVt95snEwNKNQvei/gt/Zz61NxthjXzqJGzbQATTmkBDXRVMlN+OVV6jqhqMUTmvDGALt5vHtblJQ2SpL9b4ZJKzOMTV8mkKgkhtJdTvsy8ycPSJBA2DyVVUAY5vpyYUNWtA4RzWP3J9V5WgTY= Received: from DS7PR03CA0307.namprd03.prod.outlook.com (2603:10b6:8:2b::13) by SJ0PR12MB8113.namprd12.prod.outlook.com (2603:10b6:a03:4e0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.11; Mon, 5 Dec 2022 23:33:26 +0000 Received: from DS1PEPF0000E643.namprd02.prod.outlook.com (2603:10b6:8:2b:cafe::12) by DS7PR03CA0307.outlook.office365.com (2603:10b6:8:2b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:33:25 +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 DS1PEPF0000E643.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:33:25 +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, 5 Dec 2022 17:33:24 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 3/7] x86/cpu: Make X86_FEATURE_LFENCE_RDTSC a scattered feature bit Date: Mon, 5 Dec 2022 17:32:31 -0600 Message-ID: <20221205233235.622491-4-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E643:EE_|SJ0PR12MB8113:EE_ X-MS-Office365-Filtering-Correlation-Id: 3efab710-16c3-4f79-6cb8-08dad7191b46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DgDTpTa7WdpDLcuEzS7mUiV0G8FGCodnUoK57m3wZ4xW/4aEaLJE20kGDUdaToZokVtbZKvLzWP2SAHNcXqpp36WltxZwOgDX65oapU7eBC/s3TCSbU8V3mdrkhhnGSl9dPdmH1+3riL29KRDPIERlDnXVSKaZglPdn8qz7M6Hn8UUPBoltvEuYnLPRCGqN0RPC9yfYn8JrKPpNGOORoVPxxfVX5dy2rdglgIWGDPOZ8aeltYwD7fahMrZ7Gvhb/ZX291Gpo77ofRFrUc+skRhbIfq23rRWZsTT7g5ogLC3IWIwU67ltob7q450H5nD+L5GwR/AYURULXDC7WC6jErTx2QBNaYF3nASE4puu27O+VL/ykyVDYaOtME1Pi14q8dnEkwitiSzALGaRJvWBasFKN94JKnd1tUxctfF5feV42kq4FEOQKqGJY7O67s0kZVJXtkpR0IDBDh73oII9MPOnqGsmFBGFc9lK8I+fYSBMWTt0KrNCQS305Bcy1OWWp/VcZWOgg/kXAf8n4A6XK+HD4+bMIy6113PHgEbU8uCrRsK75vV9zrZc7aaEOZM3dohT8dL40lMkKLSLBsWr7E3GwF8YtUWH1plg+RBxor/wE5HYDXhMZcM9z/fQaFc3p44co5zlIxQTc+pplA3v0sAgQC3OYsVOIS/LhaYRYz8TxcjqOoC3R8eDf8NbitZH+pZ+CiDP4SQj5csEQsM2RWW3+DQkJVGfDv5E7U/7WVk= 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)(39860400002)(376002)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(86362001)(4326008)(82740400003)(70586007)(2906002)(8936002)(70206006)(81166007)(478600001)(44832011)(8676002)(7416002)(356005)(36860700001)(40460700003)(336012)(2616005)(316002)(6916009)(41300700001)(186003)(426003)(1076003)(54906003)(16526019)(47076005)(40480700001)(82310400005)(5660300002)(6666004)(26005)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:33:25.7319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3efab710-16c3-4f79-6cb8-08dad7191b46 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: DS1PEPF0000E643.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8113 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?1751419060208095982?= X-GMAIL-MSGID: =?utf-8?q?1751419060208095982?= It's a part of the CPUID 0x80000021 leaf, and will be grouped with other feature bits to being propagated via kvm_set_cpu_caps() instead of open-coding them in __do_cpuid_func(). Unlike the other CPUID 0x80000021 EAX feature bits, X86_FEATURE_LFENCE_RDTSC already had an entry in cpufeatures.h. Signed-off-by: Kim Phillips --- arch/x86/kernel/cpu/scattered.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index d0734cc19d37..caa03466cd9e 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -46,6 +46,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_NO_NESTED_DATA_BP,CPUID_EAX, 0, 0x80000021, 0 }, + { X86_FEATURE_LFENCE_RDTSC, CPUID_EAX, 2, 0x80000021, 0 }, { X86_FEATURE_NULL_SEL_CLR_BASE,CPUID_EAX, 6, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, From patchwork Mon Dec 5 23:32:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529825wrr; Mon, 5 Dec 2022 15:35:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7oWZBVzDae78IKoAvoAdiIw9/AcHryY91kgPcpm2pnw3gLJHSwQL9GxSt5cRlbaBfjV/FZ X-Received: by 2002:a17:90a:8c04:b0:219:5b3c:6983 with SMTP id a4-20020a17090a8c0400b002195b3c6983mr31667382pjo.131.1670283354356; Mon, 05 Dec 2022 15:35:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283354; cv=pass; d=google.com; s=arc-20160816; b=yt1Zg8pctXdKCu/g4PPJhYqHKi6H/6vqg95epnDExQmoUTW80y9HvB4l9OMRlscecv QiAXAYA973isCYVPnYtRPxlSXfqe3xe6evVnqDx3LKsU0iBlb01b1LRBGYAWvJ+VyJ/D T8fQ3et8J/h3Zg3f0pDjVo+sxlUDjyQ4dNNx9GSU+TEwdQ8wY+/gyyiNco0iq3Tfod3L ATXetu9E5h4b/JbhPgYp9YFO8XBDMeT15rqT3sEGS7OMJrc39P+3zsz5g6+B9Eh3xEzz UJdjgMmZ0A/i7eRaA36FRgFFMFzxvYUiHRtfecno2qJoM2DrnRr17K5wk3VDJUeC0/u3 lezA== 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=aJNYRfHM869rcVG5ek02QXWp90OIOOF7VmnPInzVI0g=; b=DWkse6AkJjFFjRlfBH2hgQjT51rrL6qk7JEy3tFjXxEeKOgWniT8W13Bz/cgUxV1P+ ZMtAkzlUNE/1VLfIROeyh1XU08O3Jn6Bj/PV6EnFowBFlu0uwQlmpEhEMIeA46myaxY4 +VeWniEQrCHJttKpftMG3SV6eRhe5gH+VZlMl6caEou5eG8NUCp1WLE9OCFDBPBOYiKX WOZi+aoJi5hgdAN0CSdky2DcyULnaEgPwr8HreJWdYVpJbRs5jKj0LdqDVZ0EU3r/lvn uXcX5r17XwfLRmxNpEuM89Y4XdkzY4vRB0u/QBWc8F+30CKmRiwaD5dW+E1ExjqmFdij rDGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ZoTYCvQy; 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 x1-20020aa79401000000b0057723dd7a4bsi1709980pfo.38.2022.12.05.15.35.41; Mon, 05 Dec 2022 15:35:54 -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=ZoTYCvQy; 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 S232480AbiLEXeN (ORCPT + 99 others); Mon, 5 Dec 2022 18:34:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232958AbiLEXdz (ORCPT ); Mon, 5 Dec 2022 18:33:55 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8962518372; Mon, 5 Dec 2022 15:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K6OX0nBCf48vM8+oJPJbPYOwkxem03kv6QgXxGcE4qmn/GybHVYpW6iQ9T8ESpkpbA1hIkz7JOGJhKF5gHex8UNXM6eo+zImgRwBGKa14mbeTChmQsXwHdQElhkNwquhmiUOUnkZLuaMpV2JMMjKUaxu8rbrfkWCQTUEYTAgIyg46QoFr/Qq/CS75dRZuZ0LJQhIyWAHVg40LV/wtEF/mAU8nsiZ8GOaHfv3RUUM6rmeWnYmk8GDoUfC7JdikYJXJL/OiNK7XczdgDMSIm+AMgaQWGlVdWPBpxUiVIXCCfb6jV/1lDLiuJv2PmEevUspHkc9pgX+e3NpbbttL6On1A== 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=aJNYRfHM869rcVG5ek02QXWp90OIOOF7VmnPInzVI0g=; b=KcNpU7TJH/cxi+Sw3C1UjgSE5iUrC8LmHrOQVkMlIskF4EY8W+98zpGW3Jbm45dwy02ri9EEL6TrktzrIed6IZJPgeSjooSX8oZHpX54xLh2r7P+k+tIhCPnaHX/3B9bFnHvLEa8+78vFmFc2ovo3/FLWlryEuUPtmDAVZd68HkreLJMXGIoXiJjGNnREgKVZ9Is+0G/6Rs6EQllEl8JiyqV+oL5GrZZBdxcnQLK2gfB/XGiTKAQfCIt1tCq3XpXoQiHWL2mTyvYkItKz29iAixfF14LI0kF0bKNRm+2WS/n2gzPbmJDT/kChpp4DU44IYrigSFuM8Ha05a9jA4eqQ== 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=aJNYRfHM869rcVG5ek02QXWp90OIOOF7VmnPInzVI0g=; b=ZoTYCvQyk0MHaWLmNUl+4IHmHJqwQ5I2ZOyiyqriFj19b0YPBY7PwyITPs19ncNxQFIoy0UowHXt8odp7T7LY1jAS5Hq38GprpV/RuCZkODAVidsgf5uoUoHe/GnowExiEICY5pGkdYMq0MsqcVTZu+1z2gJ+KkLEeT4JOpdrwQ= Received: from DS7PR03CA0273.namprd03.prod.outlook.com (2603:10b6:5:3ad::8) by MW4PR12MB7357.namprd12.prod.outlook.com (2603:10b6:303:219::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 23:33:43 +0000 Received: from DS1PEPF0000E642.namprd02.prod.outlook.com (2603:10b6:5:3ad:cafe::12) by DS7PR03CA0273.outlook.office365.com (2603:10b6:5:3ad::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:33:42 +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 DS1PEPF0000E642.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:33:42 +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, 5 Dec 2022 17:33:40 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 4/7] x86/cpu, kvm: Move CPUID 0x80000021 EAX feature bits propagation to kvm_set_cpu_caps() Date: Mon, 5 Dec 2022 17:32:32 -0600 Message-ID: <20221205233235.622491-5-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E642:EE_|MW4PR12MB7357:EE_ X-MS-Office365-Filtering-Correlation-Id: 83d102b9-eccb-4651-b83a-08dad7192554 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sfFixoy256pbkMw+oX6f/GCsm06z1AmEnq83DsxcUWgEoY/ExL7Kw910wYxMnQagPlIQugWnJvoKK14v6ATQB1iN5p/y5zujVQbIY8x/NjZO4jhqF/k+gzJwxiKT9ly748qB9axykccVKFs6wi0I4i1TkT/Ac9wuamcNlZHAxSQb2RstLz69rI+4RA9JGDYprrb7VpKhZORTkX8pfk+RyAZzbVMva4XDwqtQBKExFYfdlhHi7bENQWh5K2wYcUV8PFC/H1PiXXom/WdXhcYN+RaMqWhgO7ur/FuB5b0e6/rRbU7vUq0UPfaKD1mIlcOPbONYA3D1/R5uuGb41ORh9EE7AC0Wv8LAGxYIVOt4CrhDVTDehMd3DgxsDRdB29i0itY7BDmXl2v0HdgP2Y/uyFAGalp+3xl+jLJAiS69ZVQIVwnEkUGxmrFsXjKgfncvltx9FHmmOILKt8XEPzhFhNXcbHVfLFGxUc9JKkxmvY+eP6CdiLJhMuMph2UAYNQUFiiegk3Guj9VbtogXH/nb9JbkAWNyreq7fqIz3bU6nOTLXQqbJ1FukcuGy/HzRdT4UJj/LcpKiNfUKg4CylwUDOrqpDCV2hd04SNS6xCy0QAGhg/LcJYQDCORoO3kq3xwN/jHgMFP2kY9N+Qu+l31/n8pgdBVdRZ5suGNUn+/C3plcavyjccyBUAtFokqwYSEBjzE7NDTp7i9F/G3OIFs44G2zg68dsEw1jvVrlmvmQ= 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)(376002)(396003)(39860400002)(136003)(346002)(451199015)(36840700001)(40470700004)(46966006)(8936002)(70586007)(356005)(81166007)(36860700001)(54906003)(316002)(82310400005)(82740400003)(6916009)(4326008)(41300700001)(70206006)(86362001)(7416002)(8676002)(40460700003)(44832011)(36756003)(2906002)(478600001)(5660300002)(40480700001)(6666004)(186003)(26005)(7696005)(426003)(47076005)(16526019)(336012)(83380400001)(2616005)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:33:42.6028 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83d102b9-eccb-4651-b83a-08dad7192554 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: DS1PEPF0000E642.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7357 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?1751419038677487843?= X-GMAIL-MSGID: =?utf-8?q?1751419038677487843?= Move CPUID 0x80000021 EAX feature bits guest propagation to kvm_set_cpu_caps() instead of open-coding them in __do_cpuid_func(). Drop the bit description comments now the code is more self-describing. Whilst there, switch to using the more efficient cpu_feature_enabled() instead of static_cpu_has(). Signed-off-by: Kim Phillips --- arch/x86/kvm/cpuid.c | 25 ++++++++++--------------- arch/x86/kvm/reverse_cpuid.h | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index c92c49a0b35b..dd0fe79521eb 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -730,6 +730,15 @@ void kvm_set_cpu_caps(void) 0 /* SME */ | F(SEV) | 0 /* VM_PAGE_FLUSH */ | F(SEV_ES) | F(SME_COHERENT)); + kvm_cpu_cap_init_scattered(CPUID_8000_0021_EAX, + SF(NO_NESTED_DATA_BP) | SF(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | + SF(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */ + ); + if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC)) + kvm_cpu_cap_set(X86_FEATURE_LFENCE_RDTSC); + if (!static_cpu_has_bug(X86_BUG_NULL_SEG)) + kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE); + kvm_cpu_cap_mask(CPUID_C000_0001_EDX, F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) | F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) | @@ -1211,21 +1220,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) break; case 0x80000021: entry->ebx = entry->ecx = entry->edx = 0; - /* - * Pass down these bits: - * EAX 0 NNDBP, Processor ignores nested data breakpoints - * EAX 2 LAS, LFENCE always serializing - * EAX 6 NSCB, Null selector clear base - * - * Other defined bits are for MSRs that KVM does not expose: - * EAX 3 SPCL, SMM page configuration lock - * EAX 13 PCMSR, Prefetch control MSR - */ - entry->eax &= BIT(0) | BIT(2) | BIT(6); - if (static_cpu_has(X86_FEATURE_LFENCE_RDTSC)) - entry->eax |= BIT(2); - if (!static_cpu_has_bug(X86_BUG_NULL_SEG)) - entry->eax |= BIT(6); + cpuid_entry_override(entry, CPUID_8000_0021_EAX); break; /*Add support for Centaur's CPUID instruction*/ case 0xC0000000: diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 4e5b8444f161..184614e27d5b 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -13,6 +13,7 @@ */ enum kvm_only_cpuid_leafs { CPUID_12_EAX = NCAPINTS, + CPUID_8000_0021_EAX, NR_KVM_CPU_CAPS, NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, @@ -25,6 +26,11 @@ enum kvm_only_cpuid_leafs { #define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) #define KVM_X86_FEATURE_SGX_EDECCSSA KVM_X86_FEATURE(CPUID_12_EAX, 11) +/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX) */ +#define KVM_X86_FEATURE_NO_NESTED_DATA_BP KVM_X86_FEATURE(CPUID_8000_0021_EAX, 0) +#define KVM_X86_FEATURE_LFENCE_RDTSC KVM_X86_FEATURE(CPUID_8000_0021_EAX, 2) +#define KVM_X86_FEATURE_NULL_SEL_CLR_BASE KVM_X86_FEATURE(CPUID_8000_0021_EAX, 6) + struct cpuid_reg { u32 function; u32 index; @@ -49,6 +55,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_7_1_EAX] = { 7, 1, CPUID_EAX}, [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, + [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX}, }; /* @@ -75,12 +82,15 @@ static __always_inline void reverse_cpuid_check(unsigned int x86_leaf) */ static __always_inline u32 __feature_translate(int x86_feature) { - if (x86_feature == X86_FEATURE_SGX1) - return KVM_X86_FEATURE_SGX1; - else if (x86_feature == X86_FEATURE_SGX2) - return KVM_X86_FEATURE_SGX2; - else if (x86_feature == X86_FEATURE_SGX_EDECCSSA) - return KVM_X86_FEATURE_SGX_EDECCSSA; + switch (x86_feature) { + case X86_FEATURE_SGX1: return KVM_X86_FEATURE_SGX1; + case X86_FEATURE_SGX2: return KVM_X86_FEATURE_SGX2; + case X86_FEATURE_SGX_EDECCSSA: return KVM_X86_FEATURE_SGX_EDECCSSA; + case X86_FEATURE_NO_NESTED_DATA_BP: return KVM_X86_FEATURE_NO_NESTED_DATA_BP; + case X86_FEATURE_LFENCE_RDTSC: return KVM_X86_FEATURE_LFENCE_RDTSC; + case X86_FEATURE_NULL_SEL_CLR_BASE: return KVM_X86_FEATURE_NULL_SEL_CLR_BASE; + default: break; + } return x86_feature; } From patchwork Mon Dec 5 23:32:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529766wrr; Mon, 5 Dec 2022 15:35:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7eDRzof8yguRKCoGMSdgITGYJkjmqrLVR9zoAsnoKrLnbRqSaQDaJmpL1gqgdbmsJYoy4f X-Received: by 2002:a63:cf14:0:b0:478:22cb:f05d with SMTP id j20-20020a63cf14000000b0047822cbf05dmr35288605pgg.456.1670283345721; Mon, 05 Dec 2022 15:35:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283345; cv=pass; d=google.com; s=arc-20160816; b=Zfvm5srANkc4fZbsIqBa2wZvgPaWMFExAfzhTvsx1RhUFhy+fzjmyINOxk/U0FAoGE +Oh9LWq07VvTSaiX6G3gFyUGZ4/hL6Tgz3O1nMZcnDal44yX9Mxtm9dZgyDk1G6HrWzN PT9b6K+65pHJl6zeZRf/QxtSFm/c+w8hHjRmBG9st4EjBmYxE6fJqX5q4/JhTqx3iBUc ddlG1qOvdYqiaIjAjxlN998JtmnqBRQT9zWlI/iGqgFxjjFqR1DMa9yjsLyjFej3/JQ8 k1SRgMHUoLqGt0Cjj+gGEqWPeJPlOJf9dSP2xPhKX1nBgQk6lN/biet+cKyuhksYfsZ0 KwXA== 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=nLPAgpLB0LB1NW30EwhKp8uwdbTzlYuf2+gh4q0kInA=; b=MgI2DvMo9KJhUerwRNzJ7Swk11KDM1nWZU36P4IwWKkFofM1o0qnWC2Fx7Y6CKV9St z5vcRChFSMr9mrHiW9yK2Rrn3TXuRVld7d24FHJSFmEO9SsVLWUQYGUpFqSOkHi1ANF3 +rRTfvGZR/PCmHRn3wdD1wOT9lC2Dl1f7CAa6aqbT/ybiPQCqUsI3MfwxqSnOmR55HxH jTBAj3k6lI9EyeItJvCeYnqpsB2tHsBfibdkZrchlgrh9RlkRMJ54NjdIDHeHtuCT07K Yd7ir2vmJW35/KDNH0KC11vVrWP3D80u0ea5Kc9qZz3ZqWi8tyXLq96P6FkZgWI4d4RE gOrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=oDoFV9B3; 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 r8-20020a17090aad0800b00219f65e19fcsi904058pjq.170.2022.12.05.15.35.32; Mon, 05 Dec 2022 15:35:45 -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=oDoFV9B3; 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 S232208AbiLEXeH (ORCPT + 99 others); Mon, 5 Dec 2022 18:34:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233199AbiLEXd7 (ORCPT ); Mon, 5 Dec 2022 18:33:59 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89F2713DF9; Mon, 5 Dec 2022 15:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hxSPorhK5aSp2qHoGU0T5Hf+fJE+fmmhiir9Qsw+oVzEtB2IS2CE7si71ekLBKpbZtHgi2ZCts1u86yy9vgGt+TP5W5oVe57l7hWHAOO55/vfYFRJKosANfuWC9gjzrQu3ntyT27P5pPUjFcUg/z2TbsULggjeuhAraW42Yc2ZYR7a0Fj+J9GZF6tocCskOleFfAZI3uEzByMhQkuorOUScH3YGbMvS0xXS12GdsuAN7Xo+t6NMZu1GCJiVWFAROA9UZZDjqvXgnEG/zx5ojG3uZlBCLmOZc0SUrj8Of0Y3yMA+CEqrEzWFqa8kpS4PT2WUTblr8qEkLIsATdXpP2w== 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=nLPAgpLB0LB1NW30EwhKp8uwdbTzlYuf2+gh4q0kInA=; b=lcaGv6iEBUYaKxX15iLO8CyLw7BJfYHjKlL+rx0y4A6+Mhpd4inCZGokHgmvX1v7NCpszthTOhWU9Rwakt7FM7QwGBE0PZwxKTjBBfeSFFV6QcVtX29yf/dXwy+aLNivjPbmSstMLrBHsSuYnMM/jkAnHIdWRpKemrkv24HK7QRP35SvNW2PVFhV8D2wWWZ09nwsfzHcHHHVZWzU0oSbN4dv56/VkB2+cDWr8Pu9YBmazbB6A/IAH57ZtjcCwv85PMPW8n2biNiM/ul06A16zYnGW4+KvtGzKvO/xOVIy8dOGH3rUm/GaCcP+kt/8wjWn1UlCzVVWEw8H4Gr76cKwA== 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=nLPAgpLB0LB1NW30EwhKp8uwdbTzlYuf2+gh4q0kInA=; b=oDoFV9B33Kw864JBbms6xiSD/QphLGNVyqOPFVMIBfgqpa4kFH75KtGa1mvUJtncnE5ZDREBq3AuLhm2leWzzdflv+h8D7DoaAKclIPP2agVeSwRXxmE/uz/Fo26y5PUC57yRo5PvL3Y6RFHKay56eWi1/hdATFJEzKti+150fM= Received: from DS7PR03CA0286.namprd03.prod.outlook.com (2603:10b6:5:3ad::21) by DS7PR12MB6047.namprd12.prod.outlook.com (2603:10b6:8:84::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 23:33:54 +0000 Received: from DS1PEPF0000E642.namprd02.prod.outlook.com (2603:10b6:5:3ad:cafe::e1) by DS7PR03CA0286.outlook.office365.com (2603:10b6:5:3ad::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:33:54 +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 DS1PEPF0000E642.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:33:54 +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, 5 Dec 2022 17:33:52 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 5/7] x86/cpu: Define a scattered AMD Automatic IBRS feature bit Date: Mon, 5 Dec 2022 17:32:33 -0600 Message-ID: <20221205233235.622491-6-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E642:EE_|DS7PR12MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f942405-8a98-4279-5097-08dad7192c85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AygsS7zrbhx63L3ni1zkabrZjyrScZAVKbj+drg52qs/FHjDnMgJHL/qlhNiBO+RvIgMgBftUnwWSQ+LFq8wcOJq8Bb+efPb9nxjMAy2eMTJGUacMDtrKTed5N615aw7vTaEJtFQ85Q/eTINJeXRFHpHIwi1+flfHMCXcI22Y9TTfIgLJd7Nxyq2k/kHyRWWe3gtnmuAObPP22dLd+FlIunJFwRLZgG9uyOweStEdG8eOSqEVrByE/HZiUWqnXJpktMHGkRM/r/w7bowqkq0EQWiM6ggwAX5CiSXW2FuFhetX6VOZZ8hPefQ7q73WumUMiuiIK4ux1KnvyAcdR3mh+w9p5g/6xXEtXY0xiDrcWuQGYIySvu2TCbRLV6pVDdK4cTPA30zrDCnEDNJMnjcQufR5APHsrPO4ZXv+i2DijT3LH4s7LJF9vwPo5dW8wiAgHi4x6WHDGRlTyDTzjEy/5dmObrK7BFOwb/oSmau/34ZJbnu3VH2nrYsfn+7NTUbFWXCHLXILg24TVX0Thc+e1EHvMrIJEMUtYK+RKJkP5akcZXz0AC90EklEzUmjE0o0NZHkedN8UXPDx+HTdXtMjGaxKNV5AZfYGwdmMw84nBsoD7PD748PBIr4ZxSSIeLKZvdD3FecXp26INIyG2gjFZyMK2SSWWpWL1ang/qaKbGPZPFdgW33Gd/FLgGEG4tjSQBXG9KF+8MbcA/NzoS3kvVzmia5lhnhJzrZZ/MFQk= 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)(39860400002)(396003)(376002)(451199015)(40470700004)(36840700001)(46966006)(2906002)(7416002)(8936002)(44832011)(8676002)(4326008)(36756003)(336012)(86362001)(81166007)(356005)(186003)(16526019)(47076005)(2616005)(82310400005)(426003)(70206006)(1076003)(41300700001)(82740400003)(5660300002)(316002)(6916009)(26005)(7696005)(54906003)(6666004)(36860700001)(70586007)(40460700003)(478600001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:33:54.6653 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f942405-8a98-4279-5097-08dad7192c85 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: DS1PEPF0000E642.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6047 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?1751419029590616456?= X-GMAIL-MSGID: =?utf-8?q?1751419029590616456?= It's bit 8 of the hardware CPUID 0x80000021 EAX leaf. Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 5ddde18c1ae8..961eb49532b7 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -309,6 +309,7 @@ #define X86_FEATURE_MSR_TSX_CTRL (11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */ #define X86_FEATURE_NO_NESTED_DATA_BP (11*32+21) /* "" AMD No Nested Data Breakpoints */ #define X86_FEATURE_NULL_SEL_CLR_BASE (11*32+22) /* "" AMD Null Selector Clears Base */ +#define X86_FEATURE_AUTOIBRS (11*32+23) /* AMD Automatic IBRS */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index caa03466cd9e..7ae7203cd410 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -48,6 +48,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_NO_NESTED_DATA_BP,CPUID_EAX, 0, 0x80000021, 0 }, { X86_FEATURE_LFENCE_RDTSC, CPUID_EAX, 2, 0x80000021, 0 }, { X86_FEATURE_NULL_SEL_CLR_BASE,CPUID_EAX, 6, 0x80000021, 0 }, + { X86_FEATURE_AUTOIBRS, CPUID_EAX, 8, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { 0, 0, 0, 0, 0 } From patchwork Mon Dec 5 23:32:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2529963wrr; Mon, 5 Dec 2022 15:36:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DWHHHzZIxP3MaB3/dtATopadYDo01kO351Lxzi9Jo5xlKtLZVh8mjFStIVbu0qCELXVje X-Received: by 2002:a17:902:7584:b0:189:6292:990a with SMTP id j4-20020a170902758400b001896292990amr51950811pll.171.1670283380834; Mon, 05 Dec 2022 15:36:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283380; cv=pass; d=google.com; s=arc-20160816; b=keg41WdyaYXk9xuDUl6o0pnFf0DFYnjADnMBU5zfowxVijY7MFwV7P0ugXTBwh8A0T AZkF8l4+IYmzEyJG7q87DjCFx+xuIYhCqehtnI3gacXydXE7n04jFgBR2VSfZmvsBlyj 6DoRf4UnQKosAyfy6IGXx7Xru9pvh6qwNlHT8uDSYgDCnZuvVuE+KV+v5Go4bHfZtyZR FFB4KISscD1ZymCI6+ht/GrwWCNsS1vUe811A3SPh6zqKNY7eX11vCnf3+ytrVgaOoVX lt4IPv8eTbQC+vUP0c/LJPDZaeZW6ybncLNwssB+GIuGKKjfmrvOAGfmZ7UoE22sJv6h XP1A== 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=QtbEVcIXKPcNUDK5Ed3i+L8em6ijJ026n5PAVD1LpfY=; b=xP50kyWogVL5V1gIyOOkbOJWujo3Trtaw6BbTqyl0i8eBscvdyymgBOFMY+f9dAtvH dAmS4+rK80YGuaJPChF34idjAPUKobDX2CkW9c2CAa1knaK7vSIjWWFOUFGiXQbJMb9x vg23L2oU96XvI0KL6MGGUgMW5BpRL+q2gG0goJ4/Y0ov6ftImhuuvY/gzuzsGT8cpMS2 9wpwFExEpOXGAKVPcsHotrpnUfyzsHks52qU4fGSJCpqOsMh/Vh87V+ga32aVGk1OLo4 Mc+Qv7S5y4vJvuaJuae0Po+bCJxGyWYTJkG5XJX4RDMyYW0QGwHzT2eps0Qbg22wDF5Q czdw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=d27I1oWs; 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 x189-20020a6386c6000000b00478a51cc009si6563995pgd.873.2022.12.05.15.36.07; Mon, 05 Dec 2022 15:36:20 -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=d27I1oWs; 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 S232830AbiLEXej (ORCPT + 99 others); Mon, 5 Dec 2022 18:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232851AbiLEXe2 (ORCPT ); Mon, 5 Dec 2022 18:34:28 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0611F9D2; Mon, 5 Dec 2022 15:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtI+LEhRCaZ39hZwvQPF2zPN3jS3N3yNGEXBzCG3KSyyVpt3kNgQhDiSgIMLYBDbAZwYEG3KjTDiVHVBxvFpJRsTUmMKw10j4ESA+upri2ZFuHuIVWqwSIfqiwgUq/fZqE/dcHT11ziXWOAMj4TK+A4wncQ+mlg74PPSZY8FyPZit890pmXGfeDVyaCm5qs20Ms5DpnMvUxsCD9Oh3ci6L5WkBbg1ys7E0wwwu23421h59nsxtweSV0Od0+zujkLx5CV3j9UlBL7FL5PLfguPCEL/SpOMom06NaYpUD9HuR0HGkpG+oQD8NgiJo4uBFs09EIuJjgroscDpGD559xUw== 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=QtbEVcIXKPcNUDK5Ed3i+L8em6ijJ026n5PAVD1LpfY=; b=Zo8DPNW9pcGj4In+tJfrg91aj/OaSLUyoOwJq8PWfAFeL8DJfm1AvRp4HMe1GAHbGxu9A80BIRcsF4YxZCYUUKWFUyjGkQYeHWsBE7HQdwRJzbPWPx5xK4yRxiFbWHlyAPP63GIrX0iDoXPv4cZwhjzY8nKLFuvU3002mV6n3u3iPGcoQLbI6mO5mt54cYgL0xhkWBa0iQYV+6XLwAy1OiOsWlv6BTR3TMZE1/ejba1AIDDMZqh9F5tqQ8x/MFROzAUa+XyjCegt3TPj/NYW3uTUElSyTtsd4dsdlXuK/bWDhPVswAdQAh/ghkIXptI0+Z+KhQjy/+RSmbYh8pAQig== 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=QtbEVcIXKPcNUDK5Ed3i+L8em6ijJ026n5PAVD1LpfY=; b=d27I1oWs4zGNT9F24X0qS0EhzhO2viKKNnEbJNYVOir4+Qm2UeXmX4Z5uplVmyandR8IoAkYOP2R9hfIvQGx9Ltlny6uopJV5uGA6flfLKUDsu2mJfj7tX12HHwq4Rqwl0svI6EYY4Zfi1Lmm+4p9Zz96liHHXXqnSm26uA+ySk= Received: from DS7PR05CA0027.namprd05.prod.outlook.com (2603:10b6:5:3b9::32) by SJ0PR12MB6989.namprd12.prod.outlook.com (2603:10b6:a03:448::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 23:34:07 +0000 Received: from DS1PEPF0000E645.namprd02.prod.outlook.com (2603:10b6:5:3b9:cafe::6a) by DS7PR05CA0027.outlook.office365.com (2603:10b6:5:3b9::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.8 via Frontend Transport; Mon, 5 Dec 2022 23:34:07 +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 DS1PEPF0000E645.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:34:07 +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, 5 Dec 2022 17:34:04 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 6/7] x86/cpu: Support AMD Automatic IBRS Date: Mon, 5 Dec 2022 17:32:34 -0600 Message-ID: <20221205233235.622491-7-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E645:EE_|SJ0PR12MB6989:EE_ X-MS-Office365-Filtering-Correlation-Id: 86d44ee2-d085-467a-55a9-08dad7193444 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5h0yqurSRhuPkdKVzW7eXE0mfVZV7AEdHZjx8OojtMLMrPodd/jUwO2H0fll1NJfgfRyMxaihixZjibGegNvMW7lCftxxmqG7Ydw1aMuYBAIpxaWb/aA5dJqp5b7LSYlJDmDF9es52OM76Rm0L+mE/8p6iuMp9BbreIeF/hDNRxmQKJsJxgXocRdKpzOX1g6qYB1Xx66WVi/VUXFX9im9aJ9qWMsuAZMsh8mCRD7/wc8iu74AUrjAy80/Aot7rhiIiMGBz7gy9RKYsRaSw4YdSN0sITW+CCFL8MEeyzfyVBGFlsjeM1q+jBkJoO6GLxNwb7spcDiyArkyJKEja45jURmDlpwivA3F8fuYzR5QZ8X2E72qU0NM3QRi2sDCQ9IYVbyEnOpl9CItXtA49JK8DeTxlT6RVYV/VyiKhRdD15juaJGfSyKKicvkluu1+pIGZJGmw7MMd9ERwfu06B58LGhZnLOVCrAONtzAXdP4tm+2xenVwY8E3oYLspSegNoWsTRXGxcTMLoKZkumhZA/Om85hI5bZSKuefOUuASx6vQiicWHBjkSuFpj30szxojd3Hv6+zRyIfRAXjB1eK2TnO5YD7mSs27ixO8khLZjFnLZ77lICClAB53Qj7x4bNR53/AqKqkyhM4zqwiOBKNQQOwg0ZOUKqJAOEAoP2UUsx7gVRZCcIlCgDLfw0AiZv4jPqcgyQt8L7q3ZDYekCz1H0ccKmDRW0WfSdyfBV4H4= 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)(376002)(396003)(39860400002)(136003)(451199015)(36840700001)(46966006)(40470700004)(186003)(16526019)(336012)(41300700001)(356005)(2616005)(81166007)(82740400003)(1076003)(426003)(47076005)(2906002)(83380400001)(82310400005)(36860700001)(36756003)(7416002)(5660300002)(8936002)(40460700003)(44832011)(6666004)(40480700001)(7696005)(478600001)(86362001)(70586007)(70206006)(8676002)(4326008)(26005)(316002)(6916009)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:34:07.6613 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86d44ee2-d085-467a-55a9-08dad7193444 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: DS1PEPF0000E645.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6989 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?1751419066436237601?= X-GMAIL-MSGID: =?utf-8?q?1751419066436237601?= The AMD Zen4 core supports a new feature called Automatic IBRS. It is a "set-and-forget" feature that means that, like Intel's Enhanced IBRS, h/w manages its IBRS mitigation resources automatically across CPL transitions. The feature is advertised by CPUID_Fn80000021_EAX bit 8 and is enabled by setting MSR C000_0080 (EFER) bit 21. Enable Automatic IBRS by default if the CPU feature is present. It typically provides greater performance over the incumbent generic retpolines mitigation. Reuse the SPECTRE_V2_EIBRS spectre_v2_mitigation enum. AMD Automatic IBRS and Intel Enhanced IBRS have similar bugs.c enablement. Add NO_EIBRS_PBRSB to cpu_vuln_whitelist, since AMD Automatic IBRS isn't affected by PBRSB-eIBRS. The kernel command line option spectre_v2=eibrs is used to select AMD Automatic IBRS, if available. Signed-off-by: Kim Phillips --- Documentation/admin-guide/hw-vuln/spectre.rst | 6 +++--- .../admin-guide/kernel-parameters.txt | 6 +++--- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 20 +++++++++++-------- arch/x86/kernel/cpu/common.c | 19 ++++++++++-------- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Documentation/admin-guide/hw-vuln/spectre.rst b/Documentation/admin-guide/hw-vuln/spectre.rst index c4dcdb3d0d45..3fe6511c5405 100644 --- a/Documentation/admin-guide/hw-vuln/spectre.rst +++ b/Documentation/admin-guide/hw-vuln/spectre.rst @@ -610,9 +610,9 @@ kernel command line. retpoline,generic Retpolines retpoline,lfence LFENCE; indirect branch retpoline,amd alias for retpoline,lfence - eibrs enhanced IBRS - eibrs,retpoline enhanced IBRS + Retpolines - eibrs,lfence enhanced IBRS + LFENCE + eibrs Enhanced/Auto IBRS + eibrs,retpoline Enhanced/Auto IBRS + Retpolines + eibrs,lfence Enhanced/Auto IBRS + LFENCE ibrs use IBRS to protect kernel Not specifying this option is equivalent to diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 42af9ca0127e..3e8322acf665 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5698,9 +5698,9 @@ retpoline,generic - Retpolines retpoline,lfence - LFENCE; indirect branch retpoline,amd - alias for retpoline,lfence - eibrs - enhanced IBRS - eibrs,retpoline - enhanced IBRS + Retpolines - eibrs,lfence - enhanced IBRS + LFENCE + eibrs - Enhanced/Auto IBRS + eibrs,retpoline - Enhanced/Auto IBRS + Retpolines + eibrs,lfence - Enhanced/Auto IBRS + LFENCE ibrs - use IBRS to protect kernel Not specifying this option is equivalent to diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 37ff47552bcb..6843d6241203 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -25,6 +25,7 @@ #define _EFER_SVME 12 /* Enable virtualization */ #define _EFER_LMSLE 13 /* Long Mode Segment Limit Enable */ #define _EFER_FFXSR 14 /* Enable Fast FXSAVE/FXRSTOR */ +#define _EFER_AUTOIBRS 21 /* Enable Automatic IBRS */ #define EFER_SCE (1<<_EFER_SCE) #define EFER_LME (1<<_EFER_LME) @@ -33,6 +34,7 @@ #define EFER_SVME (1<<_EFER_SVME) #define EFER_LMSLE (1<<_EFER_LMSLE) #define EFER_FFXSR (1<<_EFER_FFXSR) +#define EFER_AUTOIBRS (1<<_EFER_AUTOIBRS) /* Intel MSRs. Some also available on other CPUs */ diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 84c14e11db90..fc8fab82cc44 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1222,9 +1222,9 @@ static const char * const spectre_v2_strings[] = { [SPECTRE_V2_NONE] = "Vulnerable", [SPECTRE_V2_RETPOLINE] = "Mitigation: Retpolines", [SPECTRE_V2_LFENCE] = "Mitigation: LFENCE", - [SPECTRE_V2_EIBRS] = "Mitigation: Enhanced IBRS", - [SPECTRE_V2_EIBRS_LFENCE] = "Mitigation: Enhanced IBRS + LFENCE", - [SPECTRE_V2_EIBRS_RETPOLINE] = "Mitigation: Enhanced IBRS + Retpolines", + [SPECTRE_V2_EIBRS] = "Mitigation: Enhanced / Automatic IBRS", + [SPECTRE_V2_EIBRS_LFENCE] = "Mitigation: Enhanced / Automatic IBRS + LFENCE", + [SPECTRE_V2_EIBRS_RETPOLINE] = "Mitigation: Enhanced / Automatic IBRS + Retpolines", [SPECTRE_V2_IBRS] = "Mitigation: IBRS", }; @@ -1293,7 +1293,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) cmd == SPECTRE_V2_CMD_EIBRS_LFENCE || cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) && !boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) { - pr_err("%s selected but CPU doesn't have eIBRS. Switching to AUTO select\n", + pr_err("%s selected but CPU doesn't have Enhanced or Automatic IBRS. Switching to AUTO select\n", mitigation_options[i].option); return SPECTRE_V2_CMD_AUTO; } @@ -1479,8 +1479,12 @@ static void __init spectre_v2_select_mitigation(void) pr_err(SPECTRE_V2_EIBRS_EBPF_MSG); if (spectre_v2_in_ibrs_mode(mode)) { - x86_spec_ctrl_base |= SPEC_CTRL_IBRS; - write_spec_ctrl_current(x86_spec_ctrl_base, true); + if (boot_cpu_has(X86_FEATURE_AUTOIBRS)) { + msr_set_bit(MSR_EFER, _EFER_AUTOIBRS); + } else { + x86_spec_ctrl_base |= SPEC_CTRL_IBRS; + write_spec_ctrl_current(x86_spec_ctrl_base, true); + } } switch (mode) { @@ -1564,8 +1568,8 @@ static void __init spectre_v2_select_mitigation(void) /* * Retpoline protects the kernel, but doesn't protect firmware. IBRS * and Enhanced IBRS protect firmware too, so enable IBRS around - * firmware calls only when IBRS / Enhanced IBRS aren't otherwise - * enabled. + * firmware calls only when IBRS / Enhanced / Automatic IBRS aren't + * otherwise enabled. * * Use "mode" to check Enhanced IBRS instead of boot_cpu_has(), because * the user might select retpoline on the kernel command line and if diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8d28cd7c9072..57efc4b6eac3 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1226,8 +1226,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = { VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO), /* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */ - VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO), - VULNWL_HYGON(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO), + VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO | NO_EIBRS_PBRSB), + VULNWL_HYGON(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS | NO_SWAPGS | NO_ITLB_MULTIHIT | NO_MMIO | NO_EIBRS_PBRSB), /* Zhaoxin Family 7 */ VULNWL(CENTAUR, 7, X86_MODEL_ANY, NO_SPECTRE_V2 | NO_SWAPGS | NO_MMIO), @@ -1338,8 +1338,16 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) !cpu_has(c, X86_FEATURE_AMD_SSB_NO)) setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS); - if (ia32_cap & ARCH_CAP_IBRS_ALL) + /* + * AMD's AutoIBRS is equivalent to Intel's eIBRS - use the Intel feature + * flag and protect from vendor-specific bugs via the whitelist. + */ + if ((ia32_cap & ARCH_CAP_IBRS_ALL) || cpu_has(c, X86_FEATURE_AUTOIBRS)) { setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED); + if (!cpu_matches(cpu_vuln_whitelist, NO_EIBRS_PBRSB) && + !(ia32_cap & ARCH_CAP_PBRSB_NO)) + setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB); + } if (!cpu_matches(cpu_vuln_whitelist, NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO)) { @@ -1401,11 +1409,6 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) setup_force_cpu_bug(X86_BUG_RETBLEED); } - if (cpu_has(c, X86_FEATURE_IBRS_ENHANCED) && - !cpu_matches(cpu_vuln_whitelist, NO_EIBRS_PBRSB) && - !(ia32_cap & ARCH_CAP_PBRSB_NO)) - setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB); - if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN)) return; From patchwork Mon Dec 5 23:32:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 30026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2530460wrr; Mon, 5 Dec 2022 15:37:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6FYQzepmymHt8EoIjJVcqcPB7HhnXbX9zGxi2DOuEdKvlW+inpPm223KJpxUAco/TasCUg X-Received: by 2002:aa7:c78b:0:b0:467:97e4:6339 with SMTP id n11-20020aa7c78b000000b0046797e46339mr75684203eds.381.1670283463190; Mon, 05 Dec 2022 15:37:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670283463; cv=pass; d=google.com; s=arc-20160816; b=kaKYq3sJMdRNvgeBkkizvypnihfDCPQYHlQeUUmiocKXWfRSLhihX6TQsFJxGiMraq i2iddp06mwCXg77B0udfVzl/5Y1oiGF97UjS61roPXx3hXhndJ5XWgJ8aqGPcLaC/K5A thTwWRmDSkn3YNPYlCc88ZSGq3ICy5VxkKadyMPyHvfSmcasAFASdkL6Ue0vz34gPTiP XaMqI0N4dBu8QkLzTX0s9ZeNAaN1kc8eKqISWE+KNZDPwsH/x4WYNiD9HAx8j9Nu1StP OKgLkJNT0+2XoARjWVT03Z/XB454fc5K4uUONRKL2NWowuwp2Ap2z2E75kVXAQe/n4ZV NiJw== 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=gGvG9Rf9xVNCz0RYULQ5crweJXubHrQh73RG4+BymoQ=; b=SELzbQDsIhE5jVdOoO5VWL7ZEpPf0Kg3sdclyM3xY0Allisadm+nrHzv9+6mrgtCmx 8QvJf8Y3iyLbxt4sslU3KZ7uu67Pd73jCd2UleJXyBWTJUWPGh6CQ1saRFPk02N+zrK8 5gK0QIiCruQBWhXSgxv9tN8ZM/MC+2bMIdB8aipj54vfcrfw/VX2pO2g0xqIUdIo2XIC Q0Z8WIsthSpLjdclMwCmK5b0en5m73MdsbDKVgrPiCdKVWPAkeXvZES2WT+eGYzBcSEm 4IGpK4rrm7/l4IzaiVdYrP81eg5LSpQKBt14XUwGcvA4IHwl4O5Jhj2dQKQcffBV99rx eBCQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pb4QPrCP; 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 f17-20020a170906825100b007c0ef0592fasi2738662ejx.645.2022.12.05.15.37.19; Mon, 05 Dec 2022 15:37:43 -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=pb4QPrCP; 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 S232919AbiLEXfM (ORCPT + 99 others); Mon, 5 Dec 2022 18:35:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232574AbiLEXei (ORCPT ); Mon, 5 Dec 2022 18:34:38 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8762037A; Mon, 5 Dec 2022 15:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKv4vgrNnEUSWzQuBKCzs3GMJsXkhjGIQUQ1IG4g3WZ59j/Z03VsddgIkqjdaoAlrRIDIQyZ/1quDj6pYFZLazYLSCa4GyC5lw5HC3+WGS+X4XCQKkFUUdE9/QmgDQYhuTWh6TQd0OHKDG3FDQer1LQG7Z6yMcba6ZxTrJLKG6XNgqpiYPU5Nf/PSCjjLt04qRt305mu1vOX+QDGotbH6Ewm1epg2r5i/f/UOm0RXvdKs6ogbffeC1W30L8R0kXRgutksImhBJL/YS8WXW7eVKlxsl53+LgNwYpC9Twu+L8qG8AAeiH/2sbY5+qrditwiBqFik/cMEQoMAHpRR7axg== 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=gGvG9Rf9xVNCz0RYULQ5crweJXubHrQh73RG4+BymoQ=; b=a7i4EAzna/s6Pwi9K2qbhLYtCvUbV3j069DKLZMnrDqzFwVemCKGlz8sdOd6ECTL6DvVgB1Nh7491fCH2P5PcxXbrqiSEYTCvF8w5FCVrHd8VvufTJ6OtNKYUDaIcVFXlNHa0GUnRyoAosiZRKWE0ySPoy3H8ZL6UDONHxBDVETzkwesmesYSr4pBBFwUKK7WroyW3cKwkSol79Ey5eH33HkbJgxEmNQ01YAQqQdm12lkKJ9xGOoi6Agsa6vb4HypCK0CWqoZ6RBhYeo9f667d4yob9NvJp9jKDs9xX8Qqfqfz3S4kRoNsLq/0qU5MdW3CUMpJGQ5tEESFhTCO7ZOw== 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=gGvG9Rf9xVNCz0RYULQ5crweJXubHrQh73RG4+BymoQ=; b=pb4QPrCPSczPHLmG3dIsyoVFN4+ctfLhIS7awrTVXUmGml5L8kUzBDWN4NJOYiauqTY2dza1wEWMoLaSSBcqk3enQYhcKDc4VDUROmIbjliiQPEg2+ccg3Szq/Pr8Zo0vdw870TBOiNoXQnT3dVT0VjF2fmsTfwTHoTDfBsOGw0= Received: from DM5PR07CA0110.namprd07.prod.outlook.com (2603:10b6:4:ae::39) by DM4PR12MB5890.namprd12.prod.outlook.com (2603:10b6:8:66::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 23:34:23 +0000 Received: from DS1PEPF0000E640.namprd02.prod.outlook.com (2603:10b6:4:ae:cafe::db) by DM5PR07CA0110.outlook.office365.com (2603:10b6:4:ae::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Mon, 5 Dec 2022 23:34: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 DS1PEPF0000E640.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Mon, 5 Dec 2022 23:34: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, 5 Dec 2022 17:34:21 -0600 From: Kim Phillips To: CC: Kim Phillips , Babu Moger , Borislav Petkov , 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 v5 7/7] x86/cpu, kvm: Propagate the AMD Automatic IBRS feature to the guest Date: Mon, 5 Dec 2022 17:32:35 -0600 Message-ID: <20221205233235.622491-8-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205233235.622491-1-kim.phillips@amd.com> References: <20221205233235.622491-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E640:EE_|DM4PR12MB5890:EE_ X-MS-Office365-Filtering-Correlation-Id: 54a912ea-65b0-4504-6084-08dad7193d6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h5WNjcicmMVeYE3+iM432qfkHr6pKivq3Ca1OLkIGkvW3zN2MmtrcqkPySKV/ORSnYpcvT2HRgGSFQwIZPFHm46m8uAmPle76ZTKfk1cMstA6L58nhac5+fLIGdELk9eDrj7SbgNVrN3jvXKOEDJPrS9jN1OMBX8POVeUcIp/uOKAzok3ZNSLWdTuPaIpcxktra349dNMsccVun3vCHRwrP6/I4BoW2fsYwiWOeQlNMRpi2xJe+rHzM2bjmcPAjit083hC2NVC5wDhyqy/moRN26IEbY3YN4GfYok/snID9gosYb47p/4U0iIPccSAcWepnEeQPMKjrZP17G43PgCKR64rpOUU+HFVXFRedX+gLrcuFIx8pjMuly1/BqUZxYIemOeo9KBzhY50LVus6zDqfGIErihpWu7XMgIFxGZrvktv69vfeoeb0dTKc1L34r8a8zc7khEPpCbi7cMSRySQZi9sHwpqNV4nEbHwzYqqJpDtTzYVKh24Bjcn+fBmSHo7AH6HBJikqgr3URlJ/OGH26nLu4LYQA0t/S3fHMCrXvw2ONsm6Qc1JtohXJ4sAt/CI7dew7ehlhcVqzgDoqnTsCLXy19hAj8an8g8u6phfBusDV8I4kKfvocuw09hKHNFNWaO9pfXCHjdiRZCmkl6rxJ7xsXsgRDf1eXwdhVOX50J4hznZH8zAjuQOqR9qjiVCdbfScmpdik6lEfz1EYIV8cPGVn/G16UgfFLezhMg= 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)(39860400002)(396003)(136003)(346002)(376002)(451199015)(46966006)(40470700004)(36840700001)(36756003)(7416002)(81166007)(86362001)(41300700001)(40460700003)(8936002)(4326008)(2906002)(44832011)(5660300002)(82740400003)(36860700001)(83380400001)(356005)(70206006)(70586007)(478600001)(2616005)(6916009)(54906003)(316002)(40480700001)(8676002)(82310400005)(336012)(16526019)(1076003)(47076005)(426003)(6666004)(186003)(7696005)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2022 23:34:23.0101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54a912ea-65b0-4504-6084-08dad7193d6a 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: DS1PEPF0000E640.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5890 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?1751419152865484779?= X-GMAIL-MSGID: =?utf-8?q?1751419152865484779?= Add the AMD Automatic IBRS feature bit to those being propagated to the guest, and enable the guest EFER bit. Signed-off-by: Kim Phillips --- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 2 ++ arch/x86/kvm/svm/svm.c | 3 +++ arch/x86/kvm/x86.c | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index dd0fe79521eb..0ed3ad3e9341 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -732,7 +732,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_init_scattered(CPUID_8000_0021_EAX, SF(NO_NESTED_DATA_BP) | SF(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | - SF(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */ + SF(NULL_SEL_CLR_BASE) | SF(AUTOIBRS) | 0 /* PrefetchCtlMsr */ ); if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC)) kvm_cpu_cap_set(X86_FEATURE_LFENCE_RDTSC); diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 184614e27d5b..0bf02c02bb0a 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -30,6 +30,7 @@ enum kvm_only_cpuid_leafs { #define KVM_X86_FEATURE_NO_NESTED_DATA_BP KVM_X86_FEATURE(CPUID_8000_0021_EAX, 0) #define KVM_X86_FEATURE_LFENCE_RDTSC KVM_X86_FEATURE(CPUID_8000_0021_EAX, 2) #define KVM_X86_FEATURE_NULL_SEL_CLR_BASE KVM_X86_FEATURE(CPUID_8000_0021_EAX, 6) +#define KVM_X86_FEATURE_AUTOIBRS KVM_X86_FEATURE(CPUID_8000_0021_EAX, 8) struct cpuid_reg { u32 function; @@ -89,6 +90,7 @@ static __always_inline u32 __feature_translate(int x86_feature) case X86_FEATURE_NO_NESTED_DATA_BP: return KVM_X86_FEATURE_NO_NESTED_DATA_BP; case X86_FEATURE_LFENCE_RDTSC: return KVM_X86_FEATURE_LFENCE_RDTSC; case X86_FEATURE_NULL_SEL_CLR_BASE: return KVM_X86_FEATURE_NULL_SEL_CLR_BASE; + case X86_FEATURE_AUTOIBRS: return KVM_X86_FEATURE_AUTOIBRS; default: break; } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index ce362e88a567..1551a791cff0 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4946,6 +4946,9 @@ static __init int svm_hardware_setup(void) tsc_aux_uret_slot = kvm_add_user_return_msr(MSR_TSC_AUX); + if (boot_cpu_has(X86_FEATURE_AUTOIBRS)) + kvm_enable_efer_bits(EFER_AUTOIBRS); + /* Check for pause filtering support */ if (!boot_cpu_has(X86_FEATURE_PAUSEFILTER)) { pause_filter_count = 0; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2835bd796639..0697d444c715 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1688,6 +1688,9 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data) static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer) { + if (efer & EFER_AUTOIBRS && !guest_cpuid_has(vcpu, X86_FEATURE_AUTOIBRS)) + return false; + if (efer & EFER_FFXSR && !guest_cpuid_has(vcpu, X86_FEATURE_FXSR_OPT)) return false;