The branch main has been updated by andrew:

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

commit 534aec00976c18c4c4b485b2fade9d5f33de89c8
Author:     Andrew Turner <and...@freebsd.org>
AuthorDate: 2025-10-07 08:26:00 +0000
Commit:     Andrew Turner <and...@freebsd.org>
CommitDate: 2025-10-07 08:27:15 +0000

    arm64/vmm: Handle debug exits
    
    This is enough to boot FreeBSD again.
    
    PR:             290044
    Reported by:    Siva Mahadevan <m...@svmhdvn.name>
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D52931
---
 sys/arm64/vmm/arm64.h |  1 +
 sys/arm64/vmm/vmm.c   | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/sys/arm64/vmm/arm64.h b/sys/arm64/vmm/arm64.h
index 334b795832a3..f9b74aef7188 100644
--- a/sys/arm64/vmm/arm64.h
+++ b/sys/arm64/vmm/arm64.h
@@ -119,6 +119,7 @@ struct hypctx {
        struct vgic_v3_regs     vgic_v3_regs;
        struct vgic_v3_cpu      *vgic_cpu;
        bool                    has_exception;
+       bool                    dbg_oslock;
 };
 
 struct hyp {
diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c
index 1dcefa1489e9..a551a2807183 100644
--- a/sys/arm64/vmm/vmm.c
+++ b/sys/arm64/vmm/vmm.c
@@ -651,6 +651,33 @@ vmm_reg_wi(struct vcpu *vcpu, uint64_t wval, void *arg)
        return (0);
 }
 
+static int
+vmm_write_oslar_el1(struct vcpu *vcpu, uint64_t wval, void *arg)
+{
+       struct hypctx *hypctx;
+
+       hypctx = vcpu_get_cookie(vcpu);
+       /* All other fields are RES0 & we don't do anything with this */
+       /* TODO: Disable access to other debug state when locked */
+       hypctx->dbg_oslock = (wval & OSLAR_OSLK) == OSLAR_OSLK;
+       return (0);
+}
+
+static int
+vmm_read_oslsr_el1(struct vcpu *vcpu, uint64_t *rval, void *arg)
+{
+       struct hypctx *hypctx;
+       uint64_t val;
+
+       hypctx = vcpu_get_cookie(vcpu);
+       val = OSLSR_OSLM_1;
+       if (hypctx->dbg_oslock)
+               val |= OSLSR_OSLK;
+       *rval = val;
+
+       return (0);
+}
+
 static const struct vmm_special_reg vmm_special_regs[] = {
 #define        SPECIAL_REG(_reg, _read, _write)                                
\
        {                                                               \
@@ -707,6 +734,13 @@ static const struct vmm_special_reg vmm_special_regs[] = {
        SPECIAL_REG(CNTP_TVAL_EL0, vtimer_phys_tval_read,
            vtimer_phys_tval_write),
        SPECIAL_REG(CNTPCT_EL0, vtimer_phys_cnt_read, vtimer_phys_cnt_write),
+
+       /* Debug registers */
+       SPECIAL_REG(DBGPRCR_EL1, vmm_reg_raz, vmm_reg_wi),
+       SPECIAL_REG(OSDLR_EL1, vmm_reg_raz, vmm_reg_wi),
+       /* TODO: Exceptions on invalid access */
+       SPECIAL_REG(OSLAR_EL1, vmm_reg_raz, vmm_write_oslar_el1),
+       SPECIAL_REG(OSLSR_EL1, vmm_read_oslsr_el1, vmm_reg_wi),
 #undef SPECIAL_REG
 };
 

Reply via email to