From owner-svn-src-stable-11@freebsd.org Thu Mar 15 19:56:45 2018 Return-Path: Delivered-To: svn-src-stable-11@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 A4B72F4E282; Thu, 15 Mar 2018 19:56:45 +0000 (UTC) (envelope-from kevans@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 56DC274F42; Thu, 15 Mar 2018 19:56:45 +0000 (UTC) (envelope-from kevans@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 51A431A6D7; Thu, 15 Mar 2018 19:56:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FJujHc080205; Thu, 15 Mar 2018 19:56:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FJuiOU080199; Thu, 15 Mar 2018 19:56:44 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201803151956.w2FJuiOU080199@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 15 Mar 2018 19:56:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331022 - in stable/11/sys: arm64/arm64 arm64/include conf modules X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/sys: arm64/arm64 arm64/include conf modules X-SVN-Commit-Revision: 331022 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 19:56:45 -0000 Author: kevans Date: Thu Mar 15 19:56:44 2018 New Revision: 331022 URL: https://svnweb.freebsd.org/changeset/base/331022 Log: MFC r324495: Support the EFI Runtime Services on arm64. As with amd64 we use the 1:1 mapping. This uses the new common code shared with amd64. The RTC should only be accessed via EFI. There is no locking around it as the spec only has this as a requirement for the PC-AT CMOS device. NOTE: r326311's changes to arm64/efirt_machdep.c have been hand-applied to this import of efirt_machdep.c due to r326311 having already been merged. Added: stable/11/sys/arm64/arm64/efirt_machdep.c - copied, changed from r324495, head/sys/arm64/arm64/efirt_machdep.c Modified: stable/11/sys/arm64/arm64/machdep.c stable/11/sys/arm64/include/efi.h stable/11/sys/conf/files.arm64 stable/11/sys/conf/options.arm64 stable/11/sys/modules/Makefile Directory Properties: stable/11/ (props changed) Copied and modified: stable/11/sys/arm64/arm64/efirt_machdep.c (from r324495, head/sys/arm64/arm64/efirt_machdep.c) ============================================================================== --- head/sys/arm64/arm64/efirt_machdep.c Tue Oct 10 13:05:26 2017 (r324495, copy source) +++ stable/11/sys/arm64/arm64/efirt_machdep.c Thu Mar 15 19:56:44 2018 (r331022) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); static vm_object_t obj_1t1_pt; static vm_page_t efi_l0_page; static pd_entry_t *efi_l0; +static vm_pindex_t efi_1t1_idx; void efi_destroy_1t1_map(void) @@ -86,10 +87,10 @@ efi_destroy_1t1_map(void) } static vm_page_t -efi_1t1_page(vm_pindex_t idx) +efi_1t1_page(void) { - return (vm_page_grab(obj_1t1_pt, idx, VM_ALLOC_NOBUSY | + return (vm_page_grab(obj_1t1_pt, efi_1t1_idx++, VM_ALLOC_NOBUSY | VM_ALLOC_WIRED | VM_ALLOC_ZERO)); } @@ -105,7 +106,7 @@ efi_1t1_l3(vm_offset_t va) l0_idx = pmap_l0_index(va); l0 = &efi_l0[l0_idx]; if (*l0 == 0) { - m = efi_1t1_page(1 + l0_idx); + m = efi_1t1_page(); mphys = VM_PAGE_TO_PHYS(m); *l0 = mphys | L0_TABLE; } else { @@ -116,7 +117,7 @@ efi_1t1_l3(vm_offset_t va) l1_idx = pmap_l1_index(va); l1 += l1_idx; if (*l1 == 0) { - m = efi_1t1_page(1 + L0_ENTRIES + (l0_idx + 1) * (l1_idx + 1)); + m = efi_1t1_page(); mphys = VM_PAGE_TO_PHYS(m); *l1 = mphys | L1_TABLE; } else { @@ -127,8 +128,7 @@ efi_1t1_l3(vm_offset_t va) l2_idx = pmap_l2_index(va); l2 += l2_idx; if (*l2 == 0) { - m = efi_1t1_page(1 + L0_ENTRIES + L0_ENTRIES * Ln_ENTRIES + - (l0_idx + 1) * (l1_idx + 1) * (l2_idx + 1)); + m = efi_1t1_page(); mphys = VM_PAGE_TO_PHYS(m); *l2 = mphys | L2_TABLE; } else { @@ -160,7 +160,8 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int L0_ENTRIES * Ln_ENTRIES * Ln_ENTRIES * Ln_ENTRIES, VM_PROT_ALL, 0, NULL); VM_OBJECT_WLOCK(obj_1t1_pt); - efi_l0_page = efi_1t1_page(0); + efi_1t1_idx = 0; + efi_l0_page = efi_1t1_page(); VM_OBJECT_WUNLOCK(obj_1t1_pt); efi_l0 = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(efi_l0_page)); bzero(efi_l0, L0_ENTRIES * sizeof(*efi_l0)); Modified: stable/11/sys/arm64/arm64/machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/machdep.c Thu Mar 15 19:41:26 2018 (r331021) +++ stable/11/sys/arm64/arm64/machdep.c Thu Mar 15 19:56:44 2018 (r331022) @@ -111,6 +111,12 @@ int64_t idcache_line_size; /* The minimum cache line s int64_t dczva_line_size; /* The size of cache line the dc zva zeroes */ int has_pan; +/* + * Physical address of the EFI System Table. Stashed from the metadata hints + * passed into the kernel and used by the EFI code to call runtime services. + */ +vm_paddr_t efi_systbl_phys; + /* pagezero_* implementations are provided in support.S */ void pagezero_simple(void *); void pagezero_cache(void *); @@ -910,6 +916,8 @@ initarm(struct arm64_bootparams *abp) #ifdef FDT try_load_dtb(kmdp); #endif + + efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); /* Find the address to start allocating from */ lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); Modified: stable/11/sys/arm64/include/efi.h ============================================================================== --- stable/11/sys/arm64/include/efi.h Thu Mar 15 19:41:26 2018 (r331021) +++ stable/11/sys/arm64/include/efi.h Thu Mar 15 19:56:44 2018 (r331022) @@ -1,6 +1,32 @@ /*- - * This file is in the public domain since it's just boilerplate. + * Copyright (c) 2017 Andrew Turner + * All rights reserved. * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * * $FreeBSD$ */ @@ -8,5 +34,11 @@ #define __ARM64_INCLUDE_EFI_H_ #define EFIABI_ATTR + +#ifdef _KERNEL +#define EFI_TIME_LOCK() +#define EFI_TIME_UNLOCK() +#define EFI_TIME_OWNED() +#endif #endif /* __ARM64_INCLUDE_EFI_H_ */ Modified: stable/11/sys/conf/files.arm64 ============================================================================== --- stable/11/sys/conf/files.arm64 Thu Mar 15 19:41:26 2018 (r331021) +++ stable/11/sys/conf/files.arm64 Thu Mar 15 19:56:44 2018 (r331022) @@ -35,6 +35,7 @@ arm64/arm64/db_trace.c optional ddb arm64/arm64/debug_monitor.c optional ddb arm64/arm64/disassem.c optional ddb arm64/arm64/dump_machdep.c standard +arm64/arm64/efirt_machdep.c optional efirt arm64/arm64/elf_machdep.c standard arm64/arm64/exception.S standard arm64/arm64/gicv3_its.c optional intrng Modified: stable/11/sys/conf/options.arm64 ============================================================================== --- stable/11/sys/conf/options.arm64 Thu Mar 15 19:41:26 2018 (r331021) +++ stable/11/sys/conf/options.arm64 Thu Mar 15 19:56:44 2018 (r331022) @@ -7,6 +7,10 @@ SOCDEV_VA opt_global.h THUNDERX_PASS_1_1_ERRATA opt_global.h VFP opt_global.h +# EFI Runtime services support +EFIRT opt_efirt.h + +# Devices DEV_PSCI opt_platform.h # SoC Support Modified: stable/11/sys/modules/Makefile ============================================================================== --- stable/11/sys/modules/Makefile Thu Mar 15 19:41:26 2018 (r331021) +++ stable/11/sys/modules/Makefile Thu Mar 15 19:56:44 2018 (r331022) @@ -560,6 +560,7 @@ _cxgb= cxgb .endif .if ${MACHINE_CPUARCH} == "aarch64" +_efirt= efirt _em= em _igb= igb .endif