linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Jessica Yu <jeyu@redhat.com>, Jiri Kosina <jikos@kernel.org>,
	Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>
Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	x86@kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, Vojtech Pavlik <vojtech@suse.com>,
	Jiri Slaby <jslaby@suse.cz>,
	Chris J Arges <chris.j.arges@canonical.com>,
	Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
	Balbir Singh <bsingharora@gmail.com>
Subject: [PATCH v5 04/15] livepatch/x86: add TIF_PATCH_PENDING thread flag
Date: Mon, 13 Feb 2017 19:42:31 -0600	[thread overview]
Message-ID: <dc5ea01305bfe3baae37b9c08b9daeec7fae9ee6.1487036215.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1487036215.git.jpoimboe@redhat.com>

Add the TIF_PATCH_PENDING thread flag to enable the new livepatch
per-task consistency model for x86_64.  The bit getting set indicates
the thread has a pending patch which needs to be applied when the thread
exits the kernel.

The bit is placed in the _TIF_ALLWORK_MASK macro, which results in
exit_to_usermode_loop() calling klp_update_patch_state() when it's set.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
---
 arch/x86/entry/common.c            | 9 ++++++---
 arch/x86/include/asm/thread_info.h | 4 +++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index b83c61c..6a9d564 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -21,6 +21,7 @@
 #include <linux/context_tracking.h>
 #include <linux/user-return-notifier.h>
 #include <linux/uprobes.h>
+#include <linux/livepatch.h>
 
 #include <asm/desc.h>
 #include <asm/traps.h>
@@ -129,14 +130,13 @@ static long syscall_trace_enter(struct pt_regs *regs)
 
 #define EXIT_TO_USERMODE_LOOP_FLAGS				\
 	(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE |	\
-	 _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY)
+	 _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY | _TIF_PATCH_PENDING)
 
 static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags)
 {
 	/*
 	 * In order to return to user mode, we need to have IRQs off with
-	 * none of _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_USER_RETURN_NOTIFY,
-	 * _TIF_UPROBE, or _TIF_NEED_RESCHED set.  Several of these flags
+	 * none of EXIT_TO_USERMODE_LOOP_FLAGS set.  Several of these flags
 	 * can be set at any time on preemptable kernels if we have IRQs on,
 	 * so we need to loop.  Disabling preemption wouldn't help: doing the
 	 * work to clear some of the flags can sleep.
@@ -163,6 +163,9 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags)
 		if (cached_flags & _TIF_USER_RETURN_NOTIFY)
 			fire_user_return_notifiers();
 
+		if (cached_flags & _TIF_PATCH_PENDING)
+			klp_update_patch_state(current);
+
 		/* Disable IRQs and retry */
 		local_irq_disable();
 
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index 207d0d9..83372dc 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -84,6 +84,7 @@ struct thread_info {
 #define TIF_SECCOMP		8	/* secure computing */
 #define TIF_USER_RETURN_NOTIFY	11	/* notify kernel of userspace return */
 #define TIF_UPROBE		12	/* breakpointed or singlestepping */
+#define TIF_PATCH_PENDING	13	/* pending live patching update */
 #define TIF_NOTSC		16	/* TSC is not accessible in userland */
 #define TIF_IA32		17	/* IA32 compatibility process */
 #define TIF_NOHZ		19	/* in adaptive nohz mode */
@@ -107,6 +108,7 @@ struct thread_info {
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
 #define _TIF_USER_RETURN_NOTIFY	(1 << TIF_USER_RETURN_NOTIFY)
 #define _TIF_UPROBE		(1 << TIF_UPROBE)
+#define _TIF_PATCH_PENDING	(1 << TIF_PATCH_PENDING)
 #define _TIF_NOTSC		(1 << TIF_NOTSC)
 #define _TIF_IA32		(1 << TIF_IA32)
 #define _TIF_NOHZ		(1 << TIF_NOHZ)
@@ -133,7 +135,7 @@ struct thread_info {
 	(_TIF_SYSCALL_TRACE | _TIF_NOTIFY_RESUME | _TIF_SIGPENDING |	\
 	 _TIF_NEED_RESCHED | _TIF_SINGLESTEP | _TIF_SYSCALL_EMU |	\
 	 _TIF_SYSCALL_AUDIT | _TIF_USER_RETURN_NOTIFY | _TIF_UPROBE |	\
-	 _TIF_NOHZ | _TIF_SYSCALL_TRACEPOINT)
+	 _TIF_PATCH_PENDING | _TIF_NOHZ | _TIF_SYSCALL_TRACEPOINT)
 
 /* flags to check in __switch_to() */
 #define _TIF_WORK_CTXSW							\
-- 
2.7.4

  parent reply	other threads:[~2017-02-14  1:43 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14  1:42 [PATCH v5 00/15] livepatch: hybrid consistency model Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 01/15] stacktrace/x86: add function for detecting reliable stack traces Josh Poimboeuf
2017-02-15 12:18   ` Miroslav Benes
2017-02-15 14:40     ` Josh Poimboeuf
2017-03-07  6:50   ` Balbir Singh
2017-03-07 16:12     ` Josh Poimboeuf
2017-03-08  9:47       ` Balbir Singh
2017-04-10 15:40   ` Petr Mladek
2017-02-14  1:42 ` [PATCH v5 02/15] x86/entry: define _TIF_ALLWORK_MASK flags explicitly Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 03/15] livepatch: create temporary klp_update_patch_state() stub Josh Poimboeuf
2017-02-14  1:42 ` Josh Poimboeuf [this message]
2017-02-14  1:42 ` [PATCH v5 05/15] livepatch/powerpc: add TIF_PATCH_PENDING thread flag Josh Poimboeuf
2017-03-07  6:46   ` Balbir Singh
2017-03-08  4:02   ` Michael Ellerman
2017-02-14  1:42 ` [PATCH v5 06/15] livepatch/s390: reorganize TIF thread flag bits Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 07/15] livepatch/s390: add TIF_PATCH_PENDING thread flag Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 08/15] livepatch: separate enabled and patched states Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 09/15] livepatch: remove unnecessary object loaded check Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 10/15] livepatch: move patching functions into patch.c Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 11/15] livepatch: use kstrtobool() in enabled_store() Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 12/15] livepatch: store function sizes Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 13/15] livepatch: change to a per-task consistency model Josh Poimboeuf
2017-02-16 14:33   ` Miroslav Benes
2017-02-16 20:31     ` Josh Poimboeuf
2017-02-17  8:51       ` Miroslav Benes
2017-02-21 21:21         ` Josh Poimboeuf
2017-02-22  9:03           ` Miroslav Benes
2017-03-07 14:16   ` Miroslav Benes
2017-04-11 12:35   ` Petr Mladek
2018-01-25  9:04   ` Peter Zijlstra
2018-01-25 10:24     ` Petr Mladek
2018-01-25 10:38       ` Peter Zijlstra
2018-01-25 12:13         ` Petr Mladek
2018-01-25 12:44           ` Peter Zijlstra
2017-02-14  1:42 ` [PATCH v5 14/15] livepatch: add /proc/<pid>/patch_state Josh Poimboeuf
2017-02-14  1:42 ` [PATCH v5 15/15] livepatch: allow removal of a disabled patch Josh Poimboeuf
2017-03-06 17:20   ` [PATCH v5.1 " Josh Poimboeuf
2017-03-07 14:50     ` Miroslav Benes
2017-02-17  8:55 ` [PATCH v5 00/15] livepatch: hybrid consistency model Miroslav Benes
2017-03-07  8:53 ` Ingo Molnar
2017-03-08  9:06 ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc5ea01305bfe3baae37b9c08b9daeec7fae9ee6.1487036215.git.jpoimboe@redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=bsingharora@gmail.com \
    --cc=chris.j.arges@canonical.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jeyu@redhat.com \
    --cc=jikos@kernel.org \
    --cc=jslaby@suse.cz \
    --cc=kamalesh@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=live-patching@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=vojtech@suse.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).