Skip to contentSkip to conversation

KVM: vmx: fix a build warning in hv_enable_direct_tlbflush() on i386

PATCH Superseded Vitaly Kuznetsov 2 participants 3 messages Sep 25, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: vmx: fix a build warning in hv_enable_direct_tlbflush() on i386

The following was reported on i386:

arch/x86/kvm/vmx/vmx.c: In function 'hv_enable_direct_tlbflush':
arch/x86/kvm/vmx/vmx.c:503:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

The particular pr_debug() causing it is more or less useless, let's just remove it. Also, simplify the condition a little bit.

---
 arch/x86/kvm/vmx/vmx.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx/vmx.c +4 -6
index a7c9922e3905..812553b7270f 100644
@@ -495,13 +495,11 @@ static int hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu)
 	 * Synthetic VM-Exit is not enabled in current code and so All
 	 * evmcs in singe VM shares same assist page.
 	 */
-	if (!*p_hv_pa_pg) {
+	if (!*p_hv_pa_pg)
 		*p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL);
-		if (!*p_hv_pa_pg)
-			return -ENOMEM;
-		pr_debug("KVM: Hyper-V: allocated PA_PG for %llx\n",
-		       (u64)&vcpu->kvm);
-	}
+
+	if (!*p_hv_pa_pg)
+		return -ENOMEM;
 
 	evmcs = (struct hv_enlightened_vmcs *)to_vmx(vcpu)->loaded_vmcs->vmcs;
 
Signature · 1 line
2.20.1
#1 lore raw

There is another warning in the report.

arch/x86/kvm/vmx/vmx.c: In function 'hv_enable_direct_tlbflush':
arch/x86/kvm/vmx/vmx.c:507:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

  evmcs->hv_vm_id = (u64)vcpu->kvm;
                    ^
The following change can fix it.
-       evmcs->hv_vm_id = (u64)vcpu->kvm;
+       evmcs->hv_vm_id = (unsigned long)vcpu->kvm;
        evmcs->hv_enlightenments_control.nested_flush_hypercall = 1;

-----Original Message-----
From: Vitaly Kuznetsov <[email protected]>
Sent: Wednesday, September 25, 2019 4:53 PM
To: [email protected]
Cc: [email protected]; Paolo Bonzini <[email protected]>; Radim Krčmář <[email protected]>; Sean Christopherson <[email protected]>; Jim Mattson <[email protected]>; Tianyu Lan <[email protected]>
Subject: [PATCH] KVM: vmx: fix a build warning in hv_enable_direct_tlbflush() on i386

The following was reported on i386:

arch/x86/kvm/vmx/vmx.c: In function 'hv_enable_direct_tlbflush':
arch/x86/kvm/vmx/vmx.c:503:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

The particular pr_debug() causing it is more or less useless, let's just remove it. Also, simplify the condition a little bit.

---
 arch/x86/kvm/vmx/vmx.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx/vmx.c +4 -6
@@ -495,13 +495,11 @@ static int hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu)
 	 * Synthetic VM-Exit is not enabled in current code and so All
 	 * evmcs in singe VM shares same assist page.
 	 */
-	if (!*p_hv_pa_pg) {
+	if (!*p_hv_pa_pg)
 		*p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL);
-		if (!*p_hv_pa_pg)
-			return -ENOMEM;
-		pr_debug("KVM: Hyper-V: allocated PA_PG for %llx\n",
-		       (u64)&vcpu->kvm);
-	}
+
+	if (!*p_hv_pa_pg)
+		return -ENOMEM;
 
 	evmcs = (struct hv_enlightened_vmcs *)to_vmx(vcpu)->loaded_vmcs->vmcs;
 

--
2.20.1

#2 lore raw

Review

Quoted 11 lines · Tianyu Lan

There is another warning in the report.

arch/x86/kvm/vmx/vmx.c: In function 'hv_enable_direct_tlbflush':
arch/x86/kvm/vmx/vmx.c:507:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

  evmcs->hv_vm_id = (u64)vcpu->kvm;
                    ^

The following change can fix it.

(quoted diff) +1 -1
-       evmcs->hv_vm_id = (u64)vcpu->kvm;
+       evmcs->hv_vm_id = (unsigned long)vcpu->kvm;
        evmcs->hv_enlightenments_control.nested_flush_hypercall = 1;

Missed that one (and I have to admit I haven't compiled my patch on i386 :-). Will send v2 with this included, thanks!

Signature · 1 line
Vitaly