diff mbox

[0/5] Live patching for powerpc

Message ID 20160414152029.GA24525@lst.de (mailing list archive)
State Not Applicable
Headers show

Commit Message

Torsten Duwe April 14, 2016, 3:20 p.m. UTC
On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote:
> On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote:
> 
> > FTR: then I still have a few ppc64 hunks floating around to support certain consistency
> > models...
> 
> OK. I'm not quite sure what you mean but post them and we'll see I guess :)

It's *roughly* the ppc64 equivalent of Josh Poimboeuf's Mar 25
| [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel
which only considers x86.

It's forward ported from an earlier code base; there's some glue missing,
but here it is, for reference.

Signed-off-by: Torsten Duwe <duwe@suse.de>

Comments

Josh Poimboeuf April 14, 2016, 4:41 p.m. UTC | #1
On Thu, Apr 14, 2016 at 05:20:29PM +0200, Torsten Duwe wrote:
> On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote:
> > On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote:
> > 
> > > FTR: then I still have a few ppc64 hunks floating around to support certain consistency
> > > models...
> > 
> > OK. I'm not quite sure what you mean but post them and we'll see I guess :)
> 
> It's *roughly* the ppc64 equivalent of Josh Poimboeuf's Mar 25
> | [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel
> which only considers x86.
> 
> It's forward ported from an earlier code base; there's some glue missing,
> but here it is, for reference.
> 
> Signed-off-by: Torsten Duwe <duwe@suse.de>

Hi Torsten,

Thanks for sharing.  This is quite fortuitous as Miroslav just today
mentioned to me that we would need something like this.  If you don't
mind, I may pull this patch or some variant of it into v2 of the
consistency model.

> 
> 
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index b034ecd..3e749f4 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -92,6 +92,7 @@ static inline struct thread_info *current_thread_info(void)
>  					   TIF_NEED_RESCHED */
>  #define TIF_32BIT		4	/* 32 bit binary */
>  #define TIF_RESTORE_TM		5	/* need to restore TM FP/VEC/VSX */
> +#define TIF_KLP_NEED_UPDATE	6	/* kGraft patching in progress */
>  #define TIF_SYSCALL_AUDIT	7	/* syscall auditing active */
>  #define TIF_SINGLESTEP		8	/* singlestepping active */
>  #define TIF_NOHZ		9	/* in adaptive nohz mode */
> @@ -115,8 +116,10 @@ static inline struct thread_info *current_thread_info(void)
>  #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
>  #define _TIF_32BIT		(1<<TIF_32BIT)
>  #define _TIF_RESTORE_TM		(1<<TIF_RESTORE_TM)
> +#define _TIF_KLP_NEED_UPDATE	(1<<TIF_KLP_NEED_UPDATE)
>  #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
>  #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
> +#define _TIF_NOHZ		(1<<TIF_NOHZ)
>  #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
>  #define _TIF_RESTOREALL		(1<<TIF_RESTOREALL)
>  #define _TIF_NOERROR		(1<<TIF_NOERROR)
> @@ -124,7 +127,7 @@ static inline struct thread_info *current_thread_info(void)
>  #define _TIF_UPROBE		(1<<TIF_UPROBE)
>  #define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
>  #define _TIF_EMULATE_STACK_STORE	(1<<TIF_EMULATE_STACK_STORE)
> -#define _TIF_NOHZ		(1<<TIF_NOHZ)
> +
>  #define _TIF_SYSCALL_DOTRACE	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
>  				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
>  				 _TIF_NOHZ)
> @@ -132,7 +135,8 @@ static inline struct thread_info *current_thread_info(void)
>  #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
>  				 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
>  				 _TIF_RESTORE_TM)
> -#define _TIF_PERSYSCALL_MASK	(_TIF_RESTOREALL|_TIF_NOERROR)
> +
> +#define _TIF_PERSYSCALL_MASK	(_TIF_RESTOREALL|_TIF_NOERROR|_TIF_KLP_NEED_UPDATE)
>  
>  /* Bits in local_flags */
>  /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index 5bbd1bc..17f8a18 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -151,8 +151,8 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
>  
>  	CURRENT_THREAD_INFO(r11, r1)
>  	ld	r10,TI_FLAGS(r11)
> -	andi.	r11,r10,_TIF_SYSCALL_DOTRACE
> -	bne	syscall_dotrace		/* does not return */
> +	andi.	r10,r10,(_TIF_SYSCALL_DOTRACE|_TIF_KLP_NEED_UPDATE)
> +	bne-	syscall_precall		/* does not return */
>  	cmpldi	0,r0,NR_syscalls
>  	bge-	syscall_enosys
>  
> @@ -245,6 +245,17 @@ syscall_error:
>  	neg	r3,r3
>  	std	r5,_CCR(r1)
>  	b	.Lsyscall_error_cont
> +
> +syscall_precall:
> +	andi.	r10,r10,(_TIF_KLP_NEED_UPDATE)
> +	beq+	syscall_dotrace
> +
> +	addi	r11,r11,TI_FLAGS
> +1:	ldarx	r12,0,r11
> +	andc	r12,r12,r10
> +	stdcx.	r12,0,r11
> +	bne-	1b
> +	subi	r11,r11,TI_FLAGS
>  	
>  /* Traced system call support */
>  syscall_dotrace:
Michael Ellerman April 15, 2016, 11:22 a.m. UTC | #2
On Thu, 2016-04-14 at 11:41 -0500, Josh Poimboeuf wrote:
> On Thu, Apr 14, 2016 at 05:20:29PM +0200, Torsten Duwe wrote:
> > On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote:
> > > On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote:
> > > > FTR: then I still have a few ppc64 hunks floating around to support certain consistency
> > > > models...
> > > 
> > > OK. I'm not quite sure what you mean but post them and we'll see I guess :)
> > 
> > It's *roughly* the ppc64 equivalent of Josh Poimboeuf's Mar 25

> > > [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel
> > which only considers x86.
> > 
> > It's forward ported from an earlier code base; there's some glue missing,
> > but here it is, for reference.
> > 
> > Signed-off-by: Torsten Duwe <duwe@suse.de>
> 
> Hi Torsten,
> 
> Thanks for sharing.  This is quite fortuitous as Miroslav just today
> mentioned to me that we would need something like this.  If you don't
> mind, I may pull this patch or some variant of it into v2 of the
> consistency model.
 
Well please wait for me to review & ack it before you pull it into anything
permanent.

At a quick glance it seems OK but I'd probably do it a little differently. I'll
try and have a closer look next week.

cheers
Josh Poimboeuf April 15, 2016, 12:59 p.m. UTC | #3
On Fri, Apr 15, 2016 at 09:22:49PM +1000, Michael Ellerman wrote:
> On Thu, 2016-04-14 at 11:41 -0500, Josh Poimboeuf wrote:
> > On Thu, Apr 14, 2016 at 05:20:29PM +0200, Torsten Duwe wrote:
> > > On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote:
> > > > On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote:
> > > > > FTR: then I still have a few ppc64 hunks floating around to support certain consistency
> > > > > models...
> > > > 
> > > > OK. I'm not quite sure what you mean but post them and we'll see I guess :)
> > > 
> > > It's *roughly* the ppc64 equivalent of Josh Poimboeuf's Mar 25
> 
> > > > [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel
> > > which only considers x86.
> > > 
> > > It's forward ported from an earlier code base; there's some glue missing,
> > > but here it is, for reference.
> > > 
> > > Signed-off-by: Torsten Duwe <duwe@suse.de>
> > 
> > Hi Torsten,
> > 
> > Thanks for sharing.  This is quite fortuitous as Miroslav just today
> > mentioned to me that we would need something like this.  If you don't
> > mind, I may pull this patch or some variant of it into v2 of the
> > consistency model.
>  
> Well please wait for me to review & ack it before you pull it into anything
> permanent.
> 
> At a quick glance it seems OK but I'd probably do it a little differently. I'll
> try and have a closer look next week.

Sure, no problem.  The consistency model patches are still in
development so they won't be merged anytime soon.  And we wouldn't merge
any powerpc code without maintainer acks anyway.  I'm just glad you guys
are looking at it so I don't have to butcher it ;-)
Michael Ellerman April 15, 2016, 1:21 p.m. UTC | #4
On Fri, 2016-04-15 at 07:59 -0500, Josh Poimboeuf wrote:
> On Fri, Apr 15, 2016 at 09:22:49PM +1000, Michael Ellerman wrote:
> > On Thu, 2016-04-14 at 11:41 -0500, Josh Poimboeuf wrote:
> > > On Thu, Apr 14, 2016 at 05:20:29PM +0200, Torsten Duwe wrote:
> > > > On Thu, Apr 14, 2016 at 11:08:02PM +1000, Michael Ellerman wrote:
> > > > > On Thu, 2016-04-14 at 14:57 +0200, Torsten Duwe wrote:
> > > > > > FTR: then I still have a few ppc64 hunks floating around to support certain consistency
> > > > > > models...
> > > > > 
> > > > > OK. I'm not quite sure what you mean but post them and we'll see I guess :)
> > > > 
> > > > It's *roughly* the ppc64 equivalent of Josh Poimboeuf's Mar 25
> > > > > [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel
> > > > which only considers x86.
> > > > 
> > > > It's forward ported from an earlier code base; there's some glue missing,
> > > > but here it is, for reference.
> > > > 
> > > > Signed-off-by: Torsten Duwe <duwe@suse.de>
> > > 
> > > Hi Torsten,
> > > 
> > > Thanks for sharing.  This is quite fortuitous as Miroslav just today
> > > mentioned to me that we would need something like this.  If you don't
> > > mind, I may pull this patch or some variant of it into v2 of the
> > > consistency model.
> >  
> > Well please wait for me to review & ack it before you pull it into anything
> > permanent.
> > 
> > At a quick glance it seems OK but I'd probably do it a little differently. I'll
> > try and have a closer look next week.
> 
> Sure, no problem.  The consistency model patches are still in
> development so they won't be merged anytime soon.  And we wouldn't merge
> any powerpc code without maintainer acks anyway.  I'm just glad you guys
> are looking at it so I don't have to butcher it ;-)

I'm paid to butcher it ;)

cheers
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index b034ecd..3e749f4 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -92,6 +92,7 @@  static inline struct thread_info *current_thread_info(void)
 					   TIF_NEED_RESCHED */
 #define TIF_32BIT		4	/* 32 bit binary */
 #define TIF_RESTORE_TM		5	/* need to restore TM FP/VEC/VSX */
+#define TIF_KLP_NEED_UPDATE	6	/* kGraft patching in progress */
 #define TIF_SYSCALL_AUDIT	7	/* syscall auditing active */
 #define TIF_SINGLESTEP		8	/* singlestepping active */
 #define TIF_NOHZ		9	/* in adaptive nohz mode */
@@ -115,8 +116,10 @@  static inline struct thread_info *current_thread_info(void)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 #define _TIF_32BIT		(1<<TIF_32BIT)
 #define _TIF_RESTORE_TM		(1<<TIF_RESTORE_TM)
+#define _TIF_KLP_NEED_UPDATE	(1<<TIF_KLP_NEED_UPDATE)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
+#define _TIF_NOHZ		(1<<TIF_NOHZ)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_RESTOREALL		(1<<TIF_RESTOREALL)
 #define _TIF_NOERROR		(1<<TIF_NOERROR)
@@ -124,7 +127,7 @@  static inline struct thread_info *current_thread_info(void)
 #define _TIF_UPROBE		(1<<TIF_UPROBE)
 #define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_EMULATE_STACK_STORE	(1<<TIF_EMULATE_STACK_STORE)
-#define _TIF_NOHZ		(1<<TIF_NOHZ)
+
 #define _TIF_SYSCALL_DOTRACE	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
 				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
 				 _TIF_NOHZ)
@@ -132,7 +135,8 @@  static inline struct thread_info *current_thread_info(void)
 #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 				 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
 				 _TIF_RESTORE_TM)
-#define _TIF_PERSYSCALL_MASK	(_TIF_RESTOREALL|_TIF_NOERROR)
+
+#define _TIF_PERSYSCALL_MASK	(_TIF_RESTOREALL|_TIF_NOERROR|_TIF_KLP_NEED_UPDATE)
 
 /* Bits in local_flags */
 /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 5bbd1bc..17f8a18 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -151,8 +151,8 @@  END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 
 	CURRENT_THREAD_INFO(r11, r1)
 	ld	r10,TI_FLAGS(r11)
-	andi.	r11,r10,_TIF_SYSCALL_DOTRACE
-	bne	syscall_dotrace		/* does not return */
+	andi.	r10,r10,(_TIF_SYSCALL_DOTRACE|_TIF_KLP_NEED_UPDATE)
+	bne-	syscall_precall		/* does not return */
 	cmpldi	0,r0,NR_syscalls
 	bge-	syscall_enosys
 
@@ -245,6 +245,17 @@  syscall_error:
 	neg	r3,r3
 	std	r5,_CCR(r1)
 	b	.Lsyscall_error_cont
+
+syscall_precall:
+	andi.	r10,r10,(_TIF_KLP_NEED_UPDATE)
+	beq+	syscall_dotrace
+
+	addi	r11,r11,TI_FLAGS
+1:	ldarx	r12,0,r11
+	andc	r12,r12,r10
+	stdcx.	r12,0,r11
+	bne-	1b
+	subi	r11,r11,TI_FLAGS
 	
 /* Traced system call support */
 syscall_dotrace: