[lkml]   [2011]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectcode sections beyond .text skipped from alternatives_smp_module_add
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?


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

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

 \ /
  Last update: 2011-06-21 10:13    [W:1.087 / U:2.360 seconds]
©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site