History log of /netbsd-current/tests/kernel/h_segv.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.15 14-May-2024 riastradh

tests/kernel/h_segv: Disable SIGFPE test on RISC-V.

No floating-point exception traps on RISC-V.

Also don't pass the result of divide-by-zero converted to integer to
usleep. Although the floating-point result of divide-by-zero is
well-defined by IEEE 754 (+/-infinity), the outcome of C conversion
to integer is not. And while on some architectures this might return
zero, on RISC-V it looks like it'll return all bits set. And as of
PR 58184, usleep now honours sleeps longer than 1sec, which means
this will be waiting at least two billion microseconds, or about half
an hour...

So instead, just write the result to a volatile variable.


Revision tags: netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.14 25-Apr-2019 kamil

Fix typo


# 1.13 30-Jan-2019 martin

Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.


# 1.12 27-Jan-2019 christos

vaxinate against ieeefp.h


Revision tags: pgoyette-compat-20190127
# 1.11 26-Jan-2019 martin

Some arm CPUs do not implement traps on floating point exceptions.


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.10 12-Nov-2018 riastradh

Make fenv.h optional for this test to unbreak the vax build.


# 1.9 11-Nov-2018 riastradh

Use feenableexcept to trap fp exceptions, and trigger one, for SIGFPE.

Not every CPU traps integer division by zero -- aarch64, powerpc,
&c., just return zero.


# 1.8 11-Nov-2018 riastradh

Sort #includes.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.7 30-May-2018 kamil

branches: 1.7.2;
Add a comment for the workaround in trigger_bus()

Explain PROT_READ|PROT_WRITE.


# 1.6 30-May-2018 kamil

Make the trigger_bus() test compatible with more CPUs (at least ALPHA)

If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
- write register wide memory without rmw sequence,
- mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>


# 1.5 27-May-2018 kamil

Handle FPE and BUS scenarios in the ATF t_trapsignal tests

These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>


# 1.4 22-May-2018 kamil

Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps

There are at least four types of SIGTRAP events:
- software/hardware single step (trace trap)
- software breakpoint
- hardware breakpoint/watchpoint
- kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>


# 1.3 21-May-2018 kamil

Add new ATF test: t_trapsignal:trap_ignore

Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.2 08-Dec-2017 christos

branches: 1.2.2;
fix usage.


# 1.1 07-Dec-2017 christos

Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.


# 1.14 25-Apr-2019 kamil

Fix typo


# 1.13 30-Jan-2019 martin

Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.


# 1.12 27-Jan-2019 christos

vaxinate against ieeefp.h


Revision tags: pgoyette-compat-20190127
# 1.11 26-Jan-2019 martin

Some arm CPUs do not implement traps on floating point exceptions.


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.10 12-Nov-2018 riastradh

Make fenv.h optional for this test to unbreak the vax build.


# 1.9 11-Nov-2018 riastradh

Use feenableexcept to trap fp exceptions, and trigger one, for SIGFPE.

Not every CPU traps integer division by zero -- aarch64, powerpc,
&c., just return zero.


# 1.8 11-Nov-2018 riastradh

Sort #includes.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625
# 1.7 30-May-2018 kamil

Add a comment for the workaround in trigger_bus()

Explain PROT_READ|PROT_WRITE.


# 1.6 30-May-2018 kamil

Make the trigger_bus() test compatible with more CPUs (at least ALPHA)

If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
- write register wide memory without rmw sequence,
- mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>


# 1.5 27-May-2018 kamil

Handle FPE and BUS scenarios in the ATF t_trapsignal tests

These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>


# 1.4 22-May-2018 kamil

Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps

There are at least four types of SIGTRAP events:
- software/hardware single step (trace trap)
- software breakpoint
- hardware breakpoint/watchpoint
- kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>


# 1.3 21-May-2018 kamil

Add new ATF test: t_trapsignal:trap_ignore

Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.2 08-Dec-2017 christos

branches: 1.2.2;
fix usage.


# 1.1 07-Dec-2017 christos

Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.


# 1.2 08-Dec-2017 christos

fix usage.


# 1.1 07-Dec-2017 christos

Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.