Skip to contentSkip to conversation

2.5.48 s390 (5/16): module loader.

PATCH New Martin Schwidefsky 1 participant 1 message Nov 18, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.48 s390 (5/16): module loader.

arch/s390/kernel/Makefile +1 -1
diff -urN linux-2.5.48/arch/s390/kernel/Makefile linux-2.5.48-s390/arch/s390/kernel/Makefile
@@ -10,7 +10,7 @@
             setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
             semaphore.o reipl.o s390_ext.o debug.o
 
-obj-$(CONFIG_MODULES)		+= s390_ksyms.o
+obj-$(CONFIG_MODULES)		+= s390_ksyms.o module.o
 obj-$(CONFIG_SMP)		+= smp.o
 
 #
arch/s390/kernel/entry.S +3 -3
diff -urN linux-2.5.48/arch/s390/kernel/entry.S linux-2.5.48-s390/arch/s390/kernel/entry.S
@@ -474,10 +474,10 @@
         .long  sys_adjtimex
         .long  sys_mprotect              /* 125 */
         .long  sys_sigprocmask
-        .long  sys_create_module
+        .long  sys_ni_syscall		 /* old "create module" */
         .long  sys_init_module
         .long  sys_delete_module
-        .long  sys_get_kernel_syms       /* 130 */
+        .long  sys_ni_syscall		 /* 130: old get_kernel_syms */
         .long  sys_quotactl
         .long  sys_getpgid
         .long  sys_fchdir
@@ -514,7 +514,7 @@
         .long  sys_setresuid16
         .long  sys_getresuid16           /* 165 */
         .long  sys_ni_syscall            /* for vm86 */
-        .long  sys_query_module
+        .long  sys_ni_syscall		 /* old sys_query_module */
         .long  sys_poll
         .long  sys_nfsservctl
         .long  sys_setresgid16           /* 170 */
arch/s390/kernel/module.c +174 -0

174 lines not on this page · raw message

arch/s390/kernel/traps.c +4 -4
diff -urN linux-2.5.48/arch/s390/kernel/traps.c linux-2.5.48-s390/arch/s390/kernel/traps.c
@@ -72,8 +72,8 @@
 
 #ifdef CONFIG_MODULES
 
-extern struct module *module_list;
-extern struct module kernel_module;
+/* FIXME: Accessed without a lock --RR */
+extern struct list_head modules;
 
 static inline int kernel_text_address(unsigned long addr)
 {
@@ -84,11 +84,11 @@
 	    addr <= (unsigned long) &_etext)
 		return 1;
 
-	for (mod = module_list; mod != &kernel_module; mod = mod->next) {
+	list_for_each_entry(mod, &modules, list) {
 		/* mod_bound tests for addr being inside the vmalloc'ed
 		 * module area. Of course it'd be better to test only
 		 * for the .text subset... */
-		if (mod_bound(addr, 0, mod)) {
+		if (mod_bound((void*)addr, 0, mod)) {
 			retval = 1;
 			break;
 		}
arch/s390/mm/extable.c +8 -6
diff -urN linux-2.5.48/arch/s390/mm/extable.c linux-2.5.48-s390/arch/s390/mm/extable.c
@@ -42,6 +42,7 @@
 unsigned long
 search_exception_table(unsigned long addr)
 {
+	struct list_head *i;
 	unsigned long ret = 0;
 
 #ifndef CONFIG_MODULES
@@ -52,16 +53,17 @@
 	return ret;
 #else
 	unsigned long flags;
-	/* The kernel is the last "module" -- no need to treat it special.  */
-	struct module *mp;
         addr &= 0x7fffffff;  /* remove amode bit from address */
 
+	/* The kernel is the last "module" -- no need to treat it special. */
 	spin_lock_irqsave(&modlist_lock, flags);
-	for (mp = module_list; mp != NULL; mp = mp->next) {
-		if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
+	list_for_each(i, &extables) {
+		struct exception_table *ex
+			= list_entry(i, struct exception_table, list);
+		if (ex->num_entries == 0)
 			continue;
-		ret = search_one_table(mp->ex_table_start,
-				       mp->ex_table_end - 1, addr);
+		ret = search_one_table(ex->entry,
+				       ex->entry + ex->num_entries - 1, addr);
 		if (ret) {
 			ret = ret | PSW_ADDR_AMODE31;
 			break;
arch/s390x/kernel/Makefile +1 -1
diff -urN linux-2.5.48/arch/s390x/kernel/Makefile linux-2.5.48-s390/arch/s390x/kernel/Makefile
@@ -12,7 +12,7 @@
 		   setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
 		   semaphore.o reipl.o s390_ext.o debug.o
 
-obj-$(CONFIG_MODULES)		+= s390_ksyms.o
+obj-$(CONFIG_MODULES)		+= s390_ksyms.o module.o
 obj-$(CONFIG_SMP)		+= smp.o
 
 #
arch/s390x/kernel/entry.S +3 -3
diff -urN linux-2.5.48/arch/s390x/kernel/entry.S linux-2.5.48-s390/arch/s390x/kernel/entry.S
@@ -503,10 +503,10 @@
         .long  SYSCALL(sys_adjtimex,sys32_adjtimex_wrapper)
         .long  SYSCALL(sys_mprotect,sys32_mprotect_wrapper) /* 125 */
         .long  SYSCALL(sys_sigprocmask,sys32_sigprocmask_wrapper)
-        .long  SYSCALL(sys_create_module,sys32_create_module_wrapper)
+        .long  SYSCALL(sys_ni_syscall,sys_ni_syscall) /* old "create module" */
         .long  SYSCALL(sys_init_module,sys32_init_module_wrapper)
         .long  SYSCALL(sys_delete_module,sys32_delete_module_wrapper)
-        .long  SYSCALL(sys_get_kernel_syms,sys32_get_kernel_syms_wrapper) /* 130 */
+        .long  SYSCALL(sys_ni_syscall,sys_ni_syscall) /* 130: old get_kernel_syms */
         .long  SYSCALL(sys_quotactl,sys32_quotactl_wrapper)
         .long  SYSCALL(sys_getpgid,sys32_getpgid_wrapper)
         .long  SYSCALL(sys_fchdir,sys32_fchdir_wrapper)
@@ -543,7 +543,7 @@
         .long  SYSCALL(sys_ni_syscall,sys32_setresuid16_wrapper) /* old setresuid16 syscall */
         .long  SYSCALL(sys_ni_syscall,sys32_getresuid16_wrapper) /* old getresuid16 syscall */
         .long  SYSCALL(sys_ni_syscall,sys_ni_syscall) /* for vm86 */
-        .long  SYSCALL(sys_query_module,sys32_query_module_wrapper)
+        .long  SYSCALL(sys_ni_syscall,sys_ni_syscall) /* old sys_query_module */
         .long  SYSCALL(sys_poll,sys32_poll_wrapper)
         .long  SYSCALL(sys_nfsservctl,sys32_nfsservctl_wrapper)
         .long  SYSCALL(sys_ni_syscall,sys32_setresgid16_wrapper) /* old setresgid16 syscall */
arch/s390x/kernel/linux32.c +0 -115

140 lines not on this page · raw message

arch/s390x/kernel/module.c +190 -0

190 lines not on this page · raw message

arch/s390x/kernel/traps.c +4 -4
diff -urN linux-2.5.48/arch/s390x/kernel/traps.c linux-2.5.48-s390/arch/s390x/kernel/traps.c
@@ -74,8 +74,8 @@
 
 #ifdef CONFIG_MODULES
 
-extern struct module *module_list;
-extern struct module kernel_module;
+/* FIXME: Accessed without a lock --RR */
+extern struct list_head modules;
 
 static inline int kernel_text_address(unsigned long addr)
 {
@@ -86,11 +86,11 @@
 	    addr <= (unsigned long) &_etext)
 		return 1;
 
-	for (mod = module_list; mod != &kernel_module; mod = mod->next) {
+	list_for_each_entry(mod, &modules, list) {
 		/* mod_bound tests for addr being inside the vmalloc'ed
 		 * module area. Of course it'd be better to test only
 		 * for the .text subset... */
-		if (mod_bound(addr, 0, mod)) {
+		if (mod_bound((void*)addr, 0, mod)) {
 			retval = 1;
 			break;
 		}
arch/s390x/kernel/wrapper32.S +0 -20
diff -urN linux-2.5.48/arch/s390x/kernel/wrapper32.S linux-2.5.48-s390/arch/s390x/kernel/wrapper32.S
@@ -564,12 +564,6 @@
 	llgtr	%r4,%r4			# old_sigset_emu31 *
 	jg	sys32_sigprocmask		# branch to system call
 
-	.globl  sys32_create_module_wrapper 
-sys32_create_module_wrapper:
-	llgtr	%r2,%r2			# const char *
-	llgfr	%r3,%r3			# size_t
-	jg	sys32_create_module	# branch to system call
-
 	.globl  sys32_init_module_wrapper 
 sys32_init_module_wrapper:
 	llgtr	%r2,%r2			# const char *
@@ -581,11 +575,6 @@
 	llgtr	%r2,%r2			# const char *
 	jg	sys32_delete_module	# branch to system call
 
-	.globl  sys32_get_kernel_syms_wrapper 
-sys32_get_kernel_syms_wrapper:
-	llgtr	%r2,%r2			# struct kernel_sym_emu31 *
-	jg	sys32_get_kernel_syms	# branch to system call
-
 	.globl  sys32_quotactl_wrapper 
 sys32_quotactl_wrapper:
 	lgfr	%r2,%r2			# int
@@ -786,15 +775,6 @@
 	llgtr	%r4,%r4			# __kernel_old_uid_emu31_t *
 	jg	sys32_getresuid16	# branch to system call
 
-	.globl  sys32_query_module_wrapper 
-sys32_query_module_wrapper:
-	llgtr	%r2,%r2			# const char * 
-	lgfr	%r3,%r3			# int 
-	llgtr	%r4,%r4			# char * 
-	llgfr	%r5,%r5			# size_t 
-	llgtr	%r6,%r6			# size_t * 
-	jg	sys32_query_module	# branch to system call
-
 	.globl  sys32_poll_wrapper 
 sys32_poll_wrapper:
 	llgtr	%r2,%r2			# struct pollfd * 
arch/s390x/mm/extable.c +12 -11
diff -urN linux-2.5.48/arch/s390x/mm/extable.c linux-2.5.48-s390/arch/s390x/mm/extable.c
@@ -2,10 +2,8 @@
  *  arch/s390/mm/extable.c
  *
  *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Hartmut Penner ([email protected])
  *
- *  Derived from "arch/i386/mm/extable.c"
+ *  identical to arch/i386/mm/extable.c
  */
 
 #include <linux/config.h>
@@ -42,24 +40,27 @@
 unsigned long
 search_exception_table(unsigned long addr)
 {
+	struct list_head *i;
 	unsigned long ret = 0;
-
+	
 #ifndef CONFIG_MODULES
 	/* There is only the kernel to search.  */
 	ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
 	return ret;
 #else
 	unsigned long flags;
-	/* The kernel is the last "module" -- no need to treat it special.  */
-	struct module *mp;
+	struct list_head *i;
 
+	/* The kernel is the last "module" -- no need to treat it special.  */
 	spin_lock_irqsave(&modlist_lock, flags);
-	for (mp = module_list; mp != NULL; mp = mp->next) {
-		if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
+	list_for_each(i, &extables) {
+		struct exception_table *ex
+			= list_entry(i, struct exception_table, list);
+		if (ex->num_entries == 0)
 			continue;
-		ret = search_one_table(mp->ex_table_start,
-				       mp->ex_table_end - 1, addr);
-		if (ret) 
+		ret = search_one_table(ex->entry,
+				       ex->entry + ex->num_entries - 1, addr);
+		if (ret)
 			break;
 	}
 	spin_unlock_irqrestore(&modlist_lock, flags);
include/asm-s390/module.h +17 -4
diff -urN linux-2.5.48/include/asm-s390/module.h linux-2.5.48-s390/include/asm-s390/module.h
@@ -4,9 +4,22 @@
  * This file contains the s390 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
+{
+	void *module_got, *module_plt;
+	unsigned long got_size, plt_size;
+};
 
+#ifdef CONFIG_ARCH_S390X
+#define ElfW(x) Elf64_ ## x
+#define ELFW(x) ELF64_ ## x
+#else
+#define ElfW(x) Elf32_ ## x
+#define ELFW(x) ELF32_ ## x
+#endif
+
+#define Elf_Shdr ElfW(Shdr)
+#define Elf_Sym ElfW(Sym)
+#define Elf_Ehdr ElfW(Ehdr)
+#define ELF_R_TYPE ELFW(R_TYPE)
 #endif /* _ASM_S390_MODULE_H */
include/asm-s390x/module.h +17 -4
diff -urN linux-2.5.48/include/asm-s390x/module.h linux-2.5.48-s390/include/asm-s390x/module.h
@@ -4,9 +4,22 @@
  * This file contains the s390 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
+{
+	void *module_got, *module_plt;
+	unsigned long got_size, plt_size;
+};
 
+#ifdef CONFIG_ARCH_S390X
+#define ElfW(x) Elf64_ ## x
+#define ELFW(x) ELF64_ ## x
+#else
+#define ElfW(x) Elf32_ ## x
+#define ELFW(x) ELF64_ ## x
+#endif
+
+#define Elf_Shdr ElfW(Shdr)
+#define Elf_Sym ElfW(Sym)
+#define Elf_Ehdr ElfW(Ehdr)
+#define ELF_R_TYPE ELFW(R_TYPE)
 #endif /* _ASM_S390_MODULE_H */
include/linux/elf.h +31 -0
diff -urN linux-2.5.48/include/linux/elf.h linux-2.5.48-s390/include/linux/elf.h
@@ -413,6 +413,37 @@
 /* Keep this the last entry.  */
 #define R_PPC_NUM		37
 
+/* s390 relocations defined by the ABIs */
+#define R_390_NONE	0	       /* No reloc.  */
+#define R_390_8		1	       /* Direct 8 bit.	 */
+#define R_390_12	2	       /* Direct 12 bit.  */
+#define R_390_16	3	       /* Direct 16 bit.  */
+#define R_390_32	4	       /* Direct 32 bit.  */
+#define R_390_PC32	5	       /* PC relative 32 bit.  */
+#define R_390_GOT12	6	       /* 12 bit GOT offset.  */
+#define R_390_GOT32	7	       /* 32 bit GOT offset.  */
+#define R_390_PLT32	8	       /* 32 bit PC relative PLT address.  */
+#define R_390_COPY	9	       /* Copy symbol at runtime.  */
+#define R_390_GLOB_DAT	10	       /* Create GOT entry.  */
+#define R_390_JMP_SLOT	11	       /* Create PLT entry.  */
+#define R_390_RELATIVE	12	       /* Adjust by program base.  */
+#define R_390_GOTOFF	13	       /* 32 bit offset to GOT.	 */
+#define R_390_GOTPC	14	       /* 32 bit PC relative offset to GOT.  */
+#define R_390_GOT16	15	       /* 16 bit GOT offset.  */
+#define R_390_PC16	16	       /* PC relative 16 bit.  */
+#define R_390_PC16DBL	17	       /* PC relative 16 bit shifted by 1.  */
+#define R_390_PLT16DBL	18	       /* 16 bit PC rel. PLT shifted by 1.  */
+#define R_390_PC32DBL	19	       /* PC relative 32 bit shifted by 1.  */
+#define R_390_PLT32DBL	20	       /* 32 bit PC rel. PLT shifted by 1.  */
+#define R_390_GOTPCDBL	21	       /* 32 bit PC rel. GOT shifted by 1.  */
+#define R_390_64	22	       /* Direct 64 bit.  */
+#define R_390_PC64	23	       /* PC relative 64 bit.  */
+#define R_390_GOT64	24	       /* 64 bit GOT offset.  */
+#define R_390_PLT64	25	       /* 64 bit PC relative PLT address.  */
+#define R_390_GOTENT	26	       /* 32 bit PC rel. to GOT entry >> 1. */
+/* Keep this the last entry.  */
+#define R_390_NUM	27
+
 /* Legal values for e_flags field of Elf64_Ehdr.  */
 
 #define EF_ALPHA_32BIT		1	/* All addresses are below 2GB */