git: db6e3260a8b9 - main - arm64: Remove the E2H check from has_hyp

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Wed, 21 Aug 2024 08:48:25 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=db6e3260a8b9257aa4f1991867e46973e4f0dce8

commit db6e3260a8b9257aa4f1991867e46973e4f0dce8
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-08-19 12:46:05 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-08-21 08:46:59 +0000

    arm64: Remove the E2H check from has_hyp
    
    This was added to not use the physical timer when E2H was set. As we
    now use the correct timer in this case we can remove this extra check.
    
    Tested by:      kevans
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D46086
---
 sys/arm64/arm64/genassym.c  | 1 -
 sys/arm64/arm64/locore.S    | 1 -
 sys/arm64/arm64/machdep.c   | 9 +--------
 sys/arm64/include/machdep.h | 1 -
 4 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c
index c4f52ae61a77..a4db825e976c 100644
--- a/sys/arm64/arm64/genassym.c
+++ b/sys/arm64/arm64/genassym.c
@@ -42,7 +42,6 @@ ASSYM(BP_MODULEP, offsetof(struct arm64_bootparams, modulep));
 ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack));
 ASSYM(BP_KERN_TTBR0, offsetof(struct arm64_bootparams, kern_ttbr0));
 ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el));
-ASSYM(BP_HCR_EL2, offsetof(struct arm64_bootparams, hcr_el2));
 
 ASSYM(PCPU_SIZE, sizeof(struct pcpu));
 ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 4252ea3f59f8..ab1fea0c4716 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -134,7 +134,6 @@ virtdone:
 	str	x25, [x0, #BP_KERN_STACK]
 	str	x27, [x0, #BP_KERN_TTBR0]
 	str	x23, [x0, #BP_BOOT_EL]
-	str	x4,  [x0, #BP_HCR_EL2]
 
 #ifdef KASAN
 	/* Save bootparams */
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 090ea2c10853..c73c6d205c1a 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -131,7 +131,6 @@ static struct trapframe proc0_tf;
 int early_boot = 1;
 int cold = 1;
 static int boot_el;
-static uint64_t hcr_el2;
 
 struct kva_md_info kmi;
 
@@ -207,12 +206,7 @@ pan_enable(void)
 bool
 has_hyp(void)
 {
-
-	/*
-	 * XXX The E2H check is wrong, but it's close enough for now.  Needs to
-	 * be re-evaluated once we're running regularly in EL2.
-	 */
-	return (boot_el == CURRENTEL_EL_EL2 && (hcr_el2 & HCR_E2H) == 0);
+	return (boot_el == CURRENTEL_EL_EL2);
 }
 
 bool
@@ -905,7 +899,6 @@ initarm(struct arm64_bootparams *abp)
 	TSRAW(&thread0, TS_ENTER, __func__, NULL);
 
 	boot_el = abp->boot_el;
-	hcr_el2 = abp->hcr_el2;
 
 	/* Parse loader or FDT boot parametes. Determine last used address. */
 	lastaddr = parse_boot_param(abp);
diff --git a/sys/arm64/include/machdep.h b/sys/arm64/include/machdep.h
index 2f2960ae39f2..4fa80219da42 100644
--- a/sys/arm64/include/machdep.h
+++ b/sys/arm64/include/machdep.h
@@ -33,7 +33,6 @@ struct arm64_bootparams {
 	vm_offset_t	modulep;
 	vm_offset_t	kern_stack;
 	vm_paddr_t	kern_ttbr0;
-	uint64_t	hcr_el2;
 	int		boot_el;	/* EL the kernel booted from */
 	int		pad;
 };