Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4950469pxu; Thu, 10 Dec 2020 09:12:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXYhL6h3KMjqacvQjwDIdzO64YR36fVao+juQYb248DjyaNd/s0kFYh4co/30p+Gj54izB X-Received: by 2002:a17:906:710b:: with SMTP id x11mr7619487ejj.433.1607620378084; Thu, 10 Dec 2020 09:12:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1607620378; cv=pass; d=google.com; s=arc-20160816; b=FbrNclu8mdHyWl0hhSqEdq/BRidi81nxiaTpZNCb/TFDX+VQbkjkjmAFZSoFjJ0vPK /MYDVn4dZ1ZR1TjO06uCebgX39ZlWFay1wsM8NwI0o2oKlUu92b+wnqf4480hS6ApWXO jtNNKHB3ahnlyE+pq96zfydUJ2ffK+asQEX5Dit9MxHIbaN+ggPpEGaT+ZKa8GmchDdw BsakL2tNACl7ita2BdWQGJuaITZVHJbudfju1o15k6RwZV6fC0Y/e3na0OoJElB+Wu7O V2o8cYT+JOUWQVKIccIahzXJZAV2Nl6uL1Ogpuljrdq6TsDg6YNsefw7q8ss6AeTWtLM W0Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jIDSQVwBhceTkXrKGCJrfTL5U9e5STc9iqm9UuU3694=; b=hWfBxfPVaCfVcU4jZYiY9LuD3sEM1x7YluYnGATdXKq1yGPNQUgjFIpDrfkq0jNTkO rqsjO+wYYC6eJmG80iVp6Iv/VW1wgAZ6LrOeO+zsQwpGD+q/PMtQC4wFsDlS0Wp78isa 4y/dSwp4SkA2X2UpHDPwapriBADrNpLDIbUDF4dKabYV2GZj7lPN2tNOquQuLMXjo905 UldD9Dc0Nxbwv765ya0B/JwZWaS3ySuPdn3j7VqSI60CAYtgHENPwE7c7ZNYrY7nR9ui WqzUZzlPgnM/1Wwuwlclb8tMsgWqn1A8GBi/oguPLpobQFiO1p9QYTzp3W8gtQKN+pm1 UQtQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=NdS51naC; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si3098211edf.160.2020.12.10.09.12.34; Thu, 10 Dec 2020 09:12:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=NdS51naC; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392497AbgLJRJa (ORCPT + 99 others); Thu, 10 Dec 2020 12:09:30 -0500 Received: from mail-dm6nam12on2055.outbound.protection.outlook.com ([40.107.243.55]:46528 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730503AbgLJRJK (ORCPT ); Thu, 10 Dec 2020 12:09:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lLAJzhBDKxzJdFcSf89HT1YTauyoEQ/4TziLaGANXL8Y/KWjh+/VR+qiKKvWWJTj7yOGKyaJrREb4KmXscXrc+QG2m4mfsYTPXzPZDllSr1pAu54ghjPFY79XlL4QEcn0ETyFqmEJxY+MwjlAjr3+enW8odIVTq4ceBIL3JRn/fpMdI9qrSUMJ58ilYJEpP4qbZeB1n0ZiDJpxETofVjKRpY+IpRHiGsZdMyL+k02tlzMl8mvL98erg+t/+gNm4ZXWmiuljgvRWdHMKzf+o2A1KuOMPq4V72O98KTguO8CJjSa/iiba+kSULCCtKd4d3eQiCRHRPniMFQOlQyhYzSA== 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-SenderADCheck; bh=jIDSQVwBhceTkXrKGCJrfTL5U9e5STc9iqm9UuU3694=; b=jWouVlkxPGesp+cgKzaZXoFSsmGuvve45KZw+wtsGiWj8AJbv5KKg+pPqFq0YYYZDaRb4uXhy/LqBWtjOuwA/lUFtTNTDNEoXhPpVcEZ7GxotVY2uqddsJdfkLKuZ8lzSL7fOcOM4xqJHlSJReVs5KlPVjzSy3nOfQfUMBEKJ6enKIXi72bxNsJzcf+4i0EmlJgZtp/AWRjeFenkvl+VHnjQJULL/9mMuImy6/q3GCIaDNu7WXhT9XxWyY9qQYoZTXDfyh9eUCHW1MT5JAqbgb6pxmGhfCkKbGyX/QfcoNMNlzG7abz8B4Nh1BvnTfp8bPE/xP9fQTQNxnE2Lc7VQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jIDSQVwBhceTkXrKGCJrfTL5U9e5STc9iqm9UuU3694=; b=NdS51naCgAUj3Gvu6z0BMHLHBDsNM366Fb5sA6CCt9jgssQSk6y8VVV2acrpf9Avcmr5eUlEhPP+eZGeOceZ8sEODN06awJubZ1Rm0hjpnKelKjCWNJcTSQfSwhoHDYQHPvvtJChKBjvNf8CRFULL+0FzZkscIFjC0BQTx+C3/E= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1493.namprd12.prod.outlook.com (2603:10b6:910:11::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Thu, 10 Dec 2020 17:07:43 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::a10a:295e:908d:550d]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::a10a:295e:908d:550d%8]) with mapi id 15.20.3632.021; Thu, 10 Dec 2020 17:07:43 +0000 From: Tom Lendacky To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: Paolo Bonzini , Jim Mattson , Joerg Roedel , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: [PATCH v5 01/34] x86/cpu: Add VM page flush MSR availablility as a CPUID feature Date: Thu, 10 Dec 2020 11:06:45 -0600 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CH2PR03CA0013.namprd03.prod.outlook.com (2603:10b6:610:59::23) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by CH2PR03CA0013.namprd03.prod.outlook.com (2603:10b6:610:59::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Thu, 10 Dec 2020 17:07:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f213ff22-85c6-4d90-4d6d-08d89d2e1bc9 X-MS-TrafficTypeDiagnostic: CY4PR12MB1493: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gMfvoe2AdnTKdr6tfMlnus88PrYJm1e0iKvqCte7+5TJStINuX6B61I75KMoSEg2tHZYbdoh5aDDQ2ruuJOzA9Uii2RkMCYRn9luKo8RMMshri0IqLd2zpHrcGDFUMwcPNbOu0rvAuiXbk4qm/rWo4vt21lGfUSatF+xMIA0ptIo8caPW3+OqALiUNxrKx1En0ShP0bV7IV0uYFcW9kFJ7sdtffHJ8uIKv1WYPD3P2dIHg2qc7FJXz8QN50EbhB5AFHaXO9+P3tC6XzhDzLA4HlIcI4QPvz9j2bnDl8yqjvKV++0jvd20wApQoo4KBocq4CbSfh8l0rfz9UPTRA/hKx6pIK9TeC3kt8/pzzkiQyO5zldaq7ttWrXGy3xN/PU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(376002)(346002)(5660300002)(66476007)(186003)(52116002)(8676002)(36756003)(8936002)(4326008)(86362001)(2906002)(66946007)(66556008)(26005)(508600001)(34490700003)(7416002)(2616005)(16526019)(54906003)(7696005)(956004)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam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ok24yVZYltMklvkHb6Zl0p9Vk4lzFH9ymuB8yLQ?= =?us-ascii?Q?v7N5ZaDithe9pTuIuCfSr+MyT6MWwSOqhbsZ9fqkutHfmPxbQ1PO09ay0oEg?= =?us-ascii?Q?TSJIWILxljReN1Mttsa/Ez+8vSE4lJaGQrknOznQgj/wYvD3LAOVyrO0KfyD?= =?us-ascii?Q?tHCE?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2020 17:07:43.2509 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: f213ff22-85c6-4d90-4d6d-08d89d2e1bc9 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: d8I5PNeM1OeCRnSKJ1wO2yXAnqPBNTc17PK+JtouS+g8+3rwNXppOM7Yba3JIyj2t3ENEj2TM0i6KRkzNEUFvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1493 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Lendacky On systems that do not have hardware enforced cache coherency between encrypted and unencrypted mappings of the same physical page, the hypervisor can use the VM page flush MSR (0xc001011e) to flush the cache contents of an SEV guest page. When a small number of pages are being flushed, this can be used in place of issuing a WBINVD across all CPUs. CPUID 0x8000001f_eax[2] is used to determine if the VM page flush MSR is available. Add a CPUID feature to indicate it is supported and define the MSR. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index dad350d42ecf..54df367b3180 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -237,6 +237,7 @@ #define X86_FEATURE_VMCALL ( 8*32+18) /* "" Hypervisor supports the VMCALL instruction */ #define X86_FEATURE_VMW_VMMCALL ( 8*32+19) /* "" VMware prefers VMMCALL hypercall instruction */ #define X86_FEATURE_SEV_ES ( 8*32+20) /* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_VM_PAGE_FLUSH ( 8*32+21) /* "" VM Page Flush MSR is supported */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/ diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 972a34d93505..abfc9b0fbd8d 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -470,6 +470,7 @@ #define MSR_AMD64_ICIBSEXTDCTL 0xc001103c #define MSR_AMD64_IBSOPDATA4 0xc001103d #define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */ +#define MSR_AMD64_VM_PAGE_FLUSH 0xc001011e #define MSR_AMD64_SEV_ES_GHCB 0xc0010130 #define MSR_AMD64_SEV 0xc0010131 #define MSR_AMD64_SEV_ENABLED_BIT 0 diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 866c9a9bcdee..236924930bf0 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -44,6 +44,7 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 }, { X86_FEATURE_SEV_ES, CPUID_EAX, 3, 0x8000001f, 0 }, { X86_FEATURE_SME_COHERENT, CPUID_EAX, 10, 0x8000001f, 0 }, + { X86_FEATURE_VM_PAGE_FLUSH, CPUID_EAX, 2, 0x8000001f, 0 }, { 0, 0, 0, 0, 0 } }; -- 2.28.0