From owner-svn-src-head@freebsd.org Thu Jun 7 17:04:35 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 25E85FE498F; Thu, 7 Jun 2018 17:04:35 +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 C961B74658; Thu, 7 Jun 2018 17:04:34 +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 AAA4F22FDE; Thu, 7 Jun 2018 17:04:34 +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 w57H4YUY044328; Thu, 7 Jun 2018 17:04:34 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w57H4Yhb044326; Thu, 7 Jun 2018 17:04:34 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201806071704.w57H4Yhb044326@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 7 Jun 2018 17:04:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334799 - 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: 334799 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.26 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, 07 Jun 2018 17:04:35 -0000 Author: kib Date: Thu Jun 7 17:04:34 2018 New Revision: 334799 URL: https://svnweb.freebsd.org/changeset/base/334799 Log: Account for dmap limit when selecting the pages for the bootstrap pagetables. physmap[] can be inconsistent with the physical memory limit due to buggy bios, or to the hw.physmem tunable. Since bootstrap pagetables are initialized by accesses through the DMAP, we must ensure that DMAP really cover the selected pages. This is only relevant when machine has less than 4G RAM and buggy BIOS, which is the combination on Acer Chromebook 720. The call to mp_bootaddress() is moved later to have Maxmem initialized. An alternative could be to always cover 4G for DMAP, but this change seems to be simpler. Reported and tested by: grembo Reviewed by: royger Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15675 Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/mp_machdep.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Thu Jun 7 16:35:09 2018 (r334798) +++ head/sys/amd64/amd64/machdep.c Thu Jun 7 17:04:34 2018 (r334799) @@ -1248,15 +1248,6 @@ getmemsize(caddr_t kmdp, u_int64_t first) } /* - * Make hole for "AP -> long mode" bootstrap code. The - * mp_bootaddress vector is only available when the kernel - * is configured to support APs and APs for the system start - * in real mode mode (e.g. SMP bare metal). - */ - if (init_ops.mp_bootaddress) - init_ops.mp_bootaddress(physmap, &physmap_idx); - - /* * Maxmem isn't the "maximum memory", it's one larger than the * highest page of the physical address space. It should be * called something like "Maxphyspage". We may adjust this @@ -1293,6 +1284,15 @@ getmemsize(caddr_t kmdp, u_int64_t first) if (atop(physmap[physmap_idx + 1]) != Maxmem && (boothowto & RB_VERBOSE)) printf("Physical memory use set to %ldK\n", Maxmem * 4); + + /* + * Make hole for "AP -> long mode" bootstrap code. The + * mp_bootaddress vector is only available when the kernel + * is configured to support APs and APs for the system start + * in real mode mode (e.g. SMP bare metal). + */ + if (init_ops.mp_bootaddress) + init_ops.mp_bootaddress(physmap, &physmap_idx); /* call pmap initialization to make new kernel address space */ pmap_bootstrap(&first); Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Thu Jun 7 16:35:09 2018 (r334798) +++ head/sys/amd64/amd64/mp_machdep.c Thu Jun 7 17:04:34 2018 (r334799) @@ -113,12 +113,16 @@ mp_bootaddress(vm_paddr_t *physmap, unsigned int *phys allocated = false; for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { /* - * Find a memory region big enough below the 4GB boundary to - * store the initial page tables. Note that it needs to be - * aligned to a page boundary. + * Find a memory region big enough below the 4GB + * boundary to store the initial page tables. Region + * must be mapped by the direct map. + * + * Note that it needs to be aligned to a page + * boundary. */ - if (physmap[i] >= GiB(4) || - (physmap[i + 1] - round_page(physmap[i])) < (PAGE_SIZE * 3)) + if (physmap[i] >= GiB(4) || physmap[i + 1] - + round_page(physmap[i]) < PAGE_SIZE * 3 || + physmap[i + 1] > Maxmem) continue; allocated = true;