From c7e46c4ad25b222ae8d2549fc113a5b853c99446 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 3 Mar 2013 18:25:14 -0800 Subject: [PATCH] kernel - Increase size of savefpu area in pcb for vkernel64 * The vkernel64 uses bcopy. The ucontext_t/mcontext_t reserves a 1024 byte space for the fpu area, but the savefpu structure only reserves 834 bytes. Increase the savefpu structure appropriately. * Did not effect real 64-bit kernels because they used machine instructions to save/restore the FP state and/or bcopy'd using the savefpu structure sdize instead of the size of the fpu area in the ucontext/mcontext structure. * Fixes panics in vkernel64 Reported-by: tuxillo --- sys/cpu/x86_64/include/npx.h | 1 + sys/cpu/x86_64/include/ucontext.h | 7 +++++-- sys/platform/pc64/include/pcb.h | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/cpu/x86_64/include/npx.h b/sys/cpu/x86_64/include/npx.h index ca6e73e3e3..06e33506ea 100644 --- a/sys/cpu/x86_64/include/npx.h +++ b/sys/cpu/x86_64/include/npx.h @@ -132,6 +132,7 @@ union savefpu { struct save87 sv_87; struct savexmm sv_xmm; struct saveymm sv_ymm; + char sv_savearea[1024]; /* see mcontext_t */ }; /* diff --git a/sys/cpu/x86_64/include/ucontext.h b/sys/cpu/x86_64/include/ucontext.h index f19575b3b5..e1ef476612 100644 --- a/sys/cpu/x86_64/include/ucontext.h +++ b/sys/cpu/x86_64/include/ucontext.h @@ -75,8 +75,11 @@ struct __mcontext { unsigned int mc_reserved; unsigned int mc_unused[8]; - /* 64 byte aligned */ - int mc_fpregs[256]; /* 1024 bytes */ + /* + * NOTE! 64-byte aligned as of here. Also must match savefpu + * structure. + */ + int mc_fpregs[256]; } __attribute__((aligned(64))); typedef struct __mcontext mcontext_t; diff --git a/sys/platform/pc64/include/pcb.h b/sys/platform/pc64/include/pcb.h index 0369ea6cc4..f33affc656 100644 --- a/sys/platform/pc64/include/pcb.h +++ b/sys/platform/pc64/include/pcb.h @@ -45,6 +45,9 @@ /* * x86_64 process control block + * + * WARNING! union savefpu has a 64-byte alignment requirement built-in + * which will adjust the size of this structure. */ #include -- 2.41.0