Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
251a1272
Commit
251a1272
authored
Jan 15, 2003
by
Anton Blanchard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ppc64: 2.5 module support, from Rusty
parent
37deafa7
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
500 additions
and
430 deletions
+500
-430
arch/ppc64/kernel/Makefile
arch/ppc64/kernel/Makefile
+2
-1
arch/ppc64/kernel/ioctl32.c
arch/ppc64/kernel/ioctl32.c
+1
-2
arch/ppc64/kernel/module.c
arch/ppc64/kernel/module.c
+464
-0
arch/ppc64/kernel/ppc_ksyms.c
arch/ppc64/kernel/ppc_ksyms.c
+1
-7
arch/ppc64/kernel/sys_ppc32.c
arch/ppc64/kernel/sys_ppc32.c
+10
-403
arch/ppc64/mm/extable.c
arch/ppc64/mm/extable.c
+4
-3
include/asm-ppc64/module.h
include/asm-ppc64/module.h
+18
-14
No files found.
arch/ppc64/kernel/Makefile
View file @
251a1272
...
...
@@ -6,7 +6,7 @@ EXTRA_CFLAGS += -mno-minimal-toc
EXTRA_TARGETS
:=
head.o
export-objs
:=
ppc_ksyms.o
obj-y
:=
ppc_ksyms.o
setup.o entry.o traps.o irq.o idle.o
\
obj-y
:=
setup.o entry.o traps.o irq.o idle.o
\
time.o process.o signal.o syscalls.o misc.o ptrace.o
\
align.o semaphore.o bitops.o stab.o htab.o pacaData.o
\
udbg.o binfmt_elf32.o sys_ppc32.o sys32.o ioctl32.o
\
...
...
@@ -30,3 +30,4 @@ obj-y += open_pic.o xics.o pSeries_htab.o rtas.o \
obj-$(CONFIG_RTAS_FLASH)
+=
rtas_flash.o
obj-$(CONFIG_SMP)
+=
smp.o
obj-$(CONFIG_PROFILING)
+=
profile.o
obj-$(CONFIG_MODULES)
+=
module.o ppc_ksyms.o
arch/ppc64/kernel/ioctl32.c
View file @
251a1272
...
...
@@ -4495,10 +4495,9 @@ int register_ioctl32_conversion(unsigned int cmd, int (*handler)(unsigned int, u
{
int
i
;
if
(
!
additional_ioctls
)
{
additional_ioctls
=
module_map
(
PAGE_SIZE
);
additional_ioctls
=
get_zeroed_page
(
GFP_KERNEL
);
if
(
!
additional_ioctls
)
return
-
ENOMEM
;
memset
(
additional_ioctls
,
0
,
PAGE_SIZE
);
}
for
(
i
=
0
;
i
<
PAGE_SIZE
/
sizeof
(
struct
ioctl_trans
);
i
++
)
{
if
(
!
additional_ioctls
[
i
].
cmd
)
...
...
arch/ppc64/kernel/module.c
0 → 100644
View file @
251a1272
/* Kernel module help for PPC64.
Copyright (C) 2001, 2003 Rusty Russell IBM Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/module.h>
#include <linux/elf.h>
#include <linux/moduleloader.h>
#include <linux/err.h>
#include <linux/vmalloc.h>
/* FIXME: We don't do .init separately. To do this, we'd need to have
a separate r2 value in the init and core section, and stub between
them, too.
Using a magic allocator which places modules within 32MB solves
this, and makes other things simpler. Anton?
--RR. */
#if 0
#define DEBUGP printk
#else
#define DEBUGP(fmt , ...)
#endif
/* There's actually a third entry here, but it's unused */
struct
ppc64_opd_entry
{
unsigned
long
funcaddr
;
unsigned
long
r2
;
};
/* Like PPC32, we need little trampolines to do > 24-bit jumps (into
the kernel itself). But on PPC64, these need to be used for every
jump, actually, to reset r2 (TOC+0x8000). */
struct
ppc64_stub_entry
{
/* 28 byte jump instruction sequence (7 instructions) */
unsigned
char
jump
[
28
];
unsigned
char
unused
[
4
];
/* Data for the above code */
struct
ppc64_opd_entry
opd
;
};
/* We use a stub to fix up r2 (TOC ptr) and to jump to the (external)
function which may be more than 24-bits away. We could simply
patch the new r2 value and function pointer into the stub, but it's
significantly shorter to put these values at the end of the stub
code, and patch the stub address (32-bits relative to the TOC ptr,
r2) into the stub. */
static
struct
ppc64_stub_entry
ppc64_stub
=
{
.
jump
=
{
0x3d
,
0x82
,
0x00
,
0x00
,
/* addis r12,r2, <high> */
0x39
,
0x8c
,
0x00
,
0x00
,
/* addi r12,r12, <low> */
/* Save current r2 value in magic place on the stack. */
0xf8
,
0x41
,
0x00
,
0x28
,
/* std r2,40(r1) */
0xe9
,
0x6c
,
0x00
,
0x20
,
/* ld r11,32(r12) */
0xe8
,
0x4c
,
0x00
,
0x28
,
/* ld r2,40(r12) */
0x7d
,
0x69
,
0x03
,
0xa6
,
/* mtctr r11 */
0x4e
,
0x80
,
0x04
,
0x20
/* bctr */
}
};
/* Count how many different 24-bit relocations (different symbol,
different addend) */
static
unsigned
int
count_relocs
(
const
Elf64_Rela
*
rela
,
unsigned
int
num
)
{
unsigned
int
i
,
j
,
ret
=
0
;
/* FIXME: Only count external ones --RR */
/* Sure, this is order(n^2), but it's usually short, and not
time critical */
for
(
i
=
0
;
i
<
num
;
i
++
)
{
/* Only count 24-bit relocs, others don't need stubs */
if
(
ELF64_R_TYPE
(
rela
[
i
].
r_info
)
!=
R_PPC_REL24
)
continue
;
for
(
j
=
0
;
j
<
i
;
j
++
)
{
/* If this addend appeared before, it's
already been counted */
if
(
rela
[
i
].
r_info
==
rela
[
j
].
r_info
&&
rela
[
i
].
r_addend
==
rela
[
j
].
r_addend
)
break
;
}
if
(
j
==
i
)
ret
++
;
}
return
ret
;
}
void
*
module_alloc
(
unsigned
long
size
)
{
if
(
size
==
0
)
return
NULL
;
return
vmalloc
(
size
);
}
/* Free memory returned from module_alloc */
void
module_free
(
struct
module
*
mod
,
void
*
module_region
)
{
vfree
(
module_region
);
/* FIXME: If module_region == mod->init_region, trim exception
table entries. */
}
/* Get size of potential trampolines required. */
static
unsigned
long
get_stubs_size
(
const
Elf64_Ehdr
*
hdr
,
const
Elf64_Shdr
*
sechdrs
)
{
/* One extra reloc so it's always 0-funcaddr terminated */
unsigned
long
relocs
=
1
;
unsigned
i
;
/* Every relocated section... */
for
(
i
=
1
;
i
<
hdr
->
e_shnum
;
i
++
)
{
if
(
sechdrs
[
i
].
sh_type
==
SHT_RELA
)
{
DEBUGP
(
"Found relocations in section %u
\n
"
,
i
);
DEBUGP
(
"Ptr: %p. Number: %lu
\n
"
,
(
void
*
)
sechdrs
[
i
].
sh_addr
,
sechdrs
[
i
].
sh_size
/
sizeof
(
Elf64_Rela
));
relocs
+=
count_relocs
((
void
*
)
sechdrs
[
i
].
sh_addr
,
sechdrs
[
i
].
sh_size
/
sizeof
(
Elf64_Rela
));
}
}
DEBUGP
(
"Looks like a total of %lu stubs, max
\n
"
,
relocs
);
return
relocs
*
sizeof
(
struct
ppc64_stub_entry
);
}
int
module_frob_arch_sections
(
Elf64_Ehdr
*
hdr
,
Elf64_Shdr
*
sechdrs
,
char
*
secstrings
,
struct
module
*
me
)
{
unsigned
int
i
;
/* Find .toc and .stubs sections */
for
(
i
=
1
;
i
<
hdr
->
e_shnum
;
i
++
)
{
char
*
p
;
if
(
strcmp
(
secstrings
+
sechdrs
[
i
].
sh_name
,
".stubs"
)
==
0
)
me
->
arch
.
stubs_section
=
i
;
else
if
(
strcmp
(
secstrings
+
sechdrs
[
i
].
sh_name
,
".toc"
)
==
0
)
me
->
arch
.
toc_section
=
i
;
/* We don't handle .init for the moment: rename to _init */
while
((
p
=
strstr
(
secstrings
+
sechdrs
[
i
].
sh_name
,
".init"
)))
p
[
0
]
=
'_'
;
}
if
(
!
me
->
arch
.
stubs_section
||
!
me
->
arch
.
toc_section
)
{
printk
(
"%s: doesn't contain .toc or .stubs.
\n
"
,
me
->
name
);
return
-
ENOEXEC
;
}
/* Override the stubs size */
sechdrs
[
me
->
arch
.
stubs_section
].
sh_size
=
get_stubs_size
(
hdr
,
sechdrs
);
return
0
;
}
int
apply_relocate
(
Elf64_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
printk
(
KERN_ERR
"%s: Non-ADD RELOCATION unsupported
\n
"
,
me
->
name
);
return
-
ENOEXEC
;
}
/* Both low and high 16 bits are added as SIGNED additions, so if low
16 bits has high bit set, high 16 bits must be adjusted. These
macros do that (stolen from binutils). */
#define PPC_LO(v) ((v) & 0xffff)
#define PPC_HI(v) (((v) >> 16) & 0xffff)
#define PPC_HA(v) PPC_HI ((v) + 0x8000)
/* Patch stub to reference function and correct r2 value. */
static
inline
int
create_stub
(
struct
ppc64_stub_entry
*
entry
,
unsigned
long
my_r2
,
unsigned
long
func
,
unsigned
long
r2
)
{
Elf64_Half
*
loc1
,
*
loc2
;
long
reladdr
;
*
entry
=
ppc64_stub
;
loc1
=
(
Elf64_Half
*
)
&
entry
->
jump
[
2
];
loc2
=
(
Elf64_Half
*
)
&
entry
->
jump
[
6
];
/* Stub uses address relative to r2, which is set to the TOC +
0x8000. */
reladdr
=
(
unsigned
long
)
entry
-
my_r2
;
if
(
reladdr
>
0x7FFFFFFF
||
reladdr
<
-
(
0x80000000L
))
{
printk
(
"Address %p of stub out of range of %p.
\n
"
,
(
void
*
)
reladdr
,
(
void
*
)
my_r2
);
return
0
;
}
DEBUGP
(
"Stub %p get data from reladdr %li
\n
"
,
entry
,
reladdr
);
*
loc1
=
PPC_HA
(
reladdr
);
*
loc2
=
PPC_LO
(
reladdr
);
entry
->
opd
.
funcaddr
=
func
;
entry
->
opd
.
r2
=
r2
;
DEBUGP
(
"Stub: %08X %08X %08X %08X %08X %08X %08X: %p %p
\n
"
,
((
unsigned
int
*
)
entry
->
jump
)[
0
],
((
unsigned
int
*
)
entry
->
jump
)[
1
],
((
unsigned
int
*
)
entry
->
jump
)[
2
],
((
unsigned
int
*
)
entry
->
jump
)[
3
],
((
unsigned
int
*
)
entry
->
jump
)[
4
],
((
unsigned
int
*
)
entry
->
jump
)[
5
],
((
unsigned
int
*
)
entry
->
jump
)[
6
],
(
void
*
)
entry
->
opd
.
funcaddr
,
(
void
*
)
entry
->
opd
.
r2
);
return
1
;
}
/* Given ".function" reference, return address of "function" opd entry */
static
struct
ppc64_opd_entry
*
find_function
(
const
char
*
name
,
Elf64_Shdr
*
sechdrs
,
unsigned
int
symindex
,
const
char
*
strtab
,
struct
module
*
me
,
struct
kernel_symbol_group
**
ksg
)
{
unsigned
long
val
;
if
(
name
[
0
]
!=
'.'
)
return
0
;
val
=
find_symbol_internal
(
sechdrs
,
symindex
,
strtab
,
name
+
1
,
me
,
ksg
);
DEBUGP
(
"Function %s is at %p
\n
"
,
name
+
1
,
(
void
*
)
val
);
return
(
void
*
)
val
;
}
/* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this
gives the value maximum span in an instruction which uses a signed
offset) */
static
inline
unsigned
long
my_r2
(
Elf64_Shdr
*
sechdrs
,
struct
module
*
me
)
{
return
sechdrs
[
me
->
arch
.
toc_section
].
sh_addr
+
0x8000
;
}
/* Create stub for this OPD address */
static
unsigned
long
stub_for_addr
(
Elf64_Shdr
*
sechdrs
,
unsigned
long
addr
,
unsigned
long
r2
,
struct
module
*
me
)
{
struct
ppc64_stub_entry
*
stubs
;
unsigned
int
i
,
num_stubs
;
DEBUGP
(
"Looking for stub for %p
\n
"
,
(
void
*
)
addr
);
num_stubs
=
sechdrs
[
me
->
arch
.
stubs_section
].
sh_size
/
sizeof
(
*
stubs
);
/* Find this stub, or if that fails, the next avail. entry */
stubs
=
(
void
*
)
sechdrs
[
me
->
arch
.
stubs_section
].
sh_addr
;
for
(
i
=
0
;
stubs
[
i
].
opd
.
funcaddr
;
i
++
)
{
BUG_ON
(
i
>=
num_stubs
);
if
(
stubs
[
i
].
opd
.
funcaddr
==
addr
)
{
DEBUGP
(
"Reusing stub %u (%p) for %p
\n
"
,
i
,
&
stubs
[
i
],
(
void
*
)
addr
);
return
(
unsigned
long
)
&
stubs
[
i
];
}
}
DEBUGP
(
"Here for %p
\n
"
,
(
void
*
)
addr
);
if
(
!
create_stub
(
&
stubs
[
i
],
my_r2
(
sechdrs
,
me
),
addr
,
r2
))
return
(
unsigned
long
)
-
EINVAL
;
DEBUGP
(
"CREATED stub %u for %p
\n
"
,
i
,
(
void
*
)
addr
);
return
(
unsigned
long
)
&
stubs
[
i
];
}
/* We need a stub to set the toc ptr when we make external calls. */
static
unsigned
long
do_stub_call
(
Elf64_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
void
*
location
,
const
char
*
funcname
,
struct
module
*
me
)
{
struct
ppc64_opd_entry
*
opd
;
struct
kernel_symbol_group
*
ksg
;
DEBUGP
(
"Doing stub for %lu (%s)
\n
"
,
(
unsigned
long
)
location
,
funcname
);
opd
=
find_function
(
funcname
,
sechdrs
,
symindex
,
strtab
,
me
,
&
ksg
);
if
(
!
opd
)
{
printk
(
"%s: Can't find function `%s'
\n
"
,
me
->
name
,
funcname
);
return
(
unsigned
long
)
-
ENOENT
;
}
return
stub_for_addr
(
sechdrs
,
opd
->
funcaddr
,
opd
->
r2
,
me
);
}
/* We expect a noop next: if it is, replace it with instruction to
restore r2. */
static
int
restore_r2
(
u32
*
instruction
)
{
if
(
*
instruction
!=
0x60000000
)
{
printk
(
"Expect noop after relocate, got %08x
\n
"
,
*
instruction
);
return
0
;
}
*
instruction
=
0xe8410028
;
/* ld r2,40(r1) */
return
1
;
}
int
apply_relocate_add
(
Elf64_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
unsigned
int
i
;
Elf64_Rela
*
rela
=
(
void
*
)
sechdrs
[
relsec
].
sh_addr
;
Elf64_Sym
*
sym
;
unsigned
long
*
location
;
unsigned
long
value
;
DEBUGP
(
"Applying ADD relocate section %u to %u
\n
"
,
relsec
,
sechdrs
[
relsec
].
sh_info
);
for
(
i
=
0
;
i
<
sechdrs
[
relsec
].
sh_size
/
sizeof
(
*
rela
);
i
++
)
{
/* This is where to make the change */
location
=
(
void
*
)
sechdrs
[
sechdrs
[
relsec
].
sh_info
].
sh_addr
+
rela
[
i
].
r_offset
;
/* This is the symbol it is referring to */
sym
=
(
Elf64_Sym
*
)
sechdrs
[
symindex
].
sh_addr
+
ELF64_R_SYM
(
rela
[
i
].
r_info
);
DEBUGP
(
"RELOC at %p: %li-type as %s (%lu) + %li
\n
"
,
location
,
(
long
)
ELF64_R_TYPE
(
rela
[
i
].
r_info
),
strtab
+
sym
->
st_name
,
(
unsigned
long
)
sym
->
st_value
,
(
long
)
rela
[
i
].
r_addend
);
/* REL24 references to (external) .function won't
resolve; deal with that below */
if
(
!
sym
->
st_value
&&
ELF64_R_TYPE
(
rela
[
i
].
r_info
)
!=
R_PPC_REL24
)
{
printk
(
"%s: Unknown symbol %s (index %u)
\n
"
,
me
->
name
,
strtab
+
sym
->
st_name
,
sym
->
st_shndx
);
return
-
ENOENT
;
}
/* `Everything is relative'. */
value
=
sym
->
st_value
+
rela
[
i
].
r_addend
;
switch
(
ELF64_R_TYPE
(
rela
[
i
].
r_info
))
{
case
R_PPC64_ADDR32
:
/* Simply set it */
DEBUGP
(
"Setting location %p to 32-bit value %u
\n
"
,
location
,
(
unsigned
int
)
value
);
*
(
u32
*
)
location
=
value
;
break
;
case
R_PPC64_ADDR64
:
/* Simply set it */
*
(
unsigned
long
*
)
location
=
value
;
DEBUGP
(
"Setting location %p to 64-bit value %p
\n
"
,
location
,
(
void
*
)
value
);
break
;
case
R_PPC64_TOC
:
*
(
unsigned
long
*
)
location
=
my_r2
(
sechdrs
,
me
);
break
;
case
R_PPC64_TOC16_DS
:
/* Subtact TOC pointer */
value
-=
my_r2
(
sechdrs
,
me
);
if
((
value
&
3
)
!=
0
||
value
+
0x8000
>
0xffff
)
{
DEBUGP
(
"%s: bad TOC16_DS relocation (%lu)
\n
"
,
me
->
name
,
value
);
return
-
ENOEXEC
;
}
*
((
uint16_t
*
)
location
)
=
(
*
((
uint16_t
*
)
location
)
&
~
0xfffc
)
|
(
value
&
0xfffc
);
DEBUGP
(
"Modifying location %p by TOC (%p) => %i
\n
"
,
location
,
(
void
*
)
my_r2
(
sechdrs
,
me
),
*
(
uint16_t
*
)
location
);
break
;
case
R_PPC_REL24
:
/* FIXME: Handle weak symbols here --RR */
if
(
sym
->
st_shndx
==
SHN_UNDEF
)
{
value
=
do_stub_call
(
sechdrs
,
strtab
,
symindex
,
location
,
strtab
+
sym
->
st_name
,
me
);
if
(
IS_ERR
((
void
*
)
value
))
return
value
;
value
+=
rela
[
i
].
r_addend
;
if
(
!
restore_r2
((
u32
*
)
location
+
1
))
return
-
ENOEXEC
;
}
/* Convert value to relative */
value
-=
(
unsigned
long
)
location
;
if
(
value
+
0x2000000
>
0x3ffffff
||
(
value
&
3
)
!=
0
){
printk
(
"REL24 relocation %li out of range!
\n
"
,
(
long
int
)
value
);
return
-
ENOEXEC
;
}
/* Only replace bits 2 through 26 */
*
(
uint32_t
*
)
location
=
(
*
(
uint32_t
*
)
location
&
~
0x03fffffc
)
|
(
value
&
0x03fffffc
);
break
;
default:
printk
(
"Unknown ADD relocation: %lu
\n
"
,
(
unsigned
long
)
ELF64_R_TYPE
(
rela
[
i
].
r_info
));
return
-
ENOEXEC
;
}
}
return
0
;
}
/* In arch/ppc64/mm/extable.c */
extern
void
sort_ex_table
(
struct
exception_table_entry
*
start
,
struct
exception_table_entry
*
finish
);
int
module_finalize
(
const
Elf_Ehdr
*
hdr
,
const
Elf_Shdr
*
sechdrs
,
struct
module
*
me
)
{
struct
ppc64_stub_entry
*
stubs
;
unsigned
int
i
;
/* Here is where we copy the OPD entry into the stub: we don't
do it ealier in case it's actually in the same module, and
hasn't been relocated yet. */
stubs
=
(
void
*
)
sechdrs
[
me
->
arch
.
stubs_section
].
sh_addr
;
for
(
i
=
0
;
stubs
[
i
].
opd
.
funcaddr
;
i
++
)
{
struct
ppc64_opd_entry
*
opd
;
/* We mark opd pointers by setting r2 to 0: otherwise
it's a function pointer already. */
if
(
stubs
[
i
].
opd
.
r2
==
0
)
{
/* We put the opd entry ptr in the funcaddr member. */
opd
=
(
void
*
)
stubs
[
i
].
opd
.
funcaddr
;
stubs
[
i
].
opd
=
*
opd
;
}
}
sort_ex_table
(
me
->
extable
.
entry
,
me
->
extable
.
entry
+
me
->
extable
.
num_entries
);
return
0
;
}
arch/ppc64/kernel/ppc_ksyms.c
View file @
251a1272
...
...
@@ -47,9 +47,6 @@
#include <asm/iSeries/HvLpConfig.h>
#endif
/* Tell string.h we don't want memcpy etc. as cpp defines */
#define EXPORT_SYMTAB_STROPS
extern
int
sys_ioctl
(
unsigned
int
fd
,
unsigned
int
cmd
,
unsigned
long
arg
);
extern
int
sys_sigreturn
(
struct
pt_regs
*
regs
);
extern
int
do_signal
(
sigset_t
*
,
struct
pt_regs
*
);
...
...
@@ -81,6 +78,7 @@ EXPORT_SYMBOL(isa_io_base);
EXPORT_SYMBOL
(
pci_io_base
);
EXPORT_SYMBOL
(
find_next_zero_bit
);
EXPORT_SYMBOL
(
find_next_zero_le_bit
);
EXPORT_SYMBOL
(
strcpy
);
EXPORT_SYMBOL
(
strncpy
);
...
...
@@ -184,7 +182,6 @@ EXPORT_SYMBOL(giveup_fpu);
EXPORT_SYMBOL
(
enable_kernel_fp
);
EXPORT_SYMBOL
(
flush_icache_range
);
EXPORT_SYMBOL
(
flush_icache_user_range
);
EXPORT_SYMBOL
(
flush_icache_page
);
EXPORT_SYMBOL
(
flush_dcache_page
);
#ifdef CONFIG_SMP
#ifdef CONFIG_PPC_ISERIES
...
...
@@ -207,9 +204,6 @@ EXPORT_SYMBOL(find_all_nodes);
EXPORT_SYMBOL
(
get_property
);
EXPORT_SYMBOL_NOVERS
(
__ashrdi3
);
EXPORT_SYMBOL_NOVERS
(
__ashldi3
);
EXPORT_SYMBOL_NOVERS
(
__lshrdi3
);
EXPORT_SYMBOL_NOVERS
(
memcpy
);
EXPORT_SYMBOL_NOVERS
(
memset
);
EXPORT_SYMBOL_NOVERS
(
memmove
);
...
...
arch/ppc64/kernel/sys_ppc32.c
View file @
251a1272
...
...
@@ -934,431 +934,38 @@ asmlinkage long sys32_adjtimex(struct timex32 *utp)
return
ret
;
}
#ifdef CONFIG_MODULES
extern
asmlinkage
unsigned
long
sys_create_module
(
const
char
*
name_user
,
size_t
size
);
asmlinkage
unsigned
long
sys32_create_module
(
const
char
*
name_user
,
compat_size_t
size
)
{
return
sys_create_module
(
name_user
,
(
size_t
)
size
);
}
extern
asmlinkage
long
sys_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
);
asmlinkage
long
sys32_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
)
{
return
sys_init_module
(
name_user
,
mod_user
);
}
extern
asmlinkage
long
sys_delete_module
(
const
char
*
name_user
);
asmlinkage
long
sys32_delete_module
(
const
char
*
name_user
)
{
return
sys_delete_module
(
name_user
);
}
struct
module_info32
{
u32
addr
;
u32
size
;
u32
flags
;
s32
usecount
;
};
/* Query various bits about modules. */
static
inline
long
get_mod_name
(
const
char
*
user_name
,
char
**
buf
)
{
unsigned
long
page
;
long
retval
;
if
((
unsigned
long
)
user_name
>=
TASK_SIZE
&&
!
segment_eq
(
get_fs
(),
KERNEL_DS
))
return
-
EFAULT
;
page
=
__get_free_page
(
GFP_KERNEL
);
if
(
!
page
)
return
-
ENOMEM
;
retval
=
strncpy_from_user
((
char
*
)
page
,
user_name
,
PAGE_SIZE
);
if
(
retval
>
0
)
{
if
(
retval
<
PAGE_SIZE
)
{
*
buf
=
(
char
*
)
page
;
return
retval
;
}
retval
=
-
ENAMETOOLONG
;
}
else
if
(
!
retval
)
retval
=
-
EINVAL
;
free_page
(
page
);
return
retval
;
}
static
inline
void
put_mod_name
(
char
*
buf
)
{
free_page
((
unsigned
long
)
buf
);
}
static
__inline__
struct
module
*
find_module
(
const
char
*
name
)
{
struct
module
*
mod
;
for
(
mod
=
module_list
;
mod
;
mod
=
mod
->
next
)
{
if
(
mod
->
flags
&
MOD_DELETED
)
continue
;
if
(
!
strcmp
(
mod
->
name
,
name
))
break
;
}
return
mod
;
}
static
int
qm_modules
(
char
*
buf
,
size_t
bufsize
,
compat_size_t
*
ret
)
{
struct
module
*
mod
;
size_t
nmod
,
space
,
len
;
nmod
=
space
=
0
;
for
(
mod
=
module_list
;
mod
->
next
!=
NULL
;
mod
=
mod
->
next
,
++
nmod
)
{
len
=
strlen
(
mod
->
name
)
+
1
;
if
(
len
>
bufsize
)
goto
calc_space_needed
;
if
(
copy_to_user
(
buf
,
mod
->
name
,
len
))
return
-
EFAULT
;
buf
+=
len
;
bufsize
-=
len
;
space
+=
len
;
}
if
(
put_user
(
nmod
,
ret
))
return
-
EFAULT
;
else
return
0
;
calc_space_needed:
space
+=
len
;
while
((
mod
=
mod
->
next
)
->
next
!=
NULL
)
space
+=
strlen
(
mod
->
name
)
+
1
;
if
(
put_user
(
space
,
ret
))
return
-
EFAULT
;
else
return
-
ENOSPC
;
}
static
int
qm_deps
(
struct
module
*
mod
,
char
*
buf
,
size_t
bufsize
,
compat_size_t
*
ret
)
{
size_t
i
,
space
,
len
;
if
(
mod
->
next
==
NULL
)
return
-
EINVAL
;
if
(
!
MOD_CAN_QUERY
(
mod
))
return
put_user
(
0
,
ret
);
space
=
0
;
for
(
i
=
0
;
i
<
mod
->
ndeps
;
++
i
)
{
const
char
*
dep_name
=
mod
->
deps
[
i
].
dep
->
name
;
len
=
strlen
(
dep_name
)
+
1
;
if
(
len
>
bufsize
)
goto
calc_space_needed
;
if
(
copy_to_user
(
buf
,
dep_name
,
len
))
return
-
EFAULT
;
buf
+=
len
;
bufsize
-=
len
;
space
+=
len
;
}
return
put_user
(
i
,
ret
);
calc_space_needed:
space
+=
len
;
while
(
++
i
<
mod
->
ndeps
)
space
+=
strlen
(
mod
->
deps
[
i
].
dep
->
name
)
+
1
;
if
(
put_user
(
space
,
ret
))
return
-
EFAULT
;
else
return
-
ENOSPC
;
}
static
int
qm_refs
(
struct
module
*
mod
,
char
*
buf
,
size_t
bufsize
,
compat_size_t
*
ret
)
{
size_t
nrefs
,
space
,
len
;
struct
module_ref
*
ref
;
if
(
mod
->
next
==
NULL
)
return
-
EINVAL
;
if
(
!
MOD_CAN_QUERY
(
mod
))
if
(
put_user
(
0
,
ret
))
return
-
EFAULT
;
else
return
0
;
space
=
0
;
for
(
nrefs
=
0
,
ref
=
mod
->
refs
;
ref
;
++
nrefs
,
ref
=
ref
->
next_ref
)
{
const
char
*
ref_name
=
ref
->
ref
->
name
;
len
=
strlen
(
ref_name
)
+
1
;
if
(
len
>
bufsize
)
goto
calc_space_needed
;
if
(
copy_to_user
(
buf
,
ref_name
,
len
))
return
-
EFAULT
;
buf
+=
len
;
bufsize
-=
len
;
space
+=
len
;
}
if
(
put_user
(
nrefs
,
ret
))
return
-
EFAULT
;
else
return
0
;
calc_space_needed:
space
+=
len
;
while
((
ref
=
ref
->
next_ref
)
!=
NULL
)
space
+=
strlen
(
ref
->
ref
->
name
)
+
1
;
if
(
put_user
(
space
,
ret
))
return
-
EFAULT
;
else
return
-
ENOSPC
;
}
static
inline
int
qm_symbols
(
struct
module
*
mod
,
char
*
buf
,
size_t
bufsize
,
compat_size_t
*
ret
)
{
size_t
i
,
space
,
len
;
struct
module_symbol
*
s
;
char
*
strings
;
unsigned
*
vals
;
if
(
!
MOD_CAN_QUERY
(
mod
))
if
(
put_user
(
0
,
ret
))
return
-
EFAULT
;
else
return
0
;
space
=
mod
->
nsyms
*
2
*
sizeof
(
u32
);
i
=
len
=
0
;
s
=
mod
->
syms
;
if
(
space
>
bufsize
)
goto
calc_space_needed
;
if
(
!
access_ok
(
VERIFY_WRITE
,
buf
,
space
))
return
-
EFAULT
;
bufsize
-=
space
;
vals
=
(
unsigned
*
)
buf
;
strings
=
buf
+
space
;
for
(;
i
<
mod
->
nsyms
;
++
i
,
++
s
,
vals
+=
2
)
{
len
=
strlen
(
s
->
name
)
+
1
;
if
(
len
>
bufsize
)
goto
calc_space_needed
;
if
(
copy_to_user
(
strings
,
s
->
name
,
len
)
||
__put_user
(
s
->
value
,
vals
+
0
)
||
__put_user
(
space
,
vals
+
1
))
return
-
EFAULT
;
strings
+=
len
;
bufsize
-=
len
;
space
+=
len
;
}
if
(
put_user
(
i
,
ret
))
return
-
EFAULT
;
else
return
0
;
calc_space_needed:
for
(;
i
<
mod
->
nsyms
;
++
i
,
++
s
)
space
+=
strlen
(
s
->
name
)
+
1
;
if
(
put_user
(
space
,
ret
))
return
-
EFAULT
;
else
return
-
ENOSPC
;
}
extern
asmlinkage
long
sys_init_module
(
void
*
,
unsigned
long
,
const
char
*
);
static
inline
int
qm_info
(
struct
module
*
mod
,
char
*
buf
,
size_t
bufsize
,
compat_size_t
*
ret
)
asmlinkage
int
sys32_init_module
(
void
*
umod
,
u32
len
,
const
char
*
uargs
)
{
int
error
=
0
;
if
(
mod
->
next
==
NULL
)
return
-
EINVAL
;
if
(
sizeof
(
struct
module_info32
)
<=
bufsize
)
{
struct
module_info32
info
;
info
.
addr
=
(
unsigned
long
)
mod
;
info
.
size
=
mod
->
size
;
info
.
flags
=
mod
->
flags
;
info
.
usecount
=
((
mod_member_present
(
mod
,
can_unload
)
&&
mod
->
can_unload
)
?
-
1
:
atomic_read
(
&
mod
->
uc
.
usecount
));
if
(
copy_to_user
(
buf
,
&
info
,
sizeof
(
struct
module_info32
)))
return
-
EFAULT
;
}
else
error
=
-
ENOSPC
;
if
(
put_user
(
sizeof
(
struct
module_info32
),
ret
))
return
-
EFAULT
;
return
error
;
}
/* Note: it is necessary to treat which as an unsigned int,
* with the corresponding cast to a signed int to insure that the
* proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
* and the register representation of a signed int (msr in 64-bit mode) is performed.
*/
asmlinkage
long
sys32_query_module
(
char
*
name_user
,
u32
which
,
char
*
buf
,
compat_size_t
bufsize
,
u32
ret
)
{
struct
module
*
mod
;
int
err
;
lock_kernel
();
if
(
name_user
==
0
)
{
/* This finds "kernel_module" which is not exported. */
for
(
mod
=
module_list
;
mod
->
next
!=
NULL
;
mod
=
mod
->
next
)
;
}
else
{
long
namelen
;
char
*
name
;
if
((
namelen
=
get_mod_name
(
name_user
,
&
name
))
<
0
)
{
err
=
namelen
;
goto
out
;
}
err
=
-
ENOENT
;
if
(
namelen
==
0
)
{
/* This finds "kernel_module" which is not exported. */
for
(
mod
=
module_list
;
mod
->
next
!=
NULL
;
mod
=
mod
->
next
)
;
}
else
if
((
mod
=
find_module
(
name
))
==
NULL
)
{
put_mod_name
(
name
);
goto
out
;
}
put_mod_name
(
name
);
}
switch
((
int
)
which
)
{
case
0
:
err
=
0
;
break
;
case
QM_MODULES
:
err
=
qm_modules
(
buf
,
bufsize
,
(
compat_size_t
*
)
AA
(
ret
));
break
;
case
QM_DEPS
:
err
=
qm_deps
(
mod
,
buf
,
bufsize
,
(
compat_size_t
*
)
AA
(
ret
));
break
;
case
QM_REFS
:
err
=
qm_refs
(
mod
,
buf
,
bufsize
,
(
compat_size_t
*
)
AA
(
ret
));
break
;
case
QM_SYMBOLS
:
err
=
qm_symbols
(
mod
,
buf
,
bufsize
,
(
compat_size_t
*
)
AA
(
ret
));
break
;
case
QM_INFO
:
err
=
qm_info
(
mod
,
buf
,
bufsize
,
(
compat_size_t
*
)
AA
(
ret
));
break
;
default:
err
=
-
EINVAL
;
break
;
}
out:
unlock_kernel
();
return
err
;
return
sys_init_module
(
umod
,
len
,
uargs
);
}
extern
asmlinkage
long
sys_delete_module
(
const
char
*
,
unsigned
int
);
struct
kernel_sym32
{
u32
value
;
char
name
[
60
];
};
extern
asmlinkage
long
sys_get_kernel_syms
(
struct
kernel_sym
*
table
);
asmlinkage
long
sys32_get_kernel_syms
(
struct
kernel_sym32
*
table
)
asmlinkage
int
sys32_delete_module
(
const
char
*
name_user
,
unsigned
int
flags
)
{
int
len
,
i
;
struct
kernel_sym
*
tbl
;
mm_segment_t
old_fs
;
len
=
sys_get_kernel_syms
(
NULL
);
if
(
!
table
)
return
len
;
tbl
=
kmalloc
(
len
*
sizeof
(
struct
kernel_sym
),
GFP_KERNEL
);
if
(
!
tbl
)
return
-
ENOMEM
;
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
sys_get_kernel_syms
(
tbl
);
set_fs
(
old_fs
);
for
(
i
=
0
;
i
<
len
;
i
++
,
table
+=
sizeof
(
struct
kernel_sym32
))
{
if
(
put_user
(
tbl
[
i
].
value
,
&
table
->
value
)
||
copy_to_user
(
table
->
name
,
tbl
[
i
].
name
,
60
))
break
;
}
kfree
(
tbl
);
return
i
;
return
sys_delete_module
(
name_user
,
flags
);
}
#else
/* CONFIG_MODULES */
asmlinkage
unsigned
long
sys32_create_module
(
const
char
*
name_user
,
size_t
size
)
{
return
-
ENOSYS
;
}
asmlinkage
long
sys32_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
)
asmlinkage
int
sys32_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
)
{
return
-
ENOSYS
;
}
asmlinkage
long
sys32_delete_module
(
const
char
*
name_user
)
{
return
-
ENOSYS
;
}
asmlinkage
long
sys32_query_module
(
const
char
*
name_user
,
int
which
,
char
*
buf
,
size_t
bufsize
,
size_t
*
ret
)
{
/* Let the program know about the new interface. Not that it'll do them much good. */
if
(
which
==
0
)
return
0
;
return
-
ENOSYS
;
}
asmlinkage
long
sys32_get_kernel_syms
(
struct
kernel_sym
*
table
)
asmlinkage
int
sys32_delete_module
(
const
char
*
name_user
)
{
return
-
ENOSYS
;
}
#endif
/* CONFIG_MODULES */
/* Stuff for NFS server syscalls... */
struct
nfsctl_svc32
{
u16
svc32_port
;
...
...
arch/ppc64/mm/extable.c
View file @
251a1272
...
...
@@ -21,10 +21,11 @@ extern struct exception_table_entry __stop___ex_table[];
* The exception table needs to be sorted because we use the macros
* which put things into the exception table in a variety of segments
* as well as the init segment and the main kernel text segment.
*
* Also used for modules.
*/
static
inline
void
sort_ex_table
(
struct
exception_table_entry
*
start
,
struct
exception_table_entry
*
finish
)
void
sort_ex_table
(
struct
exception_table_entry
*
start
,
struct
exception_table_entry
*
finish
)
__init_or_module
{
struct
exception_table_entry
el
,
*
p
,
*
q
;
...
...
include/asm-ppc64/module.h
View file @
251a1272
#ifndef _ASM_PPC64_MODULE_H
#define _ASM_PPC64_MODULE_H
/*
* This file contains the PPC architecture specific module code.
*
* Copyright (C) 2001 PPC 64 Team, IBM Corp
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#define module_map(x) vmalloc(x)
#define module_unmap(x) vfree(x)
#define arch_init_modules(x) do { } while (0)
#define module_arch_init(x) (0)
struct
mod_arch_specific
{
/* Index of stubs section within module. */
unsigned
int
stubs_section
;
/* What section is the TOC? */
unsigned
int
toc_section
;
};
#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
#define Elf_Ehdr Elf64_Ehdr
/* Make empty section for module_frob_arch_sections to expand. */
#ifdef MODULE
asm
(
".section .stubs,
\"
ax
\"
,@nobits; .align 3; .previous"
);
#endif
#endif
/* _ASM_PPC64_MODULE_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment