1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * AMD SVM-SEV command line parsing support 4 * 5 * Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. 6 * 7 * Author: Michael Roth <michael.roth@amd.com> 8 */ 9 10 #include <linux/string.h> 11 #include <linux/printk.h> 12 #include <linux/cache.h> 13 #include <linux/cpufeature.h> 14 15 #include <asm/sev-common.h> 16 17 struct sev_config sev_cfg __read_mostly; 18 19 static int __init init_sev_config(char *str) 20 { 21 char *s; 22 23 while ((s = strsep(&str, ","))) { 24 if (!strcmp(s, "debug")) { 25 sev_cfg.debug = true; 26 continue; 27 } 28 29 if (!strcmp(s, "nosnp")) { 30 if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) { 31 setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); 32 cc_platform_clear(CC_ATTR_HOST_SEV_SNP); 33 continue; 34 } else { 35 goto warn; 36 } 37 } 38 39 warn: 40 pr_info("SEV command-line option '%s' was not recognized\n", s); 41 } 42 43 return 1; 44 } 45 __setup("sev=", init_sev_config); 46