[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.5] x86/hvm: add HVM_PARAM_X87_FIP_WIDTH



commit 9945f6230f83a3869526bec6e5eb865098e79c05
Author:     David Vrabel <david.vrabel@xxxxxxxxxx>
AuthorDate: Mon May 9 13:04:26 2016 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon May 9 13:04:26 2016 +0200

    x86/hvm: add HVM_PARAM_X87_FIP_WIDTH
    
    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@xxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    master commit: 5d768fb1f3f7b011e7b6e75909c7f4841730de60
    master date: 2016-02-26 12:30:11 +0100
---
 tools/libxc/xc_domain_restore.c | 14 ++++++++++++++
 tools/libxc/xc_domain_save.c    | 11 +++++++++++
 tools/libxc/xg_save_restore.h   |  1 +
 xen/arch/x86/hvm/hvm.c          | 11 +++++++++++
 xen/include/public/hvm/params.h | 24 +++++++++++++++++++++++-
 5 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c
index a382701..8931391 100644
--- a/tools/libxc/xc_domain_restore.c
+++ b/tools/libxc/xc_domain_restore.c
@@ -743,6 +743,7 @@ typedef struct {
     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;
@@ -1013,6 +1014,16 @@ static int pagebuf_get_one(xc_interface *xch, struct 
restore_ctx *ctx,
         }
         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);
@@ -1748,6 +1759,9 @@ int xc_domain_restore(xc_interface *xch, int io_fd, 
uint32_t dom,
 
     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
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
index 254fdb3..2ed86bf 100644
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -1750,6 +1750,17 @@ int xc_domain_save(xc_interface *xch, int io_fd, 
uint32_t dom, uint32_t max_iter
             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 )
diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
index bdd9009..a072a1e 100644
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -262,6 +262,7 @@
 /* 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
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index cf527a2..0abc740 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5744,6 +5744,14 @@ long do_hvm_op(unsigned long op, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 
                 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 ) 
@@ -5777,6 +5785,9 @@ long do_hvm_op(unsigned long op, 
XEN_GUEST_HANDLE_PARAM(void) arg)
             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 )
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 3c51072..1c36050 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -189,6 +189,28 @@
 /* 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__ */
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.5

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.