From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC V2] arm:consider THUMB and BE endian kernel build
Date: Mon, 18 May 2015 10:40:32 +0100 [thread overview]
Message-ID: <20150518094032.GR2067@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <5559966A.5010006@gmail.com>
On Mon, May 18, 2015 at 03:36:10PM +0800, yalin wang wrote:
> this patch fix the function in kernel_thread(),
> when kernel is build as THUMB2 or BE8 endian, we should
> also set the correct bit in CPSR, so that kernel can return to
> the correct state to execute.
Why do you think any of this is needed?
When a kernel thread is created via kernel_thread(), copy_thread() is
called with the function pointer in stack_start, and the functions
argument in stk_size.
When the scheduler switches to the thread, it reads the register state
from thread->cpu_context, thereby loading r4 and r5 with the function
argument and function pointer, and directing the PC to ret_from_fork.
(For normal user clones and forks, r4 and r5 in kernel space will be
zero.)
The scheduler switch preserves the CPSR from the previous task, so if
we're running a T2 BE8 kernel, the new thread will have its ret_from_fork
called in T2 BE8 mode.
ret_from_fork checks for a non-zero r5, and if so, calls that function,
which will also see the CPSR set appropriately for the kernel mode.
Functions called from kernel_thread() are not permitted to return, so
we will never read the "childregs" off the top of the kernel stack.
Childregs are initialised because we expect them to be at the top of
every kernel stack.
Ergo, this patch is not needed at all.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-05-18 9:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 2:46 [RFC] arm:consider THUMB and BE endian kernel build yalin wang
[not found] ` <5559966A.5010006@gmail.com>
2015-05-18 9:40 ` Russell King - ARM Linux [this message]
2015-05-18 9:52 ` [RFC V2] " yalin wang
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=20150518094032.GR2067@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).