lkml.org 
[lkml]   [2011]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: code sections beyond .text skipped from alternatives_smp_module_add
From
On Tue, Jun 21, 2011 at 1:10 AM, Deep Debroy <ddebroy@gmail.com> wrote:
> In x86-64, I am running into a scenario with certain kernel modules
> where the patching of lock prefix instructions in sections other than
> .text (e.g. .exit.text) is not occurring even though the .smp_locks
> relocations in the .ko file specify instructions in sections other
> than .text for patching. For example (down in the bottom), in
> net/bluetooth/rfcomm.ko, we have a couple of entries in .exit.text for
> patching. However, when I look in the memory page containing the
> .exit.text section in a uni processor system, it doesn't appear the
> lock prefix instructions in .exit.text were patched with NOPs the same
> way other instructions from the .text section in the same page
> underwent patching. This creates a subtle inconsistency where a page
> contains the end of the .text section along with the .exit.text
> section - lock prefixes in instructions from the former section gets
> patched per .smp_locks entries while that doesn't happen for the
> latter within the same page.
>
> Looking at the code, in module_finalize for x86, only .text seems to
> be getting picked for the patching of lock prefixes while other
> sections such as .exit.text or .init.text are not. Is there a reason
> we skip the other *.text code sections from the lock patches? Would
> making the application of the patching of lock prefixes generic across
> all code sections (rather than just .text) make sense?
>
> Thanks,
> Deep
>
>            for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
>                    if (!strcmp(".text", secstrings + s->sh_name))
>                            text = s;
>                    ...
>                    if (!strcmp(".smp_locks", secstrings + s->sh_name))
>                            locks = s;
>                    ...
>            }
>
>            if (locks && text) {
>                    void *lseg = (void *)locks->sh_addr;
>                    void *tseg = (void *)text->sh_addr;
>                    alternatives_smp_module_add(me, me->name,
>                                                lseg, lseg + locks->sh_size,
>                                                tseg, tseg + text->sh_size);
>            }
>
>
>
>> objdump -r kernel/net/bluetooth/rfcomm/rfcomm.ko
>
> RELOCATION RECORDS FOR [.smp_locks]:
> OFFSET           TYPE              VALUE
> 0000000000000000 R_X86_64_64       .text+0x00000000000000ac
> 0000000000000008 R_X86_64_64       .exit.text+0x0000000000000023
> 0000000000000010 R_X86_64_64       .exit.text+0x0000000000000034
> 0000000000000018 R_X86_64_64       .text+0x0000000000000619
> 0000000000000020 R_X86_64_64       .text+0x000000000000061d
>

+ Gerd Hoffmann who introduced the SMP patching code below back in Jan
2006 as part of 2.6.15.

Any comments on why patching of smp_lock prefixes should be restricted
to .text and not other *.text code sections?

Thanks,
Deep
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-06-21 20:11    [W:0.051 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site