sev.c (1ff3c89032a8f241502a0ba8a95fe0133707a061) | sev.c (0d7bf5e5b00a131cc02ecadbbf42563c0721aaeb) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Kernel-based Virtual Machine driver for Linux 4 * 5 * AMD SVM-SEV support 6 * 7 * Copyright 2010 Red Hat, Inc. and/or its affiliates. 8 */ --- 18 unchanged lines hidden (view full) --- 27 28#include "mmu.h" 29#include "x86.h" 30#include "svm.h" 31#include "svm_ops.h" 32#include "cpuid.h" 33#include "trace.h" 34 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Kernel-based Virtual Machine driver for Linux 4 * 5 * AMD SVM-SEV support 6 * 7 * Copyright 2010 Red Hat, Inc. and/or its affiliates. 8 */ --- 18 unchanged lines hidden (view full) --- 27 28#include "mmu.h" 29#include "x86.h" 30#include "svm.h" 31#include "svm_ops.h" 32#include "cpuid.h" 33#include "trace.h" 34 |
35#ifndef CONFIG_KVM_AMD_SEV 36/* 37 * When this config is not defined, SEV feature is not supported and APIs in 38 * this file are not used but this file still gets compiled into the KVM AMD 39 * module. 40 * 41 * We will not have MISC_CG_RES_SEV and MISC_CG_RES_SEV_ES entries in the enum 42 * misc_res_type {} defined in linux/misc_cgroup.h. 43 * 44 * Below macros allow compilation to succeed. 45 */ 46#define MISC_CG_RES_SEV MISC_CG_RES_TYPES 47#define MISC_CG_RES_SEV_ES MISC_CG_RES_TYPES 48#endif | 35#define GHCB_VERSION_MAX 1ULL 36#define GHCB_VERSION_MIN 1ULL |
49 | 37 |
50#ifdef CONFIG_KVM_AMD_SEV | |
51/* enable/disable SEV support */ 52static bool sev_enabled = true; 53module_param_named(sev, sev_enabled, bool, 0444); 54 55/* enable/disable SEV-ES support */ 56static bool sev_es_enabled = true; 57module_param_named(sev_es, sev_es_enabled, bool, 0444); 58 59/* enable/disable SEV-ES DebugSwap support */ 60static bool sev_es_debug_swap_enabled = false; 61module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444); | 38/* enable/disable SEV support */ 39static bool sev_enabled = true; 40module_param_named(sev, sev_enabled, bool, 0444); 41 42/* enable/disable SEV-ES support */ 43static bool sev_es_enabled = true; 44module_param_named(sev_es, sev_es_enabled, bool, 0444); 45 46/* enable/disable SEV-ES DebugSwap support */ 47static bool sev_es_debug_swap_enabled = false; 48module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444); |
62#else 63#define sev_enabled false 64#define sev_es_enabled false 65#define sev_es_debug_swap_enabled false 66#endif /* CONFIG_KVM_AMD_SEV */ | |
67 68static u8 sev_enc_bit; 69static DECLARE_RWSEM(sev_deactivate_lock); 70static DEFINE_MUTEX(sev_bitmap_lock); 71unsigned int max_sev_asid; 72static unsigned int min_sev_asid; 73static unsigned long sev_me_mask; 74static unsigned int nr_asids; --- 2114 unchanged lines hidden (view full) --- 2189 if (sev_enabled) 2190 kvm_cpu_cap_set(X86_FEATURE_SEV); 2191 if (sev_es_enabled) 2192 kvm_cpu_cap_set(X86_FEATURE_SEV_ES); 2193} 2194 2195void __init sev_hardware_setup(void) 2196{ | 49 50static u8 sev_enc_bit; 51static DECLARE_RWSEM(sev_deactivate_lock); 52static DEFINE_MUTEX(sev_bitmap_lock); 53unsigned int max_sev_asid; 54static unsigned int min_sev_asid; 55static unsigned long sev_me_mask; 56static unsigned int nr_asids; --- 2114 unchanged lines hidden (view full) --- 2171 if (sev_enabled) 2172 kvm_cpu_cap_set(X86_FEATURE_SEV); 2173 if (sev_es_enabled) 2174 kvm_cpu_cap_set(X86_FEATURE_SEV_ES); 2175} 2176 2177void __init sev_hardware_setup(void) 2178{ |
2197#ifdef CONFIG_KVM_AMD_SEV | |
2198 unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; 2199 bool sev_es_supported = false; 2200 bool sev_supported = false; 2201 2202 if (!sev_enabled || !npt_enabled || !nrips) 2203 goto out; 2204 2205 /* --- 83 unchanged lines hidden (view full) --- 2289 sev_es_supported ? "enabled" : "disabled", 2290 min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); 2291 2292 sev_enabled = sev_supported; 2293 sev_es_enabled = sev_es_supported; 2294 if (!sev_es_enabled || !cpu_feature_enabled(X86_FEATURE_DEBUG_SWAP) || 2295 !cpu_feature_enabled(X86_FEATURE_NO_NESTED_DATA_BP)) 2296 sev_es_debug_swap_enabled = false; | 2179 unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; 2180 bool sev_es_supported = false; 2181 bool sev_supported = false; 2182 2183 if (!sev_enabled || !npt_enabled || !nrips) 2184 goto out; 2185 2186 /* --- 83 unchanged lines hidden (view full) --- 2270 sev_es_supported ? "enabled" : "disabled", 2271 min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); 2272 2273 sev_enabled = sev_supported; 2274 sev_es_enabled = sev_es_supported; 2275 if (!sev_es_enabled || !cpu_feature_enabled(X86_FEATURE_DEBUG_SWAP) || 2276 !cpu_feature_enabled(X86_FEATURE_NO_NESTED_DATA_BP)) 2277 sev_es_debug_swap_enabled = false; |
2297#endif | |
2298} 2299 2300void sev_hardware_unsetup(void) 2301{ 2302 if (!sev_enabled) 2303 return; 2304 2305 /* No need to take sev_bitmap_lock, all VMs have been destroyed. */ --- 907 unchanged lines hidden --- | 2278} 2279 2280void sev_hardware_unsetup(void) 2281{ 2282 if (!sev_enabled) 2283 return; 2284 2285 /* No need to take sev_bitmap_lock, all VMs have been destroyed. */ --- 907 unchanged lines hidden --- |