ExcServerVariants test: don’t test debug thread state flavors.

Kernel bugs prevent debug thread state flavors from being delivered to
exception handlers properly. Through luck, things work out for
x86_DEBUG_STATE and x86_DEBUG_STATE64, but a handler registered to
receive the x86_DEBUG_STATE32 thread state flavor will never be called.
For the x86 family, the only thread state flavors that can be delivered
to exception handlers are the thread, float, and exception flavors.

Radar 18312067 is filed.

TEST=util_test ExcServerVariants.ThreadStates
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/558503006
This commit is contained in:
Mark Mentovai 2014-09-12 12:14:08 -04:00
parent ab4978b51e
commit 1990a6ca2a

View File

@ -1029,28 +1029,43 @@ TEST(ExcServerVariants, ThreadStates) {
};
const TestData test_data[] = {
#if defined(ARCH_CPU_X86_FAMILY)
// For the x86 family, exception handlers can only properly receive the
// thread, float, and exception state flavors. Theres a bug in the kernel
// that causes it to call thread_getstatus() (a wrapper for the more
// familiar thread_get_state()) with an incorrect state buffer size
// parameter when delivering an exception. 10.9.4
// xnu-2422.110.17/osfmk/kern/exception.c exception_deliver() uses the
// _MachineStateCount[] array indexed by the flavor number to obtain the
// buffer size. 10.9.4 xnu-2422.110.17/osfmk/i386/pcb.c contains the
// definition of this array for the x86 family. The slots corresponding to
// thread, float, and exception state flavors in both native-width (32- and
// 64-bit) and universal are correct, but the remaining elements in the
// array are not. This includes elements that would correspond to debug and
// AVX state flavors, so these cannot be tested here.
//
// When machine_thread_get_state() (the machine-specific implementation of
// thread_get_state()) encounters an undersized buffer as reported by the
// buffer size parameter, it returns KERN_INVALID_ARGUMENT, which causes
// exception_deliver() to not actually deliver the exception and instead
// return that error code to exception_triage() as well.
//
// This bug is filed as radar 18312067.
//
// Additionaly, the AVX state flavors are also not tested because theyre
// not available on all CPUs and OS versions.
#if defined(ARCH_CPU_X86)
{ x86_THREAD_STATE32, x86_THREAD_STATE32_COUNT },
{ x86_FLOAT_STATE32, x86_FLOAT_STATE32_COUNT },
{ x86_EXCEPTION_STATE32, x86_EXCEPTION_STATE32_COUNT },
{ x86_DEBUG_STATE32, x86_DEBUG_STATE32_COUNT },
// Dont test x86_AVX_STATE32 because its not available on all CPUs and
// OS versionns.
#endif
#if defined(ARCH_CPU_X86_64)
{ x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT },
{ x86_FLOAT_STATE64, x86_FLOAT_STATE64_COUNT },
{ x86_EXCEPTION_STATE64, x86_EXCEPTION_STATE64_COUNT },
{ x86_DEBUG_STATE64, x86_DEBUG_STATE64_COUNT },
// Dont test x86_AVX_STATE64 because its not available on all CPUs and
// OS versions.
#endif
{ x86_THREAD_STATE, x86_THREAD_STATE_COUNT },
{ x86_FLOAT_STATE, x86_FLOAT_STATE_COUNT },
{ x86_EXCEPTION_STATE, x86_EXCEPTION_STATE_COUNT },
{ x86_DEBUG_STATE, x86_DEBUG_STATE_COUNT },
// Dont test x86_AVX_STATE because its not available on all CPUs and OS
// versions.
#else
#error Port this test to your CPU architecture.
#endif