Commit-ID:  45dbea5f55c05980cbb4c30047c71a820cd3f282
Gitweb:     http://git.kernel.org/tip/45dbea5f55c05980cbb4c30047c71a820cd3f282
Author:     Peter Zijlstra <pet...@infradead.org>
AuthorDate: Thu, 8 Dec 2016 16:42:14 +0100
Committer:  Ingo Molnar <mi...@kernel.org>
CommitDate: Sun, 11 Dec 2016 13:09:19 +0100

x86/paravirt: Fix native_patch()

While chasing a regression I noticed we potentially patch the wrong
code in native_patch().

If we do not select the native code sequence, we must use the default
patcher, not fall-through the switch case.

Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Cc: Alok Kataria <akata...@vmware.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Chris Wright <chr...@sous-sol.org>
Cc: Jeremy Fitzhardinge <jer...@goop.org>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Pan Xinhui <xinhui....@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Peter Anvin <h...@zytor.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Rusty Russell <ru...@rustcorp.com.au>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: kernel test robot <xiaolong...@intel.com>
Fixes: 3cded4179481 ("x86/paravirt: Optimize native 
pv_lock_ops.vcpu_is_preempted()")
Link: http://lkml.kernel.org/r/20161208154349.270616...@infradead.org
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 arch/x86/kernel/paravirt_patch_32.c | 4 ++++
 arch/x86/kernel/paravirt_patch_64.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/x86/kernel/paravirt_patch_32.c 
b/arch/x86/kernel/paravirt_patch_32.c
index ff03dbd..33cdec2 100644
--- a/arch/x86/kernel/paravirt_patch_32.c
+++ b/arch/x86/kernel/paravirt_patch_32.c
@@ -58,15 +58,19 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
                                end   = end_pv_lock_ops_queued_spin_unlock;
                                goto patch_site;
                        }
+                       goto patch_default;
+
                case PARAVIRT_PATCH(pv_lock_ops.vcpu_is_preempted):
                        if (pv_is_native_vcpu_is_preempted()) {
                                start = start_pv_lock_ops_vcpu_is_preempted;
                                end   = end_pv_lock_ops_vcpu_is_preempted;
                                goto patch_site;
                        }
+                       goto patch_default;
 #endif
 
        default:
+patch_default:
                ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
                break;
 
diff --git a/arch/x86/kernel/paravirt_patch_64.c 
b/arch/x86/kernel/paravirt_patch_64.c
index e61dd97..b0fceff 100644
--- a/arch/x86/kernel/paravirt_patch_64.c
+++ b/arch/x86/kernel/paravirt_patch_64.c
@@ -70,15 +70,19 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
                                end   = end_pv_lock_ops_queued_spin_unlock;
                                goto patch_site;
                        }
+                       goto patch_default;
+
                case PARAVIRT_PATCH(pv_lock_ops.vcpu_is_preempted):
                        if (pv_is_native_vcpu_is_preempted()) {
                                start = start_pv_lock_ops_vcpu_is_preempted;
                                end   = end_pv_lock_ops_vcpu_is_preempted;
                                goto patch_site;
                        }
+                       goto patch_default;
 #endif
 
        default:
+patch_default:
                ret = paravirt_patch_default(type, clobbers, ibuf, addr, len);
                break;
 

Reply via email to