Home | History | Annotate | Download | only in hppa
History log of /src/sys/arch/hppa/hppa/trap.c
RevisionDateAuthorComments
 1.128  19-Sep-2025  skrll Whitespace
 1.127  19-Sep-2025  skrll Remove a magic number with s/3/HPPA_PC_PRIV_MASK/
 1.126  19-Sep-2025  skrll Code style around probe instruction priviledge level.

Actually use the PROBE_PL macro with a bitfield that covers the
instruction's 'i' immediate or 'r' fields and mask the bottom two bits as
the {read,write}_access_allowed architecture functions would.
 1.125  19-Sep-2025  skrll Remove empty else clause.
 1.124  19-Sep-2025  skrll Fix the inverted logic around probe access vs probe access immediate
instructions. This affected the probe

<__canonicalize_funcptr_for_compare+76>: probei,r (r20),3,r20

and manifested as tests/lib/libc/tls/t_tls_dynamic failures
 1.123  05-Oct-2023  ad branches: 1.123.8;
Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
 1.122  23-Jul-2023  skrll PR/57261: hppa should be converted to __HAVE_SYSCALL_INTERN

Provide syscall_intern and use the md_syscall in syscall trap handling.
 1.121  02-Sep-2022  thorpej branches: 1.121.4;
Remove unnecessary inclusion of <net/netisr.h>.
 1.120  09-Jun-2022  skrll Only report the SSBREAKPOINT break instruction as SIGTRAP/TRAP_TRACE. All
other break instructions will be reported as SIGTRAP/TRAP_BRKPT

This fixes a mistake I made back in 2008.

PR/56866: hppa: kernel gets confused between actual breakpoints and single-step breakpoints
 1.119  09-Jun-2022  skrll Handle 'NA' (non-access) traps for the lpa and probe instructions. The
change is inspired by OpenBSD with a bunch of my own, mainly stylistic,
changes.

Thanks to Tom Lane for the analysis.

PR/56118: sporadic app crashes in HPPA -current
 1.118  07-Jun-2022  skrll Whitespace
 1.117  28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.116  19-Aug-2020  msaitoh s/ be be / be /
 1.115  25-Apr-2020  skrll Fix KASSERT that has been incorrect since revision 1.85 from 10 years
ago.
 1.114  06-Dec-2019  skrll branches: 1.114.6;
Simplify userret function signature. From ad@
 1.113  29-Nov-2019  ad PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().
 1.112  21-Nov-2019  ad mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.
 1.111  15-Apr-2019  skrll branches: 1.111.4;
Trailing whitespace
 1.110  06-Apr-2019  kamil Centralized shared part of child_return() into MI part

Add a new function md_child_return() for MD specific bits only.

New child_return() is now part of MI and central code that handles
uniformly tracing code (KTR and ptrace(2)).

Synchronize value passed to ktrsysret() among ports to SYS_fork. This is
a traditional value and accessing p_lflag to check for PL_PPWAIT shall
use locking against proc_lock. Returning SYS_fork vs SYS_vfork still isn't
correct enough as there are more entry points to forking code. Instead of
making it too good, just settle with plain SYS_fork for all ports.
 1.109  06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.108  03-Apr-2019  kamil Rework the fork(2)/vfork(2) event signalling under ptrace(2)

Remove the constraint of SIGTRAP event being maskable by a tracee.

Now all SIGTRAP TRAP_CHLD events are delivered to debugger.

This code touches MD specific logic and the child_return routine.
It's an intermediate step with a room for refactoring in future and
right now the least invasive approach. This allows to assert expected
behavior in already existing ATF tests and make the code prettier
in future keeping the same semantics. Probably there is a need for a MI
wrapper of child_return for shared functionality between ports.
 1.107  02-Mar-2015  martin branches: 1.107.10; 1.107.18;
Send SIGBUS when accessing mmap() past end of file (handle EINVAL in fault
path). While there, handle ENOMEM as well.
 1.106  06-Mar-2014  skrll branches: 1.106.6;
Move to a flat space register convention. %sr[4-7] are all now the space
number allocated to the process. gcc produces (slightly) better code
with this convention.

Retain backwards compatiblity.

Welcome to 6.99.36
 1.105  13-Feb-2014  skrll Simplify cpu_spawn_return - setregs has done all the work already.
 1.104  25-Oct-2013  martin Change a few __unused to __diagused/__debugused
 1.103  19-Oct-2013  skrll Use __unused on a variable used in a KASSERT
 1.102  13-Jul-2013  skrll Use sy_invoke
 1.101  23-Apr-2012  skrll branches: 1.101.2; 1.101.4;
Pass the trap address in ksi_addr without privilege bits.

Previously GDB would get confused by the trap address given when hitting
the _rtld_debug_state breakpoint.
 1.100  06-Apr-2012  skrll unifdef FPEMUL. All our supported systems have an FPU.
 1.99  07-Mar-2012  skrll Deal with setting of space registers and protection ids for posix_spawn.

Thanks to martin for the help.
 1.98  19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.97  13-Feb-2012  martin branches: 1.97.2;
Add missing MD code for posix_spawn
 1.96  23-Jan-2011  skrll branches: 1.96.4; 1.96.8;
Make some more information (psw/fpu_state) per cpu.
 1.95  20-Dec-2010  matt branches: 1.95.2; 1.95.4;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.94  09-Nov-2010  skrll #if 0 out the trap checks around tf_iioq_{head,tail}. The sti(4) code
can/will trigger them.
 1.93  07-Jul-2010  chs fix hppa ucas_*():
- "ret" is a kernel-space pointer.
- move the ucas RAS check from the device interrupt path
to the page-fault path.
 1.92  31-May-2010  skrll Fix previous.
 1.91  31-May-2010  skrll Pull change across from OpenBSD:

Make single stepping a system call work. Instead of single stepping
through the syscall gateway page, which doesn't work since that page is
shared between process, this makes us step over that bit by setting a
breakpoint on the instruction where the system call returns.
 1.90  26-Apr-2010  skrll SANITY output tweak.
 1.89  26-Apr-2010  skrll KNF
 1.88  23-Apr-2010  rmind Remove lwp_uc_pool, replace it with kmem(9), plus add some consistency.
As discussed, a while ago, with ad@.
 1.87  06-Apr-2010  skrll Include SSBREAKPOINT in the PTRACE #ifdef/#endif.
 1.86  03-Apr-2010  skrll Add md_astpending to struct mdlwp and use it.
 1.85  31-Mar-2010  skrll Make cpl, ipending, and intr_depth per CPU values.
 1.84  24-Mar-2010  skrll Correct the list of traps that we need to get the va and space from
ii[os]q.

From OpenBSD.
 1.83  22-Mar-2010  skrll Wrap long line.
 1.82  22-Mar-2010  skrll Whitespace / comment formatting.
 1.81  22-Mar-2010  skrll Improve the output from frame_sanity_check.
 1.80  20-Mar-2010  chs fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.79  16-Mar-2010  skrll The FP regs are accessed in both physical and virtual modes. Make sure
they're allocated in directly mapped memory to avoid aliasing problems
and unnecessary cache flushing.

Fix various names and references. If we ever directly map the uarea and
pcb we can change things at that point.

Significantly helps my J210 (PA7200).

Mostly from OpenBSD.
 1.78  11-Mar-2010  skrll branches: 1.78.2;
Start at the first, not the second, exception register.
 1.77  11-Mar-2010  skrll Comment formating.
 1.76  10-Feb-2010  skrll Oops. Whitespace in previous.
 1.75  10-Feb-2010  skrll Remove a cast by fixing a printf format.
 1.74  10-Feb-2010  skrll Reformat a comment.
 1.73  10-Feb-2010  skrll Minor tweaks.
 1.72  10-Feb-2010  skrll Use __arraycount
 1.71  17-Jan-2010  skrll branches: 1.71.2;
Use pmap_extract instead of kvtop.
 1.70  16-Jan-2010  skrll Tweak astpending handling.
 1.69  16-Jan-2010  skrll Check cpl level has returned to entry value when leaving trap/syscall.

From OpenBSD.
 1.68  16-Jan-2010  skrll Add a comment.
 1.67  16-Jan-2010  skrll Rename type_raw to trapnum and use in a couple more places.

Reduces diff to OpenBSD.
 1.66  16-Jan-2010  skrll Count traps in uvmexp. Reduces diff to OpenBSD.
 1.65  06-Jan-2010  skrll Update 64bit arg handling to use the flags in the syscall table.

Only do trace_enter/trace_exit if we're tracing.
 1.64  06-Jan-2010  skrll curlwp is never NULL now. Sprinkle KASSERT just in case.
 1.63  27-Nov-2009  skrll Fix DEBUG build. Hi rmind.
 1.62  27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.61  21-Nov-2009  rmind Use lwp_getpcb() on hppa and ia64, clean from struct user usage.
 1.60  03-Nov-2009  snj Follow upstream license changes for files with Michael Shalayeff's
copyright. In most cases, this means dropping the 3rd and 4th clauses.
 1.59  30-Apr-2009  skrll Merge nick-hppapmap.

This is a port of the OpenBSD pmap and trap handling code to get us

- Performance boost on some/all machines.
- Well on the way to PA2.0 (in 32bit mode) support. Several
machines probe hardware, but fail sometime after interrupts
are enabled.

Other things changed / fixed on the branch are

- update autoconf to use the OpenBSD code.
- com @ dino is very close to being supported.
- HPPA_REDZONE has been replaced with a working redzone which
is enabled with DIAGNOSTIC.
- UPAGES has been halved in size.
- power(4) from OpenBSD to fix a few bugs.
- updated list of modules from OpenBSD.
- initial ports of uturn(4), astro(4) and elroy(4).
- update some copyrights (remove advertising clause, etc.)

Thanks to mjf for some of the above, testing and listening.
 1.58  11-Apr-2009  skrll Fixup two more syscalls with 64-bit args.

Remove reference to script that is supposed to do this automatically - I
don't have it.

Fixes PR/41185.
 1.57  21-Oct-2008  ad branches: 1.57.2; 1.57.8;
Provide a small inline wrapper for sysent::sy_call() and use it to store
the active syscall description in struct lwp. To be used at some future
point to prevent unloading of modules that provide syscalls, while the
syscalls are in use.
 1.56  15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.55  28-Apr-2008  martin branches: 1.55.2; 1.55.6;
Remove clause 3 and 4 from TNF licenses
 1.54  06-Feb-2008  dsl branches: 1.54.6; 1.54.8; 1.54.10;
Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
 1.53  18-Jan-2008  skrll KNF
 1.52  18-Jan-2008  skrll Correct a comment.
 1.51  10-Jan-2008  skrll Various improvements to the hppa kernel for gdb.

- add the useful space and control registers to struct reg
- update process_{read,write}_regs accordingly
- use MID_HPPA in core dumps.
- dump the fp regs into cores.
- add single stepping support from OpenBSD.
 1.50  05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.49  05-Nov-2007  ad branches: 1.49.2; 1.49.8;
Don't set l_usrpri / spc_curpriority here. mi_userret() does it.
 1.48  17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.47  02-Oct-2007  skrll branches: 1.47.2;
Make want_resched a member of cpu_info.
 1.46  15-Aug-2007  ad branches: 1.46.2; 1.46.4;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.45  27-May-2007  skrll branches: 1.45.4; 1.45.8;
Fix up the frame sanity checking to not bitch when taking interrupts in
the sti ROM code.

Fixes PR/34715.

Thanks to David H. Gutteridge.
 1.44  18-May-2007  skrll Minor KNF and make some output a bit easier to read.
 1.43  17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.42  04-Mar-2007  christos branches: 1.42.2; 1.42.4; 1.42.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41  03-Mar-2007  skrll Remove hppa_{round,trunc}_page.
 1.40  09-Feb-2007  ad branches: 1.40.2;
Merge newlock2 to head.
 1.39  18-Dec-2006  skrll Update uvm_grow to support stacks that grow upwards.

Use on hppa and fix a bug in the hppa trap handler.
 1.38  09-Oct-2006  skrll branches: 1.38.2;
Make this compile without KTRACE.

From Sergey Svishchev in a private email.
 1.37  25-Aug-2006  skrll branches: 1.37.2; 1.37.4;
Fix a spello in a debug message.
 1.36  19-Jul-2006  ad - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
 1.35  07-Jul-2006  skrll Fix use of user_backtrace. It takes a lwp pointer now.
 1.34  12-May-2006  skrll branches: 1.34.4;
P_PROFIL is held in p_flag of struct proc so test for it there.
 1.33  15-Mar-2006  drochner branches: 1.33.2;
adapt to uvm_fault() interface cleanup: kill the useless 3rd argument
 1.32  07-Mar-2006  thorpej branches: 1.32.2;
Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.31  07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.30  24-Dec-2005  perry branches: 1.30.4; 1.30.6; 1.30.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.29  11-Dec-2005  christos merge ktrace-lwp.
 1.28  03-Jul-2005  he branches: 1.28.2;
Remove "bad" label no longer in use.
 1.27  01-Jul-2005  christos PR/29607: Christian Biere systrace doesn't handle interrupted syscalls properly
Instead of jumping to the default "bad" case, jump to the error handling
switch, so that we can deal with ERESTART/EJUSTRETURN properly.
 1.26  07-May-2005  chs add additional args to frame_sanity_check() so we can log which
context it was called from and the trap type (if called from trap()).
 1.25  01-May-2005  chs check pcb_onfault for kernel T_DATALIGN traps (for ddb).
 1.24  17-Feb-2005  tsutsui user_backtrace() is used if DEBUG or USERTRACE is defined, but not DIAGNOSTIC.
 1.23  07-Aug-2004  chs branches: 1.23.4; 1.23.6;
handle T_CONDITION traps (by sending SIGFPE).
fix T_EXCEPTION code to handle the other FP major opcodes.
 1.22  24-Jul-2004  chs real siginfo support.
 1.21  24-Jul-2004  chs FPU fixes and improvements, adapted from openbsd:
- handle exceptions correctly
- emulation of unimplemented instructions (eg. on PA-7300LC)
 1.20  18-Jul-2004  chs use mi_userret().
 1.19  15-Jun-2004  chs clear pcb_onfault before calling uvm_fault() and restore it after.
remove some debug code that actually makes debugging harder.
 1.18  09-Jun-2004  chs redo rev. 1.13, handle curlwp being NULL correctly.
 1.17  16-May-2004  chs for instruction TLB miss traps, process the fault with VM_PROT_EXECUTE
instead of VM_PROT_READ (to support non-executable mappings).
 1.16  26-Mar-2004  drochner To the rest of the kernel, pretend that hppa supports SIGINFO.
There are still only "sigcontext" stackframes passed to the user,
but at least we can clean up the MI sources now.
 1.15  14-Mar-2004  cl add kernel part of concurrency support for SA on MP systems
- move per VP data into struct sadata_vp referenced from l->l_savp
* VP id
* lock on VP data
* LWP on VP
* recently blocked LWP on VP
* queue of LWPs woken which ran on this VP before sleep
* faultaddr
* LWP cache for upcalls
* upcall queue
- add current concurrency and requested concurrency variables
- make process exit run LWP on all VPs
- make signal delivery consider all VPs
- make timer events consider all VPs
- add sa_newsavp to allocate new sadata_vp structure
- add sa_increaseconcurrency to prepare new VP
- make sys_sa_setconcurrency request new VP or wakeup idle VP
- make sa_yield lower current concurrency
- set sa_cpu = VP id in upcalls
- maintain cached LWPs per VP
 1.14  28-Nov-2003  chs de-__P, remove register, ansify.
 1.13  08-Nov-2003  tsutsui In trap(), curlwp could be NULL so don't refer it implicitly.
 1.12  31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.11  21-Oct-2003  fvdl NULL -> 0 for preempt() argument.
 1.10  13-Oct-2003  cl add MD part of SA/pthread pagefault handling on hppa
 1.9  31-Aug-2003  chs update for LWPs, and some lite cleanup.
 1.8  15-Jul-2003  lukem __KERNEL_RCSID()
 1.7  01-Apr-2003  thorpej branches: 1.7.2;
Use PAGE_SIZE rather than NBPG.
 1.6  21-Dec-2002  manu Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
 1.5  15-Nov-2002  manu Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
 1.4  19-Aug-2002  fredette Since trap_kdebug() may be a macro, be sure to cast to void when not
using its result.
 1.3  07-Jul-2002  fredette branches: 1.3.2;
Now include the HPPA trap number in a user backtrace, and display
backtraces for more traps.
 1.2  17-Jun-2002  christos branches: 1.2.2;
MD systrace gluons.
 1.1  05-Jun-2002  fredette Added files to support generic HP PA-RISC based machines. hp700-specific
files to follow.
 1.2.2.3  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1  17-Jun-2002  jdolecek file trap.c was added on branch kqueue on 2002-06-23 17:37:06 +0000
 1.3.2.4  31-Aug-2002  gehenna catch up with -current.
 1.3.2.3  16-Jul-2002  gehenna catch up with -current.
 1.3.2.2  14-Jul-2002  gehenna catch up with -current.
 1.3.2.1  07-Jul-2002  gehenna file trap.c was added on branch gehenna-devsw on 2002-07-14 17:47:15 +0000
 1.7.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.3  12-Oct-2004  skrll Correct some ktr* calls to pass a struct lwp *
 1.7.2.2  12-Aug-2004  skrll Sync with HEAD.
 1.7.2.1  03-Aug-2004  skrll Sync with HEAD
 1.23.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.4.1  29-Apr-2005  kent sync with -current
 1.28.2.8  11-Feb-2008  yamt sync with head.
 1.28.2.7  21-Jan-2008  yamt sync with head
 1.28.2.6  15-Nov-2007  yamt sync with head.
 1.28.2.5  27-Oct-2007  yamt sync with head.
 1.28.2.4  03-Sep-2007  yamt sync with head.
 1.28.2.3  26-Feb-2007  yamt sync with head.
 1.28.2.2  30-Dec-2006  yamt sync with head.
 1.28.2.1  21-Jun-2006  yamt sync with head.
 1.30.8.5  03-Sep-2006  yamt sync with head.
 1.30.8.4  11-Aug-2006  yamt sync with head
 1.30.8.3  24-May-2006  yamt sync with head.
 1.30.8.2  01-Apr-2006  yamt sync with head.
 1.30.8.1  13-Mar-2006  yamt sync with head.
 1.30.6.2  01-Jun-2006  kardel Sync with head.
 1.30.6.1  22-Apr-2006  simonb Sync with head.
 1.30.4.1  09-Sep-2006  rpaulo sync with head
 1.32.2.2  19-Apr-2006  elad sync with head - hopefully this will work
 1.32.2.1  07-Mar-2006  elad file trap.c was added on branch elad-kernelauth on 2006-04-19 02:32:44 +0000
 1.33.2.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.34.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.37.4.2  18-Dec-2006  yamt sync with head.
 1.37.4.1  22-Oct-2006  yamt sync with head
 1.37.2.4  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.37.2.3  29-Jan-2007  ad Make hp700 compile.
 1.37.2.2  12-Jan-2007  ad Sync with head.
 1.37.2.1  18-Nov-2006  ad Sync with head.
 1.38.2.2  06-Jul-2007  liamjfoy Pull up following revision(s) (requested by skrll in ticket #758):
sys/arch/hppa/hppa/trap.c: revision 1.45
Fix up the frame sanity checking to not bitch when taking interrupts in
the sti ROM code.
Fixes PR/34715.
Thanks to David H. Gutteridge.
 1.38.2.1  04-Jan-2007  bouyer branches: 1.38.2.1.2;
Pull up following revision(s) (requested by skrll in ticket #323):
sys/uvm/uvm_unix.c: revision 1.37
sys/arch/hppa/hppa/trap.c: revision 1.39
Update uvm_grow to support stacks that grow upwards.
Use on hppa and fix a bug in the hppa trap handler.
 1.38.2.1.2.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.40.2.5  02-May-2007  skrll Backout previous - the problem isn't in the syscall code not saving things
correctly. It's in pmap_activate which can overwrite the saved space
registers when switching back to the lwp if it was switched away from at
a critical point, e.g. in the syscall gateway page.

Not sure of a correct fix at the moment.
 1.40.2.4  10-Apr-2007  skrll Add the hack from OpenBSD for trap while in the SYSCALLGATE page. Add the
following comment to explain what's going on.

In case we were interrupted from the syscall gate page
treat this as we were not really running user code anymore

The problem is that if we preempt when returning from this
trap the interspace branch setting of IASQ to HPPA_SID_KERNEL
is not picked up by the syscall code. Instead, it will attempt
to return into the syscall gate page with the user space id
causing a (fatal) ITLB trap for the process.

The syscall handler should probably be fixed.
 1.40.2.3  04-Apr-2007  skrll More cleanup/improvement. Still WIP.
 1.40.2.2  23-Mar-2007  skrll Adapt hp700/hppa to yamt-idlelwp.

XXX Interrupts can fire before curlwp = new in sched_switch_unlock.
XXX This triggers the DEBUG check in sys/arch/hppa/hppa/trap.c:451
 1.40.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.42.10.3  03-Oct-2007  garbled Sync with HEAD
 1.42.10.2  26-Jun-2007  garbled Sync with HEAD.
 1.42.10.1  22-May-2007  matt Update to HEAD.
 1.42.4.1  11-Jul-2007  mjf Sync with head.
 1.42.2.5  03-Dec-2007  ad Sync with HEAD.
 1.42.2.4  09-Oct-2007  ad Sync with head.
 1.42.2.3  20-Aug-2007  ad Sync with HEAD.
 1.42.2.2  09-Jun-2007  ad Sync with head.
 1.42.2.1  27-May-2007  ad Sync with head.
 1.45.8.3  06-Nov-2007  joerg Sync with HEAD.
 1.45.8.2  02-Oct-2007  joerg Sync with HEAD.
 1.45.8.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.45.4.1  03-Sep-2007  skrll Sync with HEAD.
 1.46.4.1  06-Oct-2007  yamt sync with head.
 1.46.2.3  23-Mar-2008  matt sync with HEAD
 1.46.2.2  09-Jan-2008  matt sync with HEAD
 1.46.2.1  06-Nov-2007  matt sync with HEAD
 1.47.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.49.8.3  19-Jan-2008  bouyer Sync with HEAD
 1.49.8.2  11-Jan-2008  bouyer Sync with HEAD
 1.49.8.1  08-Jan-2008  bouyer Sync with HEAD
 1.49.2.1  18-Feb-2008  mjf Sync with HEAD.
 1.54.10.4  11-Aug-2010  yamt sync with head.
 1.54.10.3  11-Mar-2010  yamt sync with head
 1.54.10.2  04-May-2009  yamt sync with head.
 1.54.10.1  16-May-2008  yamt sync with head.
 1.54.8.1  18-May-2008  yamt sync with head.
 1.54.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.54.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.55.6.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.55.6.1  19-Oct-2008  haad Sync with HEAD.
 1.55.2.4  14-Oct-2008  wrstuden Add a new vp-private flag, SAVP_FLAG_DELIVERING. This flag indicates
that the vp is in the process of delivering a new-thread upcall.
This is a BLOCKED or NEWPROC upcall. Do NOT generate any BLOCKED
upcalls while this is set. Set it at the end of sa_switchcall()
and clear it at syscall entry. Sadly, I have found no other
way to handle this. The old SA interface has no way for
userland to acknowledge that it got the upcall, so use syscall
entry as the indicator that libpthread got it.

This addresses the issue seen on current-users with firefox
dying with a blockedgen != unbockedgen error. The problem is we
deliver a BLOCKED upcall, but between the end of userret()
and when the CPU indicates that it's running in user mode, we take
a page fault. Said page fault blocks, blocking upcall delivery.
The original block, however, was short-lived, and the UNBLOCK
happens shortly. It happens before libpthread actually notices
the BLOCKED upcall. Boom!

Unfortunately a LOCKDEBUG/DIAGNOSTIC kernel still dies before
firefox opens. However this new issue is with uvm code calling
mtsleep when not holding a correct lock; sa_switch() is exploding
at KASSERT(lwp_locked(l, NULL)); before it's done _anything_.

Also, while here, add sa_system_disabled. This is an integer
that we examine when starting SA for a proc. If it's non-zero,
we error out. Once this is hooked into sysctl, you'll be able to
disable SA w/o recompiling.
 1.55.2.3  30-Jun-2008  wrstuden Change how we make SA threads not generate upcalls. Instead of clearing
LW_SA, use a private flag, LP_SA_NOBLOCK, that we set when we want
to not generate upcalls. This means we do NOT need to lock (l)
(ourselves) to set it.

Adjust tests that look at LW_SA. Now, we are an upcall-generating
lwp if ((l->l_flag & LW_SA) && (~l->l_pflag & LP_SA_NOBLOCK)).

Introduce code pattern to set & remember this:

f = ~l->l_pflag & LP_SA_NOBLOCK;
l->l_pflag |= LP_SA_NOBLOCK;

...

/* f is now LP_SA_NOBLOCK if it wasn't set in l_pflag before */

l->l_pflag ^= f;

I updated a lot of the trap handlers to do trap handling iff LP_SA_NOBLOCK
is not set. I tried to figure out if the trap handler could be triggered
for user-based faults as opposed to kernel faults to user addresses, and
only look at LP_SA_NOBLOCK for the latter.

Above is a result of discussions with rmind at to reduce lock twiddling.

Also, per same discussions, add locking to sys_sa_preempt(). p_lock is
the lock we want.

Also, per same discussions, remove use of LSSUSPENDED as a thread state.
We needed to use it when we were emulating the 4.X and previous behavior
of hiding cached threads. For the moment, we now have them instead
remain visible to all and have them sleeping on the "lwpcache" wait
channel.

sa_newcachelwp(): sa_putcachelwp() wants savp_mutex held, not p_lock.

Tweak some comments.
 1.55.2.2  22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.55.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.57.8.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.2.4  28-Apr-2009  skrll Sync with HEAD.
 1.57.2.3  19-Feb-2009  skrll Fixup redzone stuff and enable it if DIAGNOSTIC.
 1.57.2.2  22-Nov-2008  mjf Fix a typo I saw when turning on TRAPDEBUG. struct pmap doesn't have
a pmap_space member, it should be pm_space.
 1.57.2.1  27-Oct-2008  skrll Commit work in progress.
 1.71.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.71.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.78.2.3  05-Mar-2011  rmind sync with head
 1.78.2.2  03-Jul-2010  rmind sync with head
 1.78.2.1  30-May-2010  rmind sync with head
 1.95.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.95.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.96.8.4  29-Apr-2012  mrg sync to latest -current.
 1.96.8.3  11-Mar-2012  mrg sync to latest -current
 1.96.8.2  24-Feb-2012  mrg sync to -current.
 1.96.8.1  18-Feb-2012  mrg merge to -current.
 1.96.4.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.96.4.2  23-May-2012  yamt sync with head.
 1.96.4.1  17-Apr-2012  yamt sync with head
 1.97.2.2  23-Apr-2012  riz Pull up following revision(s) (requested by skrll in ticket #196):
sys/arch/hppa/hppa/trap.c: revision 1.101
Pass the trap address in ksi_addr without privilege bits.
Previously GDB would get confused by the trap address given when hitting
the _rtld_debug_state breakpoint.
 1.97.2.1  17-Mar-2012  bouyer Pull up following revision(s) (requested by skrll in ticket #114):
sys/arch/hppa/hppa/trap.c: revision 1.99
sys/arch/hppa/hppa/vm_machdep.c: revision 1.51
sys/arch/hppa/hppa/vm_machdep.c: revision 1.52
Deal with setting of space registers and protection ids for posix_spawn.
Thanks to martin for the help.
Remove WIP code.
 1.101.4.2  18-May-2014  rmind sync with head
 1.101.4.1  28-Aug-2013  rmind sync with head
 1.101.2.2  03-Dec-2017  jdolecek update from HEAD
 1.101.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.106.6.1  06-Apr-2015  skrll Sync with HEAD
 1.107.18.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.18.1  10-Jun-2019  christos Sync with HEAD
 1.107.10.1  25-Apr-2020  martin Pull up following revision(s) (requested by skrll in ticket #1542):

sys/arch/hppa/hppa/trap.c: revision 1.115

Fix KASSERT that has been incorrect since revision 1.85 from 10 years
ago.
 1.111.4.4  23-Sep-2025  martin Pull up following revision(s) (requested by skrll in ticket #1967):

sys/arch/hppa/hppa/trap.c: revision 1.124
sys/arch/hppa/hppa/trap.c: revision 1.125
sys/arch/hppa/hppa/trap.c: revision 1.126
sys/arch/hppa/hppa/trap.c: revision 1.127
sys/arch/hppa/hppa/trap.c: revision 1.128

Fix the inverted logic around probe access vs probe access immediate
instructions. This affected the probe
<__canonicalize_funcptr_for_compare+76>: probei,r (r20),3,r20
and manifested as tests/lib/libc/tls/t_tls_dynamic failures

Remove empty else clause.

Code style around probe instruction priviledge level.

Actually use the PROBE_PL macro with a bitfield that covers the
instruction's 'i' immediate or 'r' fields and mask the bottom two bits as
the {read,write}_access_allowed architecture functions would.

Remove a magic number with s/3/HPPA_PC_PRIV_MASK/

Whitespace
 1.111.4.3  10-Jun-2022  martin Pull up following revision(s) (requested by skrll in ticket #1468):

sys/arch/hppa/hppa/trap.c: revision 1.120
sys/arch/hppa/include/ptrace.h: revision 1.11-1.12 (via patch)

Define a PTRACE_ILLEGAL_ASM

Match up PTRACE_BREAKPOINT_ASM with PTRACE_BREAKPOINT which is the
gdb breakpoint instruction.

Only report the SSBREAKPOINT break instruction as SIGTRAP/TRAP_TRACE. All
other break instructions will be reported as SIGTRAP/TRAP_BRKPT
This fixes a mistake I made back in 2008.

PR/56866: hppa: kernel gets confused between actual breakpoints and
single-step breakpoints
 1.111.4.2  10-Jun-2022  martin Pull up following revision(s) (requested by skrll in ticket #1466):

sys/arch/hppa/hppa/trap.c: revision 1.119

Handle 'NA' (non-access) traps for the lpa and probe instructions. The
change is inspired by OpenBSD with a bunch of my own, mainly stylistic,
changes.

Thanks to Tom Lane for the analysis.

PR/56118: sporadic app crashes in HPPA -current
 1.111.4.1  25-Apr-2020  martin Pull up following revision(s) (requested by skrll in ticket #854):

sys/arch/hppa/hppa/trap.c: revision 1.115

Fix KASSERT that has been incorrect since revision 1.85 from 10 years
ago.
 1.114.6.1  25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.121.4.1  23-Sep-2025  martin Pull up following revision(s) (requested by skrll in ticket #1161):

sys/arch/hppa/hppa/trap.c: revision 1.124
sys/arch/hppa/hppa/trap.c: revision 1.125
sys/arch/hppa/hppa/trap.c: revision 1.126
sys/arch/hppa/hppa/trap.c: revision 1.127
sys/arch/hppa/hppa/trap.c: revision 1.128

Fix the inverted logic around probe access vs probe access immediate
instructions. This affected the probe
<__canonicalize_funcptr_for_compare+76>: probei,r (r20),3,r20
and manifested as tests/lib/libc/tls/t_tls_dynamic failures

Remove empty else clause.

Code style around probe instruction priviledge level.

Actually use the PROBE_PL macro with a bitfield that covers the
instruction's 'i' immediate or 'r' fields and mask the bottom two bits as
the {read,write}_access_allowed architecture functions would.

Remove a magic number with s/3/HPPA_PC_PRIV_MASK/

Whitespace
 1.123.8.1  23-Sep-2025  martin Pull up following revision(s) (requested by skrll in ticket #33):

sys/arch/hppa/hppa/trap.c: revision 1.124
sys/arch/hppa/hppa/trap.c: revision 1.125
sys/arch/hppa/hppa/trap.c: revision 1.126
sys/arch/hppa/hppa/trap.c: revision 1.127
sys/arch/hppa/hppa/trap.c: revision 1.128

Fix the inverted logic around probe access vs probe access immediate
instructions. This affected the probe
<__canonicalize_funcptr_for_compare+76>: probei,r (r20),3,r20
and manifested as tests/lib/libc/tls/t_tls_dynamic failures

Remove empty else clause.

Code style around probe instruction priviledge level.

Actually use the PROBE_PL macro with a bitfield that covers the
instruction's 'i' immediate or 'r' fields and mask the bottom two bits as
the {read,write}_access_allowed architecture functions would.

Remove a magic number with s/3/HPPA_PC_PRIV_MASK/

Whitespace

RSS XML Feed