From owner-svn-src-head@freebsd.org Tue Mar 3 08:28:18 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 1E3882682C6; Tue, 3 Mar 2020 08:28:18 +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) 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 48WqsF608Xz3Fnm; Tue, 3 Mar 2020 08:28:17 +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 94B0922A4; Tue, 3 Mar 2020 08:28:17 +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 0238SHJM094067; Tue, 3 Mar 2020 08:28:17 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0238SGwR094063; Tue, 3 Mar 2020 08:28:16 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202003030828.0238SGwR094063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 3 Mar 2020 08:28:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358567 - 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: 358567 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.29 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: Tue, 03 Mar 2020 08:28:18 -0000 Author: andrew Date: Tue Mar 3 08:28:16 2020 New Revision: 358567 URL: https://svnweb.freebsd.org/changeset/base/358567 Log: Store the boot exception level on arm64 so it can be queried later A hypervisor, e.g. bhyve, will need to know what exception levelthe kernel was in when it started booting. If it was EL2 we can then enable said hypervisor. Store the boot exception level and allow the kernel to later query it. Obtained from: https://github.com/FreeBSD-UPB/freebsd (earlier version) Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/genassym.c head/sys/arm64/arm64/locore.S head/sys/arm64/arm64/machdep.c head/sys/arm64/include/machdep.h Modified: head/sys/arm64/arm64/genassym.c ============================================================================== --- head/sys/arm64/arm64/genassym.c Tue Mar 3 08:24:09 2020 (r358566) +++ head/sys/arm64/arm64/genassym.c Tue Mar 3 08:28:16 2020 (r358567) @@ -45,6 +45,7 @@ ASSYM(BP_KERN_L1PT, offsetof(struct arm64_bootparams, ASSYM(BP_KERN_DELTA, offsetof(struct arm64_bootparams, kern_delta)); ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack)); ASSYM(BP_KERN_L0PT, offsetof(struct arm64_bootparams, kern_l0pt)); +ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el)); ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); Modified: head/sys/arm64/arm64/locore.S ============================================================================== --- head/sys/arm64/arm64/locore.S Tue Mar 3 08:24:09 2020 (r358566) +++ head/sys/arm64/arm64/locore.S Tue Mar 3 08:28:16 2020 (r358567) @@ -165,6 +165,7 @@ virtdone: adr x25, initstack str x25, [x0, #BP_KERN_STACK] str x24, [x0, #BP_KERN_L0PT] + str x23, [x0, #BP_BOOT_EL] /* trace back starts here */ mov fp, #0 @@ -227,9 +228,9 @@ END(mpentry) * registers and drop to EL1. */ drop_to_el1: - mrs x1, CurrentEL - lsr x1, x1, #2 - cmp x1, #0x2 + mrs x23, CurrentEL + lsr x23, x23, #2 + cmp x23, #0x2 b.eq 1f ret 1: Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Tue Mar 3 08:24:09 2020 (r358566) +++ head/sys/arm64/arm64/machdep.c Tue Mar 3 08:28:16 2020 (r358567) @@ -109,6 +109,7 @@ static struct trapframe proc0_tf; int early_boot = 1; int cold = 1; +static int boot_el; struct kva_md_info kmi; @@ -162,6 +163,13 @@ pan_enable(void) } } +bool +has_hyp(void) +{ + + return (boot_el == 2); +} + static void cpu_startup(void *dummy) { @@ -1089,6 +1097,8 @@ initarm(struct arm64_bootparams *abp) vm_offset_t lastaddr; caddr_t kmdp; bool valid; + + boot_el = abp->boot_el; /* Parse loader or FDT boot parametes. Determine last used address. */ lastaddr = parse_boot_param(abp); Modified: head/sys/arm64/include/machdep.h ============================================================================== --- head/sys/arm64/include/machdep.h Tue Mar 3 08:24:09 2020 (r358566) +++ head/sys/arm64/include/machdep.h Tue Mar 3 08:28:16 2020 (r358567) @@ -35,6 +35,8 @@ struct arm64_bootparams { uint64_t kern_delta; vm_offset_t kern_stack; vm_offset_t kern_l0pt; /* L1 page table for the kernel */ + int boot_el; /* EL the kernel booted from */ + int pad; }; enum arm64_bus { @@ -46,6 +48,7 @@ enum arm64_bus { extern enum arm64_bus arm64_bus_method; void dbg_init(void); +bool has_hyp(void); void initarm(struct arm64_bootparams *); vm_offset_t parse_boot_param(struct arm64_bootparams *abp); #ifdef FDT