The branch main has been updated by mhorne:

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

commit 972c488bf4117d9eb29e5753c6c5a2250154df3d
Author:     Doongar Singh <[email protected]>
AuthorDate: 2026-01-26 16:18:22 +0000
Commit:     Mitchell Horne <[email protected]>
CommitDate: 2026-01-26 16:23:16 +0000

    riscv: Add macro for hfence.gvma instruction
    
    Add an inline function hfence_gvma() for hfence.gvma instruction.
    
    Signed-off-by:  Doongar Singh <[email protected]>
    Reviewed by:    mhorne, markj
    Differential Revision:  https://reviews.freebsd.org/D54857
---
 sys/riscv/include/cpufunc.h | 7 +++++++
 sys/riscv/vmm/vmm_riscv.c   | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/riscv/include/cpufunc.h b/sys/riscv/include/cpufunc.h
index 75b22632c546..c39f17131eb7 100644
--- a/sys/riscv/include/cpufunc.h
+++ b/sys/riscv/include/cpufunc.h
@@ -119,6 +119,13 @@ sfence_vma_asid_page(uint64_t asid, uintptr_t addr)
            : "memory");
 }
 
+static __inline void
+hfence_gvma(void)
+{
+
+       __asm __volatile("hfence.gvma" ::: "memory");
+}
+
 #define        rdcycle()                       csr_read64(cycle)
 #define        rdtime()                        csr_read64(time)
 #define        rdinstret()                     csr_read64(instret)
diff --git a/sys/riscv/vmm/vmm_riscv.c b/sys/riscv/vmm/vmm_riscv.c
index cfd3decd8cfa..fe2ca5c07789 100644
--- a/sys/riscv/vmm/vmm_riscv.c
+++ b/sys/riscv/vmm/vmm_riscv.c
@@ -625,7 +625,7 @@ vmmops_run(void *vcpui, register_t pc, pmap_t pmap, struct 
vm_eventinfo *evinfo)
         * have been modified, it may be necessary to execute an HFENCE.GVMA
         * instruction (see Section 5.3.2) before or after writing hgatp.
         */
-       __asm __volatile("hfence.gvma" ::: "memory");
+       hfence_gvma();
 
        csr_write(hgatp, pmap->pm_satp);
        if (has_sstc)

Reply via email to