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
c6cca1c5
Commit
c6cca1c5
authored
Nov 11, 2002
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SPARC]: Updated module support.
parent
467c4b2e
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
320 additions
and
528 deletions
+320
-528
arch/sparc/kernel/Makefile
arch/sparc/kernel/Makefile
+1
-0
arch/sparc/kernel/module.c
arch/sparc/kernel/module.c
+139
-0
arch/sparc/kernel/systbls.S
arch/sparc/kernel/systbls.S
+2
-2
arch/sparc/vmlinux.lds.S
arch/sparc/vmlinux.lds.S
+3
-0
arch/sparc64/kernel/Makefile
arch/sparc64/kernel/Makefile
+1
-0
arch/sparc64/kernel/module.c
arch/sparc64/kernel/module.c
+150
-0
arch/sparc64/kernel/sys_sparc32.c
arch/sparc64/kernel/sys_sparc32.c
+8
-386
arch/sparc64/kernel/systbls.S
arch/sparc64/kernel/systbls.S
+4
-4
arch/sparc64/mm/Makefile
arch/sparc64/mm/Makefile
+1
-1
arch/sparc64/mm/modutil.c
arch/sparc64/mm/modutil.c
+0
-117
arch/sparc64/vmlinux.lds.S
arch/sparc64/vmlinux.lds.S
+3
-0
include/asm-sparc/module.h
include/asm-sparc/module.h
+4
-9
include/asm-sparc64/module.h
include/asm-sparc64/module.h
+4
-9
No files found.
arch/sparc/kernel/Makefile
View file @
c6cca1c5
...
...
@@ -22,6 +22,7 @@ obj-$(CONFIG_SMP) += trampoline.o smp.o sun4m_smp.o sun4d_smp.o
obj-$(CONFIG_SUN_AUXIO)
+=
auxio.o
obj-$(CONFIG_PCI)
+=
ebus.o
obj-$(CONFIG_SUN_PM)
+=
apc.o pmc.o
obj-$(CONFIG_MODULES)
+=
module.o
ifdef
CONFIG_SUNOS_EMUL
obj-y
+=
sys_sunos.o sunos_ioctl.o
...
...
arch/sparc/kernel/module.c
0 → 100644
View file @
c6cca1c5
/* Kernel module help for sparc32.
*
* Copyright (C) 2001 Rusty Russell.
* Copyright (C) 2002 David S. Miller.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/elf.h>
#include <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/string.h>
static
void
*
alloc_and_zero
(
unsigned
long
size
)
{
void
*
ret
;
/* We handle the zero case fine, unlike vmalloc */
if
(
size
==
0
)
return
NULL
;
ret
=
vmalloc
(
size
);
if
(
!
ret
)
ret
=
ERR_PTR
(
-
ENOMEM
);
else
memset
(
ret
,
0
,
size
);
return
ret
;
}
/* Free memory returned from module_core_alloc/module_init_alloc */
void
module_free
(
struct
module
*
mod
,
void
*
module_region
)
{
vfree
(
module_region
);
/* FIXME: If module_region == mod->init_region, trim exception
table entries. */
}
void
*
module_core_alloc
(
const
Elf32_Ehdr
*
hdr
,
const
Elf32_Shdr
*
sechdrs
,
const
char
*
secstrings
,
struct
module
*
module
)
{
return
alloc_and_zero
(
module
->
core_size
);
}
void
*
module_init_alloc
(
const
Elf32_Ehdr
*
hdr
,
const
Elf32_Shdr
*
sechdrs
,
const
char
*
secstrings
,
struct
module
*
module
)
{
return
alloc_and_zero
(
module
->
init_size
);
}
int
apply_relocate
(
Elf32_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
printk
(
KERN_ERR
"module %s: non-ADD RELOCATION unsupported
\n
"
,
me
->
name
);
return
-
ENOEXEC
;
}
int
apply_relocate_add
(
Elf32_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
unsigned
int
i
;
Elf32_Rela
*
rel
=
(
void
*
)
sechdrs
[
relsec
].
sh_offset
;
Elf32_Sym
*
sym
;
u8
*
location
;
u32
*
loc32
;
for
(
i
=
0
;
i
<
sechdrs
[
relsec
].
sh_size
/
sizeof
(
*
rel
);
i
++
)
{
Elf32_Addr
v
;
/* This is where to make the change */
location
=
(
u8
*
)
sechdrs
[
sechdrs
[
relsec
].
sh_info
].
sh_offset
+
rel
[
i
].
r_offset
;
loc32
=
(
u32
*
)
location
;
/* This is the symbol it is referring to */
sym
=
(
Elf32_Sym
*
)
sechdrs
[
symindex
].
sh_offset
+
ELF32_R_SYM
(
rel
[
i
].
r_info
);
if
(
!
(
v
=
sym
->
st_value
))
{
printk
(
KERN_WARNING
"%s: Unknown symbol %s
\n
"
,
me
->
name
,
strtab
+
sym
->
st_name
);
return
-
ENOENT
;
}
v
+=
rel
->
r_addend
;
switch
(
ELF32_R_TYPE
(
rel
[
i
].
r_info
))
{
case
R_SPARC_32
:
location
[
0
]
=
v
>>
24
;
location
[
1
]
=
v
>>
16
;
location
[
2
]
=
v
>>
8
;
location
[
3
]
=
v
>>
0
;
break
;
case
R_SPARC_WDISP30
:
v
-=
(
Elf32_Addr
)
location
;
*
loc32
=
(
*
loc32
&
~
0x3fffffff
)
|
((
v
>>
2
)
&
0x3fffffff
);
break
;
case
R_SPARC_WDISP22
:
v
-=
(
Elf32_Addr
)
location
;
*
loc32
=
(
*
loc32
&
~
0x3fffff
)
|
((
v
>>
2
)
&
0x3fffff
);
break
;
case
R_SPARC_LO10
:
*
loc32
=
(
*
loc32
&
~
0x3ff
)
|
(
v
&
0x3ff
);
break
;
case
R_SPARC_HI22
:
*
loc32
=
(
*
loc32
&
~
0x3fffff
)
|
((
v
>>
10
)
&
0x3fffff
);
break
;
default:
printk
(
KERN_ERR
"module %s: Unknown relocation: %x
\n
"
,
me
->
name
,
(
int
)
(
ELF32_R_TYPE
(
rel
[
i
].
r_info
)
&
0xff
));
return
-
ENOEXEC
;
}
}
return
0
;
}
int
module_finalize
(
const
Elf_Ehdr
*
hdr
,
const
Elf_Shdr
*
sechdrs
,
struct
module
*
me
)
{
return
0
;
}
arch/sparc/kernel/systbls.S
View file @
c6cca1c5
...
...
@@ -54,7 +54,7 @@ sys_call_table:
/*
165
*/
.
long
sys_quotactl
,
sys_nis_syscall
,
sys_mount
,
sys_ustat
,
sys_setxattr
/*
170
*/
.
long
sys_lsetxattr
,
sys_fsetxattr
,
sys_getxattr
,
sys_lgetxattr
,
sys_getdents
/*
175
*/
.
long
sys_setsid
,
sys_fchdir
,
sys_fgetxattr
,
sys_listxattr
,
sys_llistxattr
/*
180
*/
.
long
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys_sigpending
,
sys_
query_module
/*
180
*/
.
long
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys_sigpending
,
sys_
ni_syscall
/*
185
*/
.
long
sys_setpgid
,
sys_fremovexattr
,
sys_tkill
,
sys_exit_group
,
sys_newuname
/*
190
*/
.
long
sys_init_module
,
sys_personality
,
sparc_remap_file_pages
,
sys_nis_syscall
,
sys_nis_syscall
/*
195
*/
.
long
sys_nis_syscall
,
sys_nis_syscall
,
sys_getppid
,
sparc_sigaction
,
sys_sgetmask
...
...
@@ -62,7 +62,7 @@ sys_call_table:
/*
205
*/
.
long
sys_readahead
,
sys_socketcall
,
sys_syslog
,
sys_lookup_dcookie
,
sys_nis_syscall
/*
210
*/
.
long
sys_nis_syscall
,
sys_nis_syscall
,
sys_waitpid
,
sys_swapoff
,
sys_sysinfo
/*
215
*/
.
long
sys_ipc
,
sys_sigreturn
,
sys_clone
,
sys_nis_syscall
,
sys_adjtimex
/*
220
*/
.
long
sys_sigprocmask
,
sys_
create_module
,
sys_delete_module
,
sys_get_kernel_syms
,
sys_getpgid
/*
220
*/
.
long
sys_sigprocmask
,
sys_
ni_syscall
,
sys_delete_module
,
sys_ni_syscall
,
sys_getpgid
/*
225
*/
.
long
sys_bdflush
,
sys_sysfs
,
sys_nis_syscall
,
sys_setfsuid16
,
sys_setfsgid16
/*
230
*/
.
long
sys_select
,
sys_time
,
sys_nis_syscall
,
sys_stime
,
sys_nis_syscall
/
*
"We are the Knights of the Forest of Ni!!"
*/
...
...
arch/sparc/vmlinux.lds.S
View file @
c6cca1c5
...
...
@@ -29,9 +29,12 @@ SECTIONS
__start___ex_table
=
.
;
__ex_table
:
{
*(
__ex_table
)
}
__stop___ex_table
=
.
;
.
=
ALIGN
(
64
)
;
__start___ksymtab
=
.
;
__ksymtab
:
{
*(
__ksymtab
)
}
__stop___ksymtab
=
.
;
__start___kallsyms
=
.
; /* All kernel symbols */
__kallsyms
:
{
*(
__kallsyms
)
}
__stop___kallsyms
=
.
;
...
...
arch/sparc64/kernel/Makefile
View file @
c6cca1c5
...
...
@@ -21,6 +21,7 @@ obj-$(CONFIG_SMP) += smp.o trampoline.o
obj-$(CONFIG_SPARC32_COMPAT)
+=
sys32.o sys_sparc32.o signal32.o ioctl32.o
obj-$(CONFIG_BINFMT_ELF32)
+=
binfmt_elf32.o
obj-$(CONFIG_BINFMT_AOUT32)
+=
binfmt_aout32.o
obj-$(CONFIG_MODULES)
+=
module.o
ifdef
CONFIG_SUNOS_EMUL
obj-y
+=
sys_sunos32.o sunos_ioctl32.o
...
...
arch/sparc64/kernel/module.c
0 → 100644
View file @
c6cca1c5
/* Kernel module help for sparc64.
*
* Copyright (C) 2001 Rusty Russell.
* Copyright (C) 2002 David S. Miller.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/elf.h>
#include <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/string.h>
static
void
*
alloc_and_zero
(
unsigned
long
size
)
{
void
*
ret
;
/* We handle the zero case fine, unlike vmalloc */
if
(
size
==
0
)
return
NULL
;
ret
=
vmalloc
(
size
);
if
(
!
ret
)
ret
=
ERR_PTR
(
-
ENOMEM
);
else
memset
(
ret
,
0
,
size
);
return
ret
;
}
/* Free memory returned from module_core_alloc/module_init_alloc */
void
module_free
(
struct
module
*
mod
,
void
*
module_region
)
{
vfree
(
module_region
);
/* FIXME: If module_region == mod->init_region, trim exception
table entries. */
}
void
*
module_core_alloc
(
const
Elf64_Ehdr
*
hdr
,
const
Elf64_Shdr
*
sechdrs
,
const
char
*
secstrings
,
struct
module
*
module
)
{
return
alloc_and_zero
(
module
->
core_size
);
}
void
*
module_init_alloc
(
const
Elf64_Ehdr
*
hdr
,
const
Elf64_Shdr
*
sechdrs
,
const
char
*
secstrings
,
struct
module
*
module
)
{
return
alloc_and_zero
(
module
->
init_size
);
}
int
apply_relocate
(
Elf64_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
printk
(
KERN_ERR
"module %s: non-ADD RELOCATION unsupported
\n
"
,
me
->
name
);
return
-
ENOEXEC
;
}
int
apply_relocate_add
(
Elf64_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
me
)
{
unsigned
int
i
;
Elf64_Rela
*
rel
=
(
void
*
)
sechdrs
[
relsec
].
sh_offset
;
Elf64_Sym
*
sym
;
u8
*
location
;
u32
*
loc32
;
for
(
i
=
0
;
i
<
sechdrs
[
relsec
].
sh_size
/
sizeof
(
*
rel
);
i
++
)
{
Elf64_Addr
v
;
/* This is where to make the change */
location
=
(
u8
*
)
sechdrs
[
sechdrs
[
relsec
].
sh_info
].
sh_offset
+
rel
[
i
].
r_offset
;
loc32
=
(
u32
*
)
location
;
/* This is the symbol it is referring to */
sym
=
(
Elf64_Sym
*
)
sechdrs
[
symindex
].
sh_offset
+
ELF64_R_SYM
(
rel
[
i
].
r_info
);
if
(
!
(
v
=
sym
->
st_value
))
{
printk
(
KERN_WARNING
"%s: Unknown symbol %s
\n
"
,
me
->
name
,
strtab
+
sym
->
st_name
);
return
-
ENOENT
;
}
v
+=
rel
->
r_addend
;
switch
(
ELF64_R_TYPE
(
rel
[
i
].
r_info
)
&
0xff
)
{
case
R_SPARC_64
:
location
[
0
]
=
v
>>
56
;
location
[
1
]
=
v
>>
48
;
location
[
2
]
=
v
>>
40
;
location
[
3
]
=
v
>>
32
;
location
[
4
]
=
v
>>
24
;
location
[
5
]
=
v
>>
16
;
location
[
6
]
=
v
>>
8
;
location
[
7
]
=
v
>>
0
;
break
;
case
R_SPARC_32
:
location
[
0
]
=
v
>>
24
;
location
[
1
]
=
v
>>
16
;
location
[
2
]
=
v
>>
8
;
location
[
3
]
=
v
>>
0
;
break
;
case
R_SPARC_WDISP30
:
v
-=
(
Elf64_Addr
)
location
;
*
loc32
=
(
*
loc32
&
~
0x3fffffff
)
|
((
v
>>
2
)
&
0x3fffffff
);
break
;
case
R_SPARC_WDISP22
:
v
-=
(
Elf64_Addr
)
location
;
*
loc32
=
(
*
loc32
&
~
0x3fffff
)
|
((
v
>>
2
)
&
0x3fffff
);
break
;
case
R_SPARC_LO10
:
*
loc32
=
(
*
loc32
&
~
0x3ff
)
|
(
v
&
0x3ff
);
break
;
case
R_SPARC_HI22
:
*
loc32
=
(
*
loc32
&
~
0x3fffff
)
|
((
v
>>
10
)
&
0x3fffff
);
break
;
default:
printk
(
KERN_ERR
"module %s: Unknown relocation: %x
\n
"
,
me
->
name
,
(
int
)
(
ELF64_R_TYPE
(
rel
[
i
].
r_info
)
&
0xff
));
return
-
ENOEXEC
;
}
}
return
0
;
}
int
module_finalize
(
const
Elf_Ehdr
*
hdr
,
const
Elf_Shdr
*
sechdrs
,
struct
module
*
me
)
{
return
0
;
}
arch/sparc64/kernel/sys_sparc32.c
View file @
c6cca1c5
...
...
@@ -3113,388 +3113,28 @@ asmlinkage int sparc32_execve(struct pt_regs *regs)
#ifdef CONFIG_MODULES
extern
asmlinkage
unsigned
long
sys_create_module
(
const
char
*
name_user
,
size_t
size
);
extern
asmlinkage
long
sys_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
);
asmlinkage
unsigned
long
sys32_create_module
(
const
char
*
name_user
,
__kernel_size_t32
size
)
{
return
sys_create_module
(
name_user
,
(
size_t
)
size
);
}
extern
asmlinkage
int
sys_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
);
/* Hey, when you're trying to init module, take time and prepare us a nice 64bit
* module structure, even if from 32bit modutils... Why to pollute kernel... :))
/* Hey, when you're trying to init module, take time and prepare us a nice
* 64bit module structure, even if from 32bit modutils... Why to pollute
* kernel... :))
*/
asmlinkage
int
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
sys_init_module
(
name_user
,
mod_user
);
}
extern
asmlinkage
int
sys_delete_module
(
const
char
*
name_user
);
extern
asmlinkage
long
sys_delete_module
(
const
char
*
name_user
);
asmlinkage
int
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
,
__kernel_size_t32
*
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
,
__kernel_size_t32
*
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
,
__kernel_size_t32
*
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
,
__kernel_size_t32
*
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
;
}
static
inline
int
qm_info
(
struct
module
*
mod
,
char
*
buf
,
size_t
bufsize
,
__kernel_size_t32
*
ret
)
{
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
;
}
asmlinkage
int
sys32_query_module
(
char
*
name_user
,
int
which
,
char
*
buf
,
__kernel_size_t32
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
(
which
)
{
case
0
:
err
=
0
;
break
;
case
QM_MODULES
:
err
=
qm_modules
(
buf
,
bufsize
,
(
__kernel_size_t32
*
)
AA
(
ret
));
break
;
case
QM_DEPS
:
err
=
qm_deps
(
mod
,
buf
,
bufsize
,
(
__kernel_size_t32
*
)
AA
(
ret
));
break
;
case
QM_REFS
:
err
=
qm_refs
(
mod
,
buf
,
bufsize
,
(
__kernel_size_t32
*
)
AA
(
ret
));
break
;
case
QM_SYMBOLS
:
err
=
qm_symbols
(
mod
,
buf
,
bufsize
,
(
__kernel_size_t32
*
)
AA
(
ret
));
break
;
case
QM_INFO
:
err
=
qm_info
(
mod
,
buf
,
bufsize
,
(
__kernel_size_t32
*
)
AA
(
ret
));
break
;
default:
err
=
-
EINVAL
;
break
;
}
out:
unlock_kernel
();
return
err
;
}
struct
kernel_sym32
{
u32
value
;
char
name
[
60
];
};
extern
asmlinkage
int
sys_get_kernel_syms
(
struct
kernel_sym
*
table
);
asmlinkage
int
sys32_get_kernel_syms
(
struct
kernel_sym32
*
table
)
{
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
++
)
{
if
(
put_user
(
tbl
[
i
].
value
,
&
table
->
value
)
||
copy_to_user
(
table
->
name
,
tbl
[
i
].
name
,
60
))
break
;
}
kfree
(
tbl
);
return
i
;
}
#else
/* CONFIG_MODULES */
asmlinkage
unsigned
long
sys32_create_module
(
const
char
*
name_user
,
size_t
size
)
{
return
-
ENOSYS
;
}
asmlinkage
int
sys32_init_module
(
const
char
*
name_user
,
struct
module
*
mod_user
)
{
...
...
@@ -3507,24 +3147,6 @@ sys32_delete_module(const char *name_user)
return
-
ENOSYS
;
}
asmlinkage
int
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
int
sys32_get_kernel_syms
(
struct
kernel_sym
*
table
)
{
return
-
ENOSYS
;
}
#endif
/* CONFIG_MODULES */
#if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)
...
...
arch/sparc64/kernel/systbls.S
View file @
c6cca1c5
...
...
@@ -55,7 +55,7 @@ sys_call_table32:
.
word
sys_quotactl
,
sys_nis_syscall
,
sys32_mount
,
sys_ustat
,
sys_setxattr
/*
170
*/
.
word
sys_lsetxattr
,
sys_fsetxattr
,
sys_getxattr
,
sys_lgetxattr
,
sys32_getdents
.
word
sys_setsid
,
sys_fchdir
,
sys_fgetxattr
,
sys_listxattr
,
sys_llistxattr
/*
180
*/
.
word
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys32_sigpending
,
sys
32_query_module
/*
180
*/
.
word
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys32_sigpending
,
sys
_ni_syscall
.
word
sys_setpgid
,
sys_fremovexattr
,
sys_tkill
,
sys_exit_group
,
sparc64_newuname
/*
190
*/
.
word
sys32_init_module
,
sparc64_personality
,
sys_remap_file_pages
,
sys_nis_syscall
,
sys_nis_syscall
.
word
sys_nis_syscall
,
sys_nis_syscall
,
sys_getppid
,
sys32_sigaction
,
sys_sgetmask
...
...
@@ -63,7 +63,7 @@ sys_call_table32:
.
word
sys32_readahead
,
sys32_socketcall
,
sys_syslog
,
sys_lookup_dcookie
,
sys_nis_syscall
/*
210
*/
.
word
sys_nis_syscall
,
sys_nis_syscall
,
sys_waitpid
,
sys_swapoff
,
sys32_sysinfo
.
word
sys32_ipc
,
sys32_sigreturn
,
sys_clone
,
sys_nis_syscall
,
sys32_adjtimex
/*
220
*/
.
word
sys32_sigprocmask
,
sys
32_create_module
,
sys32_delete_module
,
sys32_get_kernel_syms
,
sys_getpgid
/*
220
*/
.
word
sys32_sigprocmask
,
sys
_ni_syscall
,
sys32_delete_module
,
sys_ni_syscall
,
sys_getpgid
.
word
sys32_bdflush
,
sys32_sysfs
,
sys_nis_syscall
,
sys32_setfsuid16
,
sys32_setfsgid16
/*
230
*/
.
word
sys32_select
,
sys_time
,
sys_nis_syscall
,
sys_stime
,
sys_alloc_hugepages
.
word
sys_free_hugepages
,
sys_llseek
,
sys_mlock
,
sys_munlock
,
sys_mlockall
...
...
@@ -114,7 +114,7 @@ sys_call_table:
.
word
sys_quotactl
,
sys_nis_syscall
,
sys_mount
,
sys_ustat
,
sys_setxattr
/*
170
*/
.
word
sys_lsetxattr
,
sys_fsetxattr
,
sys_getxattr
,
sys_lgetxattr
,
sys_getdents
.
word
sys_setsid
,
sys_fchdir
,
sys_fgetxattr
,
sys_listxattr
,
sys_llistxattr
/*
180
*/
.
word
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys_nis_syscall
,
sys_
query_module
/*
180
*/
.
word
sys_flistxattr
,
sys_removexattr
,
sys_lremovexattr
,
sys_nis_syscall
,
sys_
ni_syscall
.
word
sys_setpgid
,
sys_fremovexattr
,
sys_tkill
,
sys_exit_group
,
sparc64_newuname
/*
190
*/
.
word
sys_init_module
,
sparc64_personality
,
sys_remap_file_pages
,
sys_nis_syscall
,
sys_nis_syscall
.
word
sys_nis_syscall
,
sys_nis_syscall
,
sys_getppid
,
sys_nis_syscall
,
sys_sgetmask
...
...
@@ -122,7 +122,7 @@ sys_call_table:
.
word
sys_readahead
,
sys_socketcall
,
sys_syslog
,
sys_lookup_dcookie
,
sys_nis_syscall
/*
210
*/
.
word
sys_nis_syscall
,
sys_nis_syscall
,
sys_waitpid
,
sys_swapoff
,
sys_sysinfo
.
word
sys_ipc
,
sys_nis_syscall
,
sys_clone
,
sys_nis_syscall
,
sys_adjtimex
/*
220
*/
.
word
sys_nis_syscall
,
sys_
create_module
,
sys_delete_module
,
sys_get_kernel_syms
,
sys_getpgid
/*
220
*/
.
word
sys_nis_syscall
,
sys_
ni_syscall
,
sys_delete_module
,
sys_ni_syscall
,
sys_getpgid
.
word
sys_bdflush
,
sys_sysfs
,
sys_nis_syscall
,
sys_setfsuid
,
sys_setfsgid
/*
230
*/
.
word
sys_select
,
sys_nis_syscall
,
sys_nis_syscall
,
sys_stime
,
sys_nis_syscall
.
word
sys_nis_syscall
,
sys_llseek
,
sys_mlock
,
sys_munlock
,
sys_mlockall
...
...
arch/sparc64/mm/Makefile
View file @
c6cca1c5
...
...
@@ -4,7 +4,7 @@
EXTRA_AFLAGS
:=
-ansi
obj-y
:=
ultra.o fault.o init.o generic.o extable.o
modutil.o
obj-y
:=
ultra.o fault.o init.o generic.o extable.o
obj-$(CONFIG_HUGETLB_PAGE)
+=
hugetlbpage.o
...
...
arch/sparc64/mm/modutil.c
deleted
100644 → 0
View file @
467c4b2e
/* $Id: modutil.c,v 1.11 2001/12/05 06:05:35 davem Exp $
* arch/sparc64/mm/modutil.c
*
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
* Based upon code written by Linus Torvalds and others.
*/
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <asm/uaccess.h>
#include <asm/system.h>
static
struct
vm_struct
*
modvmlist
=
NULL
;
void
module_unmap
(
void
*
addr
)
{
struct
vm_struct
**
p
,
*
tmp
;
int
i
;
if
(
!
addr
)
return
;
if
((
PAGE_SIZE
-
1
)
&
(
unsigned
long
)
addr
)
{
printk
(
"Trying to unmap module with bad address (%p)
\n
"
,
addr
);
return
;
}
for
(
p
=
&
modvmlist
;
(
tmp
=
*
p
)
;
p
=
&
tmp
->
next
)
{
if
(
tmp
->
addr
==
addr
)
{
*
p
=
tmp
->
next
;
goto
found
;
}
}
printk
(
"Trying to unmap nonexistent module vm area (%p)
\n
"
,
addr
);
return
;
found:
unmap_vm_area
(
tmp
);
for
(
i
=
0
;
i
<
tmp
->
nr_pages
;
i
++
)
{
if
(
unlikely
(
!
tmp
->
pages
[
i
]))
BUG
();
__free_page
(
tmp
->
pages
[
i
]);
}
kfree
(
tmp
->
pages
);
kfree
(
tmp
);
}
void
*
module_map
(
unsigned
long
size
)
{
struct
vm_struct
**
p
,
*
tmp
,
*
area
;
struct
page
**
pages
;
void
*
addr
;
unsigned
int
nr_pages
,
array_size
,
i
;
size
=
PAGE_ALIGN
(
size
);
if
(
!
size
||
size
>
MODULES_LEN
)
return
NULL
;
addr
=
(
void
*
)
MODULES_VADDR
;
for
(
p
=
&
modvmlist
;
(
tmp
=
*
p
)
;
p
=
&
tmp
->
next
)
{
if
(
size
+
(
unsigned
long
)
addr
<
(
unsigned
long
)
tmp
->
addr
)
break
;
addr
=
(
void
*
)
(
tmp
->
size
+
(
unsigned
long
)
tmp
->
addr
);
}
if
((
unsigned
long
)
addr
+
size
>=
MODULES_END
)
return
NULL
;
area
=
(
struct
vm_struct
*
)
kmalloc
(
sizeof
(
*
area
),
GFP_KERNEL
);
if
(
!
area
)
return
NULL
;
area
->
size
=
size
+
PAGE_SIZE
;
area
->
addr
=
addr
;
area
->
next
=
*
p
;
area
->
pages
=
NULL
;
area
->
nr_pages
=
0
;
area
->
phys_addr
=
0
;
*
p
=
area
;
nr_pages
=
size
>>
PAGE_SHIFT
;
array_size
=
(
nr_pages
*
sizeof
(
struct
page
*
));
area
->
nr_pages
=
nr_pages
;
area
->
pages
=
pages
=
kmalloc
(
array_size
,
GFP_KERNEL
);
if
(
!
area
->
pages
)
goto
fail
;
memset
(
area
->
pages
,
0
,
array_size
);
for
(
i
=
0
;
i
<
area
->
nr_pages
;
i
++
)
{
area
->
pages
[
i
]
=
alloc_page
(
GFP_KERNEL
);
if
(
unlikely
(
!
area
->
pages
[
i
]))
goto
fail
;
}
if
(
map_vm_area
(
area
,
PAGE_KERNEL
,
&
pages
))
{
unmap_vm_area
(
area
);
goto
fail
;
}
return
area
->
addr
;
fail:
if
(
area
->
pages
)
{
for
(
i
=
0
;
i
<
area
->
nr_pages
;
i
++
)
{
if
(
area
->
pages
[
i
])
__free_page
(
area
->
pages
[
i
]);
}
kfree
(
area
->
pages
);
}
kfree
(
area
);
return
NULL
;
}
arch/sparc64/vmlinux.lds.S
View file @
c6cca1c5
...
...
@@ -27,10 +27,13 @@ SECTIONS
_edata
=
.
;
PROVIDE
(
edata
=
.
)
;
.
fixup
:
{
*(
.
fixup
)
}
.
=
ALIGN
(
16
)
;
__start___ex_table
=
.
;
__ex_table
:
{
*(
__ex_table
)
}
__stop___ex_table
=
.
;
.
=
ALIGN
(
64
)
;
__start___ksymtab
=
.
;
__ksymtab
:
{
*(
__ksymtab
)
}
__stop___ksymtab
=
.
;
...
...
include/asm-sparc/module.h
View file @
c6cca1c5
#ifndef _ASM_SPARC_MODULE_H
#define _ASM_SPARC_MODULE_H
/*
* This file contains the sparc architecture specific module code.
*/
#define module_map(x) vmalloc(x)
#define module_unmap(x) vfree(x)
#define module_arch_init(x) (0)
#define arch_init_modules(x) do { } while (0)
struct
mod_arch_specific
{
};
#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
#define Elf_Ehdr Elf32_Ehdr
#endif
/* _ASM_SPARC_MODULE_H */
include/asm-sparc64/module.h
View file @
c6cca1c5
#ifndef _ASM_SPARC64_MODULE_H
#define _ASM_SPARC64_MODULE_H
/*
* This file contains the sparc64 architecture specific module code.
*/
extern
void
*
module_map
(
unsigned
long
size
);
extern
void
module_unmap
(
void
*
addr
);
#define module_arch_init(x) (0)
#define arch_init_modules(x) do { } while (0)
struct
mod_arch_specific
{
};
#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
#define Elf_Ehdr Elf64_Ehdr
#endif
/* _ASM_SPARC64_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