From owner-svn-src-head@freebsd.org Thu May 10 03:59:50 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4ED53FADCAE; Thu, 10 May 2018 03:59:50 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1168873AD; Thu, 10 May 2018 03:59:49 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2BC91B1BC; Thu, 10 May 2018 03:59:49 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4A3xnSe099890; Thu, 10 May 2018 03:59:49 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4A3xnpY099886; Thu, 10 May 2018 03:59:49 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201805100359.w4A3xnpY099886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Thu, 10 May 2018 03:59:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333447 - in head/sys: ddb powerpc/include powerpc/pseries X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys: ddb powerpc/include powerpc/pseries X-SVN-Commit-Revision: 333447 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 03:59:50 -0000 Author: jhibbits Date: Thu May 10 03:59:48 2018 New Revision: 333447 URL: https://svnweb.freebsd.org/changeset/base/333447 Log: Fix PPC symbol resolution Summary: There were 2 issues that were preventing correct symbol resolution on PowerPC/pseries: 1- memory corruption at chrp_attach() - this caused the inital part of the symbol table to become zeroed, which would cause the kernel linker to fail to parse it. (this was probably zeroing out other memory parts as well) 2- DDB symbol resolution wasn't working because symtab contained not relocated addresses but it was given relocated offsets. Although relocating the symbol table fixed this, it broke the linker, that already handled this case. Thus, the fix for this consists in adding a new DDB macro: DB_STOFFS(offs) that converts a (potentially) relocated offset into one that can be compared with symbol table values. PR: 227093 Submitted by: Leandro Lupori Differential Revision: https://reviews.freebsd.org/D15372 Modified: head/sys/ddb/db_main.c head/sys/ddb/ddb.h head/sys/powerpc/include/db_machdep.h head/sys/powerpc/pseries/platform_chrp.c Modified: head/sys/ddb/db_main.c ============================================================================== --- head/sys/ddb/db_main.c Thu May 10 03:50:20 2018 (r333446) +++ head/sys/ddb/db_main.c Thu May 10 03:59:48 2018 (r333447) @@ -100,6 +100,7 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, c_linker_sym_t lsym; Elf_Sym *sym, *match; unsigned long diff; + db_addr_t stoffs; if (symtab->private == NULL) { if (!linker_ddb_search_symbol((caddr_t)off, &lsym, &diff)) { @@ -111,19 +112,20 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, diff = ~0UL; match = NULL; + stoffs = DB_STOFFS(off); for (sym = (Elf_Sym*)symtab->start; (char*)sym < symtab->end; sym++) { if (sym->st_name == 0 || sym->st_shndx == SHN_UNDEF) continue; - if (off < sym->st_value) + if (stoffs < sym->st_value) continue; if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT && ELF_ST_TYPE(sym->st_info) != STT_FUNC && ELF_ST_TYPE(sym->st_info) != STT_NOTYPE) continue; - if ((off - sym->st_value) > diff) + if ((stoffs - sym->st_value) > diff) continue; - if ((off - sym->st_value) < diff) { - diff = off - sym->st_value; + if ((stoffs - sym->st_value) < diff) { + diff = stoffs - sym->st_value; match = sym; } else { if (match == NULL) Modified: head/sys/ddb/ddb.h ============================================================================== --- head/sys/ddb/ddb.h Thu May 10 03:50:20 2018 (r333446) +++ head/sys/ddb/ddb.h Thu May 10 03:59:48 2018 (r333447) @@ -72,6 +72,10 @@ SYSCTL_DECL(_debug_ddb); #define DB_MAXSCRIPTRECURSION 3 #endif +#ifndef DB_STOFFS +#define DB_STOFFS(offs) (offs) +#endif + #ifndef DB_CALL #define DB_CALL db_fncall_generic #else Modified: head/sys/powerpc/include/db_machdep.h ============================================================================== --- head/sys/powerpc/include/db_machdep.h Thu May 10 03:50:20 2018 (r333446) +++ head/sys/powerpc/include/db_machdep.h Thu May 10 03:59:48 2018 (r333447) @@ -85,4 +85,8 @@ typedef intptr_t db_expr_t; /* expression - signed */ #define inst_load(ins) 0 #define inst_store(ins) 0 +#ifdef __powerpc64__ +#define DB_STOFFS(offs) ((offs) & ~DMAP_BASE_ADDRESS) +#endif + #endif /* _POWERPC_DB_MACHDEP_H_ */ Modified: head/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- head/sys/powerpc/pseries/platform_chrp.c Thu May 10 03:50:20 2018 (r333446) +++ head/sys/powerpc/pseries/platform_chrp.c Thu May 10 03:59:48 2018 (r333447) @@ -146,7 +146,7 @@ chrp_attach(platform_t plat) /* Set up important VPA fields */ for (i = 0; i < MAXCPU; i++) { - bzero(splpar_vpa[i], sizeof(splpar_vpa)); + bzero(splpar_vpa[i], sizeof(splpar_vpa[i])); /* First two: VPA size */ splpar_vpa[i][4] = (uint8_t)((sizeof(splpar_vpa[i]) >> 8) & 0xff);