linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Mihaela Grigore" <grigore.mihaela@gmail.com>
To: "Michael Neuling" <mikey@neuling.org>, linuxppc-dev@ozlabs.org
Subject: Re: self-modifying code in 2.6 kernel for ppc writes into readonly section
Date: Mon, 18 Aug 2008 22:57:58 +0300	[thread overview]
Message-ID: <78ef7ce10808181257u637c5597xaa992b9e4e7a0925@mail.gmail.com> (raw)
In-Reply-To: <1586.1219087193@neuling.org>

The mmu is still disabled at this point.

What is marked as readonly is the text section of the vmlinux file
generated when compiling the kernel. And since the code tries to write
to the text section, I assumed it was the reason for the segmentation
fault.

I'm not sure how this is dealt with on real hardware.

Can somebody please explain how is it supposed to work ? Is it ok to
write to text section that you load on real hardware as readonly ?
(again, no mmu involved, as it is still turned off, so i'm not sure
who's guarding this section against writing)

On Mon, Aug 18, 2008 at 10:19 PM, Michael Neuling <mikey@neuling.org> wrote:
> In message <78ef7ce10808180901v6c694e63xefc37dd97485533@mail.gmail.com> you wrote:
>> Hello,
>>
>> First, I'm talkin about the 2.6.11 version. I know arch/ppc is gone in
>> latest versions,
>> but i assume the code is still the same and just moved to powerpc.
>>
>> There is a piece of code in the early initialization of the 2.6 kernel
>> that identifies the cpu type and then tries to eliminate code that
>> does not apply to the current cpu. This is done by writing nop's over
>> sections of code that are not needed (do_cpu_ftr_fixups in
>> arch/ppc/kernel/misc.S)
>>
>> When I try to run the kernel in a ppc emulator, I get a segmentation
>> fault in do_cpu_ftr_fixups. From examining the section headers of the
>> vmlinux, the text section is marked as readonly. The piece of code
>> above mentioned is trying to write a nop to memory location inside the
>> text section which is readonly, so that explains the sigsegv  error.
>
> Any segv in the emulator sounds like a bug in the emulator.
>
> If the page really is marked read only, then writing to it should cause
> a page fault.
>
>> Since the kernel does run on boards with ppc cpu's, can somebody
>> explain how come this is actually working ? Or if/where I am mistaking
>> with my assumptions ?
>>
>> Thank you
>>
>> P.S. please add me in cc in a reply to this message
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>>
>

  reply	other threads:[~2008-08-18 19:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 16:01 self-modifying code in 2.6 kernel for ppc writes into readonly section Mihaela Grigore
2008-08-18 19:19 ` Michael Neuling
2008-08-18 19:57   ` Mihaela Grigore [this message]
2008-08-18 20:51     ` Michael Neuling
2008-08-18 21:25       ` Becky Bruce
2008-08-18 22:07         ` Mihaela Grigore
2008-08-18 23:33           ` Michael Neuling
     [not found]       ` <78ef7ce10808181427m507434f4we84d507b090a707b@mail.gmail.com>
2008-08-18 22:09         ` Michael Neuling
2008-08-18 22:13           ` Scott Wood
2008-08-18 22:18             ` Michael Neuling

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=78ef7ce10808181257u637c5597xaa992b9e4e7a0925@mail.gmail.com \
    --to=grigore.mihaela@gmail.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.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).