From nobody Mon Nov 09 17:14:51 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jNbxl6bc4z70894 for ; Mon, 09 Nov 2026 17:14:51 +0000 (UTC) (envelope-from git@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) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jNbxl5fDQz3FB7 for ; Mon, 09 Nov 2026 17:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794244491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+XBu175Tt05GU1QkFFos3CnNw/nqujIp9cnEoggciLE=; b=sHCd8sMOaGrcwAj1vBcsvo3K4kYZGgd4VTiMLGgKJ1lXsNfs9jCUka56uP5zptfPoeCUMN tkBxcPWuZID+fNa3JKQsXnK9rB59FYpdlIIP2wZZGEZ5y6WYe4ydAZiGbN2BBdEQnPKLih h3p/pj+tTIZdlNekCCY9Knsid58WJUof0N1zdRA5xZs5Q6shk/8lflf1aq8tjQ/L5oNN/C bL8Qld24drmgKK6M7L1/+Ge0X6D8HVKI4agEXj8D/AVXT42GT3P95JfXcP+k1IFV7XOPar 5X9yHwis/GomBagZbAXHffx43KOYYZrRn2YJayiKTVWAzMVEh86HY0/fjWK2ag== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794244491; b=uapJYT3mgItP/bKFSclItS5hUfZBmOarVX0D9Z1NtR6cN9qoWh7HajuliOWnhAZrBpl1Lm ea7ay5cUbqGL0itKv4idxBGfRSmA/BQz79WL2i8CaXAiKuUt3Bqvqa1nOt7krEsssCTHEp QJCzqCrMZGfq0h/BTcdMI8tAh+8c6J5JKo/ZLKiPWfMqsCFGqkVc4in8HRu2hbEzcpopmX Al/EtaLJnKY+FmVVsValspFeaseNmXXIR8hqSPNF4o4XqjcWlAnYvN995Ju2lO5oBykgoC GbNCv94o1da5ZBFe8qY//mnd4qVjRdRQF68nlsfkKqgEXNFOdf62ypfk0M5nug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794244491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+XBu175Tt05GU1QkFFos3CnNw/nqujIp9cnEoggciLE=; b=t/wYo+i8BG+D3+81DDrG0BbemVajNL6xCjj5N9psDQt0B1z4k3L5fghYTWz2aGWJplac5u MjUcQWxUbRBsKuEJF5/uMjtzlFBhVoFzquPwKiGba8k9yCYo7pRVZewWyX3wIJzwATKKkE wqelBhWt54DghF8WUr+Rm4E1mUUjPDf9Z2ACtggBulFZ2RLCDbhkhuuAk2qsR2qejxNJUF NRqVxOmstLbCDmp26NyT+bJehLP39UvtB4nSWewL9oA9m1/lD7wqoGAtieCv27JD8nSLzS 6MYHgLHaq2brUFAdsiKYWUtUl18709bDKwePJZqnD7p9KfDIi0LSCXP+PxKBmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jNbxl5Hp1zr9w for ; Mon, 09 Nov 2026 17:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 343e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 17:14:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: fb1fb7df9db5 - main - arm64: Rename the user_regs struct and array List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb1fb7df9db5c133e36c09201fbedbddb32e37c5 Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 17:14:51 +0000 Message-Id: <6af1ff8b.343e.2daf0b3e@gitrepo.freebsd.org> The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=fb1fb7df9db5c133e36c09201fbedbddb32e37c5 commit fb1fb7df9db5c133e36c09201fbedbddb32e37c5 Author: Andrew Turner AuthorDate: 2026-11-09 17:03:26 +0000 Commit: Andrew Turner CommitDate: 2026-11-09 17:14:24 +0000 arm64: Rename the user_regs struct and array In preparation for storing a non-user register rename the struct so and array so they are more obviously for sanitized registers. While here switch to a flag field and add a flag to record if the register is for userspace or just the kernel and check for this when reading the value for userspace. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D60742 --- sys/arm64/arm64/identcpu.c | 79 ++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index e75f63693a57..60591e2913d2 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -2229,21 +2229,38 @@ static const struct mrs_field mvfr1_fields[] = { }; #endif /* COMPAT_FREEBSD32 */ -struct mrs_user_reg { +struct mrs_sanitized_reg { u_int iss; - bool is64bit; + u_int flags; size_t offset; const struct mrs_field *fields; }; +/* The register is safe to be expotred to userspace */ +#define SANITIZED_REG_USER (1u << 0) +/* The register is accessible from 64 bit or 32 bit userspace */ +#define SANITIZED_REG_64BIT (1u << 1) + +/* A register accessible from userspace */ #define USER_REG(name, field_name, _is64bit) \ { \ .iss = name##_ISS, \ .offset = __offsetof(struct cpu_desc, field_name), \ .fields = field_name##_fields, \ - .is64bit = _is64bit, \ + .flags = SANITIZED_REG_USER | \ + ((_is64bit) ? SANITIZED_REG_64BIT : 0), \ + } + +/* A register only accessible from the kernel */ +#define KERNEL_REG(name, field_name) \ + { \ + .iss = name##_ISS, \ + .offset = __offsetof(struct cpu_desc, field_name), \ + .fields = field_name##_fields, \ + .flags = 0, \ } -static const struct mrs_user_reg user_regs[] = { + +static const struct mrs_sanitized_reg sanitized_regs[] = { USER_REG(ID_AA64AFR0_EL1, id_aa64afr0, true), USER_REG(ID_AA64AFR1_EL1, id_aa64afr1, true), @@ -2277,7 +2294,7 @@ static const struct mrs_user_reg user_regs[] = { }; #define CPU_DESC_FIELD(desc, idx) \ - *(uint64_t *)((char *)&(desc) + user_regs[(idx)].offset) + *(uint64_t *)((char *)&(desc) + sanitized_regs[(idx)].offset) static bool user_ctr_has_neoverse_n1_1542419(uint32_t midr, uint64_t ctr) @@ -2434,14 +2451,18 @@ user_idreg_handler(uint64_t esr, struct trapframe *frame) value = 0; if (ISS_MSR_CRm(esr) >= 4 && ISS_MSR_CRm(esr) <= 7) { - for (int i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].iss == (esr & ISS_MSR_REG_MASK)) { - if (SV_CURPROC_ABI() == SV_ABI_FREEBSD) - value = CPU_DESC_FIELD(user_cpu_desc, i); - else - value = CPU_DESC_FIELD(l_user_cpu_desc, i); + for (int i = 0; i < nitems(sanitized_regs); i++) { + if (sanitized_regs[i].iss != (esr & ISS_MSR_REG_MASK)) + continue; + + if ((sanitized_regs[i].flags & SANITIZED_REG_USER) == 0) break; - } + + if (SV_CURPROC_ABI() == SV_ABI_FREEBSD) + value = CPU_DESC_FIELD(user_cpu_desc, i); + else + value = CPU_DESC_FIELD(l_user_cpu_desc, i); + break; } } else if (ISS_MSR_CRm(esr) == 0) { switch (ISS_MSR_OP2(esr)) { @@ -2519,8 +2540,8 @@ get_kernel_reg_iss(u_int iss, uint64_t *val) { int i; - for (i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].iss == iss) { + for (i = 0; i < nitems(sanitized_regs); i++) { + if (sanitized_regs[i].iss == iss) { *val = CPU_DESC_FIELD(kern_cpu_desc, i); return; } @@ -2539,10 +2560,10 @@ get_kernel_reg_iss_masked(u_int iss, uint64_t *valp, uint64_t mask) const struct mrs_field *fields; uint64_t val; - for (int i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].iss == iss) { + for (int i = 0; i < nitems(sanitized_regs); i++) { + if (sanitized_regs[i].iss == iss) { val = CPU_DESC_FIELD(kern_cpu_desc, i); - fields = user_regs[i].fields; + fields = sanitized_regs[i].fields; for (int j = 0; fields[j].type != 0; j++) { mask = update_special_reg_field(mask, fields[j].type, val, fields[j].width, @@ -2561,8 +2582,8 @@ get_user_reg_iss(u_int iss, uint64_t *val, bool fbsd) { int i; - for (i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].iss == iss) { + for (i = 0; i < nitems(sanitized_regs); i++) { + if (sanitized_regs[i].iss == iss) { if (fbsd) *val = CPU_DESC_FIELD(user_cpu_desc, i); else @@ -2624,7 +2645,7 @@ clear_set_special_reg_idx(int idx, uint64_t clear, uint64_t set) uint64_t f_old, f_new; uint64_t l_old, l_new; - MPASS(idx < nitems(user_regs)); + MPASS(idx < nitems(sanitized_regs)); k_old = CPU_DESC_FIELD(kern_cpu_desc, idx); k_new = (k_old & ~clear) | set; @@ -2635,7 +2656,7 @@ clear_set_special_reg_idx(int idx, uint64_t clear, uint64_t set) l_old = CPU_DESC_FIELD(l_user_cpu_desc, idx); l_new = (l_old & ~clear) | set; - fields = user_regs[idx].fields; + fields = sanitized_regs[idx].fields; for (int j = 0; fields[j].type != 0; j++) { u_int type; @@ -2687,7 +2708,7 @@ update_special_regs(u_int cpu) } desc = get_cpu_desc(cpu); - for (i = 0; i < nitems(user_regs); i++) { + for (i = 0; i < nitems(sanitized_regs); i++) { value = CPU_DESC_FIELD(*desc, i); if (cpu == 0) { CPU_DESC_FIELD(kern_cpu_desc, i) = value; @@ -2720,8 +2741,8 @@ update_special_reg_iss(u_int iss, uint64_t clear, uint64_t set) /* TODO: Add said locking */ MPASS(PCPU_GET(cpuid) == 0); - for (int i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].iss != iss) + for (int i = 0; i < nitems(sanitized_regs); i++) { + if (sanitized_regs[i].iss != iss) continue; clear_set_special_reg_idx(i, clear, set); @@ -2768,12 +2789,16 @@ parse_cpu_features(bool is64bit, struct cpu_desc *cpu_desc, u_long *hwcap, u_long *cur_hwcap; int i, j, k; - for (i = 0; i < nitems(user_regs); i++) { - if (user_regs[i].is64bit != is64bit) + for (i = 0; i < nitems(sanitized_regs); i++) { + bool reg_is64bit; + + reg_is64bit = + (sanitized_regs[i].flags & SANITIZED_REG_64BIT) != 0; + if (reg_is64bit != is64bit) continue; reg = CPU_DESC_FIELD(*cpu_desc, i); - fields = user_regs[i].fields; + fields = sanitized_regs[i].fields; for (j = 0; fields[j].type != 0; j++) { hwcaps = fields[j].hwcaps; if (hwcaps == NULL)