[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/7] target-i386: xsave: Helper function to calculat
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 5/7] target-i386: xsave: Helper function to calculate xsave area size |
Date: |
Fri, 23 Sep 2016 16:45:34 -0300 |
Move the xsave area size calculation from cpu_x86_cpuid() inside
its own function. While doing it, change it to use the XSAVE area
struct sizes for the initial size, instead of the magic 0x240
number.
Signed-off-by: Eduardo Habkost <address@hidden>
---
target-i386/cpu.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7e66003..9034d8e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -548,6 +548,20 @@ static const ExtSaveArea x86_ext_save_areas[] = {
.size = sizeof(XSavePKRU) },
};
+static uint32_t xsave_area_size(uint64_t mask)
+{
+ int i;
+ uint64_t ret = sizeof(X86LegacyXSaveArea) + sizeof(X86XSaveHeader);
+
+ for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
+ const ExtSaveArea *esa = &x86_ext_save_areas[i];
+ if ((mask >> i) & 1) {
+ ret = MAX(ret, esa->offset + esa->size);
+ }
+ }
+ return ret;
+}
+
const char *get_register_name_32(unsigned int reg)
{
if (reg >= CPU_NB_REGS32) {
@@ -2519,13 +2533,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t count,
}
if (count == 0) {
- *ecx = 0x240;
- for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
- const ExtSaveArea *esa = &x86_ext_save_areas[i];
- if ((ena_mask >> i) & 1) {
- *ecx = MAX(*ecx, esa->offset + esa->size);
- }
- }
+ *ecx = xsave_area_size(ena_mask);;
*eax = ena_mask;
*edx = ena_mask >> 32;
*ebx = *ecx;
--
2.7.4
- Re: [Qemu-devel] [PATCH 1/7] target-i386: Move feature name arrays inside FeatureWordInfo, (continued)
- [Qemu-devel] [PATCH 2/7] target-i386: Don't try to enable PT State xsave component, Eduardo Habkost, 2016/09/23
- [Qemu-devel] [PATCH 3/7] target-i386: xsave: Calculate enabled components only once, Eduardo Habkost, 2016/09/23
- [Qemu-devel] [PATCH 4/7] target-i386: xsave: Simplify CPUID[0xD, 0].{EAX, EDX} calculation, Eduardo Habkost, 2016/09/23
- [Qemu-devel] [PATCH 6/7] target-i386: xsave: Calculate set of xsave components on realize, Eduardo Habkost, 2016/09/23
- [Qemu-devel] [PATCH 5/7] target-i386: xsave: Helper function to calculate xsave area size,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 7/7] target-i386: Move xsave component mask to features array, Eduardo Habkost, 2016/09/23
- Re: [Qemu-devel] [PATCH 0/7] target-i386: xsave CPUID handling refactor, Eduardo Habkost, 2016/09/27