From owner-svn-src-head@freebsd.org Wed May 9 14:39:25 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 99B5AFBEAE9; Wed, 9 May 2018 14:39:25 +0000 (UTC) (envelope-from kib@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 4BABD7368E; Wed, 9 May 2018 14:39:25 +0000 (UTC) (envelope-from kib@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 2D62712C7D; Wed, 9 May 2018 14:39:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w49EdPKI087563; Wed, 9 May 2018 14:39:25 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w49EdObK087561; Wed, 9 May 2018 14:39:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201805091439.w49EdObK087561@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 9 May 2018 14:39:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333411 - in head/sys: amd64/amd64 kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys: amd64/amd64 kern X-SVN-Commit-Revision: 333411 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: Wed, 09 May 2018 14:39:25 -0000 Author: kib Date: Wed May 9 14:39:24 2018 New Revision: 333411 URL: https://svnweb.freebsd.org/changeset/base/333411 Log: Avoid calls to bzero() before ireloc. Evaluate cpu_stdext_feature early to have moved link_elf_ireloc() see correct flags, most important is SMAP. Tested by: mjg Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D15367 Modified: head/sys/amd64/amd64/machdep.c head/sys/kern/link_elf.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Wed May 9 14:38:07 2018 (r333410) +++ head/sys/amd64/amd64/machdep.c Wed May 9 14:39:24 2018 (r333411) @@ -1556,19 +1556,24 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TSRAW(&thread0, TS_ENTER, __func__, NULL); - /* - * This may be done better later if it gets more high level - * components in it. If so just link td->td_proc here. - */ - proc_linkup0(&proc0, &thread0); - kmdp = init_ops.parse_preload_data(modulep); identify_cpu1(); identify_hypervisor(); + /* + * hw.cpu_stdext_disable is ignored by the call, it will be + * re-evaluted by the below call to finishidentcpu(). + */ + identify_cpu2(); - /* link_elf_ireloc(kmdp); */ + link_elf_ireloc(kmdp); + /* + * This may be done better later if it gets more high level + * components in it. If so just link td->td_proc here. + */ + proc_linkup0(&proc0, &thread0); + /* Init basic tunables, hz etc */ init_param1(); @@ -1753,7 +1758,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) cninit(); amd64_kdb_init(); } - link_elf_ireloc(kmdp); getmemsize(kmdp, physfree); init_param2(physmem); Modified: head/sys/kern/link_elf.c ============================================================================== --- head/sys/kern/link_elf.c Wed May 9 14:38:07 2018 (r333410) +++ head/sys/kern/link_elf.c Wed May 9 14:39:24 2018 (r333411) @@ -1692,9 +1692,15 @@ link_elf_ireloc(caddr_t kmdp) { struct elf_file eff; elf_file_t ef; + volatile char *c; + size_t i; ef = &eff; - bzero(ef, sizeof(*ef)); + + /* Do not use bzero/memset before ireloc is done. */ + for (c = (char *)ef, i = 0; i < sizeof(*ef); i++) + c[i] = 0; + ef->modptr = kmdp; ef->dynamic = (Elf_Dyn *)&_DYNAMIC; parse_dynamic(ef);