From owner-svn-src-head@freebsd.org Wed Jul 1 16:57:58 2020 Return-Path: Delivered-To: svn-src-head@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 AB4E53574CF; Wed, 1 Jul 2020 16:57:58 +0000 (UTC) (envelope-from andrew@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49xnTy47gtz4lqt; Wed, 1 Jul 2020 16:57:58 +0000 (UTC) (envelope-from andrew@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 72B48C6CD; Wed, 1 Jul 2020 16:57:58 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 061GvwDK046276; Wed, 1 Jul 2020 16:57:58 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 061Gvv9V046272; Wed, 1 Jul 2020 16:57:57 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202007011657.061Gvv9V046272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 1 Jul 2020 16:57:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362845 - in head/sys/arm64: arm64 include X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys/arm64: arm64 include X-SVN-Commit-Revision: 362845 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.33 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, 01 Jul 2020 16:57:58 -0000 Author: andrew Date: Wed Jul 1 16:57:57 2020 New Revision: 362845 URL: https://svnweb.freebsd.org/changeset/base/362845 Log: Read the CPU 0 arm64 ID registers early in initarm We also update the kernel view early in the boot. This will allow the use of the common kernel view in ifunc resolvers. Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/identcpu.c head/sys/arm64/arm64/machdep.c head/sys/arm64/arm64/mp_machdep.c head/sys/arm64/include/cpu.h Modified: head/sys/arm64/arm64/identcpu.c ============================================================================== --- head/sys/arm64/arm64/identcpu.c Wed Jul 1 16:37:08 2020 (r362844) +++ head/sys/arm64/arm64/identcpu.c Wed Jul 1 16:57:57 2020 (r362845) @@ -992,7 +992,7 @@ update_lower_register(uint64_t val, uint64_t new_val, return (val); } -static void +void update_special_regs(u_int cpu) { struct mrs_field *fields; @@ -1072,7 +1072,8 @@ identify_cpu_sysinit(void *dummy __unused) elf_hwcap = hwcap; else elf_hwcap &= hwcap; - update_special_regs(cpu); + if (cpu != 0) + update_special_regs(cpu); if (CTR_DIC_VAL(cpu_desc[cpu].ctr) == 0) dic = false; @@ -1457,23 +1458,15 @@ identify_cache(uint64_t ctr) } void -identify_cpu(void) +identify_cpu(u_int cpu) { u_int midr; u_int impl_id; u_int part_id; - u_int cpu; size_t i; const struct cpu_parts *cpu_partsp = NULL; - cpu = PCPU_GET(cpuid); midr = get_midr(); - - /* - * Store midr to pcpu to allow fast reading - * from EL0, EL1 and assembly code. - */ - PCPU_SET(midr, midr); impl_id = CPU_IMPL(midr); for (i = 0; i < nitems(cpu_implementers); i++) { Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Wed Jul 1 16:37:08 2020 (r362844) +++ head/sys/arm64/arm64/machdep.c Wed Jul 1 16:57:57 2020 (r362845) @@ -172,7 +172,6 @@ cpu_startup(void *dummy) { undef_init(); - identify_cpu(); install_cpu_errata(); vm_ksubmap_init(&kmi); @@ -1138,6 +1137,9 @@ initarm(struct arm64_bootparams *abp) if (kmdp == NULL) kmdp = preload_search_by_type("elf64 kernel"); + identify_cpu(0); + update_special_regs(0); + link_elf_ireloc(kmdp); try_load_dtb(kmdp); @@ -1181,6 +1183,7 @@ initarm(struct arm64_bootparams *abp) "msr tpidr_el1, %0" :: "r"(pcpup)); PCPU_SET(curthread, &thread0); + PCPU_SET(midr, get_midr()); /* Do basic tuning, hz etc */ init_param1(); Modified: head/sys/arm64/arm64/mp_machdep.c ============================================================================== --- head/sys/arm64/arm64/mp_machdep.c Wed Jul 1 16:37:08 2020 (r362844) +++ head/sys/arm64/arm64/mp_machdep.c Wed Jul 1 16:57:57 2020 (r362845) @@ -220,7 +220,7 @@ init_secondary(uint64_t cpu) * We need this before signalling the CPU is ready to * let the boot CPU use the results. */ - identify_cpu(); + identify_cpu(cpu); /* Ensure the stores in identify_cpu have completed */ atomic_thread_fence_acq_rel(); @@ -229,6 +229,8 @@ init_secondary(uint64_t cpu) atomic_add_int(&aps_started, 1); while (!atomic_load_int(&aps_ready)) __asm __volatile("wfe"); + + pcpup->pc_midr = get_midr(); /* Initialize curthread */ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); Modified: head/sys/arm64/include/cpu.h ============================================================================== --- head/sys/arm64/include/cpu.h Wed Jul 1 16:37:08 2020 (r362844) +++ head/sys/arm64/include/cpu.h Wed Jul 1 16:57:57 2020 (r362845) @@ -167,11 +167,12 @@ void cpu_halt(void) __dead2; void cpu_reset(void) __dead2; void fork_trampoline(void); void identify_cache(uint64_t); -void identify_cpu(void); +void identify_cpu(u_int); void install_cpu_errata(void); void swi_vm(void *v); /* Functions to read the sanitised view of the special registers */ +void update_special_regs(u_int); bool extract_user_id_field(u_int, u_int, uint8_t *); bool get_kernel_reg(u_int, uint64_t *);