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: Trap on access for some synthetic MSRs

hv_set_non_nested_msr() has special handling for SINT MSRs
when a paravisor is present. In addition to updating the MSR on the
host, the mirror MSR in the paravisor is updated, including with the
proxy bit. But with Confidential VMBus, the proxy bit must not be
used, so add a special case to skip it.

Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Tianyu Lan <tiala@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
a156ad8c e6eeb3c7

+31 -4
+25 -4
arch/x86/kernel/cpu/mshyperv.c
··· 28 28 #include <asm/apic.h> 29 29 #include <asm/timer.h> 30 30 #include <asm/reboot.h> 31 + #include <asm/msr.h> 31 32 #include <asm/nmi.h> 32 33 #include <clocksource/hyperv_timer.h> 33 34 #include <asm/msr.h> ··· 40 39 struct ms_hyperv_info ms_hyperv; 41 40 42 41 #if IS_ENABLED(CONFIG_HYPERV) 42 + /* 43 + * When running with the paravisor, controls proxying the synthetic interrupts 44 + * from the host 45 + */ 46 + static bool hv_para_sint_proxy; 47 + 43 48 static inline unsigned int hv_get_nested_msr(unsigned int reg) 44 49 { 45 50 if (hv_is_sint_msr(reg)) ··· 82 75 void hv_set_non_nested_msr(unsigned int reg, u64 value) 83 76 { 84 77 if (hv_is_synic_msr(reg) && ms_hyperv.paravisor_present) { 78 + /* The hypervisor will get the intercept. */ 85 79 hv_ivm_msr_write(reg, value); 86 80 87 - /* Write proxy bit via wrmsl instruction */ 88 - if (hv_is_sint_msr(reg)) 89 - wrmsrq(reg, value | 1 << 20); 81 + /* Using wrmsrq so the following goes to the paravisor. */ 82 + if (hv_is_sint_msr(reg)) { 83 + union hv_synic_sint sint = { .as_uint64 = value }; 84 + 85 + sint.proxy = hv_para_sint_proxy; 86 + native_wrmsrq(reg, sint.as_uint64); 87 + } 90 88 } else { 91 - wrmsrq(reg, value); 89 + native_wrmsrq(reg, value); 92 90 } 93 91 } 94 92 EXPORT_SYMBOL_GPL(hv_set_non_nested_msr); 93 + 94 + /* 95 + * Enable or disable proxying synthetic interrupts 96 + * to the paravisor. 97 + */ 98 + void hv_para_set_sint_proxy(bool enable) 99 + { 100 + hv_para_sint_proxy = enable; 101 + } 95 102 96 103 /* 97 104 * Get the SynIC register value from the paravisor.
+5
drivers/hv/hv_common.c
··· 721 721 } 722 722 EXPORT_SYMBOL_GPL(hv_enable_coco_interrupt); 723 723 724 + void __weak hv_para_set_sint_proxy(bool enable) 725 + { 726 + } 727 + EXPORT_SYMBOL_GPL(hv_para_set_sint_proxy); 728 + 724 729 u64 __weak hv_para_get_synic_register(unsigned int reg) 725 730 { 726 731 return ~0ULL;
+1
include/asm-generic/mshyperv.h
··· 310 310 u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size); 311 311 u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2); 312 312 void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set); 313 + void hv_para_set_sint_proxy(bool enable); 313 314 u64 hv_para_get_synic_register(unsigned int reg); 314 315 void hv_para_set_synic_register(unsigned int reg, u64 val); 315 316 void hyperv_cleanup(void);