Skip to contentSkip to conversation

Add support for some HYPER-V PV features

PATCH Applied Gleb Natapov 4 participants 11 messages Jan 17, 2010 – Jan 19, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover Add support for some HYPER-V PV features

HYPER-V provides PV capabilities for its guests and most new MS Windows detect and use them automatically. Older Windows guests need additional drivers to uses PV. This patch series implements some PV capabilities defined by HYPER-V spec for KVM. Windows guests running on KVM will be able to take advantage of them.

Changelog:
v1->v2
rename kvm_hyperv.h into hyperv.h and move into separate patch minor style fixes
use clear_user-page(0 to zero userspace page
use APIC register names when calling kvm_hv_vapic_msr_(read|write)()
v2->v3
fix msrs_to_save[] handling
fix access to guests memory
use kvm_read_cr0_bits() instead of direct access to cr0

Gleb Natapov (4):
Add HYPE-V header file.
Implement bare minimum of HYPER-V MSRs.
Add HYPER-V apic access MSRs.
Implement NotifyLongSpinWait HYPER-V hypercall.

 arch/x86/include/asm/hyperv.h   |  187 +++++++++++++++++++++++++++++++
 arch/x86/include/asm/kvm_host.h |    6 +
 arch/x86/include/asm/kvm_para.h |    1 +
 arch/x86/kvm/lapic.c            |   31 +++++
 arch/x86/kvm/lapic.h            |    8 ++
 arch/x86/kvm/trace.h            |   32 ++++++
 arch/x86/kvm/x86.c              |  232 ++++++++++++++++++++++++++++++++++++++-
 include/linux/kvm.h             |    3 +
 8 files changed, 499 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/include/asm/hyperv.h
#2 lore raw

PATCH v3 2/4 Implement bare minimum of HYPER-V MSRs.

Minimum HYPER-V implementation should have GUEST_OS_ID, HYPERCALL and VP_INDEX MSRs.

---
 arch/x86/include/asm/kvm_host.h |    4 +
 arch/x86/include/asm/kvm_para.h |    1 +
 arch/x86/kvm/trace.h            |   32 +++++++
 arch/x86/kvm/x86.c              |  190 ++++++++++++++++++++++++++++++++++++++-
 include/linux/kvm.h             |    1 +
 5 files changed, 227 insertions(+), 1 deletions(-)
arch/x86/include/asm/kvm_host.h +4 -0
index 93bee7a..67d19e4 100644
@@ -413,6 +413,10 @@ struct kvm_arch {
 	s64 kvmclock_offset;
 
 	struct kvm_xen_hvm_config xen_hvm_config;
+
+	/* fields used by HYPER-V emulation */
+	u64 hv_guest_os_id;
+	u64 hv_hypercall;
 };
 
 struct kvm_vm_stat {
arch/x86/include/asm/kvm_para.h +1 -0
index c584076..ffae142 100644
@@ -2,6 +2,7 @@
 #define _ASM_X86_KVM_PARA_H
 
 #include <linux/types.h>
+#include <asm/hyperv.h>
 
 /* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx.  It
  * should be used to determine that a VM is running under KVM.
arch/x86/kvm/trace.h +32 -0
index 816e044..1cb3d0e 100644
@@ -56,6 +56,38 @@ TRACE_EVENT(kvm_hypercall,
 );
 
 /*
+ * Tracepoint for hypercall.
+ */
+TRACE_EVENT(kvm_hv_hypercall,
+	TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
+		 __u64 ingpa, __u64 outgpa),
+	TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
+
+	TP_STRUCT__entry(
+		__field(	__u16, 		code		)
+		__field(	bool,		fast		)
+		__field(	__u16,		rep_cnt		)
+		__field(	__u16,		rep_idx		)
+		__field(	__u64,		ingpa		)
+		__field(	__u64,		outgpa		)
+	),
+
+	TP_fast_assign(
+		__entry->code		= code;
+		__entry->fast		= fast;
+		__entry->rep_cnt	= rep_cnt;
+		__entry->rep_idx	= rep_idx;
+		__entry->ingpa		= ingpa;
+		__entry->outgpa		= outgpa;
+	),
+
+	TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
+		  __entry->code, __entry->fast ? "fast" : "slow",
+		  __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
+		  __entry->outgpa)
+);
+
+/*
  * Tracepoint for PIO.
  */
 TRACE_EVENT(kvm_pio,
arch/x86/kvm/x86.c +189 -1

239 lines not on this page · raw message

include/linux/kvm.h +1 -0
index f2feef6..e227cba 100644
@@ -497,6 +497,7 @@ struct kvm_ioeventfd {
 #endif
 #define KVM_CAP_S390_PSW 42
 #define KVM_CAP_PPC_SEGSTATE 43
+#define KVM_CAP_HYPERV 44
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
1.6.5
#4 lore raw

PATCH v3 4/4 Implement NotifyLongSpinWait HYPER-V hypercall.

In reply to Gleb Natapov

Windows issues this hypercall after guest was spinning on a spinlock for too many iterations.

---
 arch/x86/kvm/x86.c  |   10 +++++++++-
 include/linux/kvm.h |    1 +
 2 files changed, 10 insertions(+), 1 deletions(-)
arch/x86/kvm/x86.c +9 -1
index 99d1d6c..642f2d7 100644
@@ -1565,6 +1565,7 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_VCPU_EVENTS:
 	case KVM_CAP_HYPERV:
 	case KVM_CAP_HYPERV_VAPIC:
+	case KVM_CAP_HYPERV_SPIN:
 		r = 1;
 		break;
 	case KVM_CAP_COALESCED_MMIO:
@@ -3825,7 +3826,14 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 
 	trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa);
 
-	res = HV_STATUS_INVALID_HYPERCALL_CODE;
+	switch (code) {
+	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
+		kvm_vcpu_on_spin(vcpu);
+		break;
+	default:
+		res = HV_STATUS_INVALID_HYPERCALL_CODE;
+		break;
+	}
 
 	ret = res | (((u64)rep_done & 0xfff) << 32);
 	if (longmode) {
include/linux/kvm.h +1 -0
index 5ce6173..4c4937e 100644
@@ -499,6 +499,7 @@ struct kvm_ioeventfd {
 #define KVM_CAP_PPC_SEGSTATE 43
 #define KVM_CAP_HYPERV 44
 #define KVM_CAP_HYPERV_VAPIC 45
+#define KVM_CAP_HYPERV_SPIN 46
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
1.6.5
#1 lore raw

PATCH v3 1/4 Add HYPER-V header file.

In reply to Gleb Natapov

Provide HYPER-V related defines that will be uses by following patches.

---
 arch/x86/include/asm/hyperv.h |  187 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 187 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/hyperv.h
arch/x86/include/asm/hyperv.h new file +187 -0
new file mode 100644
index 0000000..91211f3
@@ -0,0 +1,187 @@
+#ifndef _ASM_X86_KVM_HYPERV_H
+#define _ASM_X86_KVM_HYPERV_H
+
+#include <linux/types.h>
+
+/*
+ * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
+ * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
+ */
+#define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS	0x40000000
+#define HYPERV_CPUID_INTERFACE			0x40000001
+#define HYPERV_CPUID_VERSION			0x40000002
+#define HYPERV_CPUID_FEATURES			0x40000003
+#define HYPERV_CPUID_ENLIGHTMENT_INFO		0x40000004
+#define HYPERV_CPUID_IMPLEMENT_LIMITS		0x40000005
+
+/*
+ * Feature identification. EAX indicates which features are available
+ * to the partition based upon the current partition privileges.
+ */
+
+/* VP Runtime (HV_X64_MSR_VP_RUNTIME) available */
+#define HV_X64_MSR_VP_RUNTIME_AVAILABLE		(1 << 0)
+/* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
+#define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE	(1 << 1)
+/*
+ * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
+ * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
+ */
+#define HV_X64_MSR_SYNIC_AVAILABLE		(1 << 2)
+/*
+ * Synthetic Timer MSRs (HV_X64_MSR_STIMER0_CONFIG through
+ * HV_X64_MSR_STIMER3_COUNT) available
+ */
+#define HV_X64_MSR_SYNTIMER_AVAILABLE		(1 << 3)
+/*
+ * APIC access MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and HV_X64_MSR_TPR)
+ * are available
+ */
+#define HV_X64_MSR_APIC_ACCESS_AVAILABLE	(1 << 4)
+/* Hypercall MSRs (HV_X64_MSR_GUEST_OS_ID and HV_X64_MSR_HYPERCALL) available*/
+#define HV_X64_MSR_HYPERCALL_AVAILABLE		(1 << 5)
+/* Access virtual processor index MSR (HV_X64_MSR_VP_INDEX) available*/
+#define HV_X64_MSR_VP_INDEX_AVAILABLE		(1 << 6)
+/* Virtual system reset MSR (HV_X64_MSR_RESET) is available*/
+#define HV_X64_MSR_RESET_AVAILABLE		(1 << 7)
+ /*
+  * Access statistics pages MSRs (HV_X64_MSR_STATS_PARTITION_RETAIL_PAGE,
+  * HV_X64_MSR_STATS_PARTITION_INTERNAL_PAGE, HV_X64_MSR_STATS_VP_RETAIL_PAGE,
+  * HV_X64_MSR_STATS_VP_INTERNAL_PAGE) available
+  */
+#define HV_X64_MSR_STAT_PAGES_AVAILABLE		(1 << 8)
+
+/*
+ * Feature identification: EBX indicates which flags were specified at
+ * partition creation. The format is the same as the partition creation
+ * flag structure defined in section Partition Creation Flags.
+ */
+#define HV_X64_CREATE_PARTITIONS		(1 << 0)
+#define HV_X64_ACCESS_PARTITION_ID		(1 << 1)
+#define HV_X64_ACCESS_MEMORY_POOL		(1 << 2)
+#define HV_X64_ADJUST_MESSAGE_BUFFERS		(1 << 3)
+#define HV_X64_POST_MESSAGES			(1 << 4)
+#define HV_X64_SIGNAL_EVENTS			(1 << 5)
+#define HV_X64_CREATE_PORT			(1 << 6)
+#define HV_X64_CONNECT_PORT			(1 << 7)
+#define HV_X64_ACCESS_STATS			(1 << 8)
+#define HV_X64_DEBUGGING			(1 << 11)
+#define HV_X64_CPU_POWER_MANAGEMENT		(1 << 12)
+#define HV_X64_CONFIGURE_PROFILER		(1 << 13)
+
+/*
+ * Feature identification. EDX indicates which miscellaneous features
+ * are available to the partition.
+ */
+/* The MWAIT instruction is available (per section MONITOR / MWAIT) */
+#define HV_X64_MWAIT_AVAILABLE				(1 << 0)
+/* Guest debugging support is available */
+#define HV_X64_GUEST_DEBUGGING_AVAILABLE		(1 << 1)
+/* Performance Monitor support is available*/
+#define HV_X64_PERF_MONITOR_AVAILABLE			(1 << 2)
+/* Support for physical CPU dynamic partitioning events is available*/
+#define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE	(1 << 3)
+/*
+ * Support for passing hypercall input parameter block via XMM
+ * registers is available
+ */
+#define HV_X64_HYPERCALL_PARAMS_XMM_AVAILABLE		(1 << 4)
+/* Support for a virtual guest idle state is available */
+#define HV_X64_GUEST_IDLE_STATE_AVAILABLE		(1 << 5)
+
+/*
+ * Implementation recommendations. Indicates which behaviors the hypervisor
+ * recommends the OS implement for optimal performance.
+ */
+ /*
+  * Recommend using hypercall for address space switches rather
+  * than MOV to CR3 instruction
+  */
+#define HV_X64_MWAIT_RECOMMENDED		(1 << 0)
+/* Recommend using hypercall for local TLB flushes rather
+ * than INVLPG or MOV to CR3 instructions */
+#define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED	(1 << 1)
+/*
+ * Recommend using hypercall for remote TLB flushes rather
+ * than inter-processor interrupts
+ */
+#define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED	(1 << 2)
+/*
+ * Recommend using MSRs for accessing APIC registers
+ * EOI, ICR and TPR rather than their memory-mapped counterparts
+ */
+#define HV_X64_APIC_ACCESS_RECOMMENDED		(1 << 3)
+/* Recommend using the hypervisor-provided MSR to initiate a system RESET */
+#define HV_X64_SYSTEM_RESET_RECOMMENDED		(1 << 4)
+/*
+ * Recommend using relaxed timing for this partition. If used,
+ * the VM should disable any watchdog timeouts that rely on the
+ * timely delivery of external interrupts
+ */
+#define HV_X64_RELAXED_TIMING_RECOMMENDED	(1 << 5)
+
+/* MSR used to identify the guest OS. */
+#define HV_X64_MSR_GUEST_OS_ID			0x40000000
+
+/* MSR used to setup pages used to communicate with the hypervisor. */
+#define HV_X64_MSR_HYPERCALL			0x40000001
+
+/* MSR used to provide vcpu index */
+#define HV_X64_MSR_VP_INDEX			0x40000002
+
+/* Define the virtual APIC registers */
+#define HV_X64_MSR_EOI				0x40000070
+#define HV_X64_MSR_ICR				0x40000071
+#define HV_X64_MSR_TPR				0x40000072
+#define HV_X64_MSR_APIC_ASSIST_PAGE		0x40000073
+
+/* Define synthetic interrupt controller model specific registers. */
+#define HV_X64_MSR_SCONTROL			0x40000080
+#define HV_X64_MSR_SVERSION			0x40000081
+#define HV_X64_MSR_SIEFP			0x40000082
+#define HV_X64_MSR_SIMP				0x40000083
+#define HV_X64_MSR_EOM				0x40000084
+#define HV_X64_MSR_SINT0			0x40000090
+#define HV_X64_MSR_SINT1			0x40000091
+#define HV_X64_MSR_SINT2			0x40000092
+#define HV_X64_MSR_SINT3			0x40000093
+#define HV_X64_MSR_SINT4			0x40000094
+#define HV_X64_MSR_SINT5			0x40000095
+#define HV_X64_MSR_SINT6			0x40000096
+#define HV_X64_MSR_SINT7			0x40000097
+#define HV_X64_MSR_SINT8			0x40000098
+#define HV_X64_MSR_SINT9			0x40000099
+#define HV_X64_MSR_SINT10			0x4000009A
+#define HV_X64_MSR_SINT11			0x4000009B
+#define HV_X64_MSR_SINT12			0x4000009C
+#define HV_X64_MSR_SINT13			0x4000009D
+#define HV_X64_MSR_SINT14			0x4000009E
+#define HV_X64_MSR_SINT15			0x4000009F
+
+
+#define HV_X64_MSR_HYPERCALL_ENABLE		0x00000001
+#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT	12
+#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK	\
+		(~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
+
+/* Declare the various hypercall operations. */
+#define HV_X64_HV_NOTIFY_LONG_SPIN_WAIT		0x0008
+
+#define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
+#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
+#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_MASK	\
+		(~((1ull << HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
+
+#define HV_PROCESSOR_POWER_STATE_C0		0
+#define HV_PROCESSOR_POWER_STATE_C1		1
+#define HV_PROCESSOR_POWER_STATE_C2		2
+#define HV_PROCESSOR_POWER_STATE_C3		3
+
+/* hypercall status code */
+#define HV_STATUS_SUCCESS			0
+#define HV_STATUS_INVALID_HYPERCALL_CODE	2
+#define HV_STATUS_INVALID_HYPERCALL_INPUT	3
+#define HV_STATUS_INVALID_ALIGNMENT		4
+
+#endif
+
Signature · 1 line
1.6.5
#3 lore raw

PATCH v3 3/4 Add HYPER-V apic access MSRs.

In reply to Gleb Natapov

Implement HYPER-V apic MSRs. Spec defines three MSRs that speed-up access to EOI/TPR/ICR apic registers for PV guests.

---
 arch/x86/include/asm/kvm_host.h |    2 +
 arch/x86/kvm/lapic.c            |   31 ++++++++++++++++++++++++++++
 arch/x86/kvm/lapic.h            |    8 +++++++
 arch/x86/kvm/x86.c              |   42 +++++++++++++++++++++++++++++++++++---
 include/linux/kvm.h             |    1 +
 5 files changed, 80 insertions(+), 4 deletions(-)
arch/x86/include/asm/kvm_host.h +2 -0
index 67d19e4..a1f0b5d 100644
@@ -363,6 +363,8 @@ struct kvm_vcpu_arch {
 	/* used for guest single stepping over the given code position */
 	u16 singlestep_cs;
 	unsigned long singlestep_rip;
+	/* fields used by HYPER-V emulation */
+	u64 hv_vapic;
 };
 
 struct kvm_mem_alias {
arch/x86/kvm/lapic.c +31 -0
index ba8c045..4b224f9 100644
@@ -1246,3 +1246,34 @@ int kvm_x2apic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data)
 
 	return 0;
 }
+
+int kvm_hv_vapic_msr_write(struct kvm_vcpu *vcpu, u32 reg, u64 data)
+{
+	struct kvm_lapic *apic = vcpu->arch.apic;
+
+	if (!irqchip_in_kernel(vcpu->kvm))
+		return 1;
+
+	/* if this is ICR write vector before command */
+	if (reg == APIC_ICR)
+		apic_reg_write(apic, APIC_ICR2, (u32)(data >> 32));
+	return apic_reg_write(apic, reg, (u32)data);
+}
+
+int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data)
+{
+	struct kvm_lapic *apic = vcpu->arch.apic;
+	u32 low, high = 0;
+
+	if (!irqchip_in_kernel(vcpu->kvm))
+		return 1;
+
+	if (apic_reg_read(apic, reg, 4, &low))
+		return 1;
+	if (reg == APIC_ICR)
+		apic_reg_read(apic, APIC_ICR2, 4, &high);
+
+	*data = (((u64)high) << 32) | low;
+
+	return 0;
+}
arch/x86/kvm/lapic.h +8 -0
index 40010b0..f5fe32c 100644
@@ -48,4 +48,12 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu);
 
 int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data);
 int kvm_x2apic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
+
+int kvm_hv_vapic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data);
+int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data);
+
+static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu)
+{
+	return vcpu->arch.hv_vapic & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE;
+}
 #endif
arch/x86/kvm/x86.c +38 -4

70 lines not on this page · raw message

include/linux/kvm.h +1 -0
index e227cba..5ce6173 100644
@@ -498,6 +498,7 @@ struct kvm_ioeventfd {
 #define KVM_CAP_S390_PSW 42
 #define KVM_CAP_PPC_SEGSTATE 43
 #define KVM_CAP_HYPERV 44
+#define KVM_CAP_HYPERV_VAPIC 45
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
1.6.5
Applied
#5 lore raw
In reply to Gleb Natapov
Quoted 6 lines · Gleb Natapov

HYPER-V provides PV capabilities for its guests and most new MS Windows detect and use them automatically. Older Windows guests need additional drivers to uses PV. This patch series implements some PV capabilities defined by HYPER-V spec for KVM. Windows guests running on KVM will be able to take advantage of them.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function
#6 lore raw
In reply to Gleb Natapov
Quoted 6 lines · Gleb Natapov

HYPER-V provides PV capabilities for its guests and most new MS Windows detect and use them automatically. Older Windows guests need additional drivers to uses PV. This patch series implements some PV capabilities defined by HYPER-V spec for KVM. Windows guests running on KVM will be able to take advantage of them.

This series generates warnings on 32-bit hosts. I'm currently busy with more critical problems, maybe you can already have a look.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#7 lore raw
Quoted 11 lines · Jan Kiszka
Quoted 6 lines · Gleb Natapov

HYPER-V provides PV capabilities for its guests and most new MS Windows detect and use them automatically. Older Windows guests need additional drivers to uses PV. This patch series implements some PV capabilities defined by HYPER-V spec for KVM. Windows guests running on KVM will be able to take advantage of them.

This series generates warnings on 32-bit hosts. I'm currently busy with more critical problems, maybe you can already have a look.

This should fix it:

arch/x86/kvm/x86.c +3 -3
index 47c6e23..147bda7 100644
@@ -3807,11 +3807,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	longmode = is_long_mode(vcpu) && cs_l == 1;
 
 	if (!longmode) {
-		param = (kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
+		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffff);
-		ingpa = (kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
+		ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffff);
-		outgpa = (kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
+		outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffff);
 	}
 #ifdef CONFIG_X86_64

--
Gleb.

#8 lore raw
Quoted 3 lines · Gleb Natapov

This should fix it:

Unrelated, but important:

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 3812

Quoted 13 lines
arch/x86/kvm/x86.c +1 -1
index 47c6e23..147bda7 100644
@@ -3807,11 +3807,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
  	longmode = is_long_mode(vcpu)&&  cs_l == 1;
 
  	if (!longmode) {
-		param = (kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
+		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
  			(kvm_register_read(vcpu, VCPU_REGS_RAX)&  0xffffff);
 

This seems to be written for a 24-bit machine...

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw
Quoted 13 lines · Avi Kivity
Quoted 2 lines · Gleb Natapov

This should fix it:

Unrelated, but important:

Quoted 7 lines
arch/x86/kvm/x86.c +0 -0
index 47c6e23..147bda7 100644
@@ -3807,11 +3807,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	longmode = is_long_mode(vcpu)&&  cs_l == 1;
 
Quoted 7 lines

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 3811

Quoted 4 lines
arch/x86/kvm/x86.c +1 -1
 	if (!longmode) {
-		param = (kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
+		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RAX)&  0xffffff);

This seems to be written for a 24-bit machine...

I have plenty of those around.
---

Fix compilation warnings and wrong mask value.

arch/x86/kvm/x86.c +6 -6
index 47c6e23..a311751 100644
@@ -3807,12 +3807,12 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	longmode = is_long_mode(vcpu) && cs_l == 1;
 
 	if (!longmode) {
-		param = (kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
-			(kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffff);
-		ingpa = (kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
-			(kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffff);
-		outgpa = (kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
-			(kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffff);
+		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
+			(kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
+		ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
+			(kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
+		outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
+			(kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
 	}
 #ifdef CONFIG_X86_64
 	else {

--
Gleb.

#10 lore raw
Quoted 21 lines · Gleb Natapov
Quoted 13 lines · Avi Kivity
Quoted 2 lines · Gleb Natapov

This should fix it:

Unrelated, but important:

Quoted 7 lines
arch/x86/kvm/x86.c +0 -0
index 47c6e23..147bda7 100644
@@ -3807,11 +3807,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	longmode = is_long_mode(vcpu)&&  cs_l == 1;
 
Quoted 7 lines

arch/x86/kvm/x86.c int kvm_hv_hypercall(struct kvm_vcpu *vcpu) · line 3811

Quoted 4 lines
arch/x86/kvm/x86.c +1 -1
 	if (!longmode) {
-		param = (kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
+		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX)<<  32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RAX)&  0xffffff);

This seems to be written for a 24-bit machine...

Quoted 4 lines

I have plenty of those around.
---

Fix compilation warnings and wrong mask value.

Applied, thanks.