tip-queue 2016-02-16
Subsystems (3)
Borislav Petkov
maintainercover tip-queue 2016-02-16
From: Borislav Petkov <[email protected]>
Hi,
just a bunch of small cleanups, the highlight being one less paravirt_enabled() user. :)
Please apply,
thanks.
Andrzej Hajda (1):
x86/microcode: Use kmemdup() rather than duplicating its
implementation
Boris Ostrovsky (1):
x86/microcode: Remove unnecessary paravirt_enabled check
Borislav Petkov (2):
ftrace: Kill ftrace_caller_end label
x86/msr: Document msr-index.h rule for addition
arch/x86/include/asm/msr-index.h | 7 ++++++- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/core.c | 2 +- arch/x86/kernel/cpu/microcode/intel.c | 4 +--- arch/x86/kernel/ftrace.c | 11 +++++------ arch/x86/kernel/mcount_64.S | 14 ++++++++------ 6 files changed, 22 insertions(+), 20 deletions(-)
Signature · 1 line
2.3.5
Borislav Petkov
maintainerPATCH 1/4 x86/microcode: Remove unnecessary paravirt_enabled check
From: Boris Ostrovsky <[email protected]>
Commit
a18a0f6850d4 ("x86, microcode: Don't initialize microcode code on paravirt")
added a paravirt test in microcode_init(), primarily to avoid making mc_bp_resume()->load_ucode_ap()->check_loader_disabled_ap() calls because on 32-bit kernels this callchain ends up using __pa_nodebug() macro which is invalid for Xen PV guests.
A subsequent commit
fbae4ba8c4a3 ("x86, microcode: Reload microcode on resume")
eliminated this callchain thus making a18a0f6850d4 unnecessary.
--- arch/x86/kernel/cpu/microcode/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/core.c +1 -1
@@ -630,7 +630,7 @@ int __init microcode_init(void)struct cpuinfo_x86 *c = &boot_cpu_data;int error; -if (paravirt_enabled () || dis_ucode_ldr) +if (dis_ucode_ldr)return -EINVAL ;if (c->x86_vendor ==X86_VENDOR_INTEL )
Signature · 1 line
2.3.5
tip-bot for Boris Ostrovsky
merge bot[tip:x86/microcode] x86/microcode: Remove unnecessary paravirt_enabled check
x86/microcode: Remove unnecessary paravirt_enabled check
Commit-ID: 84aba677f009e20185aea322563389ad56e0ef7e Gitweb: http://git.kernel.org/tip/84aba677f009e20185aea322563389ad56e0ef7e Author: Boris Ostrovsky <[email protected]> AuthorDate: Tue, 16 Feb 2016 09:43:19 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Feb 2016 08:46:07 +0100
x86/microcode: Remove unnecessary paravirt_enabled check
Commit:
a18a0f6850d4 ("x86, microcode: Don't initialize microcode code on paravirt")
added a paravirt test in microcode_init(), primarily to avoid making mc_bp_resume()->load_ucode_ap()->check_loader_disabled_ap() calls because on 32-bit kernels this callchain ends up using __pa_nodebug() macro which is invalid for Xen PV guests.
A subsequent commit:
fbae4ba8c4a3 ("x86, microcode: Reload microcode on resume")
eliminated this callchain thus making a18a0f6850d4 unnecessary.
--- arch/x86/kernel/cpu/microcode/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/core.c +1 -1
@@ -623,7 +623,7 @@ int __init microcode_init(void)struct cpuinfo_x86 *c = &boot_cpu_data;int error; -if (paravirt_enabled () || dis_ucode_ldr) +if (dis_ucode_ldr)return -EINVAL ;if (c->x86_vendor ==X86_VENDOR_INTEL )
Borislav Petkov
maintainerPATCH 2/4 x86/microcode: Use kmemdup() rather than duplicating its implementation
In reply to Borislav PetkovFrom: Andrzej Hajda <[email protected]>
The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci.
--- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +1 -3
@@ -793,15 +793,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)return -EINVAL ; } - patch->data =kzalloc (patch_size,GFP_KERNEL ); + patch->data =kmemdup (fw +SECTION_HDR_SIZE , patch_size,GFP_KERNEL );if (!patch->data) {pr_err ("Patch data allocation failure.\n" );kfree (patch);return -EINVAL ; } -/* All looks ok, copy patch... */ -memcpy (patch->data, fw +SECTION_HDR_SIZE , patch_size);INIT_LIST_HEAD (&patch->plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id;
arch/x86/kernel/cpu/microcode/intel.c +1 -3
@@ -207,13 +207,11 @@ save_microcode(struct mc_saved_data *mc_saved_data, mc_hdr = &mc->hdr; size =get_totalsize (mc_hdr); - saved_ptr[i] =kmalloc (size,GFP_KERNEL ); + saved_ptr[i] =kmemdup (mc, size,GFP_KERNEL );if (!saved_ptr[i]) { ret = -ENOMEM ; goto err; } - -memcpy (saved_ptr[i], mc, size); }/*
Signature · 1 line
2.3.5
tip-bot for Andrzej Hajda
merge bot[tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
x86/microcode: Use kmemdup() rather than duplicating its implementation
Commit-ID: 9cc6f743c7724eb9abaf27904194c169db85dd31 Gitweb: http://git.kernel.org/tip/9cc6f743c7724eb9abaf27904194c169db85dd31 Author: Andrzej Hajda <[email protected]> AuthorDate: Tue, 16 Feb 2016 09:43:20 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Feb 2016 08:46:08 +0100
x86/microcode: Use kmemdup() rather than duplicating its implementation
The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci.
--- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +1 -3
@@ -788,15 +788,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)return -EINVAL ; } - patch->data =kzalloc (patch_size,GFP_KERNEL ); + patch->data =kmemdup (fw +SECTION_HDR_SIZE , patch_size,GFP_KERNEL );if (!patch->data) {pr_err ("Patch data allocation failure.\n" );kfree (patch);return -EINVAL ; } -/* All looks ok, copy patch... */ -memcpy (patch->data, fw +SECTION_HDR_SIZE , patch_size);INIT_LIST_HEAD (&patch->plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id;
arch/x86/kernel/cpu/microcode/intel.c +1 -3
@@ -210,13 +210,11 @@ save_microcode(struct mc_saved_data *mcs, mc_hdr = &mc->hdr; size =get_totalsize (mc_hdr); - saved_ptr[i] =kmalloc (size,GFP_KERNEL ); + saved_ptr[i] =kmemdup (mc, size,GFP_KERNEL );if (!saved_ptr[i]) { ret = -ENOMEM ; goto err; } - -memcpy (saved_ptr[i], mc, size); }/*
Borislav Petkov
maintainerPATCH 3/4 ftrace: Kill ftrace_caller_end label
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
One of ftrace_caller_end and ftrace_return is redundant so unify them. Rename ftrace_return to ftrace_epilogue to mean that everything after that label represents, like an afterword, work which happens *after* the ftrace call, e.g., the function graph tracer for one.
Steve wants this to rather mean "[a]n event which reflects meaningfully on a recently ended conflict or struggle." I can imagine that ftrace can be a struggle sometimes.
Anyway, beef up the comment about the code contents and layout before ftrace_epilogue label.
--- arch/x86/kernel/ftrace.c | 11 +++++------ arch/x86/kernel/mcount_64.S | 14 ++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-)
arch/x86/kernel/ftrace.c +5 -6
@@ -697,9 +697,8 @@ static inline void tramp_free(void *tramp) { }#endif /* Defined as markers to the end of the ftrace default trampolines */ -extern void ftrace_caller_end (void );extern void ftrace_regs_caller_end (void ); -extern void ftrace_return (void ); +extern void ftrace_epilogue (void );extern void ftrace_caller_op_ptr (void );extern void ftrace_regs_caller_op_ptr (void );
@@ -746,7 +745,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) op_offset = (unsigned long )ftrace_regs_caller_op_ptr; }else { start_offset = (unsigned long )ftrace_caller; - end_offset = (unsigned long )ftrace_caller_end; + end_offset = (unsigned long )ftrace_epilogue; op_offset = (unsigned long )ftrace_caller_op_ptr; }
@@ -754,7 +753,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)/* * Allocate enough size to store the ftrace_caller code, -* the jmp to ftrace_return, as well as the address of +* the jmp to ftrace_epilogue, as well as the address of * the ftrace_ops this trampoline is used for. */ trampoline =alloc_tramp (size +MCOUNT_INSN_SIZE +sizeof (void *));
@@ -772,8 +771,8 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) ip = (unsigned long )trampoline + size; -/* The trampoline ends with a jmp to ftrace_return */ - jmp =ftrace_jmp_replace (ip, (unsigned long )ftrace_return); +/* The trampoline ends with a jmp to ftrace_epilogue */ + jmp =ftrace_jmp_replace (ip, (unsigned long )ftrace_epilogue);memcpy (trampoline + size, jmp,MCOUNT_INSN_SIZE );/*
arch/x86/kernel/mcount_64.S +8 -6
@@ -168,12 +168,14 @@ GLOBAL(ftrace_call) restore_mcount_regs /* - * The copied trampoline must call ftrace_return as it + * The copied trampoline must call ftrace_epilogue as it * still may need to call the function graph tracer. + * + * The code up to this label is copied into trampolines so + * think twice before adding any new code or changing the + * layout here. */ -GLOBAL(ftrace_caller_end) - -GLOBAL(ftrace_return) +GLOBAL(ftrace_epilogue) #ifdef CONFIG_FUNCTION_GRAPH_TRACER GLOBAL(ftrace_graph_call)
@@ -244,14 +246,14 @@ GLOBAL(ftrace_regs_call) popfq /* - * As this jmp to ftrace_return can be a short jump + * As this jmp to ftrace_epilogue can be a short jump * it must not be copied into the trampoline. * The trampoline will add the code to jump * to the return. */ GLOBAL(ftrace_regs_caller_end) - jmp ftrace_return + jmp ftrace_epilogue END(ftrace_regs_caller)
Signature · 1 line
2.3.5
tip-bot for Borislav Petkov
merge bot[tip:x86/asm] x86/ftrace, x86/asm: Kill ftrace_caller_end label
x86/ftrace, x86/asm: Kill ftrace_caller_end label
Commit-ID: f1b92bb6b5a4e17b508f128b084fa00e0eda590c Gitweb: http://git.kernel.org/tip/f1b92bb6b5a4e17b508f128b084fa00e0eda590c Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 16 Feb 2016 09:43:21 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Feb 2016 08:47:22 +0100
x86/ftrace, x86/asm: Kill ftrace_caller_end label
One of ftrace_caller_end and ftrace_return is redundant so unify them. Rename ftrace_return to ftrace_epilogue to mean that everything after that label represents, like an afterword, work which happens *after* the ftrace call, e.g., the function graph tracer for one.
Steve wants this to rather mean "[a]n event which reflects meaningfully on a recently ended conflict or struggle." I can imagine that ftrace can be a struggle sometimes.
Anyway, beef up the comment about the code contents and layout before ftrace_epilogue label.
--- arch/x86/kernel/ftrace.c | 11 +++++------ arch/x86/kernel/mcount_64.S | 14 ++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-)
arch/x86/kernel/ftrace.c +5 -6
@@ -697,9 +697,8 @@ static inline void tramp_free(void *tramp) { }#endif /* Defined as markers to the end of the ftrace default trampolines */ -extern void ftrace_caller_end (void );extern void ftrace_regs_caller_end (void ); -extern void ftrace_return (void ); +extern void ftrace_epilogue (void );extern void ftrace_caller_op_ptr (void );extern void ftrace_regs_caller_op_ptr (void );
@@ -746,7 +745,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) op_offset = (unsigned long )ftrace_regs_caller_op_ptr; }else { start_offset = (unsigned long )ftrace_caller; - end_offset = (unsigned long )ftrace_caller_end; + end_offset = (unsigned long )ftrace_epilogue; op_offset = (unsigned long )ftrace_caller_op_ptr; }
@@ -754,7 +753,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)/* * Allocate enough size to store the ftrace_caller code, -* the jmp to ftrace_return, as well as the address of +* the jmp to ftrace_epilogue, as well as the address of * the ftrace_ops this trampoline is used for. */ trampoline =alloc_tramp (size +MCOUNT_INSN_SIZE +sizeof (void *));
@@ -772,8 +771,8 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) ip = (unsigned long )trampoline + size; -/* The trampoline ends with a jmp to ftrace_return */ - jmp =ftrace_jmp_replace (ip, (unsigned long )ftrace_return); +/* The trampoline ends with a jmp to ftrace_epilogue */ + jmp =ftrace_jmp_replace (ip, (unsigned long )ftrace_epilogue);memcpy (trampoline + size, jmp,MCOUNT_INSN_SIZE );/*
arch/x86/kernel/mcount_64.S +8 -6
@@ -168,12 +168,14 @@ GLOBAL(ftrace_call) restore_mcount_regs /* - * The copied trampoline must call ftrace_return as it + * The copied trampoline must call ftrace_epilogue as it * still may need to call the function graph tracer. + * + * The code up to this label is copied into trampolines so + * think twice before adding any new code or changing the + * layout here. */ -GLOBAL(ftrace_caller_end) - -GLOBAL(ftrace_return) +GLOBAL(ftrace_epilogue) #ifdef CONFIG_FUNCTION_GRAPH_TRACER GLOBAL(ftrace_graph_call)
@@ -244,14 +246,14 @@ GLOBAL(ftrace_regs_call) popfq /* - * As this jmp to ftrace_return can be a short jump + * As this jmp to ftrace_epilogue can be a short jump * it must not be copied into the trampoline. * The trampoline will add the code to jump * to the return. */ GLOBAL(ftrace_regs_caller_end) - jmp ftrace_return + jmp ftrace_epilogue END(ftrace_regs_caller)
Borislav Petkov
maintainerPATCH 4/4 x86/msr: Document msr-index.h rule for addition
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
In order to keep this file's size sensible and not cause too much unnecessary churn, make the rule explicit - similar to pci_ids.h - that only MSRs which are used in multiple compilation units, should get added to it.
--- arch/x86/include/asm/msr-index.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +6 -1
@@ -1,7 +1,12 @@#ifndef _ASM_X86_MSR_INDEX_H#define _ASM_X86_MSR_INDEX_H -/* CPU model specific register (MSR) numbers */ +/* +* CPU model specific register (MSR) numbers. +* +* Do not add new entries to this file unless the definitions are shared +* between multiple compilation units. +*/ /* x86-64 specific MSRs */ #define MSR_EFER 0xc0000080/* extended feature register */
Signature · 1 line
2.3.5
tip-bot for Borislav Petkov
merge bot[tip:x86/asm] x86/msr: Document msr-index.h rule for addition
x86/msr: Document msr-index.h rule for addition
Commit-ID: 053080a9d1c8cf1950115ad92ce94242ebc5f25c Gitweb: http://git.kernel.org/tip/053080a9d1c8cf1950115ad92ce94242ebc5f25c Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 16 Feb 2016 09:43:22 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Feb 2016 08:47:55 +0100
x86/msr: Document msr-index.h rule for addition
In order to keep this file's size sensible and not cause too much unnecessary churn, make the rule explicit - similar to pci_ids.h - that only MSRs which are used in multiple compilation units, should get added to it.
--- arch/x86/include/asm/msr-index.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +6 -1
@@ -1,7 +1,12 @@#ifndef _ASM_X86_MSR_INDEX_H#define _ASM_X86_MSR_INDEX_H -/* CPU model specific register (MSR) numbers */ +/* +* CPU model specific register (MSR) numbers. +* +* Do not add new entries to this file unless the definitions are shared +* between multiple compilation units. +*/ /* x86-64 specific MSRs */ #define MSR_EFER 0xc0000080/* extended feature register */