From owner-svn-src-all@freebsd.org Fri May 1 21:52:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 201722B0CCB; Fri, 1 May 2020 21:52:30 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49DQvy03Mbz49QR; Fri, 1 May 2020 21:52:30 +0000 (UTC) (envelope-from mhorne@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 F1609F0B9; Fri, 1 May 2020 21:52:29 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 041LqTBZ014391; Fri, 1 May 2020 21:52:29 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 041LqTNM014390; Fri, 1 May 2020 21:52:29 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202005012152.041LqTNM014390@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Fri, 1 May 2020 21:52:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360551 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 360551 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.29 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, 01 May 2020 21:52:30 -0000 Author: mhorne Date: Fri May 1 21:52:29 2020 New Revision: 360551 URL: https://svnweb.freebsd.org/changeset/base/360551 Log: Make mpentry independent of _start APs enter the kernel at the same point as the BSP, the _start routine. They then jump to mpentry, but not before storing the kernel's physical load address in the s9 register. Extract this calculation into its own routine, so that APs can be instructed to enter directly from mpentry. Differential Revision: https://reviews.freebsd.org/D24495 Modified: head/sys/riscv/riscv/locore.S Modified: head/sys/riscv/riscv/locore.S ============================================================================== --- head/sys/riscv/riscv/locore.S Fri May 1 21:24:19 2020 (r360550) +++ head/sys/riscv/riscv/locore.S Fri May 1 21:52:29 2020 (r360551) @@ -59,13 +59,6 @@ _start: lla gp, __global_pointer$ .option pop - /* Get the physical address kernel loaded to */ - lla t0, virt_map - ld t1, 0(t0) - sub t1, t1, t0 - li t2, KERNBASE - sub s9, t2, t1 /* s9 = physmem base */ - /* * a0 = hart id * a1 = dtbp @@ -87,6 +80,9 @@ _start: * Page tables */ 1: + /* Get the kernel's load address */ + jal get_physmem + /* Add L1 entry for kernel */ lla s1, pagetable_l1 lla s2, pagetable_l2 /* Link to next level PN */ @@ -224,6 +220,17 @@ va: call _C_LABEL(initriscv) /* Off we go */ call _C_LABEL(mi_startup) +/* + * Get the physical address the kernel is loaded to. Returned in s9. + */ +get_physmem: + lla t0, virt_map /* physical address of virt_map */ + ld t1, 0(t0) /* virtual address of virt_map */ + sub t1, t1, t0 /* calculate phys->virt delta */ + li t2, KERNBASE + sub s9, t2, t1 /* s9 = physmem base */ + ret + .align 4 initstack: .space (PAGE_SIZE * KSTACK_PAGES) @@ -302,6 +309,9 @@ ENTRY(mpentry) /* Setup stack pointer */ lla t0, bootstack ld sp, 0(t0) + + /* Get the kernel's load address */ + jal get_physmem /* Setup supervisor trap vector */ lla t0, mpva