From owner-svn-src-head@freebsd.org Wed Jun 13 10:32:22 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 11BC6101DD50; Wed, 13 Jun 2018 10:32:22 +0000 (UTC) (envelope-from br@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 BB87879D7A; Wed, 13 Jun 2018 10:32:21 +0000 (UTC) (envelope-from br@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 9CB19183F8; Wed, 13 Jun 2018 10:32:21 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DAWLr2045248; Wed, 13 Jun 2018 10:32:21 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DAWLCR045247; Wed, 13 Jun 2018 10:32:21 GMT (envelope-from br@FreeBSD.org) Message-Id: <201806131032.w5DAWLCR045247@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 13 Jun 2018 10:32:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335047 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 335047 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: Wed, 13 Jun 2018 10:32:22 -0000 Author: br Date: Wed Jun 13 10:32:21 2018 New Revision: 335047 URL: https://svnweb.freebsd.org/changeset/base/335047 Log: Don't jump to VA space until kernel is ready. This fixes the race when first core sets up the pagetables, while secondary cores do translating the address of __riscv_boot_ap. This now allows us to smpboot in QEMU with 8 cores just fine. Sponsored by: DARPA, AFRL Modified: head/sys/riscv/riscv/locore.S Modified: head/sys/riscv/riscv/locore.S ============================================================================== --- head/sys/riscv/riscv/locore.S Wed Jun 13 09:28:47 2018 (r335046) +++ head/sys/riscv/riscv/locore.S Wed Jun 13 10:32:21 2018 (r335047) @@ -263,6 +263,21 @@ END(mpentry) * Called by a core when it is being brought online. */ ENTRY(mpentry) + /* + * Calculate the offset to __riscv_boot_ap + * for the current core, cpuid is in a0. + */ + li t1, 4 + mulw t1, t1, a0 + /* Get the pointer */ + la t0, __riscv_boot_ap + add t0, t0, t1 + +1: + /* Wait the kernel to be ready */ + lw t1, 0(t0) + beqz t1, 1b + /* Setup stack pointer */ la t0, secondary_stacks li t1, (PAGE_SIZE * KSTACK_PAGES) @@ -296,20 +311,6 @@ mpva: /* Ensure sscratch is zero */ li t0, 0 csrw sscratch, t0 - /* - * Calculate the offset to __riscv_boot_ap - * for current core, cpuid in a0. - */ - li t1, 4 - mulw t1, t1, a0 - /* Get pointer */ - la t0, __riscv_boot_ap - add t0, t0, t1 - -1: - /* Wait the kernel to be ready */ - lw t1, 0(t0) - beqz t1, 1b call init_secondary END(mpentry)