Drivers: hv: vmbus: Restrict devices and configurations on 'isolated' guests
Subsystems (6)
v3 cover Drivers: hv: vmbus: Restrict devices and configurations on 'isolated' guests
Changes since v2 [1]:
- improve/add logging (Michael Kelley)
- rename 'hypercalls_features' to 'features_b' (Michael Kelley)
- move VMBus and NVSC version checks after 'for' loop (Michael Kelley)
- remove/inline helper functions (Michael Kelley)
- other minor changes (Michael Kelley)
Changes since v1 [2]:
- improve/add logging (Haiyang Zhang)
- move NVSC version check after version negotiation (Haiyang Zhang)
[1] https://lkml.kernel.org/r/[email protected]
[1] https://lkml.kernel.org/r/[email protected]
Andrea Parri (Microsoft) (4):
x86/hyperv: Load/save the Isolation Configuration leaf
Drivers: hv: vmbus: Restrict vmbus_devices on isolated guests
Drivers: hv: vmbus: Enforce 'VMBus version >= 5.2' on isolated guests
hv_netvsc: Restrict configurations on isolated guests
arch/x86/hyperv/hv_init.c | 15 ++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 15 ++++++++++++ arch/x86/kernel/cpu/mshyperv.c | 9 +++++++ drivers/hv/channel_mgmt.c | 38 ++++++++++++++++++++++++++++++ drivers/hv/connection.c | 7 ++++++ drivers/net/hyperv/netvsc.c | 18 ++++++++++++-- include/asm-generic/hyperv-tlfs.h | 1 + include/asm-generic/mshyperv.h | 5 ++++ include/linux/hyperv.h | 1 + 9 files changed, 107 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/4 x86/hyperv: Load/save the Isolation Configuration leaf
If bit 22 of Group B Features is set, the guest has access to the Isolation Configuration CPUID leaf. On x86, the first four bits of EAX in this leaf provide the isolation type of the partition; we entail three isolation types: 'SNP' (hardware-based isolation), 'VBS' (software-based isolation), and 'NONE' (no isolation).
--- arch/x86/hyperv/hv_init.c | 15 +++++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 15 +++++++++++++++ arch/x86/kernel/cpu/mshyperv.c | 9 +++++++++ include/asm-generic/hyperv-tlfs.h | 1 + include/asm-generic/mshyperv.h | 5 +++++ 5 files changed, 45 insertions(+)
arch/x86/hyperv/hv_init.c +15 -0
@@ -10,6 +10,7 @@#include <linux/acpi.h> #include <linux/efi.h> #include <linux/types.h> +#include <linux/bitfield.h> #include <asm/apic.h> #include <asm/desc.h> #include <asm/hypervisor.h>
@@ -528,3 +529,17 @@ bool hv_is_hibernation_supported(void)return acpi_sleep_state_supported (ACPI_STATE_S4 ); }EXPORT_SYMBOL_GPL (hv_is_hibernation_supported); + +enum hv_isolation_type hv_get_isolation_type (void ) +{ +if (!(ms_hyperv.features_b &HV_ISOLATION )) +return HV_ISOLATION_TYPE_NONE ; +return FIELD_GET (HV_ISOLATION_TYPE , ms_hyperv.isolation_config_b); +} +EXPORT_SYMBOL_GPL (hv_get_isolation_type); + +bool hv_is_isolation_supported (void ) +{ +return hv_get_isolation_type () !=HV_ISOLATION_TYPE_NONE ; +} +EXPORT_SYMBOL_GPL (hv_is_isolation_supported);
arch/x86/include/asm/hyperv-tlfs.h +15 -0
@@ -22,6 +22,7 @@#define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004#define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005#define HYPERV_CPUID_NESTED_FEATURES 0x4000000A +#define HYPERV_CPUID_ISOLATION_CONFIG 0x4000000C#define HYPERV_CPUID_VIRT_STACK_INTERFACE 0x40000081#define HYPERV_VS_INTERFACE_EAX_SIGNATURE 0x31235356/* "VS#1" */
@@ -122,6 +123,20 @@#define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18)#define HV_X64_NESTED_MSR_BITMAP BIT(19) +/* HYPERV_CPUID_ISOLATION_CONFIG.EAX bits. */ +#define HV_PARAVISOR_PRESENT BIT(0) + +/* HYPERV_CPUID_ISOLATION_CONFIG.EBX bits. */ +#define HV_ISOLATION_TYPE GENMASK(3, 0) +#define HV_SHARED_GPA_BOUNDARY_ACTIVE BIT(5) +#define HV_SHARED_GPA_BOUNDARY_BITS GENMASK(11, 6) + +enum hv_isolation_type { +HV_ISOLATION_TYPE_NONE =0 , +HV_ISOLATION_TYPE_VBS =1 , +HV_ISOLATION_TYPE_SNP =2 +}; +/* Hyper-V specific model specific registers (MSRs) */ /* MSR used to identify the guest OS. */
arch/x86/kernel/cpu/mshyperv.c +9 -0
@@ -225,6 +225,7 @@ static void __init ms_hyperv_init_platform(void)* Extract the features and hints */ ms_hyperv.features =cpuid_eax (HYPERV_CPUID_FEATURES ); + ms_hyperv.features_b =cpuid_ebx (HYPERV_CPUID_FEATURES ); ms_hyperv.misc_features =cpuid_edx (HYPERV_CPUID_FEATURES ); ms_hyperv.hints =cpuid_eax (HYPERV_CPUID_ENLIGHTMENT_INFO );
@@ -259,6 +260,14 @@ static void __init ms_hyperv_init_platform(void) x86_platform.calibrate_cpu = hv_get_tsc_khz; } +if (ms_hyperv.features_b &HV_ISOLATION ) { + ms_hyperv.isolation_config_a =cpuid_eax (HYPERV_CPUID_ISOLATION_CONFIG ); + ms_hyperv.isolation_config_b =cpuid_ebx (HYPERV_CPUID_ISOLATION_CONFIG ); + +pr_info ("Hyper-V: Isolation Config: Group A 0x%x, Group B 0x%x\n" , + ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); + } +if (ms_hyperv.hints &HV_X64_ENLIGHTENED_VMCS_RECOMMENDED ) { ms_hyperv.nested_features =cpuid_eax (HYPERV_CPUID_NESTED_FEATURES );
include/asm-generic/hyperv-tlfs.h +1 -0
@@ -89,6 +89,7 @@#define HV_ACCESS_STATS BIT(8)#define HV_DEBUGGING BIT(11)#define HV_CPU_POWER_MANAGEMENT BIT(12) +#define HV_ISOLATION BIT(22)/*
include/asm-generic/mshyperv.h +5 -0
@@ -27,11 +27,14 @@struct ms_hyperv_info {u32 features; +u32 features_b;u32 misc_features;u32 hints;u32 nested_features;u32 max_vp_index;u32 max_lp_index; +u32 isolation_config_a; +u32 isolation_config_b; };extern struct ms_hyperv_info ms_hyperv;
@@ -169,6 +172,8 @@ void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);void hyperv_report_panic_msg (phys_addr_t pa,size_t size);bool hv_is_hyperv_initialized (void );bool hv_is_hibernation_supported (void ); +enum hv_isolation_type hv_get_isolation_type (void ); +bool hv_is_isolation_supported (void );void hyperv_cleanup (void );#else /* CONFIG_HYPERV */ static inline bool hv_is_hyperv_initialized (void ) {return false; }
Signature · 1 line
2.25.1
RE: [PATCH v3 hyperv-next 1/4] x86/hyperv: Load/save the Isolation Configuration leaf
From: Andrea Parri (Microsoft) <[email protected]> Sent: Monday, February 1, 2021 6:48 AM
Quoted 153 lines
If bit 22 of Group B Features is set, the guest has access to the Isolation Configuration CPUID leaf. On x86, the first four bits of EAX in this leaf provide the isolation type of the partition; we entail three isolation types: 'SNP' (hardware-based isolation), 'VBS' (software-based isolation), and 'NONE' (no isolation).
Signed-off-by Andrea Parri (Microsoft) <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Arnd Bergmann <[email protected]>--- arch/x86/hyperv/hv_init.c | 15 +++++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 15 +++++++++++++++ arch/x86/kernel/cpu/mshyperv.c | 9 +++++++++ include/asm-generic/hyperv-tlfs.h | 1 + include/asm-generic/mshyperv.h | 5 +++++ 5 files changed, 45 insertions(+)arch/x86/hyperv/hv_init.c +15
-0@@ -10,6 +10,7 @@#include <linux/acpi.h> #include <linux/efi.h> #include <linux/types.h> +#include <linux/bitfield.h> #include <asm/apic.h> #include <asm/desc.h> #include <asm/hypervisor.h> @@ -528,3 +529,17 @@ bool hv_is_hibernation_supported(void)return acpi_sleep_state_supported (ACPI_STATE_S4 ); }EXPORT_SYMBOL_GPL (hv_is_hibernation_supported); + +enum hv_isolation_type hv_get_isolation_type (void ) +{ +if (!(ms_hyperv.features_b &HV_ISOLATION )) +return HV_ISOLATION_TYPE_NONE ; +return FIELD_GET (HV_ISOLATION_TYPE , ms_hyperv.isolation_config_b); +} +EXPORT_SYMBOL_GPL (hv_get_isolation_type); + +bool hv_is_isolation_supported (void ) +{ +return hv_get_isolation_type () !=HV_ISOLATION_TYPE_NONE ; +} +EXPORT_SYMBOL_GPL (hv_is_isolation_supported);arch/x86/include/asm/hyperv-tlfs.h +15
-0@@ -22,6 +22,7 @@#define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004#define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005#define HYPERV_CPUID_NESTED_FEATURES 0x4000000A +#define HYPERV_CPUID_ISOLATION_CONFIG 0x4000000C#define HYPERV_CPUID_VIRT_STACK_INTERFACE 0x40000081#define HYPERV_VS_INTERFACE_EAX_SIGNATURE 0x31235356/* "VS#1" */ @@ -122,6 +123,20 @@#define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18)#define HV_X64_NESTED_MSR_BITMAP BIT(19) +/* HYPERV_CPUID_ISOLATION_CONFIG.EAX bits. */ +#define HV_PARAVISOR_PRESENT BIT(0) + +/* HYPERV_CPUID_ISOLATION_CONFIG.EBX bits. */ +#define HV_ISOLATION_TYPE GENMASK(3, 0) +#define HV_SHARED_GPA_BOUNDARY_ACTIVE BIT(5) +#define HV_SHARED_GPA_BOUNDARY_BITS GENMASK(11, 6) + +enum hv_isolation_type { +HV_ISOLATION_TYPE_NONE =0 , +HV_ISOLATION_TYPE_VBS =1 , +HV_ISOLATION_TYPE_SNP =2 +}; +/* Hyper-V specific model specific registers (MSRs) */ /* MSR used to identify the guest OS. */ arch/x86/kernel/cpu/mshyperv.c +9
-0@@ -225,6 +225,7 @@ static void __init ms_hyperv_init_platform(void)* Extract the features and hints */ ms_hyperv.features =cpuid_eax (HYPERV_CPUID_FEATURES ); + ms_hyperv.features_b =cpuid_ebx (HYPERV_CPUID_FEATURES ); ms_hyperv.misc_features =cpuid_edx (HYPERV_CPUID_FEATURES ); ms_hyperv.hints =cpuid_eax (HYPERV_CPUID_ENLIGHTMENT_INFO );@@ -259,6 +260,14 @@ static void __init ms_hyperv_init_platform(void) x86_platform.calibrate_cpu = hv_get_tsc_khz; } +if (ms_hyperv.features_b &HV_ISOLATION ) { + ms_hyperv.isolation_config_a =cpuid_eax (HYPERV_CPUID_ISOLATION_CONFIG ); + ms_hyperv.isolation_config_b =cpuid_ebx (HYPERV_CPUID_ISOLATION_CONFIG ); + +pr_info ("Hyper-V: Isolation Config: Group A 0x%x, Group B 0x%x\n" , + ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); + } +if (ms_hyperv.hints &HV_X64_ENLIGHTENED_VMCS_RECOMMENDED ) { ms_hyperv.nested_features =cpuid_eax (HYPERV_CPUID_NESTED_FEATURES );include/asm-generic/hyperv-tlfs.h +1
-0@@ -89,6 +89,7 @@#define HV_ACCESS_STATS BIT(8)#define HV_DEBUGGING BIT(11)#define HV_CPU_POWER_MANAGEMENT BIT(12) +#define HV_ISOLATION BIT(22)/* include/asm-generic/mshyperv.h +5
-0@@ -27,11 +27,14 @@struct ms_hyperv_info {u32 features; +u32 features_b;u32 misc_features;u32 hints;u32 nested_features;u32 max_vp_index;u32 max_lp_index; +u32 isolation_config_a; +u32 isolation_config_b; };extern struct ms_hyperv_info ms_hyperv;@@ -169,6 +172,8 @@ void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);void hyperv_report_panic_msg (phys_addr_t pa,size_t size);bool hv_is_hyperv_initialized (void );bool hv_is_hibernation_supported (void ); +enum hv_isolation_type hv_get_isolation_type (void ); +bool hv_is_isolation_supported (void );void hyperv_cleanup (void );#else /* CONFIG_HYPERV */
Quoted 3 lines
static inline bool
hv_is_hyperv_initialized(void){ return false; }
--
2.25.1
PATCH v3 2/4 Drivers: hv: vmbus: Restrict vmbus_devices on isolated guests
In reply to Andrea Parri (Microsoft)Only the VSCs or ICs that have been hardened and that are critical for the successful adoption of Confidential VMs should be allowed if the guest is running isolated. This change reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.
--- drivers/hv/channel_mgmt.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/hyperv.h | 1 + 2 files changed, 39 insertions(+)
drivers/hv/channel_mgmt.c +38 -0
@@ -31,101 +31,118 @@ const struct vmbus_device vmbus_devs[] = { { .dev_type = HV_IDE,HV_IDE_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* SCSI */ { .dev_type = HV_SCSI,HV_SCSI_GUID , .perf_device = true, + .allowed_in_isolated = true, }, /* Fibre Channel */ { .dev_type = HV_FC,HV_SYNTHFC_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* Synthetic NIC */ { .dev_type = HV_NIC,HV_NIC_GUID , .perf_device = true, + .allowed_in_isolated = true, }, /* Network Direct */ { .dev_type = HV_ND,HV_ND_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* PCIE */ { .dev_type = HV_PCIE,HV_PCIE_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic Frame Buffer */ { .dev_type = HV_FB,HV_SYNTHVID_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic Keyboard */ { .dev_type = HV_KBD,HV_KBD_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic MOUSE */ { .dev_type = HV_MOUSE,HV_MOUSE_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* KVP */ { .dev_type = HV_KVP,HV_KVP_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Time Synch */ { .dev_type = HV_TS,HV_TS_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* Heartbeat */ { .dev_type = HV_HB,HV_HEART_BEAT_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* Shutdown */ { .dev_type = HV_SHUTDOWN,HV_SHUTDOWN_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* File copy */ { .dev_type = HV_FCOPY,HV_FCOPY_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Backup */ { .dev_type = HV_BACKUP,HV_VSS_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Dynamic Memory */ { .dev_type = HV_DM,HV_DM_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Unknown GUID */ { .dev_type = HV_UNKNOWN, .perf_device = false, + .allowed_in_isolated = false, }, };
@@ -903,6 +920,20 @@ find_primary_channel_by_offer(const struct vmbus_channel_offer_channel *offer)return channel; } +static bool vmbus_is_valid_device (const guid_t *guid) +{ +u16 i; + +if (!hv_is_isolation_supported ()) +return true; + +for (i =0 ; i <ARRAY_SIZE (vmbus_devs); i++) { +if (guid_equal (guid, &vmbus_devs[i].guid)) +return vmbus_devs[i].allowed_in_isolated; + } +return false; +} +/* * vmbus_onoffer - Handler for channel offers from vmbus in parent partition. *
@@ -917,6 +948,13 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)trace_vmbus_onoffer (offer); +if (!vmbus_is_valid_device (&offer->offer.if_type)) { +pr_err_ratelimited ("Invalid offer %d from the host supporting isolation\n" , + offer->child_relid); +atomic_dec (&vmbus_connection.offer_in_progress); +return ; + } + oldchannel =find_primary_channel_by_offer (offer);if (oldchannel !=NULL ) {
include/linux/hyperv.h +1 -0
@@ -789,6 +789,7 @@ struct vmbus_device {u16 dev_type;guid_t guid;bool perf_device; +bool allowed_in_isolated; };#define VMBUS_DEFAULT_MAX_PKT_SIZE 4096
Signature · 1 line
2.25.1
RE: [PATCH v3 hyperv-next 2/4] Drivers: hv: vmbus: Restrict vmbus_devices on isolated guests
From: Andrea Parri (Microsoft) <[email protected]> Sent: Monday, February 1, 2021 6:48 AM
Quoted 186 lines
Only the VSCs or ICs that have been hardened and that are critical for the successful adoption of Confidential VMs should be allowed if the guest is running isolated. This change reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.
Signed-off-by Andrea Parri (Microsoft) <[email protected]>--- drivers/hv/channel_mgmt.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/hyperv.h | 1 + 2 files changed, 39 insertions(+)drivers/hv/channel_mgmt.c +31
-0@@ -31,101 +31,118 @@ const struct vmbus_device vmbus_devs[] = { { .dev_type = HV_IDE,HV_IDE_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* SCSI */ { .dev_type = HV_SCSI,HV_SCSI_GUID , .perf_device = true, + .allowed_in_isolated = true, }, /* Fibre Channel */ { .dev_type = HV_FC,HV_SYNTHFC_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* Synthetic NIC */ { .dev_type = HV_NIC,HV_NIC_GUID , .perf_device = true, + .allowed_in_isolated = true, }, /* Network Direct */ { .dev_type = HV_ND,HV_ND_GUID , .perf_device = true, + .allowed_in_isolated = false, }, /* PCIE */ { .dev_type = HV_PCIE,HV_PCIE_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic Frame Buffer */ { .dev_type = HV_FB,HV_SYNTHVID_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic Keyboard */ { .dev_type = HV_KBD,HV_KBD_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Synthetic MOUSE */ { .dev_type = HV_MOUSE,HV_MOUSE_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* KVP */ { .dev_type = HV_KVP,HV_KVP_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Time Synch */ { .dev_type = HV_TS,HV_TS_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* Heartbeat */ { .dev_type = HV_HB,HV_HEART_BEAT_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* Shutdown */ { .dev_type = HV_SHUTDOWN,HV_SHUTDOWN_GUID , .perf_device = false, + .allowed_in_isolated = true, }, /* File copy */ { .dev_type = HV_FCOPY,HV_FCOPY_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Backup */ { .dev_type = HV_BACKUP,HV_VSS_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Dynamic Memory */ { .dev_type = HV_DM,HV_DM_GUID , .perf_device = false, + .allowed_in_isolated = false, }, /* Unknown GUID */ { .dev_type = HV_UNKNOWN, .perf_device = false, + .allowed_in_isolated = false, }, };@@ -903,6 +920,20 @@ find_primary_channel_by_offer(const struct vmbus_channel_offer_channel *offer)return channel; } +static bool vmbus_is_valid_device (const guid_t *guid) +{ +u16 i; + +if (!hv_is_isolation_supported ()) +return true; + +for (i =0 ; i <ARRAY_SIZE (vmbus_devs); i++) { +if (guid_equal (guid, &vmbus_devs[i].guid)) +return vmbus_devs[i].allowed_in_isolated; + } +return false; +} +/* * vmbus_onoffer - Handler for channel offers from vmbus in parent partition. *
drivers/hv/channel_mgmt.c +7
-0@@ -917,6 +948,13 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)trace_vmbus_onoffer (offer ); +if (!vmbus_is_valid_device (&offer->offer.if_type)) { +pr_err_ratelimited ("Invalid offer %d from the host supporting isolation\n" , + offer->child_relid); +atomic_dec (&vmbus_connection.offer_in_progress); +return ; + } + oldchannel =find_primary_channel_by_offer (offer);drivers/hv/channel_mgmt.c +0
-0if (oldchannel !=NULL ) {include/linux/hyperv.h +1
-1@@ -789,6 +789,7 @@ struct vmbus_device {u16 dev_type;guid_t guid;bool perf_device; +bool allowed_in_isolated; };#define VMBUS_DEFAULT_MAX_PKT_SIZE 4096 --
Quoted 1 line
2.25.1
PATCH v3 3/4 Drivers: hv: vmbus: Enforce 'VMBus version >= 5.2' on isolated guests
In reply to Andrea Parri (Microsoft)Restrict the protocol version(s) that will be negotiated with the host to be 5.2 or greater if the guest is running isolated. This reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.
--- drivers/hv/connection.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hv/connection.c +7 -0
@@ -244,6 +244,13 @@ int vmbus_connect(void)break ; } +if (hv_is_isolation_supported () && version <VERSION_WIN10_V5_2 ) { +pr_err ("Invalid VMBus version %d.%d (expected >= %d.%d) from the host supporting isolation\n" , + version >>16 , version &0xFFFF ,VERSION_WIN10_V5_2 >>16 ,VERSION_WIN10_V5_2 &0xFFFF ); + ret = -EINVAL ; + goto cleanup; + } + vmbus_proto_version = version;pr_info ("Vmbus version:%d.%d\n" , version >>16 , version &0xFFFF );
Signature · 1 line
2.25.1
RE: [PATCH v3 hyperv-next 3/4] Drivers: hv: vmbus: Enforce 'VMBus version >= 5.2' on isolated guests
From: Andrea Parri (Microsoft) <[email protected]> Sent: Monday, February 1, 2021 6:48 AM
Quoted 30 lines
Restrict the protocol version(s) that will be negotiated with the host to be 5.2 or greater if the guest is running isolated. This reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.
Signed-off-by Andrea Parri (Microsoft) <[email protected]>--- drivers/hv/connection.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/hv/connection.c +7
-1@@ -244,6 +244,13 @@ int vmbus_connect(void)break ; } +if (hv_is_isolation_supported () && version <VERSION_WIN10_V5_2 ) { +pr_err ("Invalid VMBus version %d.%d (expected >= %d.%d) from the host supporting isolation\n" , + version >>16 , version &0xFFFF ,VERSION_WIN10_V5_2 >>16 ,VERSION_WIN10_V5_2 &0xFFFF ); + ret = -EINVAL ; + goto cleanup; + } + vmbus_proto_version = version;pr_info ("Vmbus version:%d.%d\n" , version >>16 , version &0xFFFF ); --
Quoted 1 line
2.25.1
PATCH v3 4/4 hv_netvsc: Restrict configurations on isolated guests
In reply to Andrea Parri (Microsoft)Restrict the NVSP protocol version(s) that will be negotiated with the host to be NVSP_PROTOCOL_VERSION_61 or greater if the guest is running isolated. Moreover, do not advertise the SR-IOV capability and ignore NVSP_MSG_4_TYPE_SEND_VF_ASSOCIATION messages in isolated guests, which are not supposed to support SR-IOV. This reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.
--- drivers/net/hyperv/netvsc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/net/hyperv/netvsc.c +16 -2
@@ -22,6 +22,7 @@#include <linux/prefetch.h> #include <asm/sync_bitops.h> +#include <asm/mshyperv.h> #include "hyperv_net.h" #include "netvsc_trace.h"
@@ -544,7 +545,10 @@ static int negotiate_nvsp_ver(struct hv_device *device, init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q =1 ;if (nvsp_ver >=NVSP_PROTOCOL_VERSION_5 ) { - init_packet->msg.v2_msg.send_ndis_config.capability.sriov =1 ; +if (hv_is_isolation_supported ()) +netdev_info (ndev,"SR-IOV not advertised by guests on the host supporting isolation\n" ); +else + init_packet->msg.v2_msg.send_ndis_config.capability.sriov =1 ;/* Teaming bit is needed to receive link speed updates */ init_packet->msg.v2_msg.send_ndis_config.capability.teaming =1 ;
@@ -591,6 +595,13 @@ static int netvsc_connect_vsp(struct hv_device *device, goto cleanup; } +if (hv_is_isolation_supported () && net_device->nvsp_version <NVSP_PROTOCOL_VERSION_61 ) { +netdev_err (ndev,"Invalid NVSP version 0x%x (expected >= 0x%x) from the host supporting isolation\n" , + net_device->nvsp_version,NVSP_PROTOCOL_VERSION_61 ); + ret = -EPROTO ; + goto cleanup; + } +pr_debug ("Negotiated NVSP version:%x\n" , net_device->nvsp_version);/* Send the ndis version */
@@ -1357,7 +1368,10 @@ static void netvsc_receive_inband(struct net_device *ndev,break ;case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION : -netvsc_send_vf (ndev, nvmsg, msglen); +if (hv_is_isolation_supported ()) +netdev_err (ndev,"Ignore VF_ASSOCIATION msg from the host supporting isolation\n" ); +else +netvsc_send_vf (ndev, nvmsg, msglen);break ; } }
Signature · 1 line
2.25.1
RE: [PATCH v3 hyperv-next 4/4] hv_netvsc: Restrict configurations on isolated guests
From: Andrea Parri (Microsoft) <[email protected]> Sent: Monday, February 1, 2021 6:48 AM
Quoted 70 lines
Restrict the NVSP protocol version(s) that will be negotiated with the host to be
NVSP_PROTOCOL_VERSION_61or greater if the guest is running isolated. Moreover, do not advertise the SR-IOV capability and ignoreNVSP_MSG_4_TYPE_SEND_VF_ASSOCIATIONmessages in isolated guests, which are not supposed to support SR-IOV. This reduces the footprint of the code that will be exercised by Confidential VMs and hence the exposure to bugs and vulnerabilities.Signed-off-by Andrea Parri (Microsoft) <[email protected]>Acked-by Jakub Kicinski <[email protected]>Reviewed-by Haiyang Zhang <[email protected]>Cc "David S. Miller" <[email protected]>Cc Jakub Kicinski <[email protected]>--- drivers/net/hyperv/netvsc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/net/hyperv/netvsc.c +16
-3@@ -22,6 +22,7 @@#include <linux/prefetch.h> #include <asm/sync_bitops.h> +#include <asm/mshyperv.h> #include "hyperv_net.h" #include "netvsc_trace.h" @@ -544,7 +545,10 @@ static int negotiate_nvsp_ver(struct hv_device *device, init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q =1 ;if (nvsp_ver >=NVSP_PROTOCOL_VERSION_5 ) { - init_packet->msg.v2_msg.send_ndis_config.capability.sriov =1 ; +if (hv_is_isolation_supported ()) +netdev_info (ndev,"SR-IOV not advertised by guests on the host supporting isolation\n" ); +else + init_packet->msg.v2_msg.send_ndis_config.capability.sriov =1 ;/* Teaming bit is needed to receive link speed updates */ init_packet->msg.v2_msg.send_ndis_config.capability.teaming =1 ;@@ -591,6 +595,13 @@ static int netvsc_connect_vsp(struct hv_device *device, goto cleanup; } +if (hv_is_isolation_supported () && net_device->nvsp_version <NVSP_PROTOCOL_VERSION_61 ) { +netdev_err (ndev,"Invalid NVSP version 0x%x (expected >= 0x%x) from the host supporting isolation\n" , + net_device->nvsp_version,NVSP_PROTOCOL_VERSION_61 ); + ret = -EPROTO ; + goto cleanup; + } +pr_debug ("Negotiated NVSP version:%x\n" , net_device->nvsp_version);/* Send the ndis version */ @@ -1357,7 +1368,10 @@ static void netvsc_receive_inband(struct net_device *ndev,break ;case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION : -netvsc_send_vf (ndev, nvmsg, msglen); +if (hv_is_isolation_supported ()) +netdev_err (ndev,"Ignore VF_ASSOCIATION msg from the host supporting isolation\n" ); +else +netvsc_send_vf (ndev, nvmsg, msglen);break ; } } --
Quoted 1 line
2.25.1
Quoted 5 lines · Andrea Parri (Microsoft)
Andrea Parri (Microsoft) (4):
x86/hyperv: Load/save the Isolation Configuration leaf
Drivers: hv: vmbus: Restrictvmbus_deviceson isolated guests
Drivers: hv: vmbus: Enforce 'VMBus version >= 5.2' on isolated guests
hv_netvsc: Restrict configurations on isolated guests
Applied to hyperv-next. Thanks.
Wei.