From patchwork Mon Jan 23 22:56:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857548wrn; Mon, 23 Jan 2023 15:03:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaXyvOVrxCG0vSwi4oxvwzmdYbbAFxi06/SIhmP7/zOk9H1Mbz14NEXYZ+31U+aYpLAQxK X-Received: by 2002:a17:902:f650:b0:192:b43e:272 with SMTP id m16-20020a170902f65000b00192b43e0272mr31493123plg.53.1674515023167; Mon, 23 Jan 2023 15:03:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515023; cv=pass; d=google.com; s=arc-20160816; b=JDy4u9VreVz9n7CksHf0YhA+7UuJQltWdgaSXsAc40Jm5aYZfpqcWFhSflr+sFFQ4J dBW5jQmxAAHjr0Pfb7A5ttMxCtPgeAWJ+NhYnszSN+duOSyCPNZ+HJROUHuVj1Fw9Gve 2k8NIf5CLaBC9WD5CL5RQJHRjx7diPVmG4JD+Ptu1dmu6tVnDP9LTZQysSvfMFZvZ4xH 5t0MYtBicyiO82gCHk4aWDupamUX5xiboFGauVdYo0IDfSwL0FgIFlxaubMyxJsnuy/o KBLPnMcKpiCZ8D73efShw4nNmwA7y46MGvYW9BLlrtMdzk1abXuGwD7SyPDWD7dgzxtR aWag== 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=3GAUq2qG6c/SnAW0J4ARLzMQs7G6rvaXWnTEdfazk/8=; b=FTv3piFmyBOFeEYzEW+56uGydKiGDAqWjFHOvJ/49pA+EOGLvLMzzrsvBdPSfGd5zh ohsOkuSIKUTktzBaPkrcbBXNByNjTQSAXLh1aplf5eK/7peBg4pC2ayzIS/+JYBuvYt9 9NXvvJD+MGvj3An/zhxBlWXandZsQUjiXiKYxFXphgpBLBolaD/3FgG7Y5aB0B6jyXGQ 7TA2jUm6dwxOOEbJpjmW5LFXL3MDeLtS6OBe6+72y+8GXU/c1DhvKc+n3HvYWtoyNW/P /4ZVykvZyOFvizTbtAXQGil65MUekcCAYovu0cTxC0YQuBLS5u3dJRK5G7qKh1cYGmVP ZDHg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=a7dWmsIG; 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 jb19-20020a170903259300b001867db1d29csi631555plb.60.2023.01.23.15.03.31; Mon, 23 Jan 2023 15:03: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=a7dWmsIG; 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 S233423AbjAWW5a (ORCPT + 99 others); Mon, 23 Jan 2023 17:57:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjAWW52 (ORCPT ); Mon, 23 Jan 2023 17:57:28 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2046.outbound.protection.outlook.com [40.107.101.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79DBE14484; Mon, 23 Jan 2023 14:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgMqh7j3OXmfjSepdwgV/Y/n4cCGH0BLUlSmMHudZOyu0a5dLOn4uS2qXYOqeOD/5QMQnf01eUQcekRoHhqkE+A5Ll9noeZozNsN/cwYotoeeGYKY4LZC9wfoqSdQ2lGoYrshf4Hn4QCwVEtjyh7W5ZRcuoqC8g+bO36vyTJMJ3pV4B600YjiB0veNZ3oUxgi01BeAZGb7gsIkhYCqMwBclJxe6YsVjinyYcr95vGfGFz1t8BoirCHJuXzpLilkPmqTWltQfS7JJd5qcmtxk0ASJu6E7BecfK60Da+U268vC1KEUkvVpMl0YNQ6zPX0cfaTNW/fdANh9jXku/ogkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3GAUq2qG6c/SnAW0J4ARLzMQs7G6rvaXWnTEdfazk/8=; b=NbOtXBYhrqqS82JvdAu5WPykca22oAu2h+Xa3mVDBwA0G+WDT/91aAivx3Q9dS7nzTfLizYw7AFy0H/Qmkk3Hl1zZxFdt0qWfbCsaC9DYy4q8K46BG/H01r3KlwCNAqnpqnqDZwrwMj/wrxXNuOK/1fiXD6oaBC/3eeD+wr4dDCMCC1Bs1MA4uwlSBmgBr+ObYmU0rdsY9S49APX+pkDqIxcCMkh/tBwYx4j2/GT77UWETdHfKR4OAbwM6EgIRcC6mH/X8Shn/wnskHIU2JRudaQNMxWyPdH2QbvX3RGipfqH/szHrng1wJiYwvQdVIfoMhD1EKLz2BY7+Pofk8SRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3GAUq2qG6c/SnAW0J4ARLzMQs7G6rvaXWnTEdfazk/8=; b=a7dWmsIG6FGOTxy/nDdAd47tOIhpnYPk51cX0KP+8iucE6WYm1kEUc1VUPEyW+XhWLGDVYF7nsv4ly3Q+6JQOZt8aIjrvAhcW2aPI3fzwRmqeGcpO7NtOHXc8jcTEC4C2amlLVMV579H0WIcuWa9Lb+boS7tEvb+EYUYUhyuAgE= Received: from BN9PR03CA0257.namprd03.prod.outlook.com (2603:10b6:408:ff::22) by CH3PR12MB7739.namprd12.prod.outlook.com (2603:10b6:610:151::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:57:24 +0000 Received: from BN8NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::94) by BN9PR03CA0257.outlook.office365.com (2603:10b6:408:ff::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:57:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT070.mail.protection.outlook.com (10.13.177.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:57:23 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:57:21 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 1/8] x86/cpu, kvm: Add support for CPUID_80000021_EAX Date: Mon, 23 Jan 2023 16:56:53 -0600 Message-ID: <20230123225700.2224063-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT070:EE_|CH3PR12MB7739:EE_ X-MS-Office365-Filtering-Correlation-Id: 38bd5bee-bcd5-40ab-21f3-08dafd9530ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PLk9qnZ9LMEGhm9CEuYwv3z3XsC8JgPlUG30yD0ePazpMbEF96V8T2DQudPDpRLe7czrFCklQyZs8iBZw4EKWsvexILNhcfXQWDWjEZL1Tc8mmec4dvQuszHXyTQi5DdOs2a7TPrPUo0OJ6j/f0taDHKkTniBuU1c6Sj7CAdhW/kkguw4Kyngno4gks6MC74sx7dF6Fk1tLdvEXzY/NnU97zipAmuWSFHg5O9SWcJa/iOIwh6zwFxsBpCwG0cTGx1I1Pe/BV/ntY9QYom6CUTdoWntOmc22BScf/ayGgbP7es2AtH4ZCdGNc/8PhMLRlwlbvrzhKlD+iQaWzjM/81LliV4TsJhLGuVtVR0fSKCBiZ7NUwcXHFllqGzFZjFpCAZhCdrPSygRRRXTEvBiHpwABBYvHHKuWEtjTNTTfCs//2qeypSmzpIGa+1Z/iQRu7XnD4LGXsSPsdsnOlDII56I6Hvd2/PxFmzU6V02MnazBfrzPur7hnaDjzMXn0DhPw9oFAE8M9QZ4yPCtLx77d9DJ8pYkveA7WppfXOGtvZPVtxNpNvLyxecR2+uIaHfJwhtOZJQfI7LhUy0dzJHja8RS9V5bGYQJu5xlRx4fOcNd31MA2o4gFHsG8BU+a/oQCmk2mfhetALislTFHucPx40xR5o6Jk0O4ZgblG5FabvuJeNVGgOdR/7qDwe1dmg6rFqw33PdYj5eWI726ZORiJPgAp+/z+ZDvMDNaYOeySk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199015)(46966006)(40470700004)(36840700001)(81166007)(82740400003)(40460700003)(36756003)(356005)(40480700001)(82310400005)(86362001)(316002)(336012)(478600001)(54906003)(8676002)(70206006)(70586007)(6916009)(4326008)(426003)(47076005)(2616005)(7696005)(1076003)(2906002)(8936002)(186003)(41300700001)(26005)(36860700001)(83380400001)(6666004)(16526019)(44832011)(7416002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:57:23.8679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38bd5bee-bcd5-40ab-21f3-08dafd9530ed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7739 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?1755856265010170294?= X-GMAIL-MSGID: =?utf-8?q?1755856265010170294?= Add support for CPUID leaf 80000021, EAX. The majority of the features will be used in the kernel and thus a separate leaf is appropriate. Include KVM's reverse_cpuid entry because features are used by VM guests, too. [ bp: Massage commit message. ] Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeature.h | 7 +++++-- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/include/asm/disabled-features.h | 3 ++- arch/x86/include/asm/required-features.h | 3 ++- arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kvm/reverse_cpuid.h | 1 + 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 1a85e1fb0922..ce0c8f7d3218 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -32,6 +32,7 @@ enum cpuid_leafs CPUID_8000_0007_EBX, CPUID_7_EDX, CPUID_8000_001F_EAX, + CPUID_8000_0021_EAX, }; #define X86_CAP_FMT_NUM "%d:%d" @@ -94,8 +95,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 20, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 21)) #define DISABLED_MASK_BIT_SET(feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \ @@ -118,8 +120,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 20, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 21)) #define cpu_has(c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 6cfa7143c316..a84536876794 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -13,7 +13,7 @@ /* * Defines x86 CPU feature bits */ -#define NCAPINTS 20 /* N 32-bit words worth of info */ +#define NCAPINTS 21 /* N 32-bit words worth of info */ #define NBUGINTS 1 /* N 32-bit bug flags */ /* diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h index c44b56f7ffba..5dfa4fb76f4b 100644 --- a/arch/x86/include/asm/disabled-features.h +++ b/arch/x86/include/asm/disabled-features.h @@ -124,6 +124,7 @@ #define DISABLED_MASK17 0 #define DISABLED_MASK18 0 #define DISABLED_MASK19 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define DISABLED_MASK20 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) #endif /* _ASM_X86_DISABLED_FEATURES_H */ diff --git a/arch/x86/include/asm/required-features.h b/arch/x86/include/asm/required-features.h index aff774775c67..7ba1726b71c7 100644 --- a/arch/x86/include/asm/required-features.h +++ b/arch/x86/include/asm/required-features.h @@ -98,6 +98,7 @@ #define REQUIRED_MASK17 0 #define REQUIRED_MASK18 0 #define REQUIRED_MASK19 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define REQUIRED_MASK20 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) #endif /* _ASM_X86_REQUIRED_FEATURES_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 5fe56f0ec9d7..094dbcd63f2a 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1093,6 +1093,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c) if (c->extended_cpuid_level >= 0x8000001f) c->x86_capability[CPUID_8000_001F_EAX] = cpuid_eax(0x8000001f); + if (c->extended_cpuid_level >= 0x80000021) + c->x86_capability[CPUID_8000_0021_EAX] = cpuid_eax(0x80000021); + init_scattered_cpuid_features(c); init_speculation_control(c); diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 042d0aca3c92..81f4e9ce0c77 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -68,6 +68,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, [CPUID_7_1_EDX] = { 7, 1, CPUID_EDX}, + [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX}, }; /* From patchwork Mon Jan 23 22:56:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857194wrn; Mon, 23 Jan 2023 15:03:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsiPkZNrt6Gns2MHESYurj5k88zFujSB625E3S9mGHBKM88/iB2k55RIGcXMFXJ4MOB/Lqe X-Received: by 2002:a17:906:1995:b0:871:32e7:79ac with SMTP id g21-20020a170906199500b0087132e779acmr25678811ejd.5.1674514984468; Mon, 23 Jan 2023 15:03:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674514984; cv=pass; d=google.com; s=arc-20160816; b=R/gTb9zM682i49wZcSv3ftFi3msPsEN8ZzkNpEju//RhsjCUG+5k3rNVnrVLU7xSob 9jy0Iqm+FkA5NRKyaxJJdjE7dpw69UsjtcPB3xJTgYngwv88q9YBM08ii5eAA7GhTt+P VGfBs4ZGvWDaCVn3kcBFavRbcxLLIGKWJvzmneVW1j1Wl8Bm262040yoEz+DSHTq4K3t 0VFf7W4zoIyK62DB2J6FwScX09yObao52FKsaCMtFVS5fxBIr/JIf+lnpyk3rW3TMMrb c4ihENrwFOEjn5jsJ6MApWBo5je6kn1pIVICSQfB152+QfuKQl0itbN6Uu97266vn3JX KSpQ== 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=qpxlm4uEqWI7sozxahV0r65VMlPLMLdEUCMreeL+CGc=; b=qj6qVm9yZtuNm7ko5CKQCQVdunaqSQmjJfAdvHPgjZ72QgKCM9tlQftnPHLPNC9y59 uS2u46c/2P9pSdXApOD/wWanMCV9hZGpHafH89hKGnQp4KmcdQWQmplN+J+zCa47eAxe 3koN8oZTpgG3znEQmVFbIC9LegWAqxV98fYx6W93iEJ4AFfdFesvFDPNupEwrtW2KAiz oZ8oeOeo38+HNeRAepgGy4UWVzfoTLPh/Vnbx2NWBscpXyJhsVUTIWK598jyjYiCLDXP s36dfQ1Wc7eVmUCi9AUzZIbGDUdkY7vD3jgUoXwYDFjB4vhAHX9D/Qoqc+35Gysz6EBv v7gQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=LKTW4MZA; 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 ab15-20020a170907340f00b00780488c11bbsi171865ejc.388.2023.01.23.15.02.39; Mon, 23 Jan 2023 15:03:04 -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=LKTW4MZA; 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 S231634AbjAWW6N (ORCPT + 99 others); Mon, 23 Jan 2023 17:58:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjAWW6M (ORCPT ); Mon, 23 Jan 2023 17:58:12 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8AD4EF3; Mon, 23 Jan 2023 14:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/JnhKjCm2FZA/0L95gHCDAOE2UwyMlrXkpOI490E/IScDYZGgJevLukjLX/ks8Kt1BFKVfATn28+wFNorxomk7KRbc56hggzr9SJrjURavxBj3kKly6mZHmv7STyVX2mkffFV/4ugBM1YPw9IGpZCLyHWr6VCvb0CMxbjVwYghaTCODWU57ZCzIgn9W+m+3ppSff4LSlmXtv9yygVO0i910g1ifeNDC/3fvPBuTov/9zSCUnKDqxgDLRbPAmgvmIOqIbOlsin+GJdp8Cegfm8k4kcJCNRXJr3QnS+S3F+SY59xOKcftVYlFy+wEsRRIYC9YH23/9cHNMTHT0ZTyKg== 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=qpxlm4uEqWI7sozxahV0r65VMlPLMLdEUCMreeL+CGc=; b=OO+erQDieRTWPHUsKcV1m6lgi4GbJgPmo4bESHEXLdVJi99AID08kwCWQgNEdP4wW3Xh4H1MxDfY6KFfhFzgj5+wDgYMoxXlFDLU7kwfpLf/7dDmuL1kB19fHFpf3bvZ15J+5XECLOUyEMKR25kASI1d+Fx/HQ7osoJrAPXH0onqKFgvTHUYZi7/IpgimMeAfwFrLz1uRG44qt4vtJT3yl6adimATud7XIGpzh8sbls94DFFzhlDJqjyuG45vyM5vqESX7LDzHAjwcXdFku1+ZhZZ7ablahfCtIGMynAIIJXZiQOUEfNUGiw0AXQAJWbbJs9PMji5Rv/OFaD5krE8A== 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=qpxlm4uEqWI7sozxahV0r65VMlPLMLdEUCMreeL+CGc=; b=LKTW4MZApyYzq9Bup11UngsKJgsMdr8vZk+eO+sNtNR9VJUJWUi/h0feDnebOycA190FQSrlbnKhFqyoSWpb7PW4z2fqgzYAu0PrAZ+RB5cOa6qHOrK2cV2wIbr6KJ9rjVAPlw5c0N9Pz+GT+kQL2bhnEhRdGP5tsng64+bJ1ok= Received: from BN9PR03CA0934.namprd03.prod.outlook.com (2603:10b6:408:108::9) by PH8PR12MB6697.namprd12.prod.outlook.com (2603:10b6:510:1cc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.27; Mon, 23 Jan 2023 22:57:40 +0000 Received: from BN8NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::d4) by BN9PR03CA0934.outlook.office365.com (2603:10b6:408:108::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:57:39 +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 BN8NAM11FT090.mail.protection.outlook.com (10.13.177.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:57:39 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:57:38 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 2/8] x86/cpu, kvm: Move open-coded cpuid leaf 0x80000021 EAX bit propagation code Date: Mon, 23 Jan 2023 16:56:54 -0600 Message-ID: <20230123225700.2224063-3-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT090:EE_|PH8PR12MB6697:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f43fde1-0bed-406e-8911-08dafd953a71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RGjviGrUq7OLr8zLPpb5Hc/PlkX0x+HimId8XPMnNrgi4DVGyGo1jb+x9eW5jOVWhEQlq6IxC6b8EvWLWRFcLIlh2K3lsvCzf+jehLR4iJEbGYrMJR1xc4Y/fPeLntqBdGDXLMOGW2torNnVniXpbIX808y2S67fUfaU4s+oZCoiPA5knPQu6imcT+HRja3tRPDC8135fkhCpqJ+ZlFwt/V7GSw5Nr9b4Ty0d5GIQ8RZJbvhmvO0iNi+TjoyMd3t38bS7SwxflgjUpIXjCMVePtF9v+i6c7CdNMfV2160XovbBoBFSoJkOr4xYDl+Sg4owGo291Qqc9DTX48SggVel6Eq07ZIjtvcAJMf3CTlMufN6JmC5KJHV45yJXkedidcqI3mQa3Xs3QWkZy/BzmJIcrWuNjGUALcLSgyaeqFkuoQyL9Q+S4tKjwf73NriEwPjqPj6/wkGZ3N6L7o7laDc71EotmxxKGy4MPoOB5c76CfrJh4ds1DQZaNkvF6vpO4etdXHcKB7SJh25ADroKHvava2gStQYBMZ5lNBYai9H3nS/UGXP5BtQWbvYA/7toK6fU5qurjk6+PgemTGaC09tNwFLZQfaNbpynPI50EiojUZ+zBFyx05lv3o+2m+/gwUBsOVWLTGoFzQHFa5NVifEDs0kG6OE6forFFSVMCmRfMUE4fK+uvKPGy9L6BdWUXVM0tKoSDoKJxhYWt5s8OqhBviITIpoGcrve6ggVpYE= 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)(136003)(346002)(376002)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(44832011)(5660300002)(8936002)(7416002)(8676002)(82310400005)(6916009)(70586007)(70206006)(2616005)(6666004)(2906002)(16526019)(26005)(186003)(54906003)(4326008)(36756003)(7696005)(478600001)(316002)(41300700001)(83380400001)(86362001)(40480700001)(81166007)(82740400003)(36860700001)(356005)(47076005)(40460700003)(1076003)(426003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:57:39.8351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f43fde1-0bed-406e-8911-08dafd953a71 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: BN8NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6697 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?1755856224286807118?= X-GMAIL-MSGID: =?utf-8?q?1755856224286807118?= Move code from __do_cpuid_func() to kvm_set_cpu_caps() in preparation for adding the features in their native leaf. Also drop the bit description comments as it will be more self- describing once the individual features are added. 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 | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 596061c1610e..3930452bf06e 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -741,6 +741,16 @@ void kvm_set_cpu_caps(void) 0 /* SME */ | F(SEV) | 0 /* VM_PAGE_FLUSH */ | F(SEV_ES) | F(SME_COHERENT)); + kvm_cpu_cap_mask(CPUID_8000_0021_EAX, + BIT(0) /* NO_NESTED_DATA_BP */ | 0 /* SmmPgCfgLock */ | + BIT(6) /* NULL_SEL_CLR_BASE */ | 0 /* PrefetchCtlMsr */ + ); + if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC)) + kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(2) /* LFENCE Always serializing */; + if (!static_cpu_has_bug(X86_BUG_NULL_SEG)) + kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(6) /* NULL_SEL_CLR_BASE */; + kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(9) /* NO_SMM_CTL_MSR */; + 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) | @@ -1222,25 +1232,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 - * - * KVM doesn't support SMM_CTL. - * EAX 9 SMM_CTL MSR is not supported - */ - entry->eax &= BIT(0) | BIT(2) | BIT(6); - entry->eax |= BIT(9); - 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: From patchwork Mon Jan 23 22:56:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47457 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857446wrn; Mon, 23 Jan 2023 15:03:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBwl6hQScUtY74k7Xrrz5FCvONbzNjipTaWxqPnxKtTueJyOuotRtZ6bcmoRNSojR/Ua9J X-Received: by 2002:a05:6402:1f11:b0:496:9d0f:3081 with SMTP id b17-20020a0564021f1100b004969d0f3081mr30632099edb.3.1674515014980; Mon, 23 Jan 2023 15:03:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515014; cv=pass; d=google.com; s=arc-20160816; b=ZOx7ouOXfaGm8AMBonoBPJCPLdqRDsti4QmlbXd775Elt+wVh5HJjtKC+mvpblZdeK DCRnSVixmQ7sghZQfQC1ZDaP++NS8IR9TJuzb2BhdRv0U0Q0wKqgTtUTat8CIQ6dw5KQ sr7G3yPcPqWoVG9UmgagdEz2dUAThN/yTkQsRacrnOtGH0AJdFj2kGJ71YJ6ov75zw4m ljlCwM9X6385puBqK7Eu+6n8ptHijnfy7HYr9UDtMVIMrCwpUbhS7Gqiwm8IGemWK3e5 jobQ9ndcd6prlOc6/VBrtfA6iYKEfDCtvNM3vQ+lzgjqxSamL3IPhzSqqP4Vglhm7Lk4 mjGg== 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=5FfqCsvEAVPCNalYUaEV/E58Nk534dZaVTkYflQikK8=; b=Mr7GKOt2YuaZM5wXHsPURY9O0umXlvQTmDppCHl+6DJ/wG1A3/16v03icYxwKe9ISN sYWfnrqQYqVL7BoByaBGA3ZXi4GJ1YfRTizBKR3eIfCVqOBlqAzsfcnnvILBQ9mN8JYj qSNX5KP9qMjZAaqgPdZYDAYnFGieD2uirit3VRzDYJX1luc/9iMcU6E74WlY+zhgifqy c0VLoRnArrJ9GKLrc5xfIA7POLq0ye0eqmDbeV7GK1By5QRtUaKDcO4NV2uabZP0u9c8 QpyGwB7e3ofLgmBoAFFxt+YpxTZ9eF3oKebCog8XJvfTYG+3smOYq3GGNBpkkN112B+u VKbw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=GdbyfoIS; 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 x16-20020a05640226d000b004a056941677si510959edd.471.2023.01.23.15.03.11; Mon, 23 Jan 2023 15:03:34 -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=GdbyfoIS; 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 S232116AbjAWW6U (ORCPT + 99 others); Mon, 23 Jan 2023 17:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233417AbjAWW6S (ORCPT ); Mon, 23 Jan 2023 17:58:18 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD4318176; Mon, 23 Jan 2023 14:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJQJkKuQVEK2HeEZGs7VkxbNvEIJtaReDWB/PjTlN69hq7I4A9jbfjK/0iP2J6vVzyQje0b1ofs5tvv6OpEw1S66C6RnwQMBw/OdCvHoXclBUHn0lQkvfsHHVBmfABSyXXi3sYaQE0v2qnWH0cRdy14F0RtJ1adaRxG51GkvMv7jVA6D1Mq6xKlUNR5V8k/4q+PGIgOOApjSedVPBdZnZHZHJavHLD5jhiYXkrqtB4aTPDudHlbnQpuza3c5m0mjoQiXVMpXl0TuFzPWitQyDV3pchM5UWT/vOEizCJat7xfSVNHPWD4SCZOpQ0UIw4I8Wu0EW6s1wsge4ngd/SXYA== 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=5FfqCsvEAVPCNalYUaEV/E58Nk534dZaVTkYflQikK8=; b=Q3RGrKUO6025Jl1huyw8lUyff4EnEv4x6/N92IFav6ABiAlRaraMjCpDaZa1+ZHfWxaNa4qg9k1ITe+Q4NFxGudNmon4PHfl17J5KAebxp6J2qky8TU9t/LKwLRfbq7TUmNVwFO+ez+vI12szclx3tZvT7hcvuIldjd4WJhavatWTG62jpizzzZw8cegY2KzuT4Uy5SuobAeZosiwrN+nUGSnzJkO00uQl7MbJqZHsYkzUrD9ycdGsyAskYAuIjjSNgjq5KtoyXr/e3GY3sBGmdu5SGGpBh8vA4XtKKqUgt/YBFPJOLHMlEgCgcMR35f6s5ZXEzr/Y8jT0hP9sHqyw== 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=5FfqCsvEAVPCNalYUaEV/E58Nk534dZaVTkYflQikK8=; b=GdbyfoISdivmfilnl4zO1QlPAW4T/uXiTNOltagaUrFkD8X4obNaIznZ2vsGOFtZYZ3ZPI4UNbnvrKXrENvOd47qwtS3ZbGeeYCxssHwqk7bptDUvg0//auV34in1LOKaJwhrNDQK1elZIhO0oA1u/9daPacIAs0vHarxRJv710= Received: from BN6PR17CA0058.namprd17.prod.outlook.com (2603:10b6:405:75::47) by PH0PR12MB8151.namprd12.prod.outlook.com (2603:10b6:510:299::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:57:51 +0000 Received: from BN8NAM11FT101.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::3b) by BN6PR17CA0058.outlook.office365.com (2603:10b6:405:75::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:57:51 +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 BN8NAM11FT101.mail.protection.outlook.com (10.13.177.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Mon, 23 Jan 2023 22:57:51 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:57:50 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 3/8] x86/cpu, kvm: Add the NO_NESTED_DATA_BP feature Date: Mon, 23 Jan 2023 16:56:55 -0600 Message-ID: <20230123225700.2224063-4-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT101:EE_|PH0PR12MB8151:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e05d274-fd5a-42c3-ef11-08dafd954186 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NVJkWh6YuGKixCpdRj0VcqU4/TPF+AUNvcPpaS/jyVD6TB7BZFJ6wAmInUVSkqXIfvOLAKONwIi64dyQ0Wn24szplmGpzVbEGrRrwleToLJuzsFpP8e1JIBfovqI5CN5g1ZShKpGiOy9BawhxnTrvG8f32/PiMa+gimHXfiTm+F9jnYDenQXhOCm8z2ELiek339/YqdnjDHfxJLkfAY+gB9WRI2LFxGK1OYsTgwgTryMkYcR3+eV9QVTVzFdP25iOVC3DoJWkpw3fJ9ccmdb+obi+TVktrjxhPC/QuXx6bOfUuTHwRFQuq+MzjL9QPiC6dZdUYQ5CPXjkT51qlQDmQDIlZZMQ8U24r7R7/R7LZ0R3yMy8wOfK0guKdItSbCajYlO4sdS3/mgmR3i8pAT9OdBB+cYMtuJwP+0NoFPkTpbf15JtuoB9SdOtiIt45BMO4J/gLm3IVIkownYC2U2s+mFvgddLPs0S4fvdSBoEc+Qz7d9/KOmsb9wQgQTzrTRQyF2IWOpORNYCCSOK1T/t/cxskcyxbO7g6NxYiduqoYCzerhjhywJAktDFH20l5lWyB3KoP/vPv28mbFNLdJz+55R32LPlazI2EcQnePF7sLQVVG1h2wzFZYfwux1R+xSD2vyf/jM8R/spZeH+xj8h3HA6ngCq45om0MjEKnm6t7aWBrojnEODcMcqm7CZOxlJdW9Yt+noOcfu0xfkokYaoNGXqSMFCVk+LBli1s0AM= 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)(396003)(39860400002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(83380400001)(36860700001)(82310400005)(81166007)(82740400003)(7416002)(41300700001)(86362001)(356005)(44832011)(2906002)(8936002)(5660300002)(4326008)(40460700003)(40480700001)(16526019)(8676002)(6916009)(26005)(186003)(47076005)(336012)(426003)(70206006)(316002)(70586007)(2616005)(54906003)(1076003)(478600001)(7696005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:57:51.7194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e05d274-fd5a-42c3-ef11-08dafd954186 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: BN8NAM11FT101.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8151 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?1755856256269549901?= X-GMAIL-MSGID: =?utf-8?q?1755856256269549901?= The "Processor ignores nested data breakpoints" feature was being open-coded for KVM. Add the feature to its newly introduced CPUID leaf 0x80000021 EAX proper. Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 3 +++ arch/x86/kvm/cpuid.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index a84536876794..7f0fb894e432 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -428,6 +428,9 @@ #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* "" Virtual TSC_AUX */ #define X86_FEATURE_SME_COHERENT (19*32+10) /* "" AMD hardware-enforced cache coherency */ +/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */ +#define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */ + /* * BUG word(s) */ diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 3930452bf06e..13bd2769fa5a 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -742,7 +742,7 @@ void kvm_set_cpu_caps(void) F(SME_COHERENT)); kvm_cpu_cap_mask(CPUID_8000_0021_EAX, - BIT(0) /* NO_NESTED_DATA_BP */ | 0 /* SmmPgCfgLock */ | + F(NO_NESTED_DATA_BP) | 0 /* SmmPgCfgLock */ | BIT(6) /* NULL_SEL_CLR_BASE */ | 0 /* PrefetchCtlMsr */ ); if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC)) From patchwork Mon Jan 23 22:56:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857258wrn; Mon, 23 Jan 2023 15:03:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLcL9cc5I4zoeMkOazEkadPqXNQPyvI0t3p+cu0rfJwWfkjPhJtk6W2fDZKwnLROSka1H0 X-Received: by 2002:a17:906:6313:b0:7c1:6151:34c0 with SMTP id sk19-20020a170906631300b007c1615134c0mr29560322ejc.6.1674514992603; Mon, 23 Jan 2023 15:03:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674514992; cv=pass; d=google.com; s=arc-20160816; b=KQTr0iLrIwmkyUrITK9rq7Qhnn9hArEfPiqjpNURQtxmiJ4RJ4/EkUNk2ikvTcd63B GKY+hkrjYdDu7Ou0afRc9OjAXG+qIoXxNicQeqcvjP8QnP3AgpC4wZ077L0skjw2l9kT mTof5at9J1wLuxLWPXlJMcr9cxzCi2RbFCpuGaBVdQuH3Ac3Dy8cznn4pmelmvd4rh85 CtVf6rqztH5frBcB46wKlxUPVvJyA7koG0MzlTd3Mupv8qDS2tMjYol3/6519+6gKi9w ihKvaEytIwnVVEJRVJLHArlf8iIAVxFEaRUB0iMI4MB+/o3BFj9rPY37euir4942+9Hb krLw== 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=v9tHClwbTjqQsDepWLuQkEidUR6vBqMsc7y7GLLKoqo=; b=ONI3usZpSEHtZpQkRz/KaO2nDCLnZsOGG3Mc+D+tS6AUnwe8WN/U11MqjGRVTnn5en 36mrA8slOKVIrZSpMGg1CJlnUzLHwWxyfQhvUVvSAriO2hqy4f1r9vBck4KzIYkQe9uo e1NNFB2Tr2vF17w0oTgRWfhTKYXMoofutHP1bL13kk5wnsI82hlHsPQGq02wBtFlXsWX AvCS/vyJX0piOUv7Fgi1rTnyjyQjgPyehM0A3L4VIsm8CpE/T9+ChN8SuEYoXbWstN1t EeOofW+6c7jPWc1S5FY7hHAvT+bci1kmlXtjkzvSM7nwwgFT8lNpEV6inrJPCLej341I tCew== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="xOjl/RlX"; 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 l24-20020a170907915800b0086fd97e310bsi194718ejs.169.2023.01.23.15.02.49; Mon, 23 Jan 2023 15:03:12 -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="xOjl/RlX"; 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 S233443AbjAWW6X (ORCPT + 99 others); Mon, 23 Jan 2023 17:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjAWW6T (ORCPT ); Mon, 23 Jan 2023 17:58:19 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB24301AC; Mon, 23 Jan 2023 14:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gZSACIhZpdVGKncJRgs5QJnYBQeq7c5lt1SIeHd+E1pH77ATUv/DnrqtIyET4obpgVRtFgR/cunJypyOGV/t1VYd9NLWAVndRNKwFg288/5Gf87bukdCFgT0Shg1xJCBPwtrJnP6BxVOH6Elmkn4L3B2lcof5l3L49DEIEYU0zp1izq64TgON63dG7I0ZFRHpaZ1u50nNMyYuE8zRvaGKVMtvv1ZcI4bcduICBPtURB1j6Mi/O7RokAmVHr/lM6MU46qoZWJtL0X7wpuNkAmVOL/oOr8EQx3eQTIOd2yUFUjLrjaKb0YJCXEw6BR+rBppinCyFzP97sYiB1ZJYDAVg== 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=v9tHClwbTjqQsDepWLuQkEidUR6vBqMsc7y7GLLKoqo=; b=c0T6E0FuoLu8JhZkXd4ysBMx/ik/n0KKV4CdTbJDTqf6CiyMWOaGHms4j8SDVtF7Yk43pwqOx8nrVtMyqxWsPSHE3uQwVcrNElBMDxmupyM8SSCw2G7jJxIOWmBoOFwRbES/lyk2oSVAem6vcmngY6m9shDM+ix9HlFbDJyXKlZatL/hifDHXM1Y+EmBmSIJEg6+uB8ivo3K1tMMHqnnHpy8qRssqxDpS6Gy8HEEKu/8OHc5Vbe3PrTTD719PyUDKVjWxNkBnygFY9lvfWdhU/Bw2EvYdCNKbv35GymPkoGdseETBA8xLYWnShoqJLT5AgCJ3IIO/bu601+m/O4cIA== 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=v9tHClwbTjqQsDepWLuQkEidUR6vBqMsc7y7GLLKoqo=; b=xOjl/RlXDrHGFGAAQfIAbrQ5ZD+e1X7VIz1Pyd5h7mPn+Spdu/QzxZJLDERuZ98pfpv+IUbw6DAyiEbgmMxdQ4XeO8kC7dTpOZHYQojHxosvE16MeuVH9uy9BAimlroxCR8+hIhWIx6HKWgquzzuQG9viGE2KI2mLBLgxTp+WgY= Received: from BN9PR03CA0986.namprd03.prod.outlook.com (2603:10b6:408:109::31) by PH0PR12MB8125.namprd12.prod.outlook.com (2603:10b6:510:293::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:58:03 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::87) by BN9PR03CA0986.outlook.office365.com (2603:10b6:408:109::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:58:03 +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 BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:58:03 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:58:02 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 4/8] x86/cpu, kvm: Move X86_FEATURE_LFENCE_RDTSC to its native leaf Date: Mon, 23 Jan 2023 16:56:56 -0600 Message-ID: <20230123225700.2224063-5-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT030:EE_|PH0PR12MB8125:EE_ X-MS-Office365-Filtering-Correlation-Id: c28b1620-d126-4fd2-145b-08dafd954897 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yxUbnkuJhfBaPYu2bBdwBX2Yl5iSBjTc8H5E4x8eh74uSykIF36S8zIgvh4OdytouXSgct7W0ToBaURdzhC/2lvVhDZLhXOTD80K19NiV5F16idUeDSlm27ACSiu7oiF9GbBcPUr6xLSD/6YRFxuhfn8Z9k8NZ/l/g4Rm2OdGJIGNp6wczNpp2eAD1dSU3EQ30rzX3FlVreNf5akeliH7fIn+M+gaUGV8zudu9l8gM47CDnelCOzfotxzldzFIVIU6+FMXFP6jejl3t3zR++K2BLQ7porK+oOynNmCWaL42dxHNbm1tLpIXuVk9cKbT13AJmey9acETYiMW5XQRf9TKn5/2Q0sPrxXRCwJhf4o78DY17+uSFjgugsgUEN5UwnFvi2VDORszpWx+0A9aOjJnaRS9pubC5gpj7MoIPgI6/ROTFnX6Kangt9Ak2tS3TwBissVyTl5i8x1be9endtyurZY6/9FCg4uHsi1LUA1wSm4+oKvfV0TconT6MezfcTMjGrQdRumAv+humDwUwyykIBkJMh2iEfWzoOpNukm6x9Zqr4+10hS7B/rQrA8xso2qOi77pUnr6I8wI7lnYrBKoMhcyCgqeaMbxFJr2P3fybVCOvoZG5mP/qalGPOg+sHTuXqW0sdUVX8QNSWqSH5vsKpACXaNWQFBSCh1uprwktqqKQXVH28wL419EWD7iWf2pkezPviZtirrT+nRfhOjj6qE3rFoRaepUwldI+ZE= 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)(376002)(136003)(346002)(451199015)(46966006)(36840700001)(40470700004)(54906003)(316002)(2616005)(81166007)(356005)(36860700001)(40480700001)(2906002)(83380400001)(36756003)(47076005)(336012)(41300700001)(44832011)(7416002)(5660300002)(40460700003)(8936002)(70586007)(82740400003)(70206006)(426003)(8676002)(6916009)(4326008)(478600001)(16526019)(82310400005)(26005)(1076003)(86362001)(186003)(6666004)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:58:03.5692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c28b1620-d126-4fd2-145b-08dafd954897 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: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8125 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?1755856232387089756?= X-GMAIL-MSGID: =?utf-8?q?1755856232387089756?= The LFENCE always serializing feature bit was defined as scattered LFENCE_RDTSC and its native leaf bit position open-coded for KVM. Add it to its newly added CPUID leaf 0x80000021 EAX proper. Drop the bit description comments now it's more self-describing. Also, in amd_init(), don't bother setting DE_CFG[1] any more. Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 3 ++- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kvm/cpuid.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 7f0fb894e432..4f22d828c753 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -97,7 +97,7 @@ #define X86_FEATURE_SYSENTER32 ( 3*32+15) /* "" sysenter in IA32 userspace */ #define X86_FEATURE_REP_GOOD ( 3*32+16) /* REP microcode works well */ #define X86_FEATURE_AMD_LBR_V2 ( 3*32+17) /* AMD Last Branch Record Extension Version 2 */ -#define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" LFENCE synchronizes RDTSC */ +/* FREE, was #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) "" LFENCE synchronizes RDTSC */ #define X86_FEATURE_ACC_POWER ( 3*32+19) /* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */ #define X86_FEATURE_ALWAYS ( 3*32+21) /* "" Always-present feature */ @@ -430,6 +430,7 @@ /* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */ #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */ +#define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */ /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index f769d6d08b43..208c2ce8598a 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -956,7 +956,7 @@ static void init_amd(struct cpuinfo_x86 *c) init_amd_cacheinfo(c); - if (cpu_has(c, X86_FEATURE_XMM2)) { + if (!cpu_has(c, X86_FEATURE_LFENCE_RDTSC) && cpu_has(c, X86_FEATURE_XMM2)) { /* * Use LFENCE for execution serialization. On families which * don't have that MSR, LFENCE is already serializing. diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 13bd2769fa5a..601eeb03ebc9 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -742,11 +742,11 @@ void kvm_set_cpu_caps(void) F(SME_COHERENT)); kvm_cpu_cap_mask(CPUID_8000_0021_EAX, - F(NO_NESTED_DATA_BP) | 0 /* SmmPgCfgLock */ | + F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | BIT(6) /* NULL_SEL_CLR_BASE */ | 0 /* PrefetchCtlMsr */ ); if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC)) - kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(2) /* LFENCE Always serializing */; + kvm_cpu_cap_set(X86_FEATURE_LFENCE_RDTSC); if (!static_cpu_has_bug(X86_BUG_NULL_SEG)) kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(6) /* NULL_SEL_CLR_BASE */; kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(9) /* NO_SMM_CTL_MSR */; From patchwork Mon Jan 23 22:56:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857340wrn; Mon, 23 Jan 2023 15:03:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1hNDTHO1fOjtuSV3EtpCijPh2aCU1KNFtkDV1s1yuGN0BXe2T5Kzyd9x7FlP/+2XRfGYD X-Received: by 2002:a05:6402:189:b0:499:376e:6b27 with SMTP id r9-20020a056402018900b00499376e6b27mr27291125edv.5.1674515003488; Mon, 23 Jan 2023 15:03:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515003; cv=pass; d=google.com; s=arc-20160816; b=zbtZ44GCpxmBcg/uhFOYKLb7dL2yYhz4Gshj4UhM31V1LN9ZwThCyxQB+LXzqdRVyz 6Q/877QjBUNNc807Qg93jjtPXSq5ARj4n6Ac4OW/2eu2wkFcPxfcSclmib1RbZX/EtJc 1tKhlSXuWREUUXoEiptP++SneWOzimbZRNd/H4X/q1A1BMEAYaI4WFUFSABihVvNY4xU E613bzIMVwrzAP4wvckNsGG84KdmL+qjj2Ima4L5h7/u3TtVoV7NqfTCk+mrG3/XNkDs M5UILDw+iSEq4EaDOwadFQe7WKoRuX6R2vh7biZ5q3P1fp9onYpBfl7VAxErFp6PVeG9 APxg== 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=TGNQiin84mFW0kJA8uiHt2++Qo+0t+ZVpaNagY7/T4U=; b=fkY4s0j1zJXtHuxYdfEg9zQNJgk40UFuKyqVP/Jyr8Pso1TKj4dg3VuDBGN/CHfmUQ ni8fpSrOodvDHfeduBGCpJonkITlfdPZJzrBSs1knisAFV2EewjkRDWNFKfBvzNgwq13 TClbCP+IjeRPy5HVPE0w5crY2++sAuq522TWSJB3E8wfZAFXtay71f8Pc7vAiNyH816q 8Isi0TZIkA+dYh3bOS5Cn/U3Gd8AkrkikIX0bGxifmkUwSV+iuBoAfqUvP1aBo8LtAzx QkuOYPVEN/ZJk89svT8Le43trP/e1g4xydON84CXcuC+OMh58MdrdIeSh5EhJVqWqe8E xkkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gkVBLNGJ; 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 eg30-20020a056402289e00b00484b7b1b82csi703209edb.186.2023.01.23.15.02.59; Mon, 23 Jan 2023 15:03:23 -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=gkVBLNGJ; 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 S232138AbjAWW6b (ORCPT + 99 others); Mon, 23 Jan 2023 17:58:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232717AbjAWW6X (ORCPT ); Mon, 23 Jan 2023 17:58:23 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C28B138B53; Mon, 23 Jan 2023 14:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mAAai0qE44XotIKkkLJ1tFsKgNjy7MqivVxU/VCd6l69tjoAJh8wdPf5gRtVYPrdbyknuOSn/GxGAOhAtoyXizF2QjxH9C5JbpkLN5RsqEoH0GZic2H9sLltXx+FZOOTudTGw3P22biEr5912hRy/TlctbJ1zYFvRUBqLTwQt5G+cQf3AytVb+iZRoa4gv7B+ssQb0Bi3dNB9p2HWrjPmaD4OUmBJERMFGZeHsbAJ5BSjnjW2ETjc7lvlVKTHOXCdqlII0Pr56XdVtv6u3IBpiRFZtAN/6rihvfY1+tzAAfCJLVg6+3FTbKzImOnu61Sv5os/DDbNkJjaK8hek6ydQ== 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=TGNQiin84mFW0kJA8uiHt2++Qo+0t+ZVpaNagY7/T4U=; b=UeG/IRS+qFHnJ/GHDirLYdllN08ry82vCh4qru4BVBlAgWDrKPjOjbB6gGSUHUPgoQ3D64U2tufFkRPXFx5JCj/xVZ5pHgkrSLI0A9jKJcZP9cmCXckBrNdr43/1ludmdokzrQjvHfZbW5wYFzLMg4kFIGE3Y+dedI4ElLgj5jk74ukPhG/4TleCzTL3HSy6LFGa6si7cGgrzE14KLfW5JmNZSDMocNq2gsgF4LbTTEzJG1JAbFbskLNm7Np+4PU64tpAqKXxFo2kLXWMW9pKnu/xJJ3cVgTPxnvz8ZHRUD9cYXDuGLFHvILPXiAANK88QW1DgMEqfO+BPw3BQ1UdQ== 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=TGNQiin84mFW0kJA8uiHt2++Qo+0t+ZVpaNagY7/T4U=; b=gkVBLNGJq2rCR+Jjo30Qaq73+gZzWeLqFjT7SABe2LZPFbImAZivpA7MGjSwqO4bj/CUw+5hIU3uRJcL5DouDa5U0GSshh2KnOwakdB8qaU1bZklP9Hjc+qZpNKwsuY9yYBfquULifx7rx6QXjbEcoVADd2xzKH9AdvvscrOOBs= Received: from BN9PR03CA0544.namprd03.prod.outlook.com (2603:10b6:408:138::9) by SA0PR12MB7001.namprd12.prod.outlook.com (2603:10b6:806:2c0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Mon, 23 Jan 2023 22:58:15 +0000 Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::1) by BN9PR03CA0544.outlook.office365.com (2603:10b6:408:138::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14 via Frontend Transport; Mon, 23 Jan 2023 22:58:15 +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 BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:58:15 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:58:13 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 5/8] x86/cpu, kvm: Add the Null Selector Clears Base feature Date: Mon, 23 Jan 2023 16:56:57 -0600 Message-ID: <20230123225700.2224063-6-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT007:EE_|SA0PR12MB7001:EE_ X-MS-Office365-Filtering-Correlation-Id: ea2e7d54-2ca8-4f16-137b-08dafd954f8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SZJAG7n2N1bagPCE/zJNZ9QwldmZST2jwA2rgHJbxxJdk2YMnuKXdcSitVgLZdTZCb47onJgzIKGMv25kVHHTEc5jkM3eeYiIiIwNH5W79IOzEyOEHyfS/g3N9HDfe8KohrRhCZID/jSZ6ad6PqfuXjOIZcIlgbtouU5K9zTQCIBlwsr8MMux4M6d7LtaO2/su2/MfXPFgmhgfoXmhEAsOVRKM8HtCm+yxK0i6y7jhePNJGBSHIiY5f2aVgpfpOisnXyMIlWKyrA6NlUE9i1Z9MOdlt9Fw4qit3vGnJ5Rx17U4CKOhYiFnaH3158EL72nTVxrgFxZxGNBAtLYnjVtHUEPnp7E8DLbcWoKW1jSPM7DfI98LQalnW3OQapvNwDH+Bx6qr7aVIHlnWgWPSexMwmtu6vf/9XBDJGf1Q8Wv4cZeN6MzL2zTOkfnqjhQC3u4TQvIaUX8sW4qBch6w2X3O9N/NCSlwptEbX4PIR/sKOTITA2Aa3bkEbqbN0sevr+V1m9OMXkeQC28gyPZS8vO3mzTNX49g3Kq5V5d1L932Fi1GGVVgsFvy8eOO8nadLNFOFI3ITMOR+Y3AGvj31ADbj7BAdh2Stdh7EHnqWxe/D7CYmQYx/IQv8qNdQI/7irUBtWpCb1SXIzI3mJDZRGOXbLDLQ9uRUa9Xj+oC442En51mglUQS/WNKmCyHYoyuyuUagtnLLay4suy8+5PxJayLMrkSoC+vJmCKb2oZslk= 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)(376002)(396003)(451199015)(46966006)(40470700004)(36840700001)(8936002)(316002)(7696005)(40460700003)(6666004)(86362001)(36756003)(478600001)(5660300002)(83380400001)(426003)(336012)(82310400005)(47076005)(54906003)(6916009)(81166007)(2906002)(70206006)(8676002)(7416002)(40480700001)(2616005)(44832011)(82740400003)(1076003)(16526019)(70586007)(186003)(26005)(356005)(4326008)(41300700001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:58:15.2477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea2e7d54-2ca8-4f16-137b-08dafd954f8d 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: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7001 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?1755856244209415195?= X-GMAIL-MSGID: =?utf-8?q?1755856244209415195?= The Null Selector Clears Base feature was being open-coded for KVM. Add it to its newly added native CPUID leaf 0x80000021 EAX proper. Also drop the bit description comments now it's more self-describing. [ bp: Convert test in check_null_seg_clears_base() too. ] Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/common.c | 4 +--- arch/x86/kvm/cpuid.c | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 4f22d828c753..403a534691cc 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -431,6 +431,7 @@ /* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */ #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */ #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */ +#define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* "" Null Selector Clears Base */ /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 094dbcd63f2a..162352d42ce0 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1685,9 +1685,7 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c) if (!IS_ENABLED(CONFIG_X86_64)) 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/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 601eeb03ebc9..f1625a58b5ec 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -743,12 +743,12 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_mask(CPUID_8000_0021_EAX, F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | - BIT(6) /* NULL_SEL_CLR_BASE */ | 0 /* PrefetchCtlMsr */ + F(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_caps[CPUID_8000_0021_EAX] |= BIT(6) /* NULL_SEL_CLR_BASE */; + kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE); kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(9) /* NO_SMM_CTL_MSR */; kvm_cpu_cap_mask(CPUID_C000_0001_EDX, From patchwork Mon Jan 23 22:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857540wrn; Mon, 23 Jan 2023 15:03:42 -0800 (PST) X-Google-Smtp-Source: AK7set/4oPzsQh4iXvULx5tChRZlSedf40imYElbFvRj19oMQs91eHaKtEzi/fTFcD/v6ejRaAhH X-Received: by 2002:a05:6402:ca6:b0:49f:20e9:f985 with SMTP id cn6-20020a0564020ca600b0049f20e9f985mr1415130edb.41.1674515022259; Mon, 23 Jan 2023 15:03:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515022; cv=pass; d=google.com; s=arc-20160816; b=MNumC67EQ7/2U8tkDJ8kcxL/0uzTtQCn1XvE01dEUHdwt5PEL1Hoy/Pw86eUTgyrdD iB0JNpo2RsHK4G0oBbQ3hJjQ6SXbwQIPmzZIce7b3C9tXXgyfI8CXndmsbZ+AQ60mJEy 7D2Z6SEQYM/wO6GRYlxtnmIRevt6yIxtL4/DUWck7ci8BYJ1B6lxPMi3rsnErmJ+1Dd8 3n/vCBJyk75zb9nHsSsSD4W3p0kApom1UzfC4GzKM8jGrJgXpU0t6jJXmzLFjQRTdtpX Va/W8VWRhK06zMMVVXwOuKtNl6kbu7FmmRSRA6uWRvkIdn4q4ANcVB0HfoseiHPzOWbv kJcg== 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=DbM4eQmZM7N52LEpv5jH1Qpz6m9vbh9AxilHVdiiIUg=; b=AtREUDozNOQniZoZSpgYt6VZ31ige9X/FYmHYYgh+bDQ03i4slTzn1ACCXhuJyNl3F oigN55Tnt/CSXZB49M8JpoMuhEJ1HYwdzdhiEysqNfQ2zhiP/cPxF8ugJ5Jx3yxHGdI6 fheFx7y6aVS+UYmBCmXHGqrGYwU+AVQB7+y/XqYooV+2ITxX3R5VoH4UV35IPGg+2xHk h7m/YsbibL+iMsCuys97qwa+6ytB8PUD/aNG4rybFJB4RNRVAycpbOc3oVc36L3uBrah sIGKfnaqNkiM8KhEggFo6OhjlgEVweWLX7ye66FOqPEE0p67rHtw/TgOgq4JDCmcFtZN F//A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="abP/sbiW"; 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 v3-20020aa7cd43000000b004838856a8dasi764306edw.568.2023.01.23.15.03.18; Mon, 23 Jan 2023 15:03:42 -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="abP/sbiW"; 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 S233090AbjAWW7D (ORCPT + 99 others); Mon, 23 Jan 2023 17:59:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231981AbjAWW66 (ORCPT ); Mon, 23 Jan 2023 17:58:58 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28AAE46B2; Mon, 23 Jan 2023 14:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JY1/jz6xMt32QA9e6bc6qxjmrAIBf65F43tVZLJnjv2A1ZAdW6PZMM26UXvqW6rW217GkxIcbdxiOAiYU3wTvADOygW1TF0NFIRbLF46rfhNV8zOhiPDI7BXdgp4jMQhUJBnp2+exm1SelpoECakeknHiMeh/dmxnuk68DthhRK0ND9p0Ygb3fk3OlGT1g0M5h1xNt408gL8Z11zBjF8L04P9o4A3J0E66WThuHfnndX9ZqHI1Zt92jKF1h3gycH7AYwCngZ4Jz01HIJXbOyYCZgB3rPe1Zbo42We3ThyPEPqAwV1ZdHGOS9rm4vaQTxB4SrgmIVOV3N0+cllOWgkA== 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=DbM4eQmZM7N52LEpv5jH1Qpz6m9vbh9AxilHVdiiIUg=; b=GHZGiAM2msBUmPqflj59w2IemOew0JQMjXcyJpBxGOPCzDuO0ySSPMYabkjZZ1/sLKUH7QH9rOsoN2hN+SUtRDrgRCbweLkROxHqrRD5uqlttGc4c1Swu3/lCV8wQ1x7x9+ezsePFh40f5Zb7R6pmNnze6G3QScij/ju8PuxaQGX9zp6VbDt+MTiWQrdxuxHNQW84Qm+NFOWWdK28/Y5Izne6+1avB6QQ6aBXoyzcHLa9fNPqJwCYFbL7yVESFrZWxl2jEyJNahGRlAouHHwz8Np4QSaT0H55iIIAGSIWkoRlnbwgoLHeHl/hg7hTsUznM3KrNYD+HoRmItb2DVAYA== 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=DbM4eQmZM7N52LEpv5jH1Qpz6m9vbh9AxilHVdiiIUg=; b=abP/sbiWX9Ve1Y5Vuy2HoZDJ/iw3vtMqdWYSFLpKyz9IBS18ohqZr9uJw67OQ/C9vxlMGCD1MHIb8fzX5JVNBBsmWU5IozjfMA198tS0RQ59Q6/le36b9ov9xZ3EtPcHASm3aUJfPBOkfgGwTOr7R+ALcF9AcyFlIsv6YL4s9bw= Received: from BN9PR03CA0940.namprd03.prod.outlook.com (2603:10b6:408:108::15) by BL1PR12MB5994.namprd12.prod.outlook.com (2603:10b6:208:39a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:58:27 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::e2) by BN9PR03CA0940.outlook.office365.com (2603:10b6:408:108::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:58:27 +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 BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:58:27 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:58:25 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 6/8] x86/cpu, kvm: Add the SMM_CTL MSR not present feature Date: Mon, 23 Jan 2023 16:56:58 -0600 Message-ID: <20230123225700.2224063-7-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT048:EE_|BL1PR12MB5994:EE_ X-MS-Office365-Filtering-Correlation-Id: 4549386e-15ea-4253-448a-08dafd955694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /KtFf18JNJ1PDJORWUHWEiTrg7i9pfGbwXbInipyXO4uLpZ+Qx733KN1PKmMXJIG70CMzj2sfXM8XRP8QcAMZ+lVj2/6+HWwcZuSpwjVLRBtufsScv7dxnGl6kMs7b/fiQ8PtLhZ/OGaX5afgUarBcaFJZzGl2pMHsPn4UdsMU2C3PsQsuHNQS7rdYu4tr/k5k81/eI7kXMm7d0/irGceJKVOnqUxw1NSonNo4TDc+ihJ9ENU68fNBjkMZVmdiYoh51cxygyJsMUQ3N49N9bFZK/lzLPLQenGon+DohG43J8F+0mCILcSFb4137BgK9ygj3ViUNSaHkpzDLZIsWKuz/hy0JUBDLNc9n2zV9Kj9bpuA3NBPlpwIyDt+jbob3G2SRyDrkXPY0fFmm7IwhX0D6lejngOMdKXuu3i4kEsqGiy+/HvcrzZdUB+dTUP1xfIftdIBk5XdbaOgHGj8JYiQc5OUkorXTlaoVdTNadGvB41a/v/JMZNozCeB67YY495nhJ+7BOyKstQxtspDuUoArGzPS/XpF+H8fMwCl8wHI0RMMwkJXKKTSII9/ztyDyR7Z8mUjFx/ioBXSs8rNnrvxn5bU7KZ2inMz6lwPtmvXu1j72BSXulpZH1CfNIKsWQ7N/94g9pk3kEF8ri4MhU1oaFsz/h3Pm+M65jnePMQL7oqVWnfN1HTrAu0EFhD+Wcnv6FiKM1uecrdaqKxY7yMibmJRGvGn6/gArgz013Xs= 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)(136003)(396003)(39860400002)(346002)(376002)(451199015)(40470700004)(36840700001)(46966006)(47076005)(426003)(336012)(1076003)(83380400001)(2616005)(40480700001)(86362001)(40460700003)(36860700001)(81166007)(82310400005)(356005)(36756003)(82740400003)(6916009)(4326008)(8676002)(70586007)(70206006)(7416002)(5660300002)(2906002)(44832011)(41300700001)(8936002)(16526019)(6666004)(478600001)(26005)(186003)(54906003)(316002)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:58:27.0389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4549386e-15ea-4253-448a-08dafd955694 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: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5994 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?1755856263911988657?= X-GMAIL-MSGID: =?utf-8?q?1755856263911988657?= The SMM_CTL MSR not present feature was being open-coded for KVM. Add it to its newly added CPUID leaf 0x80000021 EAX proper. Also drop the bit description comments now the code is more self-describing. Signed-off-by: Kim Phillips --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kvm/cpuid.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 403a534691cc..6dcc3c3d0c8d 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -432,6 +432,7 @@ #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */ #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */ #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* "" Null Selector Clears Base */ +#define X86_FEATURE_NO_SMM_CTL_MSR (20*32+ 9) /* "" SMM_CTL MSR is not present */ /* * BUG word(s) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index f1625a58b5ec..9ba75ad9d976 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -749,7 +749,7 @@ void kvm_set_cpu_caps(void) 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_caps[CPUID_8000_0021_EAX] |= BIT(9) /* NO_SMM_CTL_MSR */; + kvm_cpu_cap_set(X86_FEATURE_NO_SMM_CTL_MSR); kvm_cpu_cap_mask(CPUID_C000_0001_EDX, F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) | From patchwork Mon Jan 23 22:56:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857860wrn; Mon, 23 Jan 2023 15:04:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXsVhXZkGfAPJNtpgtQKzLJ+flNMa37ZzLVkmNXtkxyHqculDw5MdnD2dqYVYw6NqRTYJEKt X-Received: by 2002:a17:906:6bc6:b0:7c0:f684:9092 with SMTP id t6-20020a1709066bc600b007c0f6849092mr25779500ejs.37.1674515056322; Mon, 23 Jan 2023 15:04:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515056; cv=pass; d=google.com; s=arc-20160816; b=eU8Mpm19Qw5NigkikAn2J/LU/UtcrZxzQbvgsf1fA2LhPxtP4XQ7m5eKkRIG1sOp8H teqreWjRUTxAbk7/UlXLFKwt93zY3ZM7UD6vBw3n7SCaOgYCbztMV+z1sWKnOR+PYUNy 8NlNllzvZU/BUgyPyp7pUKLz0UIyy44bSd8Tq8pkAm49wzqzJRAYr7sHjurFfql5CJr9 +2u0ZuY2MTmbm+VLGYp4ROcnMeFBSz4fJQYG8A9eDXki4dtN438PlAKw8ieVAN8MLcMd 5/YqhKTec5MoZ/aQ7Al2hLtI6qSiVzLUxjDFKUVHpzW1eU3srBdT6SwmQwGhVCkHMt0N TuHA== 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=KaxflDJEsZTN8SnbCx/QP4rFyVpc8WhAOsWzqE1f5mQ=; b=kRUM9+2jMkEwSz0cBKBAnOQfJCOmzbT9WlHulz8nunkfv2++t9xClPUfDwX29wwZuW mQt8y9UUlGqWqs0MIRJdaXcqCYXBHvoxwUoM/zkzRprFX9nNW59RXcrVCXELX1DzPI2F Gvu7gQ0mVfLPPb4mNB5ncZZiUrH3o5Uh8vpaFB9TFgiH7nxvOL8EGTXghwdL0jV48cLD UvYQsKYqOHuuBwIAL9PDwIvsXeO/UpkztdwOrddUJce4aLYFQXGfbCSxxouSNxTbThl3 MBqOimCXhKYYgpEZJxiURF5Ff5h8GC5JWRzcA6D2MpndaqiR8dzLGsyK5DSopUH/rmOI yp4A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=oHF4kZfp; 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 12-20020a17090600cc00b007da4fe085desi194271eji.157.2023.01.23.15.03.53; Mon, 23 Jan 2023 15:04:16 -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=oHF4kZfp; 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 S232021AbjAWXAM (ORCPT + 99 others); Mon, 23 Jan 2023 18:00:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232049AbjAWXAF (ORCPT ); Mon, 23 Jan 2023 18:00:05 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2053.outbound.protection.outlook.com [40.107.92.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D931039B81; Mon, 23 Jan 2023 14:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UUdv1F5EAtXwksWJ+DqVVMx2oVsexXlcS1I8BXsTmG0yAOearqDhNuUGqubnDxd/28sHV0+S5HQ7i+1GeixWXrQWc4ujBfw3R2jxIYf3onmZbcKmqfrelkCS0L28bw5hjSciXOsTuBpCDxfaxpunZtc+EG/Eum8EUaPPVyo35Nes2LYEDcmNhu/SKGRnu2vZpcIKm0+ISig+qQy6neRLUJp8ICjPz9Vrz0negE/W7nfnn9h1WuAv0rCJQcY8SLJFOH21V72ChXqrJU4EyX9c/Dn1aVpzMKW9s8tyJCGgDBDhBpsj5+cCw2OqUO/cQji4Xzu5Iwofcy7K0gKbPm+MnQ== 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=KaxflDJEsZTN8SnbCx/QP4rFyVpc8WhAOsWzqE1f5mQ=; b=Xu0CGucX/jqhRZOC8dDHSGXflaasF84yyP4YGwX9D2TA/2m0EwT5iUoX8fL07Ss3Dn7Rx5fwZqGGhDjIp2I3cROnD5ci3ueDT0bnPxtGncz/Ls5X7N4RrKsa5i2OPbz1oytqmtyQzWo0A+3reejgv6wh5Uq3bqp6lpJQeWmtNoqJDv+cpDIi/hV0Mz/SlgBKc3ahxJo8G+CjTyhiRMFs7Bsi2fwQuZFwtZrk7soR+DWKhcywQsv4R+B03BTT+dxaURJ5soqNMQw8/r+wP+bXvhDVxueza4hVw3XF83oQGq75f490H5Q0l4JWGJX3gBAda1s6TTwfBbwQbaCd2RX+9Q== 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=KaxflDJEsZTN8SnbCx/QP4rFyVpc8WhAOsWzqE1f5mQ=; b=oHF4kZfpt4DNojFjmadTCS2c5Rt1LXTCNuapyra9dtaW0rcaEwm1YpfmRQ/itIVmFLuiNfqhfrpQa7YYyNewvgn2zjTK83qP7EKJndit+3ismug28KR0eXEZHpsH+UnnyVmscmS1QtnjYIxJ45GU5femFbCGorDG3saiNsknoHA= Received: from BN9PR03CA0972.namprd03.prod.outlook.com (2603:10b6:408:109::17) by SN7PR12MB6765.namprd12.prod.outlook.com (2603:10b6:806:26b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:58:39 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::ec) by BN9PR03CA0972.outlook.office365.com (2603:10b6:408:109::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:58:39 +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 BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:58:38 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:58:37 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 7/8] x86/cpu: Support AMD Automatic IBRS Date: Mon, 23 Jan 2023 16:56:59 -0600 Message-ID: <20230123225700.2224063-8-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT030:EE_|SN7PR12MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: 63fd96f7-065c-4500-3bd8-08dafd955db1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b8IsVH3J/2c31gzV2Spa1YnjvGFJ+XCeoWQEQXOSXpKDJOkBJc+pcAHR2jy1Vo7WbRgXqNR237ix9GL5LjzwoXmvwDc1ttLL+4EU/2EknLdfJ84g3oUN8IqrGGh9W7FnWxRyKJzs4EdaQsiFTH7ZKPF7Am/zQ6aVT94Pny1/4PpwZOTjaCkMDmsGN3e+JG8Kr8fmnvdP808hUTez/LctpuB6sRE7/CNsRMhYg5PzStdfWysH6cPs1HacXcu7rPEQzFA5l0qcUf2ZfHCfK7axffSEndQM7FyknVQWH7/sfIpImZmGprNb/rvFj8rgVZOPnwV0sBqVrGNAdwJSjkF++Jt0o9P+q/+JuLwFMNRT1Le9Y0xG+h0IwmRRtn0vi+rS4wVTqs+kZIdulP1pjNRbzzIH4UCub5tHBQ7oRWC1VARkKNT2hRgVvpWKFBrC5L3Rq15ivW5S/LkrYK4wHCnSm6KNV+JH9O9XOGGw87yUGz+HjI9FomMFg2+lcM3HDCjRp8FxGChPV4lBG6RAWglheeNdD2yZetOm0mbOC9aGip37LBhCb7RrCwKcKd58aiC+3K/91XR8rwtZrdOThlwiY89A8DNexqT3kq8rXbCj2ylTgtzeIZq5CtdyMwg0d7wayxFmre+Vvftdg9kFRr+zHN3pP0jzoIAQ6rT8GPCTL8CqpFik9YbSfyZ1qaLYKD0cXyXYi6wvzygOeBxTDWZPBP/FTm5nI7QWvKnyg7N10+c= 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)(396003)(39860400002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(83380400001)(82310400005)(81166007)(82740400003)(7416002)(41300700001)(86362001)(356005)(44832011)(2906002)(8936002)(5660300002)(4326008)(40460700003)(40480700001)(16526019)(8676002)(6916009)(26005)(186003)(6666004)(47076005)(336012)(426003)(70206006)(316002)(70586007)(2616005)(54906003)(1076003)(478600001)(7696005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:58:38.9728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63fd96f7-065c-4500-3bd8-08dafd955db1 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: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6765 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?1755856299874338888?= X-GMAIL-MSGID: =?utf-8?q?1755856299874338888?= 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 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 Acked-by: Dave Hansen --- Documentation/admin-guide/hw-vuln/spectre.rst | 6 +++--- .../admin-guide/kernel-parameters.txt | 6 +++--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 20 +++++++++++-------- arch/x86/kernel/cpu/common.c | 19 ++++++++++-------- 6 files changed, 32 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 6cfa6e3996cf..839fa0fefb58 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5729,9 +5729,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/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 6dcc3c3d0c8d..7b319acda31a 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -432,6 +432,7 @@ #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */ #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */ #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* "" Null Selector Clears Base */ +#define X86_FEATURE_AUTOIBRS (20*32+ 8) /* "" Automatic IBRS */ #define X86_FEATURE_NO_SMM_CTL_MSR (20*32+ 9) /* "" SMM_CTL MSR is not present */ /* diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 47878f048aa6..b78336599247 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 4a0add86c182..cf81848b72f4 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1238,9 +1238,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", }; @@ -1309,7 +1309,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; } @@ -1495,8 +1495,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; - update_spec_ctrl(x86_spec_ctrl_base); + if (boot_cpu_has(X86_FEATURE_AUTOIBRS)) { + msr_set_bit(MSR_EFER, _EFER_AUTOIBRS); + } else { + x86_spec_ctrl_base |= SPEC_CTRL_IBRS; + update_spec_ctrl(x86_spec_ctrl_base); + } } switch (mode) { @@ -1580,8 +1584,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 162352d42ce0..8ce67a8a61a6 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1229,8 +1229,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), @@ -1341,8 +1341,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)) { @@ -1404,11 +1412,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 Jan 23 22:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 47460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1857667wrn; Mon, 23 Jan 2023 15:03:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvTTlFuO9HvGobEfhX3geX1SCEYlJjgXGlJSx7eD8Q6Cu9zWAN4z2g/zWLYfAmx2P/1zRhw X-Received: by 2002:a17:902:b60e:b0:192:8b0e:98e1 with SMTP id b14-20020a170902b60e00b001928b0e98e1mr24147109pls.54.1674515035913; Mon, 23 Jan 2023 15:03:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674515035; cv=pass; d=google.com; s=arc-20160816; b=cX3TvgN0pPkaLf01Na8ozN+fzo4arN+BDXECUKvO57E4gDvT1Z98kMnd2x8tJUYjjb JkKtxSUUuMUU89n8S0ST0HyX8ircRQDhDA0FsW3SqklLZjZGALaa0j7meUSnoEbCeER2 KXxgXT1mCzzVCQJH4dfkX5ow1GYPFb1ocMaRcxkGdLJSQnBQ/nNcEZd4TgApckX00LPN FdfE0gu6YPqYhLTyXjes+xMQIy4tBlVWfBj9uVifCJC3sForkoCdFXQCKbKTuwnOSHZh o/+CwO30tGDuUtSrBc08AjMckahueBbYzEtVnk5gH4xdUQ+h11GhNAamiwhvkcUBz4RU IAQA== 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=RPP217NhloKDoLSAeUYTREqWvKmuIsqoh8yDbZ4jU3I=; b=C92HEdoqz925o+4UnxqlTR4/guKXGEu9Pm0W1mmZNmYW45WE2wClexsqxlYHydRJxs G8Z2xbcFHOcnzONQZZO0vW0QfCOqs6bwYwTijeJ4KN1AhktEpf0qoDhSYlWFUDpcLcO7 IHCgB7JLZurkXiHcsNbcHap4DRNPR9zsjAVMGQEKi/cMBb+ktcvgEVlErmxDPZvf/fRZ MJ0DYgMX5r2tBzk3QEHIe4RpnBjWKBIwIZ3saBtkPHhw5cee+Hsw8XnoMIlxYaxjxVWO u1YdboCKU0WGP6S8G6xntut8rHc0gdURmoqOfDrAp/zXlD1JJkfqcUHnQfms6qZ1MREu PlBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=sSZfaoIH; 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 t12-20020a170902e84c00b001948440d0besi742684plg.130.2023.01.23.15.03.43; Mon, 23 Jan 2023 15:03:55 -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=sSZfaoIH; 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 S232107AbjAWXAJ (ORCPT + 99 others); Mon, 23 Jan 2023 18:00:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231965AbjAWXAF (ORCPT ); Mon, 23 Jan 2023 18:00:05 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2052.outbound.protection.outlook.com [40.107.223.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A897939B89; Mon, 23 Jan 2023 14:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDj1HHNS5kOrmbDS+OVRT4mu5FY6TPmI+6DPjKgfZvhu2UyUiVolCFAUdOtI61Ma/Bv6lZ7wMx5Zeb6grRJUbpU/LaWdDGJcrNRG57gULhaW3LXLqAR6iA8kmh+FFkXlBI3DoWmIBf0z/yfB+dI1mGes/8ZoMNKEzrhrqZkle/0qnBFhaHuZG67sGYK0dm/N40Wro5ypHoyBRUG04q+ohWGcJpyDQR50INfjsk125kG3wDJHpvxbuw6IIVd6i5/PpF/9HFMRgXorJiPiQilRoKGJq9QE5pGspj3bM1DS8fwZntBzC4himqBfSYQAOz717U7ddsJIMCVDVkoxY3T0fA== 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=RPP217NhloKDoLSAeUYTREqWvKmuIsqoh8yDbZ4jU3I=; b=kzfinTU1Vnmh1MdJgJz+HyL/OSSpFisWdDCDRFtYk8ESj4VQ7BqJRoQrlGzootAJNnXG0n6CPddmvoc2EiGA4IKh4khHRV7oNdcFvKlG4Gin4xC3hE7D++7Ndmsu/pm/uYJ1cdp5buBjosezCw4+9q0GZ1WxqC5lrAABEpIzZRS7e/BJ+rLil2gqbxetb3gHVUj1OO9L/MRP9Yqz12KAuON2gk9ZzuWzOyEb4XKGaRhKxswviYwdxU16dmrO9YKGGGiRyCX+2nu4Utti8qfGU/QIVppbLc2VRsZ2hIGYPrqwOnjAS1Mg93282bTEP9NxnVe/nQwajzeh1rpkN5YFWw== 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=RPP217NhloKDoLSAeUYTREqWvKmuIsqoh8yDbZ4jU3I=; b=sSZfaoIHIcSxDrrFMgVHcVazgREtsiCPPNYnl6taRszRx1cEKrcicc7d0r/ArhUkoy0CmOUnyR1+Co7JAl2TET/Re5znqpD+ued6zGvBdupWNzwWxDiw6YVddW3lgoL6zYOBmETaQh3EMLc67iCeiDMpljfE4nwU0tUvN1HRit4= Received: from BN9P222CA0026.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::31) by SA1PR12MB7038.namprd12.prod.outlook.com (2603:10b6:806:24d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Mon, 23 Jan 2023 22:58:50 +0000 Received: from BN8NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::be) by BN9P222CA0026.outlook.office365.com (2603:10b6:408:10c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Mon, 23 Jan 2023 22:58:50 +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 BN8NAM11FT078.mail.protection.outlook.com (10.13.176.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Mon, 23 Jan 2023 22:58:50 +0000 Received: from fritz.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 23 Jan 2023 16:58:49 -0600 From: Kim Phillips To: CC: Kim Phillips , Borislav Petkov , "Boris Ostrovsky" , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Tom Lendacky , "Alexey Kardashevskiy" , , , Subject: [PATCH v8 8/8] x86/cpu, kvm: Propagate the AMD Automatic IBRS feature to the guest Date: Mon, 23 Jan 2023 16:57:00 -0600 Message-ID: <20230123225700.2224063-9-kim.phillips@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123225700.2224063-1-kim.phillips@amd.com> References: <20230123225700.2224063-1-kim.phillips@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT078:EE_|SA1PR12MB7038:EE_ X-MS-Office365-Filtering-Correlation-Id: 21fd28f6-104e-409b-0785-08dafd956498 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qHbdLWIsWQ3644MFjExlADefMb2+oVsK7NM+ygu+StdvUxQtcnErJPy1ycTHW4xayffOjdYUHSCJrZMx7yxjsTERQs7gzgTC3/S5kUfeJzjkahCNgEjapMzic5AZ1/Vu+hc4rQhRfTq3B7KTEtH7XFlBE0ITX2H8aE/sPCtfbUhrJ8CVzmGrScJoaW1Mu97o+wIHCQu1boE67s9fHqKhwutNUTmqQWXWRF6wTM4UXQo6zaqolwtpxENIf/t/rEikXGR61X3LWeElZ+hB89JmVv0yqVbtYM62lwOh45rLpZpAlD2YIQHZQ09vDBaAXD4c2traOLbHbJn7Gks7ZVA587zrSxArIVccx+/ORa6HO+hw4b/IjI83P0ZKld3eQqz0VwVa6jNFcQa+5HgSP2Za+QXElezzTcguyHEsA1w7fqgyJwoNdMjCihHlEof/8oPJF/61UoVhGqRofI5W0f8SRO3+4ErxZOOQgpR3JUZL+dKLt6ilHZ6doBjRz0q14PXeUFb3uO2OGCs4gjPfeBbdQb+frt0vthiHT0YK3tIIy+lsSwL6Pd3Qo/rjXZEeW7MTyAfZHg8gexPSfQhJOivuIdIC4ZB3a4TRKrB1mrfRQnhXbKMtWSyxHquFNWOJBDnrXA5C7gFHk+YqGpmaC3II/ftDaepAzaNn/JXomVZFcUG8TS3wA+bZlufag+wxnN7yLy+XjOhPMmHQsi3BHGGWNhrm7Um2K5lsi1zNG/fRkDU= 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)(346002)(39860400002)(136003)(396003)(451199015)(36840700001)(46966006)(40470700004)(36756003)(86362001)(81166007)(2906002)(5660300002)(356005)(82310400005)(82740400003)(83380400001)(8936002)(7416002)(4326008)(44832011)(41300700001)(36860700001)(478600001)(7696005)(6916009)(16526019)(8676002)(186003)(40460700003)(40480700001)(26005)(2616005)(70586007)(316002)(70206006)(336012)(6666004)(54906003)(1076003)(47076005)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2023 22:58:50.5517 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21fd28f6-104e-409b-0785-08dafd956498 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: BN8NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7038 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?1755856278080106344?= X-GMAIL-MSGID: =?utf-8?q?1755856278080106344?= 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/svm/svm.c | 3 +++ arch/x86/kvm/x86.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 9ba75ad9d976..293ef07b34c3 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -743,7 +743,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_mask(CPUID_8000_0021_EAX, F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | - F(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */ + F(NULL_SEL_CLR_BASE) | F(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/svm/svm.c b/arch/x86/kvm/svm/svm.c index 9a194aa1a75a..60c7c880266b 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4969,6 +4969,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 da4bbd043a7b..8dd0cb230ef5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1685,6 +1685,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;