From owner-svn-src-all@freebsd.org Tue Sep 3 14:06:57 2019 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 6638DDC959; Tue, 3 Sep 2019 14:06:27 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7zQ6VqCz4PYK; Tue, 3 Sep 2019 14:06:26 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id 08FE61A687; Tue, 3 Sep 2019 14:06:08 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id B67351B62E; Sun, 7 Apr 2019 20:12:29 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4356F7079C; Sun, 7 Apr 2019 20:12:29 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 127271B622; Sun, 7 Apr 2019 20:12:29 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id CC16C1B620 for ; Sun, 7 Apr 2019 20:12:25 +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 83C377078F; Sun, 7 Apr 2019 20:12:25 +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 74CC7191F3; Sun, 7 Apr 2019 20:12:25 +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 x37KCPHW056300; Sun, 7 Apr 2019 20:12:25 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x37KCPHt056299; Sun, 7 Apr 2019 20:12:25 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <201904072012.x37KCPHt056299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346021 - in head/sys/riscv: include riscv X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in head/sys/riscv: include riscv X-SVN-Commit-Revision: 346021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 4356F7079C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: , Date: Tue, 03 Sep 2019 14:06:58 -0000 X-Original-Date: Sun, 7 Apr 2019 20:12:25 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:06:58 -0000 Author: mhorne Date: Sun Apr 7 20:12:24 2019 New Revision: 346021 URL: https://svnweb.freebsd.org/changeset/base/346021 Log: RISC-V: initialize pcpu slightly earlier In certain scenarios, it is possible for PCPU data to be accessed before it has been initialized (e.g. during printf if the kernel was built with the TSLOG option). Initialize the PCPU pointer for hart 0 at the beginning of initriscv() rather than near the end. Reviewed by: markj Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D19726 Modified: head/sys/riscv/include/pcpu.h head/sys/riscv/riscv/machdep.c Modified: head/sys/riscv/include/pcpu.h ============================================================================== --- head/sys/riscv/include/pcpu.h Sun Apr 7 19:08:07 2019 (r346020) +++ head/sys/riscv/include/pcpu.h Sun Apr 7 20:12:24 2019 (r346021) @@ -53,7 +53,6 @@ struct pcb; struct pcpu; -extern struct pcpu *pcpup; static inline struct pcpu * get_pcpu(void) Modified: head/sys/riscv/riscv/machdep.c ============================================================================== --- head/sys/riscv/riscv/machdep.c Sun Apr 7 19:08:07 2019 (r346020) +++ head/sys/riscv/riscv/machdep.c Sun Apr 7 20:12:24 2019 (r346021) @@ -120,8 +120,6 @@ int64_t idcache_line_size; /* The minimum cache line s extern int *end; extern int *initstack_end; -struct pcpu *pcpup; - uintptr_t mcall_trap(uintptr_t mcause, uintptr_t* regs); uintptr_t @@ -627,6 +625,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask static void init_proc0(vm_offset_t kstack) { + struct pcpu *pcpup; pcpup = &__pcpu[0]; @@ -798,6 +797,7 @@ void initriscv(struct riscv_bootparams *rvbp) { struct mem_region mem_regions[FDT_MEM_REGIONS]; + struct pcpu *pcpup; vm_offset_t rstart, rend; vm_offset_t s, e; int mem_regions_sz; @@ -806,6 +806,15 @@ initriscv(struct riscv_bootparams *rvbp) caddr_t kmdp; int i; + /* Set the pcpu data, this is needed by pmap_bootstrap */ + pcpup = &__pcpu[0]; + pcpu_init(pcpup, 0, sizeof(struct pcpu)); + + /* Set the pcpu pointer */ + __asm __volatile("mv gp, %0" :: "r"(pcpup)); + + PCPU_SET(curthread, &thread0); + /* Set the module data location */ lastaddr = fake_preload_metadata(rvbp); @@ -848,15 +857,6 @@ initriscv(struct riscv_bootparams *rvbp) } } #endif - - /* Set the pcpu data, this is needed by pmap_bootstrap */ - pcpup = &__pcpu[0]; - pcpu_init(pcpup, 0, sizeof(struct pcpu)); - - /* Set the pcpu pointer */ - __asm __volatile("mv gp, %0" :: "r"(pcpup)); - - PCPU_SET(curthread, &thread0); /* Do basic tuning, hz etc */ init_param1();