All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: nVMX: kmap() can't fail
@ 2017-01-25 10:58 David Hildenbrand
  2017-01-25 10:58 ` [PATCH 1/2] " David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Hildenbrand @ 2017-01-25 10:58 UTC (permalink / raw)
  To: kvm; +Cc: fanwenyi0529, Paolo Bonzini, rkrcmar, david

Not sure if the second one is strictly needed (delta LOC changes is 0).

David Hildenbrand (2):
  KVM: nVMX: kmap() can't fail
  KVM: nVMX: vmx_complete_nested_posted_interrupt() can't fail

 arch/x86/kvm/vmx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] KVM: nVMX: kmap() can't fail
  2017-01-25 10:58 [PATCH 0/2] KVM: nVMX: kmap() can't fail David Hildenbrand
@ 2017-01-25 10:58 ` David Hildenbrand
  2017-01-25 10:58 ` [PATCH 2/2] KVM: nVMX: vmx_complete_nested_posted_interrupt() " David Hildenbrand
  2017-01-25 12:08 ` [PATCH 0/2] KVM: nVMX: kmap() " Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2017-01-25 10:58 UTC (permalink / raw)
  To: kvm; +Cc: fanwenyi0529, Paolo Bonzini, rkrcmar, david

kmap() can't fail, therefore it will always return a valid pointer. Let's
just get rid of the unnecessary checks.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/x86/kvm/vmx.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a236dec..a409fc4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4973,10 +4973,6 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
 			return 0;
 
 		vapic_page = kmap(vmx->nested.virtual_apic_page);
-		if (!vapic_page) {
-			WARN_ON(1);
-			return -ENOMEM;
-		}
 		__kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page);
 		kunmap(vmx->nested.virtual_apic_page);
 
@@ -9730,11 +9726,6 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu,
 		return false;
 	}
 	msr_bitmap_l1 = (unsigned long *)kmap(page);
-	if (!msr_bitmap_l1) {
-		nested_release_page_clean(page);
-		WARN_ON(1);
-		return false;
-	}
 
 	memset(msr_bitmap_l0, 0xff, PAGE_SIZE);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] KVM: nVMX: vmx_complete_nested_posted_interrupt() can't fail
  2017-01-25 10:58 [PATCH 0/2] KVM: nVMX: kmap() can't fail David Hildenbrand
  2017-01-25 10:58 ` [PATCH 1/2] " David Hildenbrand
@ 2017-01-25 10:58 ` David Hildenbrand
  2017-01-25 12:08 ` [PATCH 0/2] KVM: nVMX: kmap() " Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2017-01-25 10:58 UTC (permalink / raw)
  To: kvm; +Cc: fanwenyi0529, Paolo Bonzini, rkrcmar, david

vmx_complete_nested_posted_interrupt() can't fail, let's turn it into
a void function.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/x86/kvm/vmx.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a409fc4..832fef6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4953,7 +4953,7 @@ static bool vmx_get_enable_apicv(void)
 	return enable_apicv;
 }
 
-static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
+static void vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_vmx *vmx = to_vmx(vcpu);
 	int max_irr;
@@ -4964,13 +4964,13 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
 	    vmx->nested.pi_pending) {
 		vmx->nested.pi_pending = false;
 		if (!pi_test_and_clear_on(vmx->nested.pi_desc))
-			return 0;
+			return;
 
 		max_irr = find_last_bit(
 			(unsigned long *)vmx->nested.pi_desc->pir, 256);
 
 		if (max_irr == 256)
-			return 0;
+			return;
 
 		vapic_page = kmap(vmx->nested.virtual_apic_page);
 		__kvm_apic_update_irr(vmx->nested.pi_desc->pir, vapic_page);
@@ -4983,7 +4983,6 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)
 			vmcs_write16(GUEST_INTR_STATUS, status);
 		}
 	}
-	return 0;
 }
 
 static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu)
@@ -10687,7 +10686,8 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr)
 		return 0;
 	}
 
-	return vmx_complete_nested_posted_interrupt(vcpu);
+	vmx_complete_nested_posted_interrupt(vcpu);
+	return 0;
 }
 
 static u32 vmx_get_preemption_timer_value(struct kvm_vcpu *vcpu)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] KVM: nVMX: kmap() can't fail
  2017-01-25 10:58 [PATCH 0/2] KVM: nVMX: kmap() can't fail David Hildenbrand
  2017-01-25 10:58 ` [PATCH 1/2] " David Hildenbrand
  2017-01-25 10:58 ` [PATCH 2/2] KVM: nVMX: vmx_complete_nested_posted_interrupt() " David Hildenbrand
@ 2017-01-25 12:08 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-01-25 12:08 UTC (permalink / raw)
  To: David Hildenbrand, kvm; +Cc: fanwenyi0529, rkrcmar



On 25/01/2017 11:58, David Hildenbrand wrote:
> Not sure if the second one is strictly needed (delta LOC changes is 0).
> 
> David Hildenbrand (2):
>   KVM: nVMX: kmap() can't fail
>   KVM: nVMX: vmx_complete_nested_posted_interrupt() can't fail
> 
>  arch/x86/kvm/vmx.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 

It's okay since you're removing the cases with nonzero return value.
Queued, thanks.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-25 12:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 10:58 [PATCH 0/2] KVM: nVMX: kmap() can't fail David Hildenbrand
2017-01-25 10:58 ` [PATCH 1/2] " David Hildenbrand
2017-01-25 10:58 ` [PATCH 2/2] KVM: nVMX: vmx_complete_nested_posted_interrupt() " David Hildenbrand
2017-01-25 12:08 ` [PATCH 0/2] KVM: nVMX: kmap() " Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.