summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-29 21:46:05 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-29 21:46:05 +0100
commitb5a5e5c3f8cbbb68ea7c3d94c297eafe8be40c9a (patch)
tree980a2cd3e0c98498922a4cad3e86f6ef2ec41592
parent7f61298b5d4c36b38e3c9e96fd0357c564bc3b9d (diff)
x86: Make sure we allocate as much as our structure should hold
* i386/i386/fpu.c (init_fpu): Panic if the CPU gives us a size that is smaller than it should.
-rw-r--r--i386/i386/fpu.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c
index 69c495c8..c5401fca 100644
--- a/i386/i386/fpu.c
+++ b/i386/i386/fpu.c
@@ -185,6 +185,11 @@ init_fpu(void)
cpuid(eax, ebx, ecx, edx);
if (eax & CPU_FEATURE_XSAVES) {
fp_xsave_size = offsetof(struct i386_fpsave_state, xfp_save_state) + ebx;
+ if (fp_xsave_size < sizeof(struct i386_fpsave_state))
+ panic("CPU-provided xstate size %d "
+ "is smaller than our minimum %d!\n",
+ fp_xsave_size,
+ sizeof(struct i386_fpsave_state));
fp_save_kind = FP_XSAVES;
} else {
@@ -192,6 +197,11 @@ init_fpu(void)
ecx = 0x0;
cpuid(eax, ebx, ecx, edx);
fp_xsave_size = offsetof(struct i386_fpsave_state, xfp_save_state) + ebx;
+ if(fp_xsave_size < sizeof(struct i386_fpsave_state));
+ panic("CPU-provided xstate size %d "
+ "is smaller than our minimum %d!\n",
+ fp_xsave_size,
+ sizeof(struct i386_fpsave_state));
if (eax & CPU_FEATURE_XSAVEOPT)
fp_save_kind = FP_XSAVEOPT;