From owner-svn-src-all@freebsd.org Wed Aug 15 12:48:50 2018 Return-Path: Delivered-To: svn-src-all@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 50C5510832CC; Wed, 15 Aug 2018 12:48:50 +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 07C118A741; Wed, 15 Aug 2018 12:48:50 +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 DD54A26B7; Wed, 15 Aug 2018 12:48:49 +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 w7FCmnBH012184; Wed, 15 Aug 2018 12:48:49 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7FCmnfQ012183; Wed, 15 Aug 2018 12:48:49 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201808151248.w7FCmnfQ012183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 15 Aug 2018 12:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337838 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 337838 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 12:48:50 -0000 Author: kib Date: Wed Aug 15 12:48:49 2018 New Revision: 337838 URL: https://svnweb.freebsd.org/changeset/base/337838 Log: Fix early EFIRT on PCID machines after r337773. Ensure that the valid PCID state is created for proc0 pmap, since it might be used by efirt enter() before first context switch on the BSP. Sponsored by: The FreeBSD Foundation MFC after: 6 days Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Aug 15 12:12:21 2018 (r337837) +++ head/sys/amd64/amd64/pmap.c Wed Aug 15 12:48:49 2018 (r337838) @@ -1188,8 +1188,16 @@ pmap_bootstrap(vm_paddr_t *firstaddr) kernel_pmap->pm_pcids[i].pm_pcid = PMAP_PCID_KERN; kernel_pmap->pm_pcids[i].pm_gen = 1; } - PCPU_SET(pcid_next, PMAP_PCID_KERN + 1); + + /* + * PMAP_PCID_KERN + 1 is used for initialization of + * proc0 pmap. The pmap' pcid state might be used by + * EFIRT entry before first context switch, so it + * needs to be valid. + */ + PCPU_SET(pcid_next, PMAP_PCID_KERN + 2); PCPU_SET(pcid_gen, 1); + /* * pcpu area for APs is zeroed during AP startup. * pc_pcid_next and pc_pcid_gen are initialized by AP @@ -2651,8 +2659,8 @@ pmap_pinit0(pmap_t pmap) bzero(&pmap->pm_stats, sizeof pmap->pm_stats); pmap->pm_flags = pmap_flags; CPU_FOREACH(i) { - pmap->pm_pcids[i].pm_pcid = PMAP_PCID_NONE; - pmap->pm_pcids[i].pm_gen = 0; + pmap->pm_pcids[i].pm_pcid = PMAP_PCID_KERN + 1; + pmap->pm_pcids[i].pm_gen = 1; if (!pti) { __pcpu[i].pc_kcr3 = PMAP_NO_CR3; __pcpu[i].pc_ucr3 = PMAP_NO_CR3;