]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/emul: dedup hvmemul_cpuid() and pv_emul_cpuid()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 19 Jul 2018 16:40:06 +0000 (16:40 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 17 May 2019 15:37:46 +0000 (16:37 +0100)
They are identical, so provide a single x86emul_cpuid() instead.

As x86_emulate() now only uses the ->cpuid() hook for real CPUID instructions,
the hook can be omitted from all special-purpose emulation ops.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/mm/shadow/hvm.c
xen/arch/x86/pv/emul-priv-op.c
xen/arch/x86/pv/ro-page-fault.c
xen/arch/x86/x86_emulate.c
xen/arch/x86/x86_emulate/x86_emulate.h
xen/include/asm-x86/hvm/emulate.h
xen/include/asm-x86/mm.h

index 0c63a517e899768c00f5a507cc6450ab988fccde..8659c89862d336b31067bd4953b90bc65bd5f317 100644 (file)
@@ -2156,13 +2156,6 @@ static int hvmemul_wbinvd(
     return X86EMUL_OKAY;
 }
 
-int hvmemul_cpuid(uint32_t leaf, uint32_t subleaf,
-                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt)
-{
-    guest_cpuid(current, leaf, subleaf, res);
-    return X86EMUL_OKAY;
-}
-
 static int hvmemul_get_fpu(
     enum x86_emulate_fpu_type type,
     struct x86_emulate_ctxt *ctxt)
@@ -2361,7 +2354,7 @@ static const struct x86_emulate_ops hvm_emulate_ops = {
     .read_msr      = hvmemul_read_msr,
     .write_msr     = hvmemul_write_msr,
     .wbinvd        = hvmemul_wbinvd,
-    .cpuid         = hvmemul_cpuid,
+    .cpuid         = x86emul_cpuid,
     .get_fpu       = hvmemul_get_fpu,
     .put_fpu       = hvmemul_put_fpu,
     .invlpg        = hvmemul_invlpg,
@@ -2388,7 +2381,7 @@ static const struct x86_emulate_ops hvm_emulate_ops_no_write = {
     .read_msr      = hvmemul_read_msr,
     .write_msr     = hvmemul_write_msr_discard,
     .wbinvd        = hvmemul_wbinvd_discard,
-    .cpuid         = hvmemul_cpuid,
+    .cpuid         = x86emul_cpuid,
     .get_fpu       = hvmemul_get_fpu,
     .put_fpu       = hvmemul_put_fpu,
     .invlpg        = hvmemul_invlpg,
@@ -2474,13 +2467,11 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla)
         .read       = x86emul_unhandleable_rw,
         .insn_fetch = hvmemul_insn_fetch,
         .write      = mmcfg_intercept_write,
-        .cpuid      = hvmemul_cpuid,
     };
     static const struct x86_emulate_ops hvm_ro_emulate_ops_mmio = {
         .read       = x86emul_unhandleable_rw,
         .insn_fetch = hvmemul_insn_fetch,
         .write      = mmio_ro_emulated_write,
-        .cpuid      = hvmemul_cpuid,
     };
     struct mmio_ro_emulate_ctxt mmio_ro_ctxt = { .cr2 = gla };
     struct hvm_emulate_ctxt ctxt;
index bf9fd20770f161e665417f104e3c2def2641292e..c6469c846c41fb0dfcdf23aeddca4dd983b5adc6 100644 (file)
@@ -297,7 +297,6 @@ const struct x86_emulate_ops hvm_shadow_emulator_ops = {
     .insn_fetch = hvm_emulate_insn_fetch,
     .write      = hvm_emulate_write,
     .cmpxchg    = hvm_emulate_cmpxchg,
-    .cpuid      = hvmemul_cpuid,
 };
 
 /**************************************************************************/
index aedec5f795e00b63bf72f8f99e4e87c0bbdbfe2a..b20d79c7a3af78d5b88c08aa6d588096095045ee 100644 (file)
@@ -1122,14 +1122,6 @@ static int _wbinvd(struct x86_emulate_ctxt *ctxt)
     return X86EMUL_OKAY;
 }
 
-int pv_emul_cpuid(uint32_t leaf, uint32_t subleaf,
-                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt)
-{
-    guest_cpuid(current, leaf, subleaf, res);
-
-    return X86EMUL_OKAY;
-}
-
 static int validate(const struct x86_emulate_state *state,
                     struct x86_emulate_ctxt *ctxt)
 {
@@ -1233,7 +1225,7 @@ static const struct x86_emulate_ops priv_op_ops = {
     .write_xcr           = x86emul_write_xcr,
     .read_msr            = read_msr,
     .write_msr           = write_msr,
-    .cpuid               = pv_emul_cpuid,
+    .cpuid               = x86emul_cpuid,
     .wbinvd              = _wbinvd,
 };
 
index 9d4913d9327baca564ed62bada75c06ecdbaa10a..fa358a62e783b1323744c65fba486eda56b7a35a 100644 (file)
@@ -259,7 +259,6 @@ static const struct x86_emulate_ops ptwr_emulate_ops = {
     .write      = ptwr_emulated_write,
     .cmpxchg    = ptwr_emulated_cmpxchg,
     .validate   = pv_emul_is_mem_write,
-    .cpuid      = pv_emul_cpuid,
 };
 
 /* Write page fault handler: check if guest is trying to modify a PTE. */
@@ -308,7 +307,6 @@ static const struct x86_emulate_ops mmio_ro_emulate_ops = {
     .insn_fetch = ptwr_emulated_read,
     .write      = mmio_ro_emulated_write,
     .validate   = pv_emul_is_mem_write,
-    .cpuid      = pv_emul_cpuid,
 };
 
 static const struct x86_emulate_ops mmcfg_intercept_ops = {
@@ -316,7 +314,6 @@ static const struct x86_emulate_ops mmcfg_intercept_ops = {
     .insn_fetch = ptwr_emulated_read,
     .write      = mmcfg_intercept_write,
     .validate   = pv_emul_is_mem_write,
-    .cpuid      = pv_emul_cpuid,
 };
 
 /* Check if guest is trying to modify a r/o MMIO page. */
index b1dfc9f2617ce8fd57807dc72c931e296ed7c961..d0d52c93c162e30c144efa2c6777e6f75706d80d 100644 (file)
@@ -158,6 +158,14 @@ int x86emul_write_dr(unsigned int reg, unsigned long val,
 }
 #endif /* CONFIG_PV */
 
+int x86emul_cpuid(uint32_t leaf, uint32_t subleaf,
+                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt)
+{
+    guest_cpuid(current, leaf, subleaf, res);
+
+    return X86EMUL_OKAY;
+}
+
 /*
  * Local variables:
  * mode: C
index 398df5ff09931f64a27ee3b7a1032b64c8ee67c5..08645762ccb4900a55a0ec579a84d0bcde84ce8c 100644 (file)
@@ -725,6 +725,8 @@ int x86emul_read_dr(unsigned int reg, unsigned long *val,
                     struct x86_emulate_ctxt *ctxt);
 int x86emul_write_dr(unsigned int reg, unsigned long val,
                      struct x86_emulate_ctxt *ctxt);
+int x86emul_cpuid(uint32_t leaf, uint32_t subleaf,
+                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt);
 
 #endif
 
index 26a01e83a437c52d204e84f622ce6f0cc44a2946..b39a1a033135bcd4f3e71b4f4c9eb09a5d85c410 100644 (file)
@@ -76,8 +76,6 @@ void hvm_emulate_init_per_insn(
     unsigned int insn_bytes);
 void hvm_emulate_writeback(
     struct hvm_emulate_ctxt *hvmemul_ctxt);
-int hvmemul_cpuid(uint32_t leaf, uint32_t subleaf,
-                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt);
 struct segment_register *hvmemul_get_seg_reg(
     enum x86_segment seg,
     struct hvm_emulate_ctxt *hvmemul_ctxt);
index 6faa563167dbbf9c513e59ecd58e55fa439d420c..c72e32950604f17d839da522fe00461694b4cd43 100644 (file)
@@ -541,8 +541,6 @@ extern int mmcfg_intercept_write(enum x86_segment seg,
                                  void *p_data,
                                  unsigned int bytes,
                                  struct x86_emulate_ctxt *ctxt);
-int pv_emul_cpuid(uint32_t leaf, uint32_t subleaf,
-                  struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt);
 
 int audit_adjust_pgtables(struct domain *d, int dir, int noisy);