authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-02 09:47:16+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-02 09:48:22+02:00
log846aa04a07161e865d0b28f653e1ff0a99b25840
treed3be86bcf68a42a99810d9b3dfb7801b8dec2a56
parent086f8d7b225df5ea15ef578411c94181fc53c464
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libc: update NetBSD headers to 11.0-RELEASE


22 files changed, 339 insertions(+), 87 deletions(-)

lib/libc/include/generic-netbsd/fcntl.h+4-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: fcntl.h,v 1.57 2025/07/25 23:24:46 kre Exp $ */
1/* $NetBSD: fcntl.h,v 1.57.2.1 2026/06/16 09:06:50 martin Exp $ */
22
33/*-
44 * Copyright (c) 1983, 1990, 1993
......@@ -121,6 +121,9 @@
121121#if defined(_NETBSD_SOURCE)
122122#define O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */
123123#define O_REGULAR 0x02000000 /* fail if not a regular file */
124#endif
125#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \
126 defined(_NETBSD_SOURCE)
124127#define O_EXEC 0x04000000 /* open for executing only */
125128#endif
126129#if (_POSIX_C_SOURCE - 0) >= 202405L || (_XOPEN_SOURCE - 0 >= 800) || \
lib/libc/include/generic-netbsd/i386/mcontext.h+23-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: mcontext.h,v 1.19 2024/11/30 01:04:10 christos Exp $ */
1/* $NetBSD: mcontext.h,v 1.19.2.1 2026/07/19 15:57:27 martin Exp $ */
22
33/*-
44 * Copyright (c) 1999 The NetBSD Foundation, Inc.
......@@ -40,6 +40,7 @@
4040#define _UC_CLRSTACK _UC_MD_BIT17
4141#define _UC_VM _UC_MD_BIT18
4242#define _UC_TLSBASE _UC_MD_BIT19
43#define _UC_XSAVE _UC_MD_BIT20
4344
4445/*
4546 * Layout of mcontext_t according to the System V Application Binary Interface,
......@@ -85,6 +86,27 @@ typedef struct {
8586 char __fp_xmm[512];
8687 } __fp_xmm_state; /* x87 and xmm regs in fxsave format */
8788 int __fp_fpregs[128];
89 struct {
90 /*
91 * `The XSAVE feature set does not use bytes
92 * 511:416; bytes 463:416 are reserved.'
93 *
94 * We take a part out of this to form a pointer
95 * to an external XSAVE area. This way, we can
96 * replicate the FXSAVE parts for the benefit
97 * of userland programs that aren't aware of
98 * the XSAVE pointer, have used the extended
99 * CPU registers (ymmN/zmmN/&c.), and want to
100 * examine the x87/SSE register state in a
101 * signal handler. The kernel does not use
102 * this part.
103 */
104 char __fxsave[416];
105 char __rsvd[48];
106 __greg_t __xsaveptr;
107 __greg_t __xsavelen;
108 char __pad[40];
109 } __xsave;
88110 } __fp_reg_set;
89111 int __fp_pad[33]; /* Historic padding */
90112} __fpregset_t;
lib/libc/include/generic-netbsd/i386/wchar_limits.h+1-1
......@@ -44,4 +44,4 @@
4444#define WINT_MIN (-0x7fffffff-1) /* wint_t */
4545#define WINT_MAX 0x7fffffff /* wint_t */
4646
47#endif /* !_I386_WCHAR_LIMITS_H_ */
47#endif /* !_I386_WCHAR_LIMITS_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/machine/pte.h+32-19
......@@ -1,4 +1,4 @@
1/* $NetBSD: pte.h,v 1.14.2.2 2025/10/26 12:28:36 martin Exp $ */
1/* $NetBSD: pte.h,v 1.14.2.3 2026/06/03 18:17:02 martin Exp $ */
22
33/*
44 * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
......@@ -139,6 +139,12 @@ pte_modified_p(pt_entry_t pte)
139139 return (pte & PTE_D) != 0;
140140}
141141
142static inline bool
143pte_referenced_p(pt_entry_t pte)
144{
145 return (pte & PTE_A) != 0;
146}
147
142148static inline bool
143149pte_cached_p(pt_entry_t pte)
144150{
......@@ -177,9 +183,15 @@ pte_nv_entry(bool kernel_p)
177183}
178184
179185static inline pt_entry_t
180pte_prot_nowrite(pt_entry_t pte)
186pte_clear_modify(pt_entry_t pte)
187{
188 return pte & ~PTE_D;
189}
190
191static inline pt_entry_t
192pte_clear_reference(pt_entry_t pte)
181193{
182 return pte & ~PTE_W;
194 return pte & ~PTE_A;
183195}
184196
185197static inline pt_entry_t
......@@ -237,28 +249,29 @@ pte_make_enter(paddr_t pa, struct vm_page_md *mdpg, vm_prot_t prot,
237249 pte |= pte_prot_bits(mdpg, prot, kernel_p);
238250 pte |= pte_enter_flags_to_pbmt(flags);
239251
240 if (mdpg != NULL) {
252 /*
253 * pmap_enter should have checked flags and updated
254 * VM_PAGEMD_{REFERENCED,MODIFIED}_P, so there is no
255 * need here.
256 */
257 KASSERT(((flags & VM_PROT_ALL) == 0) || VM_PAGEMD_REFERENCED_P(mdpg));
258 KASSERT(((flags & VM_PROT_WRITE) == 0) || VM_PAGEMD_MODIFIED_P(mdpg));
241259
242 if ((prot & VM_PROT_WRITE) != 0 &&
243 ((flags & VM_PROT_WRITE) != 0 || VM_PAGEMD_MODIFIED_P(mdpg))) {
260 if (mdpg != NULL) {
261 if ((prot & VM_PROT_WRITE) != 0 && VM_PAGEMD_MODIFIED_P(mdpg)) {
244262 /*
245 * This is a writable mapping, and the page's mod state
246 * indicates it has already been modified. No need for
247 * modified emulation.
248 */
263 * This is a writable mapping, and the page's mod state
264 * indicates it has already been modified. No need for
265 * reference or modified emulation.
266 */
249267 pte |= PTE_A | PTE_D;
250 } else if ((flags & VM_PROT_ALL) || VM_PAGEMD_REFERENCED_P(mdpg)) {
268 } else if (VM_PAGEMD_REFERENCED_P(mdpg)) {
251269 /*
252 * - The access type indicates that we don't need to do
253 * referenced emulation.
254 * OR
255 * - The physical page has already been referenced so no need
256 * to re-do referenced emulation here.
257 */
270 * The physical page has already been referenced so no need
271 * to re-do referenced emulation here.
272 */
258273 pte |= PTE_A;
259274 }
260 } else {
261 pte |= PTE_A | PTE_D;
262275 }
263276
264277 return pte;
lib/libc/include/generic-netbsd/machine/vmparam.h+21-9
......@@ -1,4 +1,4 @@
1/* $NetBSD: vmparam.h,v 1.14 2023/05/07 12:41:48 skrll Exp $ */
1/* $NetBSD: vmparam.h,v 1.14.8.2 2026/06/03 18:17:02 martin Exp $ */
22
33/*-
44 * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
......@@ -50,6 +50,25 @@
5050#define PAGE_SIZE (1 << PAGE_SHIFT)
5151#define PAGE_MASK (PAGE_SIZE - 1)
5252
53#ifdef _LP64
54/*
55 * Default pager_map of 16MB is awfully small. There is plenty
56 * of VA so use it.
57 */
58#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
59
60/*
61 * Defaults for Unified Buffer Cache parameters.
62 */
63
64#ifndef UBC_WINSHIFT
65#define UBC_WINSHIFT 16 /* 64kB */
66#endif
67#ifndef UBC_NWINS
68#define UBC_NWINS 4096 /* 256MB */
69#endif
70#endif
71
5372/*
5473 * USRSTACK is the top (end) of the user stack.
5574 *
......@@ -125,12 +144,6 @@
125144#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000)
126145
127146#else /* Sv32 */
128/*
129 * kernel virtual space layout:
130 * 0x8000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss)
131 * (0x4000_0000 +1GiB) KERNEL VM start of KVA
132 * (0x0000_0000 64GiB) reserved
133 */
134147
135148/*
136149 * kernel virtual space layout without direct map (common case)
......@@ -154,13 +167,12 @@
154167 *
155168 */
156169
157
158
159170#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffff_ffff_8000_0000 */
160171#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffff_ffff_8000_0000 */
161172#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x10000000) /* 0xffff_ffff_f000_0000 */
162173
163174#endif
175
164176#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
165177#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
166178#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
lib/libc/include/generic-netbsd/mips/pte.h+14-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: pte.h,v 1.27 2020/08/22 15:34:51 skrll Exp $ */
1/* $NetBSD: pte.h,v 1.27.28.1 2026/06/03 18:17:03 martin Exp $ */
22
33/*-
44 * Copyright (c) 1997 The NetBSD Foundation, Inc.
......@@ -269,6 +269,12 @@ pte_modified_p(pt_entry_t pte)
269269 return (pte & MIPS_MMU(PG_D)) != 0;
270270}
271271
272static inline bool
273pte_referenced_p(pt_entry_t pte)
274{
275 return false;
276}
277
272278static inline bool
273279pte_global_p(pt_entry_t pte)
274280{
......@@ -340,11 +346,17 @@ pte_prot_downgrade(pt_entry_t pte, vm_prot_t prot)
340346}
341347
342348static inline pt_entry_t
343pte_prot_nowrite(pt_entry_t pte)
349pte_clear_modify(pt_entry_t pte)
344350{
345351 return pte & ~MIPS_MMU(PG_D);
346352}
347353
354static inline pt_entry_t
355pte_clear_reference(pt_entry_t pte)
356{
357 return pte;
358}
359
348360static inline pt_entry_t
349361pte_cached_change(pt_entry_t pte, bool cached)
350362{
lib/libc/include/generic-netbsd/netinet/tcp_timer.h+2-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: tcp_timer.h,v 1.30 2019/08/06 15:48:18 riastradh Exp $ */
1/* $NetBSD: tcp_timer.h,v 1.30.34.1 2026/07/19 15:51:03 martin Exp $ */
22
33/*-
44 * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
......@@ -119,7 +119,7 @@
119119#define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */
120120#define TCPTV_SRTTBASE 0 /* base roundtrip time;
121121 if 0, no idea yet */
122#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */
122#define TCPTV_SRTTDFLT ( 1*PR_SLOWHZ) /* initial RTO; RFC 6298 (2.1) */
123123
124124#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */
125125#define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */
lib/libc/include/generic-netbsd/nfs/nfs.h+3-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: nfs.h,v 1.81 2024/12/07 02:05:55 riastradh Exp $ */
1/* $NetBSD: nfs.h,v 1.81.2.1 2026/06/27 09:46:05 martin Exp $ */
22/*
33 * Copyright (c) 1989, 1993, 1995
44 * The Regents of the University of California. All rights reserved.
......@@ -451,6 +451,8 @@ struct nfssvc_sock {
451451 int ns_sflags; /* b: */
452452 int ns_cc; /* b: */
453453 int ns_reclen; /* b: */
454 int ns_frag_count; /* b: */
455 int ns_streamlen; /* b: */
454456 int ns_numuids;
455457 u_int32_t ns_sref; /* g: */
456458 SIMPLEQ_HEAD(, nfsrv_descript) ns_sendq; /* s: send reply list */
lib/libc/include/generic-netbsd/nfs/nfsmount.h+4-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: nfsmount.h,v 1.54 2024/12/07 02:05:55 riastradh Exp $ */
1/* $NetBSD: nfsmount.h,v 1.54.2.1 2026/06/03 18:46:36 martin Exp $ */
22
33/*
44 * Copyright (c) 1989, 1993
......@@ -92,13 +92,15 @@ struct nfs_args {
9292#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
9393#define NFSMNT_XLATECOOKIE 0x00040000 /* 32<->64 dir cookie xlation */
9494#define NFSMNT_NOAC 0x00080000 /* Turn off attribute cache */
95#define NFSMNT_NOWCCMSG 0x00100000 /* Turn off attribute wcc messages */
9596
9697#define NFSMNT_BITS "\177\20" \
9798 "b\00soft\0b\01wsize\0b\02rsize\0b\03timeo\0" \
9899 "b\04retrans\0b\05maxgrps\0b\06intr\0b\07noconn\0" \
99100 "b\10nqnfs\0b\11nfsv3\0b\12kerb\0b\13dumbtimr\0" \
100101 "b\14leaseterm\0b\15readahead\0b\16deadthresh\0b\17resvport\0" \
101 "b\20rdirplus\0b\21readdirsize\0b\22xlatecookie\0b\23noac\0"
102 "b\20rdirplus\0b\21readdirsize\0b\22xlatecookie\0b\23noac\0" \
103 "b\24nowccmsg\0"
102104
103105/*
104106 * NFS internal flags (nm_iflag) */
lib/libc/include/generic-netbsd/pthread.h+1-1
......@@ -461,4 +461,4 @@ __END_DECLS
461461
462462#endif /* __LIBPTHREAD_SOURCE__ */
463463
464#endif /* _LIB_PTHREAD_H */
464#endif /* _LIB_PTHREAD_H */
\ No newline at end of file
lib/libc/include/generic-netbsd/riscv/pte.h+32-19
......@@ -1,4 +1,4 @@
1/* $NetBSD: pte.h,v 1.14.2.2 2025/10/26 12:28:36 martin Exp $ */
1/* $NetBSD: pte.h,v 1.14.2.3 2026/06/03 18:17:02 martin Exp $ */
22
33/*
44 * Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
......@@ -139,6 +139,12 @@ pte_modified_p(pt_entry_t pte)
139139 return (pte & PTE_D) != 0;
140140}
141141
142static inline bool
143pte_referenced_p(pt_entry_t pte)
144{
145 return (pte & PTE_A) != 0;
146}
147
142148static inline bool
143149pte_cached_p(pt_entry_t pte)
144150{
......@@ -177,9 +183,15 @@ pte_nv_entry(bool kernel_p)
177183}
178184
179185static inline pt_entry_t
180pte_prot_nowrite(pt_entry_t pte)
186pte_clear_modify(pt_entry_t pte)
187{
188 return pte & ~PTE_D;
189}
190
191static inline pt_entry_t
192pte_clear_reference(pt_entry_t pte)
181193{
182 return pte & ~PTE_W;
194 return pte & ~PTE_A;
183195}
184196
185197static inline pt_entry_t
......@@ -237,28 +249,29 @@ pte_make_enter(paddr_t pa, struct vm_page_md *mdpg, vm_prot_t prot,
237249 pte |= pte_prot_bits(mdpg, prot, kernel_p);
238250 pte |= pte_enter_flags_to_pbmt(flags);
239251
240 if (mdpg != NULL) {
252 /*
253 * pmap_enter should have checked flags and updated
254 * VM_PAGEMD_{REFERENCED,MODIFIED}_P, so there is no
255 * need here.
256 */
257 KASSERT(((flags & VM_PROT_ALL) == 0) || VM_PAGEMD_REFERENCED_P(mdpg));
258 KASSERT(((flags & VM_PROT_WRITE) == 0) || VM_PAGEMD_MODIFIED_P(mdpg));
241259
242 if ((prot & VM_PROT_WRITE) != 0 &&
243 ((flags & VM_PROT_WRITE) != 0 || VM_PAGEMD_MODIFIED_P(mdpg))) {
260 if (mdpg != NULL) {
261 if ((prot & VM_PROT_WRITE) != 0 && VM_PAGEMD_MODIFIED_P(mdpg)) {
244262 /*
245 * This is a writable mapping, and the page's mod state
246 * indicates it has already been modified. No need for
247 * modified emulation.
248 */
263 * This is a writable mapping, and the page's mod state
264 * indicates it has already been modified. No need for
265 * reference or modified emulation.
266 */
249267 pte |= PTE_A | PTE_D;
250 } else if ((flags & VM_PROT_ALL) || VM_PAGEMD_REFERENCED_P(mdpg)) {
268 } else if (VM_PAGEMD_REFERENCED_P(mdpg)) {
251269 /*
252 * - The access type indicates that we don't need to do
253 * referenced emulation.
254 * OR
255 * - The physical page has already been referenced so no need
256 * to re-do referenced emulation here.
257 */
270 * The physical page has already been referenced so no need
271 * to re-do referenced emulation here.
272 */
258273 pte |= PTE_A;
259274 }
260 } else {
261 pte |= PTE_A | PTE_D;
262275 }
263276
264277 return pte;
lib/libc/include/generic-netbsd/riscv/vmparam.h+21-9
......@@ -1,4 +1,4 @@
1/* $NetBSD: vmparam.h,v 1.14 2023/05/07 12:41:48 skrll Exp $ */
1/* $NetBSD: vmparam.h,v 1.14.8.2 2026/06/03 18:17:02 martin Exp $ */
22
33/*-
44 * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
......@@ -50,6 +50,25 @@
5050#define PAGE_SIZE (1 << PAGE_SHIFT)
5151#define PAGE_MASK (PAGE_SIZE - 1)
5252
53#ifdef _LP64
54/*
55 * Default pager_map of 16MB is awfully small. There is plenty
56 * of VA so use it.
57 */
58#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
59
60/*
61 * Defaults for Unified Buffer Cache parameters.
62 */
63
64#ifndef UBC_WINSHIFT
65#define UBC_WINSHIFT 16 /* 64kB */
66#endif
67#ifndef UBC_NWINS
68#define UBC_NWINS 4096 /* 256MB */
69#endif
70#endif
71
5372/*
5473 * USRSTACK is the top (end) of the user stack.
5574 *
......@@ -125,12 +144,6 @@
125144#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000)
126145
127146#else /* Sv32 */
128/*
129 * kernel virtual space layout:
130 * 0x8000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss)
131 * (0x4000_0000 +1GiB) KERNEL VM start of KVA
132 * (0x0000_0000 64GiB) reserved
133 */
134147
135148/*
136149 * kernel virtual space layout without direct map (common case)
......@@ -154,13 +167,12 @@
154167 *
155168 */
156169
157
158
159170#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffff_ffff_8000_0000 */
160171#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffff_ffff_8000_0000 */
161172#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x10000000) /* 0xffff_ffff_f000_0000 */
162173
163174#endif
175
164176#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
165177#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
166178#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
lib/libc/include/generic-netbsd/sys/fcntl.h+4-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: fcntl.h,v 1.57 2025/07/25 23:24:46 kre Exp $ */
1/* $NetBSD: fcntl.h,v 1.57.2.1 2026/06/16 09:06:50 martin Exp $ */
22
33/*-
44 * Copyright (c) 1983, 1990, 1993
......@@ -121,6 +121,9 @@
121121#if defined(_NETBSD_SOURCE)
122122#define O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */
123123#define O_REGULAR 0x02000000 /* fail if not a regular file */
124#endif
125#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \
126 defined(_NETBSD_SOURCE)
124127#define O_EXEC 0x04000000 /* open for executing only */
125128#endif
126129#if (_POSIX_C_SOURCE - 0) >= 202405L || (_XOPEN_SOURCE - 0 >= 800) || \
lib/libc/include/generic-netbsd/sys/lua.h+3-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: lua.h,v 1.9 2023/07/11 14:57:21 martin Exp $ */
1/* $NetBSD: lua.h,v 1.9.8.1 2026/06/29 19:52:23 martin Exp $ */
22
33/*
44 * Copyright (c) 2014 by Lourival Vieira Neto <lneto@NetBSD.org>.
......@@ -33,7 +33,9 @@
3333#define _SYS_LUA_H_
3434
3535#include <sys/param.h>
36
3637#include <sys/ioccom.h>
38#include <sys/stdbool.h>
3739
3840#include <lua.h> /* for lua_State */
3941
lib/libc/include/generic-netbsd/sys/param.h+2-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: param.h,v 1.738.2.5 2026/05/12 04:23:51 martin Exp $ */
1/* $NetBSD: param.h,v 1.738.2.9 2026/07/30 15:23:12 martin Exp $ */
22
33/*-
44 * Copyright (c) 1982, 1986, 1989, 1993
......@@ -566,4 +566,4 @@ extern size_t coherency_unit;
566566#endif
567567#endif /* !__ASSEMBLER__ */
568568
569#endif /* !_SYS_PARAM_H_ */
569#endif /* !_SYS_PARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/x86/cpu_extended_state.h+3-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: cpu_extended_state.h,v 1.19 2025/04/24 01:50:39 riastradh Exp $ */
1/* $NetBSD: cpu_extended_state.h,v 1.19.2.1 2026/07/19 15:57:27 martin Exp $ */
22
33#ifndef _X86_CPU_EXTENDED_STATE_H_
44#define _X86_CPU_EXTENDED_STATE_H_
......@@ -142,6 +142,8 @@ struct xsave_header {
142142};
143143__CTASSERT(sizeof(struct xsave_header) == 512 + 64);
144144
145#define XSAVE_ALIGN 64
146
145147/*
146148 * The ymm save area actually follows the xsave_header.
147149 */
lib/libc/include/generic-netbsd/x86/fpu.h+7-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: fpu.h,v 1.23 2020/10/24 07:14:29 mgorny Exp $ */
1/* $NetBSD: fpu.h,v 1.23.28.1 2026/07/19 15:57:27 martin Exp $ */
22
33#ifndef _X86_FPU_H_
44#define _X86_FPU_H_
......@@ -46,6 +46,12 @@ int process_read_xstate(struct lwp *, struct xstate *);
4646int process_verify_xstate(const struct xstate *);
4747int process_write_xstate(struct lwp *, const struct xstate *);
4848
49bool process_xsave_needed_p(struct lwp *);
50void process_read_xsave(struct lwp *, const struct xsave_header **, size_t *);
51int process_verify_xsavelen(struct lwp *, size_t);
52int process_verify_xsave(struct lwp *, const struct xsave_header *, size_t);
53void process_write_xsave(struct lwp *, const struct xsave_header *, size_t);
54
4955#endif
5056
5157#endif /* _X86_FPU_H_ */
\ No newline at end of file
lib/libc/include/generic-netbsd/x86/specialreg.h+71-5
......@@ -1,4 +1,4 @@
1/* $NetBSD: specialreg.h,v 1.219 2025/04/28 13:01:27 riastradh Exp $ */
1/* $NetBSD: specialreg.h,v 1.219.2.1 2026/07/19 15:57:27 martin Exp $ */
22
33/*
44 * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
......@@ -183,16 +183,82 @@
183183 "\0"
184184
185185/*
186 * Known FPU bits, only these get enabled. The save area is sized for all the
187 * fields below.
186 * XCR0_FPU: Known FPU bits, only these get enabled. The save area is
187 * sized for all the fields below.
188 *
189 * Any bits added to this will expand the extended CPU state that we
190 * may have to save and restore with XSAVE for userland processes,
191 * either in the kernel when preempting threads, or on the user's stack
192 * when delivering a signal.
193 *
194 * The kernel can dyanmically allocate larger sizes (on amd64, anyway,
195 * though not currently on i386 or Xen PV). But if the XSAVE area is
196 * expanded so much that it and mcontext_t exceed MINSIGSTKSZ
197 * (currently 8192), a userland ABI change and compatibility layer is
198 * required to accommodate that, because existing programs may use
199 * sigaltstack(2) with stacks sized for the old MINSIGSTKSZ.
200 *
201 * The current stack requirement is 3160 bytes of space plus up to
202 * 63+15+8=86 bytes of padding for alignment (could be reduced by
203 * around 512 bytes by having mcontext_t overlap with the XSAVE area a
204 * little in machdep.c cpu_getmcontext_xsave, but we don't do that
205 * right now):
206 *
207 * - mcontext_t (728 bytes: general registers and 512-byte FXSAVE area)
208 * - XSAVE header (576 bytes: 512 bytes of FXSAVE, 64 bytes of metadata)
209 * - AVX state: ymm0..ymm15 high 128-bit halves (256 bytes)
210 * - AVX-512 state:
211 * . k0..k7 opmask registers (64 bytes)
212 * . zmm0..zmm15 high 256-bit halves (512 bytes)
213 * . zmm16..zmm31 registers (1024 bytes)
214 *
215 * Likely future extensions that would expand the state beyond
216 * MINSIGSTKSZ:
217 *
218 * - AMX (Advanced Matrix Extensions) and ACE (AI Compute Extensions)
219 * state:
220 * . [AMX/ACE] TILECFG (64 bytes)
221 * . [AMX/ACE] TILEDATA (8192 bytes)
222 * . [ACE] SCALEDATA (128 bytes)
223 *
224 * As a precaution against ABI breakage, x86/identcpu.c will panic at
225 * boot if the XSAVE state size enabled in XCR0 exceeds MINSIGSTKSZ.
226 *
227 * References:
228 *
229 * - Intel 64 and IA-32 Architectures Software Developer's Manual,
230 * Volume 1: Basic Architecture, Intel, Order Number: 253665-092US,
231 * June 2026, Sec. 13.1 `XSAVE-Supported Features and State-Component
232 * Bitmaps', pp. 13-1 -- 13-2.
233 * https://web.archive.org/web/20260709150417/https://cdrdv2-public.intel.com/922477/253665-092-sdm-vol-1.pdf
234 *
235 * - AI Compute Extensions (ACE) Specification, x86 Ecosystem Advisory
236 * Group, Version 1.15, 2026-05-15, Sec 15.4.1 `XSAVE State
237 * Components', p. 86.
238 * https://web.archive.org/web/20260619062626/https://x86ecosystem.org/wp-content/uploads/2026/06/ACE_v1_Specification_public_1_15.pdf
188239 */
189240#if defined __i386__ || defined XENPV /* XXX XENPV PR kern/59371 */
190241#define XCR0_FPU (XCR0_X87 | XCR0_SSE | XCR0_YMM_Hi128 | \
191242 XCR0_Opmask | XCR0_ZMM_Hi256 | XCR0_Hi16_ZMM)
192243#else
193244#define XCR0_FPU (XCR0_X87 | XCR0_SSE | XCR0_YMM_Hi128 | \
194 XCR0_Opmask | XCR0_ZMM_Hi256 | XCR0_Hi16_ZMM | \
195 XCR0_TILECFG | XCR0_TILEDATA)
245 XCR0_Opmask | XCR0_ZMM_Hi256 | XCR0_Hi16_ZMM)
246#endif
247
248/*
249 * Maximum size of XSAVE state that we can handle without ABI changes
250 * to userland. Must match usage in cpu_getmcontext. Extra 8 is neeed
251 * on amd64 to have space for return address in 16-byte-aligned stack
252 * frame.
253 */
254#ifdef __x86_64__
255#define XSAVE_MAX_BYTES \
256 (MINSIGSTKSZ - (8 + STACK_ALIGNBYTES + \
257 sizeof(struct sigframe_siginfo) + (XSAVE_ALIGN - 1)))
258#else
259#define XSAVE_MAX_BYTES \
260 (MINSIGSTKSZ - (STACK_ALIGNBYTES + \
261 sizeof(struct sigframe_siginfo) + (XSAVE_ALIGN - 1)))
196262#endif
197263
198264/*
lib/libc/include/powerpc-netbsd-eabi/powerpc/oea/pmap.h+6-4
......@@ -1,4 +1,4 @@
1/* $NetBSD: pmap.h,v 1.39 2023/12/15 09:42:33 rin Exp $ */
1/* $NetBSD: pmap.h,v 1.39.4.1 2026/07/03 17:51:59 martin Exp $ */
22
33/*-
44 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
......@@ -122,11 +122,13 @@ __BEGIN_DECLS
122122#include <sys/systm.h>
123123
124124/*
125 * For OEA and OEA64_BRIDGE, we guarantee that pa below USER_ADDR
126 * (== 3GB < VM_MIN_KERNEL_ADDRESS) is direct-mapped.
125 * Physical memory below PMAP_DIRECT_MAPPED_LEN is direct-mapped
126 * (pa == va). Direct region covers the segments below BOTH
127 * the user copyin window (USER_SR) and the kernel HTAB window
128 * (KERNEL_SR), so it can never overlap.
127129 */
128130#if defined(PPC_OEA) || defined(PPC_OEA64_BRIDGE)
129#define PMAP_DIRECT_MAPPED_SR (USER_SR - 1)
131#define PMAP_DIRECT_MAPPED_SR (MIN(USER_SR, KERNEL_SR) - 1)
130132#define PMAP_DIRECT_MAPPED_LEN \
131133 ((vaddr_t)SEGMENT_LENGTH * (PMAP_DIRECT_MAPPED_SR + 1))
132134#endif
lib/libc/include/x86-netbsd-none/machine/mcontext.h+23-1
......@@ -1,4 +1,4 @@
1/* $NetBSD: mcontext.h,v 1.19 2024/11/30 01:04:10 christos Exp $ */
1/* $NetBSD: mcontext.h,v 1.19.2.1 2026/07/19 15:57:27 martin Exp $ */
22
33/*-
44 * Copyright (c) 1999 The NetBSD Foundation, Inc.
......@@ -40,6 +40,7 @@
4040#define _UC_CLRSTACK _UC_MD_BIT17
4141#define _UC_VM _UC_MD_BIT18
4242#define _UC_TLSBASE _UC_MD_BIT19
43#define _UC_XSAVE _UC_MD_BIT20
4344
4445/*
4546 * Layout of mcontext_t according to the System V Application Binary Interface,
......@@ -85,6 +86,27 @@ typedef struct {
8586 char __fp_xmm[512];
8687 } __fp_xmm_state; /* x87 and xmm regs in fxsave format */
8788 int __fp_fpregs[128];
89 struct {
90 /*
91 * `The XSAVE feature set does not use bytes
92 * 511:416; bytes 463:416 are reserved.'
93 *
94 * We take a part out of this to form a pointer
95 * to an external XSAVE area. This way, we can
96 * replicate the FXSAVE parts for the benefit
97 * of userland programs that aren't aware of
98 * the XSAVE pointer, have used the extended
99 * CPU registers (ymmN/zmmN/&c.), and want to
100 * examine the x87/SSE register state in a
101 * signal handler. The kernel does not use
102 * this part.
103 */
104 char __fxsave[416];
105 char __rsvd[48];
106 __greg_t __xsaveptr;
107 __greg_t __xsavelen;
108 char __pad[40];
109 } __xsave;
88110 } __fp_reg_set;
89111 int __fp_pad[33]; /* Historic padding */
90112} __fpregset_t;
lib/libc/include/x86_64-netbsd-none/amd64/mcontext.h+31-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: mcontext.h,v 1.24 2024/11/30 01:04:06 christos Exp $ */
1/* $NetBSD: mcontext.h,v 1.24.2.1 2026/07/19 15:57:26 martin Exp $ */
22
33/*-
44 * Copyright (c) 1999 The NetBSD Foundation, Inc.
......@@ -56,7 +56,28 @@ typedef __greg_t __gregset_t[_NGREG];
5656 * which requires 16 byte alignment. However the mcontext version
5757 * is never directly accessed.
5858 */
59typedef char __fpregset_t[512] __aligned(8);
59typedef union {
60 char __fxsave[512] __aligned(8);
61 struct {
62 /*
63 * `The XSAVE feature set does not use bytes 511:416;
64 * bytes 463:416 are reserved.'
65 *
66 * We take a part out of this to form a pointer to an
67 * external XSAVE area. This way, we can replicate the
68 * FXSAVE parts for the benefit of userland programs
69 * that aren't aware of the XSAVE pointer, have used
70 * the extended CPU registers (ymmN/zmmN/&c.), and want
71 * to examine the x87/SSE register state in a signal
72 * handler. The kernel does not use this part.
73 */
74 char __fxsave[416];
75 char __rsvd[48];
76 __greg_t __xsaveptr;
77 __greg_t __xsavelen;
78 char __pad[32];
79 } __xsave;
80} __fpregset_t;
6081
6182typedef struct {
6283 __gregset_t __gregs;
......@@ -75,6 +96,7 @@ typedef struct {
7596#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
7697
7798#define _UC_TLSBASE _UC_MD_BIT19
99#define _UC_XSAVE _UC_MD_BIT20
78100
79101/*
80102 * mcontext extensions to handle signal delivery.
......@@ -127,6 +149,13 @@ typedef struct {
127149 struct {
128150 char __fp_xmm[512];
129151 } __fp_xmm_state;
152 struct {
153 char __fxsave[416];
154 char __rsvd[48];
155 __greg32_t __xsaveptr;
156 __greg32_t __xsavelen;
157 char __pad[40];
158 } __xsave;
130159 } __fp_reg_set;
131160 int __fp_pad[33]; /* Historic padding */
132161} __fpregset32_t;
lib/libc/include/x86_64-netbsd-none/machine/mcontext.h+31-2
......@@ -1,4 +1,4 @@
1/* $NetBSD: mcontext.h,v 1.24 2024/11/30 01:04:06 christos Exp $ */
1/* $NetBSD: mcontext.h,v 1.24.2.1 2026/07/19 15:57:26 martin Exp $ */
22
33/*-
44 * Copyright (c) 1999 The NetBSD Foundation, Inc.
......@@ -56,7 +56,28 @@ typedef __greg_t __gregset_t[_NGREG];
5656 * which requires 16 byte alignment. However the mcontext version
5757 * is never directly accessed.
5858 */
59typedef char __fpregset_t[512] __aligned(8);
59typedef union {
60 char __fxsave[512] __aligned(8);
61 struct {
62 /*
63 * `The XSAVE feature set does not use bytes 511:416;
64 * bytes 463:416 are reserved.'
65 *
66 * We take a part out of this to form a pointer to an
67 * external XSAVE area. This way, we can replicate the
68 * FXSAVE parts for the benefit of userland programs
69 * that aren't aware of the XSAVE pointer, have used
70 * the extended CPU registers (ymmN/zmmN/&c.), and want
71 * to examine the x87/SSE register state in a signal
72 * handler. The kernel does not use this part.
73 */
74 char __fxsave[416];
75 char __rsvd[48];
76 __greg_t __xsaveptr;
77 __greg_t __xsavelen;
78 char __pad[32];
79 } __xsave;
80} __fpregset_t;
6081
6182typedef struct {
6283 __gregset_t __gregs;
......@@ -75,6 +96,7 @@ typedef struct {
7596#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
7697
7798#define _UC_TLSBASE _UC_MD_BIT19
99#define _UC_XSAVE _UC_MD_BIT20
78100
79101/*
80102 * mcontext extensions to handle signal delivery.
......@@ -127,6 +149,13 @@ typedef struct {
127149 struct {
128150 char __fp_xmm[512];
129151 } __fp_xmm_state;
152 struct {
153 char __fxsave[416];
154 char __rsvd[48];
155 __greg32_t __xsaveptr;
156 __greg32_t __xsavelen;
157 char __pad[40];
158 } __xsave;
130159 } __fp_reg_set;
131160 int __fp_pad[33]; /* Historic padding */
132161} __fpregset32_t;