Re: new text patching for review

2007-08-10 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: > > Hallo, > > I had some second thoughts about the text patching of DEBUG_RODATA kernels > using change_page_attr(). Change_page_attr is intrusive and slow and using > a separate mapping is a little more gentle. I came up with this patch. > For your

Re: new text patching for review

2007-08-10 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: Hallo, I had some second thoughts about the text patching of DEBUG_RODATA kernels using change_page_attr(). Change_page_attr is intrusive and slow and using a separate mapping is a little more gentle. I came up with this patch. For your review and

Re: new text patching for review

2007-07-21 Thread Andi Kleen
On Fri, Jul 20, 2007 at 11:17:49AM -0400, Mathieu Desnoyers wrote: > * Zachary Amsden ([EMAIL PROTECTED]) wrote: > > Mathieu Desnoyers wrote: > > >Yes, kprobes is case 1: atomic update. And we don't even have to bother > > >about Intel's erratum. This one is ok. That's mainly the > >

Re: new text patching for review

2007-07-21 Thread Andi Kleen
On Fri, Jul 20, 2007 at 11:17:49AM -0400, Mathieu Desnoyers wrote: * Zachary Amsden ([EMAIL PROTECTED]) wrote: Mathieu Desnoyers wrote: Yes, kprobes is case 1: atomic update. And we don't even have to bother about Intel's erratum. This one is ok. That's mainly the alternatives/paravirt

Re: new text patching for review

2007-07-20 Thread Mathieu Desnoyers
* Zachary Amsden ([EMAIL PROTECTED]) wrote: > Mathieu Desnoyers wrote: > >Yes, kprobes is case 1: atomic update. And we don't even have to bother > >about Intel's erratum. This one is ok. That's mainly the > >alternatives/paravirt code I worry about. > > > > Paravirt and alternatives should all

Re: new text patching for review

2007-07-20 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: > On Thu, Jul 19, 2007 at 07:49:12PM -0400, Mathieu Desnoyers wrote: > > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > > > > > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > > > > > > > > > >

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Thu, Jul 19, 2007 at 07:49:12PM -0400, Mathieu Desnoyers wrote: > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > > > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > > > > > > > > Ewww you plan to run this in SMP ? So you actually go

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Friday 20 July 2007 02:37:20 Zachary Amsden wrote: > Andi Kleen wrote: > > + *addr = opcode; > > + /* Not strictly needed, but can speed CPU recovery up */ > > + if (cpu_has_clflush) > > + asm("clflush (%0) " :: "r" (addr) : "memory"); > > + if (addr != oaddr) > > +

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Thu, Jul 19, 2007 at 06:15:46PM -0700, Zachary Amsden wrote: > Mathieu Desnoyers wrote: > >Yes, kprobes is case 1: atomic update. And we don't even have to bother > >about Intel's erratum. This one is ok. That's mainly the > >alternatives/paravirt code I worry about. > > > > Paravirt and

Re: new text patching for review

2007-07-20 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: On Thu, Jul 19, 2007 at 07:49:12PM -0400, Mathieu Desnoyers wrote: * Andi Kleen ([EMAIL PROTECTED]) wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: * Andi Kleen ([EMAIL PROTECTED]) wrote: Ewww you plan to run this in

Re: new text patching for review

2007-07-20 Thread Mathieu Desnoyers
* Zachary Amsden ([EMAIL PROTECTED]) wrote: Mathieu Desnoyers wrote: Yes, kprobes is case 1: atomic update. And we don't even have to bother about Intel's erratum. This one is ok. That's mainly the alternatives/paravirt code I worry about. Paravirt and alternatives should all be ok

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Thu, Jul 19, 2007 at 06:15:46PM -0700, Zachary Amsden wrote: Mathieu Desnoyers wrote: Yes, kprobes is case 1: atomic update. And we don't even have to bother about Intel's erratum. This one is ok. That's mainly the alternatives/paravirt code I worry about. Paravirt and alternatives

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Friday 20 July 2007 02:37:20 Zachary Amsden wrote: Andi Kleen wrote: + *addr = opcode; + /* Not strictly needed, but can speed CPU recovery up */ + if (cpu_has_clflush) + asm(clflush (%0) :: r (addr) : memory); + if (addr != oaddr) + vunmap(addr);

Re: new text patching for review

2007-07-20 Thread Andi Kleen
On Thu, Jul 19, 2007 at 07:49:12PM -0400, Mathieu Desnoyers wrote: * Andi Kleen ([EMAIL PROTECTED]) wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: * Andi Kleen ([EMAIL PROTECTED]) wrote: Ewww you plan to run this in SMP ? So you actually go byte by byte

Re: new text patching for review

2007-07-19 Thread Zachary Amsden
Mathieu Desnoyers wrote: Yes, kprobes is case 1: atomic update. And we don't even have to bother about Intel's erratum. This one is ok. That's mainly the alternatives/paravirt code I worry about. Paravirt and alternatives should all be ok because they are done before SMP bringup and with

Re: new text patching for review

2007-07-19 Thread Zachary Amsden
Andi Kleen wrote: + *addr = opcode; + /* Not strictly needed, but can speed CPU recovery up */ + if (cpu_has_clflush) + asm("clflush (%0) " :: "r" (addr) : "memory"); + if (addr != oaddr) + vunmap(addr); clflush should take oaddr. If you

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > > > > > > Ewww you plan to run this in SMP ? So you actually go byte > > > > by byte changing pieces of instructions non atomically and doing > >

Re: [patches] new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: > On Thursday 19 July 2007 22:30:12 Jeremy Fitzhardinge wrote: > > Andi Kleen wrote: > > > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > > > >> I see that IRQs are disabled in alternative_instructions(), but it does > > >> not protect against NMIs,

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Jeremy Fitzhardinge ([EMAIL PROTECTED]) wrote: > Andi Kleen wrote: > > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > >> I see that IRQs are disabled in alternative_instructions(), but it does > >> not protect against NMIs, which could come at a very inappropriate > >> moment. MCE and

Re: [patches] new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: > Either not use any pvops or make sure all the pvops patching is atomic > on the local CPU. > Erk, not really keen on that. Sounds complicated, unless there's a nice general algorithm. > Ok you can avoid MCEs by not enabling them until after you patch (which I > think >

Re: [patches] new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 22:51:51 Jeremy Fitzhardinge wrote: > Andi Kleen wrote: > > Normally there are not that many NMIs or MCEs at boot, but it would > > be still good to avoid the very rare crash by auditing the code first > > [better than try to debug it on some production system later] > >

Re: [patches] new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: > Normally there are not that many NMIs or MCEs at boot, but it would > be still good to avoid the very rare crash by auditing the code first > [better than try to debug it on some production system later] > Auditing it for what? If we want to make patching safe against

Re: [patches] new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 22:30:12 Jeremy Fitzhardinge wrote: > Andi Kleen wrote: > > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > > > >> I see that IRQs are disabled in alternative_instructions(), but it does > >> not protect against NMIs, which could come at a very inappropriate > >>

Re: new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: > Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > >> I see that IRQs are disabled in alternative_instructions(), but it does >> not protect against NMIs, which could come at a very inappropriate >> moment. MCE and SMIs would potentially cause the same kind of trouble. >> >> So

Re: new text patching for review

2007-07-19 Thread Andi Kleen
Mathieu Desnoyers <[EMAIL PROTECTED]> writes: > * Andi Kleen ([EMAIL PROTECTED]) wrote: > > > > > Ewww you plan to run this in SMP ? So you actually go byte > > > by byte changing pieces of instructions non atomically and doing > > > non-Intel's errata friendly XMC. You are really

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: > > > Ewww you plan to run this in SMP ? So you actually go byte > > by byte changing pieces of instructions non atomically and doing > > non-Intel's errata friendly XMC. You are really looking for trouble > > there :) Two distinct errors can

Re: new text patching for review

2007-07-19 Thread Andi Kleen
> Ewww you plan to run this in SMP ? So you actually go byte > by byte changing pieces of instructions non atomically and doing > non-Intel's errata friendly XMC. You are really looking for trouble > there :) Two distinct errors can occur: In this case it is ok because this only

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
Hi Andi, * Andi Kleen ([EMAIL PROTECTED]) wrote: > > Hallo, > > I had some second thoughts about the text patching of DEBUG_RODATA kernels > using change_page_attr(). Change_page_attr is intrusive and slow and using > a separate mapping is a little more gentle. I came up with this patch. > For

Re: new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 14:25:59 Jan Beulich wrote: > I like this approach much better, just one small note (I think I > had the same mistake in my changes initially): > > >@@ -202,7 +209,7 @@ static void alternatives_smp_lock(u8 **s > > continue; > > if (*ptr >

Re: new text patching for review

2007-07-19 Thread Jan Beulich
I like this approach much better, just one small note (I think I had the same mistake in my changes initially): >@@ -202,7 +209,7 @@ static void alternatives_smp_lock(u8 **s > continue; > if (*ptr > text_end) > continue; >-

new text patching for review

2007-07-19 Thread Andi Kleen
Hallo, I had some second thoughts about the text patching of DEBUG_RODATA kernels using change_page_attr(). Change_page_attr is intrusive and slow and using a separate mapping is a little more gentle. I came up with this patch. For your review and testing pleasure. The main quirk is that it

new text patching for review

2007-07-19 Thread Andi Kleen
Hallo, I had some second thoughts about the text patching of DEBUG_RODATA kernels using change_page_attr(). Change_page_attr is intrusive and slow and using a separate mapping is a little more gentle. I came up with this patch. For your review and testing pleasure. The main quirk is that it

Re: new text patching for review

2007-07-19 Thread Jan Beulich
I like this approach much better, just one small note (I think I had the same mistake in my changes initially): @@ -202,7 +209,7 @@ static void alternatives_smp_lock(u8 **s continue; if (*ptr text_end) continue; - **ptr =

Re: new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 14:25:59 Jan Beulich wrote: I like this approach much better, just one small note (I think I had the same mistake in my changes initially): @@ -202,7 +209,7 @@ static void alternatives_smp_lock(u8 **s continue; if (*ptr text_end)

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
Hi Andi, * Andi Kleen ([EMAIL PROTECTED]) wrote: Hallo, I had some second thoughts about the text patching of DEBUG_RODATA kernels using change_page_attr(). Change_page_attr is intrusive and slow and using a separate mapping is a little more gentle. I came up with this patch. For your

Re: new text patching for review

2007-07-19 Thread Andi Kleen
Ewww you plan to run this in SMP ? So you actually go byte by byte changing pieces of instructions non atomically and doing non-Intel's errata friendly XMC. You are really looking for trouble there :) Two distinct errors can occur: In this case it is ok because this only happens

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: Ewww you plan to run this in SMP ? So you actually go byte by byte changing pieces of instructions non atomically and doing non-Intel's errata friendly XMC. You are really looking for trouble there :) Two distinct errors can occur:

Re: new text patching for review

2007-07-19 Thread Andi Kleen
Mathieu Desnoyers [EMAIL PROTECTED] writes: * Andi Kleen ([EMAIL PROTECTED]) wrote: Ewww you plan to run this in SMP ? So you actually go byte by byte changing pieces of instructions non atomically and doing non-Intel's errata friendly XMC. You are really looking for

Re: new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: I see that IRQs are disabled in alternative_instructions(), but it does not protect against NMIs, which could come at a very inappropriate moment. MCE and SMIs would potentially cause the same kind of trouble. So unless you

Re: [patches] new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 22:30:12 Jeremy Fitzhardinge wrote: Andi Kleen wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: I see that IRQs are disabled in alternative_instructions(), but it does not protect against NMIs, which could come at a very inappropriate moment. MCE and SMIs

Re: [patches] new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: Normally there are not that many NMIs or MCEs at boot, but it would be still good to avoid the very rare crash by auditing the code first [better than try to debug it on some production system later] Auditing it for what? If we want to make patching safe against NMI/MCE,

Re: [patches] new text patching for review

2007-07-19 Thread Andi Kleen
On Thursday 19 July 2007 22:51:51 Jeremy Fitzhardinge wrote: Andi Kleen wrote: Normally there are not that many NMIs or MCEs at boot, but it would be still good to avoid the very rare crash by auditing the code first [better than try to debug it on some production system later]

Re: [patches] new text patching for review

2007-07-19 Thread Jeremy Fitzhardinge
Andi Kleen wrote: Either not use any pvops or make sure all the pvops patching is atomic on the local CPU. Erk, not really keen on that. Sounds complicated, unless there's a nice general algorithm. Ok you can avoid MCEs by not enabling them until after you patch (which I think is the

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Jeremy Fitzhardinge ([EMAIL PROTECTED]) wrote: Andi Kleen wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: I see that IRQs are disabled in alternative_instructions(), but it does not protect against NMIs, which could come at a very inappropriate moment. MCE and SMIs would

Re: [patches] new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: On Thursday 19 July 2007 22:30:12 Jeremy Fitzhardinge wrote: Andi Kleen wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: I see that IRQs are disabled in alternative_instructions(), but it does not protect against NMIs, which could come at

Re: new text patching for review

2007-07-19 Thread Mathieu Desnoyers
* Andi Kleen ([EMAIL PROTECTED]) wrote: Mathieu Desnoyers [EMAIL PROTECTED] writes: * Andi Kleen ([EMAIL PROTECTED]) wrote: Ewww you plan to run this in SMP ? So you actually go byte by byte changing pieces of instructions non atomically and doing non-Intel's

Re: new text patching for review

2007-07-19 Thread Zachary Amsden
Andi Kleen wrote: + *addr = opcode; + /* Not strictly needed, but can speed CPU recovery up */ + if (cpu_has_clflush) + asm(clflush (%0) :: r (addr) : memory); + if (addr != oaddr) + vunmap(addr); clflush should take oaddr. If you had to

Re: new text patching for review

2007-07-19 Thread Zachary Amsden
Mathieu Desnoyers wrote: Yes, kprobes is case 1: atomic update. And we don't even have to bother about Intel's erratum. This one is ok. That's mainly the alternatives/paravirt code I worry about. Paravirt and alternatives should all be ok because they are done before SMP bringup and with