x86/paravirt: Get rid of patch_site label
Subsystems (3)
Borislav Petkov
maintainerPATCH 1/1 x86/paravirt: Get rid of patch_site label
From: Borislav Petkov <[email protected]>
When CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but that label can simply be removed by directly calling paravirt_patch_insns() there.
--- arch/x86/kernel/paravirt_patch_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/paravirt_patch_64.c +2 -2
@@ -76,7 +76,8 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } goto patch_default;#endif
@@ -86,7 +87,6 @@ patch_default: __maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; -patch_site: ret =paravirt_patch_insns (ibuf, len, start, end);break ; }
Signature · 1 line
2.17.0.582.gccdcbd54c
Borislav Petkov
maintainerQuoted 10 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but that label can simply be removed by directly calling
paravirt_patch_insns()there.
Whoops, no, it is still being used. Lemme see if I can remove all the labels in that function.
Signature · 8 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualizationBorislav Petkov
maintainerQuoted 10 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but that label can simply be removed by directly calling
paravirt_patch_insns()there.
Whoops, no, it is still being used. Lemme see if I can remove all the labels in that function.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Borislav Petkov
maintainerPATCH v2 1/1 x86/paravirt: Get rid of patch_site and patch_default labels
Quoted 2 lines · Borislav Petkov
Whoops, no, it is still being used. Lemme see if I can remove all the labels in that function.
Ok, I think I've gotten rid of them all, in both 32- and 64-bit versions. It boots here and a bunch of all*config builds pass.
---
From: Borislav Petkov <[email protected]>
Date: Fri, 7 Sep 2018 12:47:10 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but those labels can simply be removed by directly calling the respective functions there.
--- arch/x86/kernel/paravirt_patch_32.c | 21 ++++++++++----------- arch/x86/kernel/paravirt_patch_64.c | 20 +++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +10 -11
@@ -34,14 +34,16 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end); +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -58,27 +60,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;
arch/x86/kernel/paravirt_patch_64.c +9 -11
@@ -42,14 +42,15 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end);switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, restore_fl);
@@ -68,27 +69,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;
Signature · 11 lines
2.17.0.582.gccdcbd54c
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualizationBorislav Petkov
maintainerPATCH v2 1/1 x86/paravirt: Get rid of patch_site and patch_default labels
In reply to Borislav PetkovQuoted 2 lines · Borislav Petkov
Whoops, no, it is still being used. Lemme see if I can remove all the labels in that function.
Ok, I think I've gotten rid of them all, in both 32- and 64-bit versions. It boots here and a bunch of all*config builds pass.
---
From: Borislav Petkov <[email protected]>
Date: Fri, 7 Sep 2018 12:47:10 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but those labels can simply be removed by directly calling the respective functions there.
--- arch/x86/kernel/paravirt_patch_32.c | 21 ++++++++++----------- arch/x86/kernel/paravirt_patch_64.c | 20 +++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +10 -11
@@ -34,14 +34,16 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end); +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -58,27 +60,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;
arch/x86/kernel/paravirt_patch_64.c +9 -11
@@ -42,14 +42,15 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end);switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, restore_fl);
@@ -68,27 +69,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;
Signature · 7 lines
2.17.0.582.gccdcbd54c
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Juergen Gross
maintainerRe: [PATCH v2] x86/paravirt: Get rid of patch_site and patch_default labels
Quoted 94 lines · Borislav Petkov
Quoted 2 lines · Borislav Petkov
Whoops, no, it is still being used. Lemme see if I can remove all the labels in that function.
Ok, I think I've gotten rid of them all, in both 32- and 64-bit versions. It boots here and a bunch of all*config builds pass.
---
From: Borislav Petkov <[email protected]>
Date: Fri, 7 Sep 2018 12:47:10 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitWhen
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but those labels can simply be removed by directly calling the respective functions there.
Signed-off-by Borislav Petkov <[email protected]>Cc Juergen Gross <[email protected]>--- arch/x86/kernel/paravirt_patch_32.c | 21 ++++++++++----------- arch/x86/kernel/paravirt_patch_64.c | 20 +++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-)arch/x86/kernel/paravirt_patch_32.c +10
-11@@ -34,14 +34,16 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end); +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);@@ -58,27 +60,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;arch/x86/kernel/paravirt_patch_64.c +0
-0
arch/x86/kernel/paravirt_patch_64.c extern bool pv_is_native_vcpu_is_preempted(void); · line 45
Quoted 5 lines
arch/x86/kernel/paravirt_patch_64.c +1
-1@@ -42,14 +42,15 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; +const unsigned char *start__maybe_unused , *end__maybe_unused ;
Drop start and end and ...
arch/x86/kernel/paravirt_patch_64.c extern bool pv_is_native_vcpu_is_preempted(void); · line 53
Quoted 9 lines
arch/x86/kernel/paravirt_patch_64.c +2
-1unsigned ret;#define PATCH_SITE (ops, x) \ case PARAVIRT_PATCH(ops.x): \ start = start_##ops##_##x; \ end = end_##ops##_##x; \ - goto patch_site + \ + return paravirt_patch_insns(ibuf, len, start, end);
... do: return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x)
and please omit the semicolon after the last instruction in the macro.
(below the same)
Quoted 28 lines
arch/x86/kernel/paravirt_patch_64.c +6
-4switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, restore_fl);@@ -68,27 +69,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)if (pv_is_native_spin_unlock ()) { start = start_lock_queued_spin_unlock; end = end_lock_queued_spin_unlock; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);case PARAVIRT_PATCH (lock.vcpu_is_preempted):if (pv_is_native_vcpu_is_preempted ()) { start = start_lock_vcpu_is_preempted; end = end_lock_vcpu_is_preempted; - goto patch_site; + +return paravirt_patch_insns (ibuf, len, start, end); } - goto patch_default; +return paravirt_patch_default (type, ibuf, addr, len);#endif default :
arch/x86/kernel/paravirt_patch_64.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 92
Quoted 10 lines
arch/x86/kernel/paravirt_patch_64.c +0
-5-patch_default:__maybe_unused ret =paravirt_patch_default (type, ibuf, addr, len);break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; }#undef PATCH_SITEreturn ret;
Juergen
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Borislav Petkov
maintainerPATCH 1/1 x86/paravirt: Cleanup native_patch()
When CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it.
---
It looks even more cleaner now. :)
arch/x86/kernel/paravirt_patch_32.c | 48 +++++++++++----------------- arch/x86/kernel/paravirt_patch_64.c | 49 ++++++++++++----------------- 2 files changed, 39 insertions(+), 58 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +19 -29
@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -54,32 +50,26 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len); -case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +else +return paravirt_patch_default (type, ibuf, addr, len);#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; +return paravirt_patch_default (type, ibuf, addr, len); }#undef PATCH_SITE -return ret; +return 0 ; }
arch/x86/kernel/paravirt_patch_64.c +20 -29
67 lines not on this page · raw message
Signature · 12 lines
2.17.0.582.gccdcbd54c
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualizationJuergen Gross
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
Quoted 11 lines · Borislav Petkov
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it.
Quoted 7 lines
Signed-off-by Borislav Petkov <[email protected]>Cc Juergen Gross <[email protected]>---
It looks even more cleaner now. :)
And there is still some more clean up possible:
Quoted 35 lines
arch/x86/kernel/paravirt_patch_32.c | 48 +++++++++++----------------- arch/x86/kernel/paravirt_patch_64.c | 49 ++++++++++++----------------- 2 files changed, 39 insertions(+), 58 deletions(-)arch/x86/kernel/paravirt_patch_32.c +3
-11@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);@@ -54,32 +50,26 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock;
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 10 lines
arch/x86/kernel/paravirt_patch_32.c +7
-3- goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);
Why not replace the else clause by a "break;" and ...
Quoted 5 lines
arch/x86/kernel/paravirt_patch_32.c +0
-4-case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted;
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 67
Quoted 10 lines
arch/x86/kernel/paravirt_patch_32.c +7
-3- goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +else +return paravirt_patch_default (type, ibuf, addr, len);
... this as well and ...
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 71
Quoted 11 lines
arch/x86/kernel/paravirt_patch_32.c +1
-7#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; +return paravirt_patch_default (type, ibuf, addr, len);
... remove this return and ...
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 74
Quoted 4 lines
arch/x86/kernel/paravirt_patch_32.c +1
-1}#undef PATCH_SITE -return ret; +return 0 ;
Replace this by
return paravirt_patch_default(type, ibuf, addr, len);
Same for paravirt_patch_64.c, of course.
Juergen
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Juergen Gross
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
In reply to Borislav PetkovQuoted 11 lines · Borislav Petkov
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it.
Quoted 7 lines
Signed-off-by Borislav Petkov <[email protected]>Cc Juergen Gross <[email protected]>---
It looks even more cleaner now. :)
And there is still some more clean up possible:
Quoted 35 lines
arch/x86/kernel/paravirt_patch_32.c | 48 +++++++++++----------------- arch/x86/kernel/paravirt_patch_64.c | 49 ++++++++++++----------------- 2 files changed, 39 insertions(+), 58 deletions(-)arch/x86/kernel/paravirt_patch_32.c +3
-11@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);@@ -54,32 +50,26 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock;
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 10 lines
arch/x86/kernel/paravirt_patch_32.c +7
-3- goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);
Why not replace the else clause by a "break;" and ...
Quoted 5 lines
arch/x86/kernel/paravirt_patch_32.c +0
-4-case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted;
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 67
Quoted 10 lines
arch/x86/kernel/paravirt_patch_32.c +7
-3- goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +else +return paravirt_patch_default (type, ibuf, addr, len);
... this as well and ...
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 71
Quoted 11 lines
arch/x86/kernel/paravirt_patch_32.c +1
-7#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end); -break ; +return paravirt_patch_default (type, ibuf, addr, len);
... remove this return and ...
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 74
Quoted 4 lines
arch/x86/kernel/paravirt_patch_32.c +1
-1}#undef PATCH_SITE -return ret; +return 0 ;
Replace this by
return paravirt_patch_default(type, ibuf, addr, len);
Same for paravirt_patch_64.c, of course.
Juergen
Borislav Petkov
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
Quoted 9 lines · Juergen Gross
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 7 lines
arch/x86/kernel/paravirt_patch_32.c +7
-0+case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);Why not replace the else clause by a "break;" and ...
Because I think that exiting right then and there is much easier to follow than adding all those breaks and wading through ifdeffery to realize that this is the default path and we'll end up calling paravirt_patch_default() in the end.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Borislav Petkov
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 7 lines
arch/x86/kernel/paravirt_patch_32.c +7
-0+case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);Why not replace the else clause by a "break;" and ...
Because I think that exiting right then and there is much easier to follow than adding all those breaks and wading through ifdeffery to realize that this is the default path and we'll end up calling paravirt_patch_default() in the end.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Juergen Gross
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
Quoted 11 lines · Borislav Petkov
Quoted 9 lines · Juergen Gross
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 7 lines
arch/x86/kernel/paravirt_patch_32.c +7
-0+case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);Why not replace the else clause by a "break;" and ...
Quoted 5 lines
Because I think that exiting right then and there is much easier to follow than adding all those breaks and wading through ifdeffery to realize that this is the default path and we'll end up calling
paravirt_patch_default()in the end.
Really? All of the remaining coding would fit easily on one screen. No hidden breaks anywhere and no deep nesting involved. And the ifdefs hardly makes it more difficult to understand, as they are not even nested.
Juergen
Juergen Gross
maintainerRe: [PATCH] x86/paravirt: Cleanup native_patch()
In reply to Borislav PetkovQuoted 11 lines · Borislav Petkov
Quoted 9 lines · Juergen Gross
arch/x86/kernel/paravirt_patch_32.c unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len) · line 59
Quoted 7 lines
arch/x86/kernel/paravirt_patch_32.c +7
-0+case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +else +return paravirt_patch_default (type, ibuf, addr, len);Why not replace the else clause by a "break;" and ...
Quoted 5 lines
Because I think that exiting right then and there is much easier to follow than adding all those breaks and wading through ifdeffery to realize that this is the default path and we'll end up calling
paravirt_patch_default()in the end.
Really? All of the remaining coding would fit easily on one screen. No hidden breaks anywhere and no deep nesting involved. And the ifdefs hardly makes it more difficult to understand, as they are not even nested.
Juergen
Borislav Petkov
maintainerPATCH v2 1/1 x86/paravirt: Cleanup native_patch()
When CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it. Also, simplify function flow for better readability.
---
Here it is, rebased ontop of rc3+tip/master.
arch/x86/kernel/paravirt_patch_32.c | 44 ++++++++++----------------- arch/x86/kernel/paravirt_patch_64.c | 46 +++++++++++------------------ 2 files changed, 33 insertions(+), 57 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +16 -28
@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -54,32 +50,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +break ; -case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +break ;#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end);break ; }#undef PATCH_SITE -return ret; +return paravirt_patch_default (type, ibuf, addr, len); }
arch/x86/kernel/paravirt_patch_64.c +17 -29
64 lines not on this page · raw message
Signature · 11 lines
2.17.0.582.gccdcbd54c
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualizationBorislav Petkov
maintainerPATCH v2 1/1 x86/paravirt: Cleanup native_patch()
In reply to Juergen GrossWhen CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it. Also, simplify function flow for better readability.
---
Here it is, rebased ontop of rc3+tip/master.
arch/x86/kernel/paravirt_patch_32.c | 44 ++++++++++----------------- arch/x86/kernel/paravirt_patch_64.c | 46 +++++++++++------------------ 2 files changed, 33 insertions(+), 57 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +16 -28
@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -54,32 +50,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +break ; -case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +break ;#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end);break ; }#undef PATCH_SITE -return ret; +return paravirt_patch_default (type, ibuf, addr, len); }
arch/x86/kernel/paravirt_patch_64.c +17 -29
64 lines not on this page · raw message
Signature · 7 lines
2.17.0.582.gccdcbd54c
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2] x86/paravirt: Cleanup native_patch()
Quoted 9 lines · Borislav Petkov
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but those labels can simply be removed by directly calling the respective functions there.
Quoted 7 lines
Get rid of local variables too, while at it. Also, simplify function flow for better readability.
Signed-off-by Borislav Petkov <[email protected]>Cc Juergen Gross <[email protected]>
Juergen
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v2] x86/paravirt: Cleanup native_patch()
In reply to Borislav PetkovQuoted 9 lines · Borislav Petkov
When
CONFIG_PARAVIRT_SPINLOCKS=n, it fires
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:but those labels can simply be removed by directly calling the respective functions there.
Quoted 7 lines
Get rid of local variables too, while at it. Also, simplify function flow for better readability.
Signed-off-by Borislav Petkov <[email protected]>Cc Juergen Gross <[email protected]>
Juergen
tip-bot for Borislav Petkov
merge bot[tip:x86/paravirt] x86/paravirt: Clean up native_patch()
In reply to Borislav Petkovx86/paravirt: Clean up native_patch()
Commit-ID: 3637897b6c9bc2f12f38956d64724a6d0bbb56fd Gitweb: https://git.kernel.org/tip/3637897b6c9bc2f12f38956d64724a6d0bbb56fd Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 11 Sep 2018 11:15:10 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 11 Sep 2018 12:45:14 +0200
x86/paravirt: Clean up native_patch()
When CONFIG_PARAVIRT_SPINLOCKS=n, it generates a warning:
arch/x86/kernel/paravirt_patch_64.c: In function ‘native_patch’:
arch/x86/kernel/paravirt_patch_64.c:89:1: warning: label ‘patch_site’ defined but not used [-Wunused-label]
patch_site:
... but those labels can simply be removed by directly calling the respective functions there.
Get rid of local variables too, while at it. Also, simplify function flow for better readability.
--- arch/x86/kernel/paravirt_patch_32.c | 44 +++++++++++++---------------------- arch/x86/kernel/paravirt_patch_64.c | 46 ++++++++++++++----------------------- 2 files changed, 33 insertions(+), 57 deletions(-)
arch/x86/kernel/paravirt_patch_32.c +16 -28
@@ -34,14 +34,10 @@ extern bool pv_is_native_vcpu_is_preempted(void);unsigned native_patch (u8 type,void *ibuf,unsigned long addr,unsigned len) { -const unsigned char *start, *end; -unsigned ret; -#define PATCH_SITE (ops, x) \ - case PARAVIRT_PATCH(ops.x): \ - start = start_##ops##_##x; \ - end = end_##ops##_##x; \ - goto patch_site + case PARAVIRT_PATCH(ops.x): \ + return paravirt_patch_insns(ibuf, len, start_##ops##_##x, end_##ops##_##x) +switch (type) {#ifdef CONFIG_PARAVIRT_XXL PATCH_SITE (irq, irq_disable);
@@ -54,32 +50,24 @@ unsigned native_patch(u8 type, void *ibuf, unsigned long addr, unsigned len)PATCH_SITE (mmu, write_cr3);#endif #if defined(CONFIG_PARAVIRT_SPINLOCKS ) -case PARAVIRT_PATCH (lock.queued_spin_unlock): -if (pv_is_native_spin_unlock ()) { - start = start_lock_queued_spin_unlock; - end = end_lock_queued_spin_unlock; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.queued_spin_unlock): +if (pv_is_native_spin_unlock ()) +return paravirt_patch_insns (ibuf, len, + start_lock_queued_spin_unlock, + end_lock_queued_spin_unlock); +break ; -case PARAVIRT_PATCH (lock.vcpu_is_preempted): -if (pv_is_native_vcpu_is_preempted ()) { - start = start_lock_vcpu_is_preempted; - end = end_lock_vcpu_is_preempted; - goto patch_site; - } - goto patch_default; +case PARAVIRT_PATCH (lock.vcpu_is_preempted): +if (pv_is_native_vcpu_is_preempted ()) +return paravirt_patch_insns (ibuf, len, + start_lock_vcpu_is_preempted, + end_lock_vcpu_is_preempted); +break ;#endif default : -patch_default:__maybe_unused - ret =paravirt_patch_default (type, ibuf, addr, len); -break ; - -patch_site: - ret =paravirt_patch_insns (ibuf, len, start, end);break ; }#undef PATCH_SITE -return ret; +return paravirt_patch_default (type, ibuf, addr, len); }
arch/x86/kernel/paravirt_patch_64.c +17 -29
64 lines not on this page · raw message