From owner-svn-src-all@freebsd.org Fri Apr 6 16:22:15 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 1AB5EF92A75; Fri, 6 Apr 2018 16:22:15 +0000 (UTC) (envelope-from royger@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 C3F81848D9; Fri, 6 Apr 2018 16:22:14 +0000 (UTC) (envelope-from royger@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 BEEC514341; Fri, 6 Apr 2018 16:22:14 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36GMEFT032304; Fri, 6 Apr 2018 16:22:14 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36GMEi2032302; Fri, 6 Apr 2018 16:22:14 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201804061622.w36GMEi2032302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Fri, 6 Apr 2018 16:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332109 - in head/sys: amd64/amd64 x86/x86 X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head/sys: amd64/amd64 x86/x86 X-SVN-Commit-Revision: 332109 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.25 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: Fri, 06 Apr 2018 16:22:15 -0000 Author: royger Date: Fri Apr 6 16:22:14 2018 New Revision: 332109 URL: https://svnweb.freebsd.org/changeset/base/332109 Log: x86: fix trampoline memory allocation after r332073 Add the missing breaks in the for loops, in order to exit the loop when a suitable entry is found. Also switch amd64 native_start_all_aps to use PHYS_TO_DMAP in order to find the virtual address of the boot_trampoline and the initial page tables. Reported and tested by: pho Sponsored by: Citrix Systems R&D Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 15:57:20 2018 (r332108) +++ head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 16:22:14 2018 (r332109) @@ -128,6 +128,7 @@ mp_bootaddress(vm_paddr_t *physmap, unsigned int *phys sizeof(*physmap) * (*physmap_idx - i + 2)); *physmap_idx -= 2; } + break; } if (!allocated) { @@ -336,7 +337,6 @@ init_secondary(void) int native_start_all_aps(void) { - vm_offset_t va = boot_address + KERNBASE; u_int64_t *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; int apic_id, cpu, i; @@ -344,13 +344,11 @@ native_start_all_aps(void) mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - /* install the AP 1st level boot code */ - pmap_kenter(va, boot_address); - pmap_invalidate_page(kernel_pmap, va); - bcopy(mptramp_start, (void *)va, bootMP_size); + /* copy the AP 1st level boot code */ + bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size); /* Locate the page tables, they'll be below the trampoline */ - pt4 = (u_int64_t *)(uintptr_t)(mptramp_pagetables + KERNBASE); + pt4 = (uint64_t *)PHYS_TO_DMAP(mptramp_pagetables); pt3 = pt4 + (PAGE_SIZE) / sizeof(u_int64_t); pt2 = pt3 + (PAGE_SIZE) / sizeof(u_int64_t); Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Fri Apr 6 15:57:20 2018 (r332108) +++ head/sys/x86/x86/mp_x86.c Fri Apr 6 16:22:14 2018 (r332109) @@ -947,6 +947,7 @@ alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int sizeof(*physmap) * (*physmap_idx - i + 2)); *physmap_idx -= 2; } + break; } if (!allocated) {