| 267 | } |
| 268 | |
| 269 | static int print_sev(void) |
| 270 | { |
| 271 | int error = -1; |
| 272 | #ifndef __DARWIN__ |
| 273 | int ncpus = get_number_of_cpus(); |
| 274 | int i = 0; |
| 275 | bool sev_supported, sev_snp_supported; |
| 276 | unsigned int max_guest, min_asid; |
| 277 | |
| 278 | printf("\n============= Dumping AMD SEV status =============\n"); |
| 279 | |
| 280 | if (ncpus < 1) { |
| 281 | perror("Failed to get number of CPUs"); |
| 282 | error = -1; |
| 283 | } else { |
| 284 | /* |
| 285 | * The following use CPUID, so should be the same for each core |
| 286 | * in the scope of processor. |
| 287 | */ |
| 288 | sev_supported = is_sev_supported(); |
| 289 | sev_snp_supported = is_sev_snp_supported(); |
| 290 | if (sev_supported) { |
| 291 | max_guest = get_sev_max_guest_num(); |
| 292 | min_asid = get_sev_min_asid(); |
| 293 | } |
| 294 | |
| 295 | for (i = 0; i < ncpus ; i++) { |
| 296 | printf("------------- CPU %d ----------------\n", i); |
| 297 | printf("SEV supported : %s\n", |
| 298 | sev_supported ? "YES" : "NO"); |
| 299 | if (sev_supported) { |
| 300 | printf("Max SEV encrypted guests : %u\n", |
| 301 | max_guest); |
| 302 | printf("Min SEV ASID : %u\n", |
| 303 | min_asid); |
| 304 | } |
| 305 | printf("SEV-ES supported : %s\n", |
| 306 | is_sev_es_supported() ? "YES" : "NO"); |
| 307 | printf("SEV-SNP supported : %s\n", |
| 308 | sev_snp_supported ? "YES" : "NO"); |
| 309 | if (sev_snp_supported) |
| 310 | printf("SEV-SNP enabled : %s\n", |
| 311 | is_sev_snp_enabled(i) ? "YES" : "NO"); |
| 312 | } |
| 313 | error = 0; |
| 314 | } |
| 315 | printf("===================================================="); |
| 316 | #endif |
| 317 | return error; |
| 318 | } |
| 319 | |
| 320 | static void get_cpu_brand_string(char *cpu_string) |
| 321 | { |
no test coverage detected