mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: Tigran Aivazian <tigran@veritas.com>
Cc: Paul Mackerras <paulus@samba.org>,
	Balbir Singh <balbir_soni@yahoo.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Nice values for kernel modules
Date: Sat, 16 Mar 2002 23:34:35 +1100	[thread overview]
Message-ID: <16358.1016282075@ocs3.intra.ocs.com.au> (raw)
In-Reply-To: Your message of "Sat, 16 Mar 2002 11:27:03 -0000." <Pine.LNX.4.33.0203161126130.1090-100000@einstein.homenet>

On Sat, 16 Mar 2002 11:27:03 +0000 (GMT), 
Tigran Aivazian <tigran@veritas.com> wrote:
>On Sat, 16 Mar 2002, Paul Mackerras wrote:
>
>> Keith Owens writes:
>>
>> > On Sat, 16 Mar 2002 09:51:16 +0000 (GMT),
>> > <tigran@aivazian.fsnet.co.uk> wrote:
>> > >jump to sys_nice() indirectly via exported sys_call_table[].
>> >
>> > Breaks on ia64 and ppc.
>>
>> Not that I want to encourage this sort of thing, but why would it
>> break on ppc?

Should have been ppc64, not ppc.

>and also why would it break on ia64. I can understand __mips but why ia64?

Address of function text is NOT the same as &function.  On many
architectures &function is the same as the first byte of the function
text but not on all architectures.  On IA64 &func points to a function
descriptor which contains { void * __gp; void * function_text; }.  When
you call a function on ia64, the code is really :-

  save current __gp
  load address of function_text
  load __gp (global data pointer) for new function
  call function_text
  restore original __gp

Within the kernel, all direct function calls (call function by name)
are assumed to have the same __gp so the code reduces to :-

  load address of function_text
  call function_text

just like most other architectures, this is why syscalls within the
kernel work.

When the kernel calls a function via a pointer then __gp must be saved,
set and restored.  This is especially true when calling from the kernel
to a module or vice versa, I guarantee that kernel and modules have
different __gp values.

Fetching &sys_nice from the syscall table and blindly calling that
address from a module will crash the kernel.  PPC64 has a similar
problem, it has a function descriptor that contains 3 fields.

There is no architecture independent method for accessing syscall
entries _as functions_ from a module.  Code that works on ix86 will
break on ia64 and ppc64.  I can see no good reason why the syscall
table has been exported.


  reply	other threads:[~2002-03-16 12:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-15 23:59 Balbir Singh
2002-03-16  9:51 ` tigran
2002-03-16 10:00   ` Keith Owens
2002-03-16 10:41   ` Paul Mackerras
2002-03-16 11:27     ` Tigran Aivazian
2002-03-16 12:34       ` Keith Owens [this message]
2002-03-16 13:04         ` Tigran Aivazian
2002-03-16 13:52           ` Christoph Hellwig
2002-03-16 17:42           ` Alan Cox
2002-03-16 15:48         ` John Levon
     [not found] <Pine.LNX.4.33.0203161126130.1090-100000@einstein.homenet.suse.lists.linux.kernel>
     [not found] ` <16358.1016282075@ocs3.intra.ocs.com.au.suse.lists.linux.kernel>
     [not found]   ` <20020316154848.GA82190@compsoc.man.ac.uk.suse.lists.linux.kernel>
2002-03-16 16:03     ` Andi Kleen
     [not found] <Pine.LNX.4.33.0203161300300.1089-100000@einstein.homenet.suse.lists.linux.kernel>
     [not found] ` <E16mICa-0006mr-00@the-village.bc.nu.suse.lists.linux.kernel>
2002-03-16 22:03   ` Andi Kleen
2002-03-25  7:47     ` Eric W. Biederman
2002-03-25  8:20       ` John Levon

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=16358.1016282075@ocs3.intra.ocs.com.au \
    --to=kaos@ocs.com.au \
    --cc=balbir_soni@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=tigran@veritas.com \
    /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

all inboxes | Powered by JetHome®