git: 3113ac28cf84 - main - arm64: Add get_user_reg
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jun 2025 12:07:34 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=3113ac28cf846c685a4560db910bba8855abc430
commit 3113ac28cf846c685a4560db910bba8855abc430
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2025-06-23 10:14:51 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2025-06-23 10:18:19 +0000
arm64: Add get_user_reg
This is similar to get_kernel_reg such that it gives us a common view
of the userspace ID register.
This will be used to replace extract_user_id_field in a future change.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50902
---
sys/arm64/arm64/identcpu.c | 18 ++++++++++++++++++
sys/arm64/include/cpu.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c
index 6dc9c447ee29..0f0e727f5b1f 100644
--- a/sys/arm64/arm64/identcpu.c
+++ b/sys/arm64/arm64/identcpu.c
@@ -2555,6 +2555,24 @@ get_kernel_reg_masked(u_int reg, uint64_t *valp, uint64_t mask)
return (false);
}
+bool
+get_user_reg(u_int reg, uint64_t *val, bool fbsd)
+{
+ int i;
+
+ for (i = 0; i < nitems(user_regs); i++) {
+ if (user_regs[i].reg == reg) {
+ if (fbsd)
+ *val = CPU_DESC_FIELD(user_cpu_desc, i);
+ else
+ *val = CPU_DESC_FIELD(l_user_cpu_desc, i);
+ return (true);
+ }
+ }
+
+ return (false);
+}
+
static uint64_t
update_special_reg_field(uint64_t user_reg, u_int type, uint64_t value,
u_int width, u_int shift, bool sign)
diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h
index df38c69fdb30..6ac5d53f28fc 100644
--- a/sys/arm64/include/cpu.h
+++ b/sys/arm64/include/cpu.h
@@ -236,6 +236,7 @@ void update_special_reg(u_int reg, uint64_t, uint64_t);
bool extract_user_id_field(u_int, u_int, uint8_t *);
bool get_kernel_reg(u_int, uint64_t *);
bool get_kernel_reg_masked(u_int, uint64_t *, uint64_t);
+bool get_user_reg(u_int, uint64_t *, bool);
void cpu_desc_init(void);