Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jul 2017 21:24:20 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321728 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux
Message-ID:  <201707302124.v6ULOKVf054084@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun Jul 30 21:24:20 2017
New Revision: 321728
URL: https://svnweb.freebsd.org/changeset/base/321728

Log:
  Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code.
  This is needed for https://reviews.freebsd.org/D11780.
  
  Reported by:	kib@

Modified:
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/compat/linux/linux_vdso.c
  head/sys/compat/linux/linux_vdso.h
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- head/sys/amd64/linux/linux_sysvec.c	Sun Jul 30 19:58:31 2017	(r321727)
+++ head/sys/amd64/linux/linux_sysvec.c	Sun Jul 30 21:24:20 2017	(r321728)
@@ -844,14 +844,14 @@ linux_vdso_install(void *param)
 	linux_shared_page_obj = __elfN(linux_shared_page_init)
 	    (&linux_shared_page_mapping);
 
-	__elfN(linux_vdso_reloc)(&elf_linux_sysvec, SHAREDPAGE);
+	__elfN(linux_vdso_reloc)(&elf_linux_sysvec);
 
 	bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
 
 	linux_kplatform = linux_shared_page_mapping +
-	    (linux_platform - (caddr_t)SHAREDPAGE);
+	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     (sysinit_cfunc_t)linux_vdso_install, NULL);

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c	Sun Jul 30 19:58:31 2017	(r321727)
+++ head/sys/amd64/linux32/linux32_sysvec.c	Sun Jul 30 21:24:20 2017	(r321728)
@@ -1062,14 +1062,14 @@ linux_vdso_install(void *param)
 	linux_shared_page_obj = __elfN(linux_shared_page_init)
 	    (&linux_shared_page_mapping);
 
-	__elfN(linux_vdso_reloc)(&elf_linux_sysvec, LINUX32_SHAREDPAGE);
+	__elfN(linux_vdso_reloc)(&elf_linux_sysvec);
 
 	bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
 
 	linux_kplatform = linux_shared_page_mapping +
-	    (linux_platform - (caddr_t)LINUX32_SHAREDPAGE);
+	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     (sysinit_cfunc_t)linux_vdso_install, NULL);

Modified: head/sys/compat/linux/linux_vdso.c
==============================================================================
--- head/sys/compat/linux/linux_vdso.c	Sun Jul 30 19:58:31 2017	(r321727)
+++ head/sys/compat/linux/linux_vdso.c	Sun Jul 30 21:24:20 2017	(r321728)
@@ -139,7 +139,7 @@ __elfN(linux_vdso_fixup)(struct sysentvec *sv)
 }
 
 void
-__elfN(linux_vdso_reloc)(struct sysentvec *sv, long vdso_adjust)
+__elfN(linux_vdso_reloc)(struct sysentvec *sv)
 {
 	struct linux_vdso_sym *lsym;
 	Elf_Ehdr *ehdr;
@@ -152,13 +152,13 @@ __elfN(linux_vdso_reloc)(struct sysentvec *sv, long vd
 	ehdr = (Elf_Ehdr *) sv->sv_sigcode;
 
 	/* Adjust our so relative to the sigcode_base */
-	if (vdso_adjust != 0) {
-		ehdr->e_entry += vdso_adjust;
+	if (sv->sv_shared_page_base != 0) {
+		ehdr->e_entry += sv->sv_shared_page_base;
 		phdr = (Elf_Phdr *)((caddr_t)ehdr + ehdr->e_phoff);
 
 		/* phdrs */
 		for (i = 0; i < ehdr->e_phnum; i++) {
-			phdr[i].p_vaddr += vdso_adjust;
+			phdr[i].p_vaddr += sv->sv_shared_page_base;
 			if (phdr[i].p_type != PT_DYNAMIC)
 				continue;
 			dyn = (Elf_Dyn *)((caddr_t)ehdr + phdr[i].p_offset);
@@ -178,13 +178,13 @@ __elfN(linux_vdso_reloc)(struct sysentvec *sv, long vd
 				case DT_VERDEF:
 				case DT_VERNEED:
 				case DT_ADDRRNGLO ... DT_ADDRRNGHI:
-					dyn->d_un.d_ptr += vdso_adjust;
+					dyn->d_un.d_ptr += sv->sv_shared_page_base;
 					break;
 				case DT_ENCODING ... DT_LOOS-1:
 				case DT_LOOS ... DT_HIOS:
 					if (dyn->d_tag >= DT_ENCODING &&
 					    (dyn->d_tag & 1) == 0)
-						dyn->d_un.d_ptr += vdso_adjust;
+						dyn->d_un.d_ptr += sv->sv_shared_page_base;
 					break;
 				default:
 					break;
@@ -197,7 +197,7 @@ __elfN(linux_vdso_reloc)(struct sysentvec *sv, long vd
 		for(i = 0; i < ehdr->e_shnum; i++) {
 			if (!(shdr[i].sh_flags & SHF_ALLOC))
 				continue;
-			shdr[i].sh_addr += vdso_adjust;
+			shdr[i].sh_addr += sv->sv_shared_page_base;
 			if (shdr[i].sh_type != SHT_SYMTAB &&
 			    shdr[i].sh_type != SHT_DYNSYM)
 				continue;
@@ -209,7 +209,7 @@ __elfN(linux_vdso_reloc)(struct sysentvec *sv, long vd
 				if (sym->st_shndx == SHN_UNDEF ||
 				    sym->st_shndx == SHN_ABS)
 					continue;
-				sym->st_value += vdso_adjust;
+				sym->st_value += sv->sv_shared_page_base;
 			}
 		}
 	}

Modified: head/sys/compat/linux/linux_vdso.h
==============================================================================
--- head/sys/compat/linux/linux_vdso.h	Sun Jul 30 19:58:31 2017	(r321727)
+++ head/sys/compat/linux/linux_vdso.h	Sun Jul 30 21:24:20 2017	(r321728)
@@ -41,7 +41,7 @@ struct linux_vdso_sym {
 vm_object_t __elfN(linux_shared_page_init)(char **);
 void	__elfN(linux_shared_page_fini)(vm_object_t);
 void	__elfN(linux_vdso_fixup)(struct sysentvec *);
-void	__elfN(linux_vdso_reloc)(struct sysentvec *, long);
+void	__elfN(linux_vdso_reloc)(struct sysentvec *);
 void	__elfN(linux_vdso_sym_init)(struct linux_vdso_sym *);
 
 #define	LINUX_VDSO_SYM_INTPTR(name)				\

Modified: head/sys/i386/linux/linux_sysvec.c
==============================================================================
--- head/sys/i386/linux/linux_sysvec.c	Sun Jul 30 19:58:31 2017	(r321727)
+++ head/sys/i386/linux/linux_sysvec.c	Sun Jul 30 21:24:20 2017	(r321728)
@@ -1044,7 +1044,7 @@ linux_vdso_install(void *param)
 	linux_shared_page_obj = __elfN(linux_shared_page_init)
 	    (&linux_shared_page_mapping);
 
-	__elfN(linux_vdso_reloc)(&elf_linux_sysvec, LINUX_SHAREDPAGE);
+	__elfN(linux_vdso_reloc)(&elf_linux_sysvec);
 
 	bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
 	    linux_szsigcode);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707302124.v6ULOKVf054084>