x86/hyperv: Use TDX GHCI to access some MSRs in a TDX VM with the paravisor
When the paravisor is present, a SNP VM must use GHCB to access some special MSRs, including HV_X64_MSR_GUEST_OS_ID and some SynIC MSRs. Similarly, when the paravisor is present, a TDX VM must use TDX GHCI to access the same MSRs. Implement hv_tdx_msr_write() and hv_tdx_msr_read(), and use the helper functions hv_ivm_msr_read() and hv_ivm_msr_write() to access the MSRs in a unified way for SNP/TDX VMs with the paravisor. Do not export hv_tdx_msr_write() and hv_tdx_msr_read(), because we never really used hv_ghcb_msr_write() and hv_ghcb_msr_read() in any module. Update arch/x86/include/asm/mshyperv.h so that the kernel can still build if CONFIG_AMD_MEM_ENCRYPT or CONFIG_INTEL_TDX_GUEST is not set, or neither is set. Signed-off-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Tianyu Lan <tiala@microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org> Link: https://lore.kernel.org/r/20230824080712.30327-9-decui@microsoft.com
This commit is contained in:
@@ -70,8 +70,8 @@ u64 hv_get_non_nested_register(unsigned int reg)
|
||||
{
|
||||
u64 value;
|
||||
|
||||
if (hv_is_synic_reg(reg) && hv_isolation_type_snp())
|
||||
hv_ghcb_msr_read(reg, &value);
|
||||
if (hv_is_synic_reg(reg) && ms_hyperv.paravisor_present)
|
||||
hv_ivm_msr_read(reg, &value);
|
||||
else
|
||||
rdmsrl(reg, value);
|
||||
return value;
|
||||
@@ -80,8 +80,8 @@ EXPORT_SYMBOL_GPL(hv_get_non_nested_register);
|
||||
|
||||
void hv_set_non_nested_register(unsigned int reg, u64 value)
|
||||
{
|
||||
if (hv_is_synic_reg(reg) && hv_isolation_type_snp()) {
|
||||
hv_ghcb_msr_write(reg, value);
|
||||
if (hv_is_synic_reg(reg) && ms_hyperv.paravisor_present) {
|
||||
hv_ivm_msr_write(reg, value);
|
||||
|
||||
/* Write proxy bit via wrmsl instruction */
|
||||
if (hv_is_sint_reg(reg))
|
||||
|
||||
Reference in New Issue
Block a user