The HVM parameter HVM_PARAM_X87_FIP_WIDTH to allow tools and the guest
to adjust the width of the FIP/FDP registers to be saved/restored by
the hypervisor. This is in case the hypervisor hueristics do not do
the right thing.
Add this parameter to the set saved during domain save/migrate.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
master commit:
5d768fb1f3f7b011e7b6e75909c7f4841730de60
master date: 2016-02-26 12:30:11 +0100
uint64_t vm_generationid_addr;
uint64_t ioreq_server_pfn;
uint64_t nr_ioreq_server_pages;
+ uint64_t x87_fip_width;
struct toolstack_data_t tdata;
} pagebuf_t;
}
return pagebuf_get_one(xch, ctx, buf, fd, dom);
+ case XC_SAVE_ID_HVM_X87_FIP_WIDTH:
+ /* Skip padding 4 bytes then read the x87 FIP width. */
+ if ( RDEXACT(fd, &buf->x87_fip_width, sizeof(uint32_t)) ||
+ RDEXACT(fd, &buf->x87_fip_width, sizeof(uint64_t)) )
+ {
+ PERROR("error reading the x87 FIP width");
+ return -1;
+ }
+ return pagebuf_get_one(xch, ctx, buf, fd, dom);
+
default:
if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
ERROR("Max batch size exceeded (%d). Giving up.", count);
if (pagebuf.viridian != 0)
xc_hvm_param_set(xch, dom, HVM_PARAM_VIRIDIAN, pagebuf.viridian);
+ if (pagebuf.x87_fip_width != 0)
+ xc_hvm_param_set(xch, dom, HVM_PARAM_X87_FIP_WIDTH,
+ pagebuf.x87_fip_width);
/*
* If we are migrating in from a host that does not support
PERROR("Error when writing the ioreq server gmfn count");
goto out;
}
+
+ chunk.id = XC_SAVE_ID_HVM_X87_FIP_WIDTH;
+ chunk.data = 0;
+ xc_hvm_param_get(xch, dom, HVM_PARAM_X87_FIP_WIDTH, &chunk.data);
+
+ if ( (chunk.data != 0) &&
+ wrexact(io_fd, &chunk, sizeof(chunk)) )
+ {
+ PERROR("Error writing the x87 FIP width");
+ goto out;
+ }
}
if ( callbacks != NULL && callbacks->toolstack_save != NULL )
/* These are a pair; it is an error for one to exist without the other */
#define XC_SAVE_ID_HVM_IOREQ_SERVER_PFN -19
#define XC_SAVE_ID_HVM_NR_IOREQ_SERVER_PAGES -20
+#define XC_SAVE_ID_HVM_X87_FIP_WIDTH -21
/*
** We process save/restore/migrate in batches of pages; the below
break;
}
+ case HVM_PARAM_X87_FIP_WIDTH:
+ if ( a.value != 0 && a.value != 4 && a.value != 8 )
+ {
+ rc = -EINVAL;
+ break;
+ }
+ d->arch.x87_fip_width = a.value;
+ break;
}
if ( rc == 0 )
case HVM_PARAM_ACPI_S_STATE:
a.value = d->arch.hvm_domain.is_s3_suspended ? 3 : 0;
break;
+ case HVM_PARAM_X87_FIP_WIDTH:
+ a.value = d->arch.x87_fip_width;
+ break;
case HVM_PARAM_IOREQ_SERVER_PFN:
case HVM_PARAM_NR_IOREQ_SERVER_PAGES:
if ( d == current->domain )
/* Location of the VM Generation ID in guest physical address space. */
#define HVM_PARAM_VM_GENERATION_ID_ADDR 34
-#define HVM_NR_PARAMS 35
+/*
+ * Size of the x87 FPU FIP/FDP registers that the hypervisor needs to
+ * save/restore. This is a workaround for a hardware limitation that
+ * does not allow the full FIP/FDP and FCS/FDS to be restored.
+ *
+ * Valid values are:
+ *
+ * 8: save/restore 64-bit FIP/FDP and clear FCS/FDS (default if CPU
+ * has FPCSDS feature).
+ *
+ * 4: save/restore 32-bit FIP/FDP, FCS/FDS, and clear upper 32-bits of
+ * FIP/FDP.
+ *
+ * 0: allow hypervisor to choose based on the value of FIP/FDP
+ * (default if CPU does not have FPCSDS).
+ *
+ * If FPCSDS (bit 13 in CPUID leaf 0x7, subleaf 0x0) is set, the CPU
+ * never saves FCS/FDS and this parameter should be left at the
+ * default of 8.
+ */
+#define HVM_PARAM_X87_FIP_WIDTH 36
+
+#define HVM_NR_PARAMS 37
#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */