sync with OpenBSD -current
This commit is contained in:
parent
665ee5434a
commit
5c45f68af5
20 changed files with 207 additions and 131 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: drm_linux.c,v 1.115 2024/07/13 15:38:21 kettenis Exp $ */
|
||||
/* $OpenBSD: drm_linux.c,v 1.119 2024/09/30 12:21:17 jsg Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
|
||||
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -982,18 +982,12 @@ SPLAY_GENERATE(xarray_tree, xarray_entry, entry, xarray_cmp);
|
|||
void
|
||||
xa_init_flags(struct xarray *xa, gfp_t flags)
|
||||
{
|
||||
static int initialized;
|
||||
|
||||
if (!initialized) {
|
||||
pool_init(&xa_pool, sizeof(struct xarray_entry), 0, IPL_NONE, 0,
|
||||
"xapl", NULL);
|
||||
initialized = 1;
|
||||
}
|
||||
SPLAY_INIT(&xa->xa_tree);
|
||||
if (flags & XA_FLAGS_LOCK_IRQ)
|
||||
mtx_init(&xa->xa_lock, IPL_TTY);
|
||||
else
|
||||
mtx_init(&xa->xa_lock, IPL_NONE);
|
||||
xa->xa_flags = flags;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1009,11 +1003,15 @@ xa_destroy(struct xarray *xa)
|
|||
|
||||
/* Don't wrap ids. */
|
||||
int
|
||||
__xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
||||
__xa_alloc(struct xarray *xa, u32 *id, void *entry, struct xarray_range xr,
|
||||
gfp_t gfp)
|
||||
{
|
||||
struct xarray_entry *xid;
|
||||
int start = (xa->xa_flags & XA_FLAGS_ALLOC1) ? 1 : 0;
|
||||
int begin;
|
||||
uint32_t start = xr.start;
|
||||
uint32_t end = xr.end;
|
||||
|
||||
if (start == 0 && (xa->xa_flags & XA_FLAGS_ALLOC1))
|
||||
start = 1;
|
||||
|
||||
if (gfp & GFP_NOWAIT) {
|
||||
xid = pool_get(&xa_pool, PR_NOWAIT);
|
||||
|
@ -1026,17 +1024,14 @@ __xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
|||
if (xid == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if (limit <= 0)
|
||||
limit = INT_MAX;
|
||||
|
||||
xid->id = begin = start;
|
||||
xid->id = start;
|
||||
|
||||
while (SPLAY_INSERT(xarray_tree, &xa->xa_tree, xid)) {
|
||||
if (xid->id == limit)
|
||||
if (xid->id == end)
|
||||
xid->id = start;
|
||||
else
|
||||
xid->id++;
|
||||
if (xid->id == begin) {
|
||||
if (xid->id == start) {
|
||||
pool_put(&xa_pool, xid);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
@ -1052,10 +1047,10 @@ __xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
|||
* The only caller of this (i915_drm_client.c) doesn't use next id.
|
||||
*/
|
||||
int
|
||||
__xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, int limit, u32 *next,
|
||||
gfp_t gfp)
|
||||
__xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry,
|
||||
struct xarray_range xr, u32 *next, gfp_t gfp)
|
||||
{
|
||||
int r = __xa_alloc(xa, id, entry, limit, gfp);
|
||||
int r = __xa_alloc(xa, id, entry, xr, gfp);
|
||||
*next = *id + 1;
|
||||
return r;
|
||||
}
|
||||
|
@ -2853,6 +2848,8 @@ drm_linux_init(void)
|
|||
|
||||
pool_init(&idr_pool, sizeof(struct idr_entry), 0, IPL_TTY, 0,
|
||||
"idrpl", NULL);
|
||||
pool_init(&xa_pool, sizeof(struct xarray_entry), 0, IPL_NONE, 0,
|
||||
"xapl", NULL);
|
||||
|
||||
kmap_atomic_va =
|
||||
(vaddr_t)km_alloc(PAGE_SIZE, &kv_any, &kp_none, &kd_waitok);
|
||||
|
@ -2868,6 +2865,7 @@ drm_linux_init(void)
|
|||
void
|
||||
drm_linux_exit(void)
|
||||
{
|
||||
pool_destroy(&xa_pool);
|
||||
pool_destroy(&idr_pool);
|
||||
|
||||
taskq_destroy(taskletq);
|
||||
|
@ -2946,20 +2944,25 @@ unregister_shrinker(struct shrinker *shrinker)
|
|||
TAILQ_REMOVE(&shrinkers, shrinker, next);
|
||||
}
|
||||
|
||||
void
|
||||
unsigned long
|
||||
drmbackoff(long npages)
|
||||
{
|
||||
struct shrink_control sc;
|
||||
struct shrinker *shrinker;
|
||||
u_long ret;
|
||||
u_long ret, freed = 0;
|
||||
|
||||
shrinker = TAILQ_FIRST(&shrinkers);
|
||||
while (shrinker && npages > 0) {
|
||||
sc.nr_to_scan = npages;
|
||||
ret = shrinker->scan_objects(shrinker, &sc);
|
||||
if (ret == SHRINK_STOP)
|
||||
break;
|
||||
npages -= ret;
|
||||
freed += ret;
|
||||
shrinker = TAILQ_NEXT(shrinker, next);
|
||||
}
|
||||
|
||||
return freed;
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include <sys/tree.h>
|
||||
|
||||
#define XA_FLAGS_ALLOC 1
|
||||
#define XA_FLAGS_ALLOC1 2
|
||||
#define XA_FLAGS_LOCK_IRQ 4
|
||||
#define XA_FLAGS_ALLOC (1 << 0)
|
||||
#define XA_FLAGS_ALLOC1 (1 << 1)
|
||||
#define XA_FLAGS_LOCK_IRQ (1 << 2)
|
||||
|
||||
/*
|
||||
* lower bits of pointer are tagged:
|
||||
|
@ -29,10 +29,19 @@ struct xarray {
|
|||
SPLAY_HEAD(xarray_tree, xarray_entry) xa_tree;
|
||||
};
|
||||
|
||||
struct xarray_range {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
#define XA_LIMIT(_start, _end) (struct xarray_range){ _start, _end }
|
||||
#define xa_limit_32b XA_LIMIT(0, UINT_MAX)
|
||||
|
||||
void xa_init_flags(struct xarray *, gfp_t);
|
||||
void xa_destroy(struct xarray *);
|
||||
int __xa_alloc(struct xarray *, u32 *, void *, int, gfp_t);
|
||||
int __xa_alloc_cyclic(struct xarray *, u32 *, void *, int, u32 *, gfp_t);
|
||||
int __xa_alloc(struct xarray *, u32 *, void *, struct xarray_range, gfp_t);
|
||||
int __xa_alloc_cyclic(struct xarray *, u32 *, void *, struct xarray_range,
|
||||
u32 *, gfp_t);
|
||||
void *__xa_load(struct xarray *, unsigned long);
|
||||
void *__xa_store(struct xarray *, unsigned long, void *, gfp_t);
|
||||
void *__xa_erase(struct xarray *, unsigned long);
|
||||
|
@ -41,8 +50,6 @@ void *xa_get_next(struct xarray *, unsigned long *);
|
|||
#define xa_for_each(xa, index, entry) \
|
||||
for (index = 0; ((entry) = xa_get_next(xa, &(index))) != NULL; index++)
|
||||
|
||||
#define xa_limit_32b 0
|
||||
|
||||
#define xa_lock(_xa) do { \
|
||||
mtx_enter(&(_xa)->xa_lock); \
|
||||
} while (0)
|
||||
|
@ -112,11 +119,12 @@ xa_is_err(const void *e)
|
|||
}
|
||||
|
||||
static inline int
|
||||
xa_alloc(struct xarray *xa, u32 *id, void *entry, int limit, gfp_t gfp)
|
||||
xa_alloc(struct xarray *xa, u32 *id, void *entry, struct xarray_range xr,
|
||||
gfp_t gfp)
|
||||
{
|
||||
int r;
|
||||
mtx_enter(&xa->xa_lock);
|
||||
r = __xa_alloc(xa, id, entry, limit, gfp);
|
||||
r = __xa_alloc(xa, id, entry, xr, gfp);
|
||||
mtx_leave(&xa->xa_lock);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: wsconsio.h,v 1.101 2024/01/19 17:51:15 kettenis Exp $ */
|
||||
/* $OpenBSD: wsconsio.h,v 1.102 2024/09/30 01:41:49 jsg Exp $ */
|
||||
/* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -476,15 +476,6 @@ struct wsdisplay_fbinfo {
|
|||
};
|
||||
#define WSDISPLAYIO_GINFO _IOR('W', 65, struct wsdisplay_fbinfo)
|
||||
|
||||
/* Backwards compat; remove after OpenBSD 7.3 is released. */
|
||||
struct wsdisplay_ofbinfo {
|
||||
u_int height; /* height in pixels */
|
||||
u_int width; /* width in pixels */
|
||||
u_int depth; /* bits per pixel */
|
||||
u_int cmsize; /* color map size (entries) */
|
||||
};
|
||||
#define WSDISPLAYIO_OGINFO _IOR('W', 65, struct wsdisplay_ofbinfo)
|
||||
|
||||
/* Colormap operations. Not applicable to all display types. */
|
||||
struct wsdisplay_cmap {
|
||||
u_int index; /* first element (0 origin) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: wsdisplay.c,v 1.152 2023/01/10 16:33:18 tobhe Exp $ */
|
||||
/* $OpenBSD: wsdisplay.c,v 1.153 2024/09/30 01:41:49 jsg Exp $ */
|
||||
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -1315,25 +1315,6 @@ wsdisplay_driver_ioctl(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
|
|||
{
|
||||
int error;
|
||||
|
||||
#if defined(OpenBSD7_1) || defined(OpenBSD7_2) || defined(OpenBSD7_3)
|
||||
if (cmd == WSDISPLAYIO_OGINFO) {
|
||||
struct wsdisplay_ofbinfo *oinfo =
|
||||
(struct wsdisplay_ofbinfo *)data;
|
||||
struct wsdisplay_fbinfo info;
|
||||
|
||||
error = (*sc->sc_accessops->ioctl)(sc->sc_accesscookie,
|
||||
WSDISPLAYIO_GINFO, (caddr_t)&info, flag, p);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
oinfo->height = info.height;
|
||||
oinfo->width = info.width;
|
||||
oinfo->depth = info.depth;
|
||||
oinfo->cmsize = info.cmsize;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
error = ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, cmd, data,
|
||||
flag, p));
|
||||
/* Do not report parameters with empty ranges to userland. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_exec.c,v 1.258 2024/08/21 03:07:45 deraadt Exp $ */
|
||||
/* $OpenBSD: kern_exec.c,v 1.259 2024/09/30 11:49:44 claudio Exp $ */
|
||||
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -796,11 +796,7 @@ exec_abort:
|
|||
free_pack_abort:
|
||||
free(pack.ep_hdr, M_EXEC, pack.ep_hdrlen);
|
||||
exit1(p, 0, SIGABRT, EXIT_NORMAL);
|
||||
|
||||
/* NOTREACHED */
|
||||
atomic_clearbits_int(&pr->ps_flags, PS_INEXEC);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_exit.c,v 1.233 2024/09/06 08:21:21 mpi Exp $ */
|
||||
/* $OpenBSD: kern_exit.c,v 1.234 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -746,7 +746,7 @@ proc_finish_wait(struct proc *waiter, struct process *pr)
|
|||
* If we got the child via a ptrace 'attach',
|
||||
* we need to give it back to the old parent.
|
||||
*/
|
||||
if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_pptr->ps_pid) &&
|
||||
if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_ppid) &&
|
||||
(tr = prfind(pr->ps_oppid))) {
|
||||
pr->ps_oppid = 0;
|
||||
atomic_clearbits_int(&pr->ps_flags, PS_TRACED);
|
||||
|
@ -774,7 +774,7 @@ process_untrace(struct process *pr)
|
|||
KASSERT(pr->ps_flags & PS_TRACED);
|
||||
|
||||
if (pr->ps_oppid != 0 &&
|
||||
(pr->ps_oppid != pr->ps_pptr->ps_pid))
|
||||
(pr->ps_oppid != pr->ps_ppid))
|
||||
ppr = prfind(pr->ps_oppid);
|
||||
|
||||
/* not being traced any more */
|
||||
|
@ -803,7 +803,7 @@ process_reparent(struct process *child, struct process *parent)
|
|||
return;
|
||||
|
||||
KASSERT(child->ps_oppid == 0 ||
|
||||
child->ps_oppid == child->ps_pptr->ps_pid);
|
||||
child->ps_oppid == child->ps_ppid);
|
||||
|
||||
LIST_REMOVE(child, ps_sibling);
|
||||
LIST_INSERT_HEAD(&parent->ps_children, child, ps_sibling);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_sysctl.c,v 1.447 2024/09/24 12:37:11 bluhm Exp $ */
|
||||
/* $OpenBSD: kern_sysctl.c,v 1.448 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -1996,8 +1996,6 @@ fill_kproc(struct process *pr, struct kinfo_proc *ki, struct proc *p,
|
|||
show_pointers);
|
||||
|
||||
/* stuff that's too painful to generalize into the macros */
|
||||
if (pr->ps_pptr)
|
||||
ki->p_ppid = pr->ps_ppid;
|
||||
if (s->s_leader)
|
||||
ki->p_sid = s->s_leader->ps_pid;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sys_process.c,v 1.98 2024/06/03 12:48:25 claudio Exp $ */
|
||||
/* $OpenBSD: sys_process.c,v 1.99 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -291,7 +291,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
|
|||
if (ISSET(tr->ps_flags, PS_TRACED))
|
||||
return EBUSY;
|
||||
atomic_setbits_int(&tr->ps_flags, PS_TRACED);
|
||||
tr->ps_oppid = tr->ps_pptr->ps_pid;
|
||||
tr->ps_oppid = tr->ps_ppid;
|
||||
if (tr->ps_ptstat == NULL)
|
||||
tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat),
|
||||
M_SUBPROC, M_WAITOK);
|
||||
|
@ -520,7 +520,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
|
|||
* Stop the target.
|
||||
*/
|
||||
atomic_setbits_int(&tr->ps_flags, PS_TRACED);
|
||||
tr->ps_oppid = tr->ps_pptr->ps_pid;
|
||||
tr->ps_oppid = tr->ps_ppid;
|
||||
process_reparent(tr, p->p_p);
|
||||
if (tr->ps_ptstat == NULL)
|
||||
tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: tty_tty.c,v 1.32 2022/08/14 01:58:28 jsg Exp $ */
|
||||
/* $OpenBSD: tty_tty.c,v 1.33 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: tty_tty.c,v 1.13 1996/03/30 22:24:46 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -117,7 +117,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
|||
return EINVAL;
|
||||
sess = p->p_p->ps_pgrp->pg_session;
|
||||
sess->s_verauthuid = p->p_ucred->cr_ruid;
|
||||
sess->s_verauthppid = p->p_p->ps_pptr->ps_pid;
|
||||
sess->s_verauthppid = p->p_p->ps_ppid;
|
||||
timeout_add_sec(&sess->s_verauthto, secs);
|
||||
return 0;
|
||||
case TIOCCLRVERAUTH:
|
||||
|
@ -135,7 +135,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
|||
*/
|
||||
sess = p->p_p->ps_pgrp->pg_session;
|
||||
if (sess->s_verauthuid == p->p_ucred->cr_ruid &&
|
||||
sess->s_verauthppid == p->p_p->ps_pptr->ps_pid)
|
||||
sess->s_verauthppid == p->p_p->ps_ppid)
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sysctl.h,v 1.237 2024/08/02 14:34:45 mvs Exp $ */
|
||||
/* $OpenBSD: sysctl.h,v 1.238 2024/09/30 12:32:26 claudio Exp $ */
|
||||
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -568,7 +568,7 @@ struct kinfo_vmentry {
|
|||
* lim - source struct plimits
|
||||
* sa - source struct sigacts
|
||||
* There are some members that are not handled by these macros
|
||||
* because they're too painful to generalize: p_ppid, p_sid, p_tdev,
|
||||
* because they're too painful to generalize: p_sid, p_tdev,
|
||||
* p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid
|
||||
*/
|
||||
|
||||
|
@ -645,6 +645,7 @@ do { \
|
|||
(kp)->p_sigmask = (p)->p_sigmask; \
|
||||
\
|
||||
PR_LOCK(pr); \
|
||||
(kp)->p_ppid = (pr)->ps_ppid; \
|
||||
(kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0; \
|
||||
(kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0; \
|
||||
\
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uvm_pdaemon.c,v 1.114 2024/05/01 12:54:27 mpi Exp $ */
|
||||
/* $OpenBSD: uvm_pdaemon.c,v 1.115 2024/09/30 08:09:39 mpi Exp $ */
|
||||
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -84,7 +84,7 @@
|
|||
#include "drm.h"
|
||||
|
||||
#if NDRM > 0
|
||||
extern void drmbackoff(long);
|
||||
extern unsigned long drmbackoff(long);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue