Re: [PATCH hyperv-next v3 03/15] arch: hyperv: Get/set SynIC synth.registers via paravisor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 04-06-2025 06:13, Roman Kisel wrote:
The confidential VMBus is built on the guest talking to the
paravisor only.

Provide functions that allow manipulating the SynIC registers
via paravisor. No functional changes.

Signed-off-by: Roman Kisel <romank@xxxxxxxxxxxxxxxxxxx>
Reviewed-by: Alok Tiwari <alok.a.tiwari@xxxxxxxxxx>
---
  arch/x86/kernel/cpu/mshyperv.c | 44 ++++++++++++++++++++++++++++++++++
  drivers/hv/hv_common.c         | 13 ++++++++++
  include/asm-generic/mshyperv.h |  2 ++
  3 files changed, 59 insertions(+)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 3e2533954675..83a85d94bcb3 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -89,6 +89,50 @@ void hv_set_non_nested_msr(unsigned int reg, u64 value)
  }
  EXPORT_SYMBOL_GPL(hv_set_non_nested_msr);
+/*
+ * Attempt to get the SynIC register value from the paravisor.
+ *
+ * Not all paravisors support reading SynIC registers, so this function
+ * may fail. The register for the SynIC of the running CPU is accessed.
+ *
+ * Writes the SynIC register value into the memory pointed by val,
+ * and ~0ULL is on failure.
+ *
+ * Returns -ENODEV if the MSR is not a SynIC register, or another error
+ * code if getting the MSR fails (meaning the paravisor doesn't support
+ * relaying VMBus comminucations).

comminucations -> communications

+ */
+int hv_para_get_synic_register(unsigned int reg, u64 *val)
+{
+	u64 reg_val = ~0ULL;
+	int err = -ENODEV;
+
+	if (hv_is_synic_msr(reg))
+		reg_val = native_read_msr_safe(reg, &err);
+	*val = reg_val;
+
+	return err;
+}
+
+/*
+ * Attempt to set the SynIC register value with the paravisor.
+ *
+ * Not all paravisors support reading SynIC registers, so this function
+ * may fail. The register for the SynIC of the running CPU is accessed.

you are writing, not reading. ?
-> "Not all paravisors support writing SynIC registers"

+ *
+ * Sets the register to the value supplied.
+ *
+ * Returns: -ENODEV if the MSR is not a SynIC register, or another error
+ * code if writing to the MSR fails (meaning the paravisor doesn't support
+ * relaying VMBus comminucations).
+ */
+int hv_para_set_synic_register(unsigned int reg, u64 val)
+{
+	if (!hv_is_synic_msr(reg))
+		return -ENODEV;
+	return wrmsrl_safe(reg, val);
+}


Thanks,
Alok




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux