All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] tip-queue 2016-02-16
@ 2016-02-16  8:43 Borislav Petkov
  2016-02-16  8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Borislav Petkov @ 2016-02-16  8:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

From: Borislav Petkov <bp@suse.de>

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(-)

-- 
2.3.5

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

* [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check
  2016-02-16  8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
@ 2016-02-16  8:43 ` Borislav Petkov
  2016-02-17 12:12   ` [tip:x86/microcode] " tip-bot for Boris Ostrovsky
  2016-02-16  8:43 ` [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2016-02-16  8:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

From: Boris Ostrovsky <boris.ostrovsky@oracle.com>

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.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: david.vrabel@citrix.com
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: konrad.wilk@oracle.com
Cc: mingo@redhat.com
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/1455203598-14378-1-git-send-email-boris.ostrovsky@oracle.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index faec7120c508..86ec92a0bbbe 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -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)
-- 
2.3.5

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

* [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation
  2016-02-16  8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
  2016-02-16  8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
@ 2016-02-16  8:43 ` Borislav Petkov
  2016-02-17 12:12   ` [tip:x86/microcode] " tip-bot for Andrzej Hajda
  2016-02-16  8:43 ` [PATCH 3/4] ftrace: Kill ftrace_caller_end label Borislav Petkov
  2016-02-16  8:43 ` [PATCH 4/4] x86/msr: Document msr-index.h rule for addition Borislav Petkov
  3 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2016-02-16  8:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

From: Andrzej Hajda <a.hajda@samsung.com>

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1439201994-28067-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/microcode/amd.c   | 4 +---
 arch/x86/kernel/cpu/microcode/intel.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 2233f8a76615..34b391bb71c5 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -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;
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index ee81c544ee0d..b7efe1f02f01 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -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);
 	}
 
 	/*
-- 
2.3.5

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

* [PATCH 3/4] ftrace: Kill ftrace_caller_end label
  2016-02-16  8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
  2016-02-16  8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
  2016-02-16  8:43 ` [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
@ 2016-02-16  8:43 ` Borislav Petkov
  2016-02-17 12:13   ` [tip:x86/asm] x86/ftrace, x86/asm: " tip-bot for Borislav Petkov
  2016-02-16  8:43 ` [PATCH 4/4] x86/msr: Document msr-index.h rule for addition Borislav Petkov
  3 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2016-02-16  8:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

From: Borislav Petkov <bp@suse.de>

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.

Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/1450109314-20323-1-git-send-email-bp@alien8.de
---
 arch/x86/kernel/ftrace.c    | 11 +++++------
 arch/x86/kernel/mcount_64.S | 14 ++++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 29408d6d6626..04f9641e0cb6 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -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);
 
 	/*
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index 87e1762e2bca..ed48a9f465f8 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -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)
 
-- 
2.3.5

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

* [PATCH 4/4] x86/msr: Document msr-index.h rule for addition
  2016-02-16  8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
                   ` (2 preceding siblings ...)
  2016-02-16  8:43 ` [PATCH 3/4] ftrace: Kill ftrace_caller_end label Borislav Petkov
@ 2016-02-16  8:43 ` Borislav Petkov
  2016-02-17 12:13   ` [tip:x86/asm] " tip-bot for Borislav Petkov
  3 siblings, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2016-02-16  8:43 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

From: Borislav Petkov <bp@suse.de>

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.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: alex.williamson@redhat.com
Cc: gleb@kernel.org
Cc: joro@8bytes.org
Cc: kvm@vger.kernel.org
CC: Paolo Bonzini <pbonzini@redhat.com>
Cc: sherry.hurwitz@amd.com
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: wei@redhat.com
Cc: x86-ml <x86@kernel.org>
---
 arch/x86/include/asm/msr-index.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index b05402ef3b84..984ab75bf621 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -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 */
-- 
2.3.5

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

* [tip:x86/microcode] x86/microcode: Remove unnecessary paravirt_enabled check
  2016-02-16  8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
@ 2016-02-17 12:12   ` tip-bot for Boris Ostrovsky
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Boris Ostrovsky @ 2016-02-17 12:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, mingo, boris.ostrovsky, linux-kernel, peterz, torvalds, hpa, tglx

Commit-ID:  84aba677f009e20185aea322563389ad56e0ef7e
Gitweb:     http://git.kernel.org/tip/84aba677f009e20185aea322563389ad56e0ef7e
Author:     Boris Ostrovsky <boris.ostrovsky@oracle.com>
AuthorDate: Tue, 16 Feb 2016 09:43:19 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: david.vrabel@citrix.com
Cc: konrad.wilk@oracle.com
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/1455612202-14414-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index cea8552..ac360bf 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -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)

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

* [tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
  2016-02-16  8:43 ` [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
@ 2016-02-17 12:12   ` tip-bot for Andrzej Hajda
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Andrzej Hajda @ 2016-02-17 12:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: b.zolnierkie, peterz, torvalds, hpa, a.hajda, bp, tglx,
	m.szyprowski, mingo, linux-kernel

Commit-ID:  9cc6f743c7724eb9abaf27904194c169db85dd31
Gitweb:     http://git.kernel.org/tip/9cc6f743c7724eb9abaf27904194c169db85dd31
Author:     Andrzej Hajda <a.hajda@samsung.com>
AuthorDate: Tue, 16 Feb 2016 09:43:20 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1455612202-14414-3-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/microcode/amd.c   | 4 +---
 arch/x86/kernel/cpu/microcode/intel.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index f66cbfe..e397fc1 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -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;
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index cb397947..cbb3cf0 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -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);
 	}
 
 	/*

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

* [tip:x86/asm] x86/ftrace, x86/asm: Kill ftrace_caller_end label
  2016-02-16  8:43 ` [PATCH 3/4] ftrace: Kill ftrace_caller_end label Borislav Petkov
@ 2016-02-17 12:13   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Borislav Petkov @ 2016-02-17 12:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, bp, dvlasenk, brgerst, bp, hpa, rostedt, luto, mingo,
	torvalds, tglx, linux-kernel

Commit-ID:  f1b92bb6b5a4e17b508f128b084fa00e0eda590c
Gitweb:     http://git.kernel.org/tip/f1b92bb6b5a4e17b508f128b084fa00e0eda590c
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Tue, 16 Feb 2016 09:43:21 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1455612202-14414-4-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/ftrace.c    | 11 +++++------
 arch/x86/kernel/mcount_64.S | 14 ++++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 29408d6..04f9641e 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -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);
 
 	/*
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index 87e1762..ed48a9f 100644
--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -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)
 

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

* [tip:x86/asm] x86/msr: Document msr-index.h rule for addition
  2016-02-16  8:43 ` [PATCH 4/4] x86/msr: Document msr-index.h rule for addition Borislav Petkov
@ 2016-02-17 12:13   ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Borislav Petkov @ 2016-02-17 12:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, luto, pbonzini, hpa, tglx, brgerst, torvalds, bp, dvlasenk,
	linux-kernel, mingo, Suravee.Suthikulpanit, peterz

Commit-ID:  053080a9d1c8cf1950115ad92ce94242ebc5f25c
Gitweb:     http://git.kernel.org/tip/053080a9d1c8cf1950115ad92ce94242ebc5f25c
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Tue, 16 Feb 2016 09:43:22 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: alex.williamson@redhat.com
Cc: gleb@kernel.org
Cc: joro@8bytes.org
Cc: kvm@vger.kernel.org
Cc: sherry.hurwitz@amd.com
Cc: wei@redhat.com
Link: http://lkml.kernel.org/r/1455612202-14414-5-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/msr-index.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index b05402e..984ab75 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -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 */

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

end of thread, other threads:[~2016-02-17 12:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16  8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
2016-02-16  8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
2016-02-17 12:12   ` [tip:x86/microcode] " tip-bot for Boris Ostrovsky
2016-02-16  8:43 ` [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
2016-02-17 12:12   ` [tip:x86/microcode] " tip-bot for Andrzej Hajda
2016-02-16  8:43 ` [PATCH 3/4] ftrace: Kill ftrace_caller_end label Borislav Petkov
2016-02-17 12:13   ` [tip:x86/asm] x86/ftrace, x86/asm: " tip-bot for Borislav Petkov
2016-02-16  8:43 ` [PATCH 4/4] x86/msr: Document msr-index.h rule for addition Borislav Petkov
2016-02-17 12:13   ` [tip:x86/asm] " tip-bot for Borislav Petkov

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.