From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 6/6] x86/emul: dedup hvmemul_cpuid() and pv_emul_cpuid()
Date: Mon, 5 Nov 2018 11:21:07 +0000 [thread overview]
Message-ID: <1541416867-30253-7-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1541416867-30253-1-git-send-email-andrew.cooper3@citrix.com>
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>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/hvm/emulate.c | 13 ++-----------
xen/arch/x86/mm/shadow/hvm.c | 1 -
xen/arch/x86/pv/emul-priv-op.c | 10 +---------
xen/arch/x86/pv/ro-page-fault.c | 3 ---
xen/arch/x86/x86_emulate.c | 8 ++++++++
xen/arch/x86/x86_emulate/x86_emulate.h | 2 ++
xen/include/asm-x86/hvm/emulate.h | 2 --
xen/include/asm-x86/mm.h | 2 --
8 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 91fa9db..3c42381 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2107,13 +2107,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)
@@ -2312,7 +2305,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,
@@ -2339,7 +2332,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,
@@ -2424,13 +2417,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;
diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c
index 4cc7591..5087cd9 100644
--- a/xen/arch/x86/mm/shadow/hvm.c
+++ b/xen/arch/x86/mm/shadow/hvm.c
@@ -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,
};
/**************************************************************************/
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index 5968f99..d5a4046 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -1178,14 +1178,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)
{
@@ -1289,7 +1281,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,
};
diff --git a/xen/arch/x86/pv/ro-page-fault.c b/xen/arch/x86/pv/ro-page-fault.c
index 9d4913d..fa358a6 100644
--- a/xen/arch/x86/pv/ro-page-fault.c
+++ b/xen/arch/x86/pv/ro-page-fault.c
@@ -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. */
diff --git a/xen/arch/x86/x86_emulate.c b/xen/arch/x86/x86_emulate.c
index 886bd87..60f73d0 100644
--- a/xen/arch/x86/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate.c
@@ -156,6 +156,14 @@ int x86emul_write_dr(unsigned int reg, unsigned long val,
}
}
+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
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h
index 0397c1d..73201b9 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.h
+++ b/xen/arch/x86/x86_emulate/x86_emulate.h
@@ -724,6 +724,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
diff --git a/xen/include/asm-x86/hvm/emulate.h b/xen/include/asm-x86/hvm/emulate.h
index 26a01e8..b39a1a0 100644
--- a/xen/include/asm-x86/hvm/emulate.h
+++ b/xen/include/asm-x86/hvm/emulate.h
@@ -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);
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index 6e45651..cda73e2 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -528,8 +528,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);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-05 11:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 11:21 [PATCH 0/6] x86/emul: Use struct cpuid_policy for feature checks Andrew Cooper
2018-11-05 11:21 ` [PATCH 1/6] tools: Move the typesafe min/max helpers into xen-tools/libs.h Andrew Cooper
2018-11-05 11:23 ` Wei Liu
2018-11-05 11:21 ` [PATCH 2/6] libx86: Split x86_cpuid_policy_fill_native() out of calculate_raw_policy() Andrew Cooper
2018-11-06 13:44 ` Jan Beulich
2018-11-09 16:24 ` Andrew Cooper
2018-11-12 8:13 ` Jan Beulich
2018-11-06 16:31 ` Roger Pau Monné
2018-11-09 16:26 ` Andrew Cooper
2018-11-05 11:21 ` [PATCH 3/6] tools/x86emul: Use struct cpuid_policy in the userspace test harnesses Andrew Cooper
2018-11-06 15:25 ` Jan Beulich
2018-11-05 11:21 ` [PATCH 4/6] x86/emul: Pass a full cpuid_policy into x86_emulate() Andrew Cooper
2018-11-06 15:28 ` Jan Beulich
2018-11-05 11:21 ` [PATCH 5/6] x86/emul: Don't use the ->cpuid() hook for feature checks Andrew Cooper
2018-11-06 15:32 ` Jan Beulich
2018-11-05 11:21 ` Andrew Cooper [this message]
2018-11-06 15:38 ` [PATCH 6/6] x86/emul: dedup hvmemul_cpuid() and pv_emul_cpuid() Jan Beulich
2018-11-06 15:52 ` Andrew Cooper
2018-11-06 16:16 ` Jan Beulich
2018-11-09 17:16 ` Andrew Cooper
2018-11-12 8:17 ` Jan Beulich
2018-11-14 0:20 ` Woods, Brian
2018-11-14 7:47 ` Jan Beulich
2018-11-15 14:23 ` Andrew Cooper
2018-11-15 15:09 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541416867-30253-7-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).