Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arch/x86: mshyperv: Discover Confidential VMBus availability

Confidential VMBus requires enabling paravisor SynIC, and
the x86_64 guest has to inspect the Virtualization Stack (VS)
CPUID leaf to see if Confidential VMBus is available. If it is,
the guest shall enable the paravisor SynIC.

Read the relevant data from the VS CPUID leaf. Refactor the
code to avoid repeating CPUID and add flags to the struct
ms_hyperv_info. For ARM64, the flag for Confidential VMBus
is not set which provides the desired behaviour for now as
it is not available on ARM64 just yet. Once ARM64 CCA guests
are supported, this flag will be set unconditionally when
running such a guest.

Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Roman Kisel and committed by
Wei Liu
7c8b6c32 6802d8af

+17 -13
+15 -13
arch/x86/kernel/cpu/mshyperv.c
··· 440 440 441 441 static void __init ms_hyperv_init_platform(void) 442 442 { 443 - int hv_max_functions_eax; 443 + int hv_max_functions_eax, eax; 444 444 445 445 #ifdef CONFIG_PARAVIRT 446 446 pv_info.name = "Hyper-V"; ··· 477 477 hv_nested = true; 478 478 pr_info("Hyper-V: running on a nested hypervisor\n"); 479 479 } 480 + 481 + /* 482 + * There is no check against the max function for HYPERV_CPUID_VIRT_STACK_* CPUID 483 + * leaves as the hypervisor doesn't handle them. Even a nested root partition (L2 484 + * root) will not get them because the nested (L1) hypervisor filters them out. 485 + * These are handled through intercept processing by the Windows Hyper-V stack 486 + * or the paravisor. 487 + */ 488 + eax = cpuid_eax(HYPERV_CPUID_VIRT_STACK_PROPERTIES); 489 + ms_hyperv.confidential_vmbus_available = 490 + eax & HYPERV_VS_PROPERTIES_EAX_CONFIDENTIAL_VMBUS_AVAILABLE; 491 + ms_hyperv.msi_ext_dest_id = 492 + eax & HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE; 480 493 481 494 if (ms_hyperv.features & HV_ACCESS_FREQUENCY_MSRS && 482 495 ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { ··· 691 678 * pci-hyperv host bridge. 692 679 * 693 680 * Note: for a Hyper-V root partition, this will always return false. 694 - * The hypervisor doesn't expose these HYPERV_CPUID_VIRT_STACK_* cpuids by 695 - * default, they are implemented as intercepts by the Windows Hyper-V stack. 696 - * Even a nested root partition (L2 root) will not get them because the 697 - * nested (L1) hypervisor filters them out. 698 681 */ 699 682 static bool __init ms_hyperv_msi_ext_dest_id(void) 700 683 { 701 - u32 eax; 702 - 703 - eax = cpuid_eax(HYPERV_CPUID_VIRT_STACK_INTERFACE); 704 - if (eax != HYPERV_VS_INTERFACE_EAX_SIGNATURE) 705 - return false; 706 - 707 - eax = cpuid_eax(HYPERV_CPUID_VIRT_STACK_PROPERTIES); 708 - return eax & HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE; 684 + return ms_hyperv.msi_ext_dest_id; 709 685 } 710 686 711 687 #ifdef CONFIG_AMD_MEM_ENCRYPT
+2
include/asm-generic/mshyperv.h
··· 62 62 }; 63 63 }; 64 64 u64 shared_gpa_boundary; 65 + bool msi_ext_dest_id; 66 + bool confidential_vmbus_available; 65 67 }; 66 68 extern struct ms_hyperv_info ms_hyperv; 67 69 extern bool hv_nested;