From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Kevin Tian <kevin.tian@intel.com>,
Jan Beulich <JBeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: [PATCH 4/6] x86/hvm: Move hvm_funcs.cpuid_intercept() handling into hvm_cpuid()
Date: Wed, 16 Nov 2016 12:31:48 +0000 [thread overview]
Message-ID: <1479299510-700-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1479299510-700-1-git-send-email-andrew.cooper3@citrix.com>
This reduces the net complexity of CPUID handling by having all adjustments in
at the same place. Remove the now-unused hvm_funcs.cpuid_intercept
infrastructure.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
xen/arch/x86/hvm/emulate.c | 2 +-
xen/arch/x86/hvm/hvm.c | 21 +++++++++++++++------
xen/arch/x86/hvm/svm/svm.c | 39 ++-------------------------------------
xen/arch/x86/hvm/vmx/vmx.c | 31 ++-----------------------------
xen/include/asm-x86/hvm/hvm.h | 3 ---
5 files changed, 20 insertions(+), 76 deletions(-)
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index e9b8f8c..540458c 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -1558,7 +1558,7 @@ int hvmemul_cpuid(
hvm_check_cpuid_faulting(current) )
return X86EMUL_EXCEPTION;
- hvm_funcs.cpuid_intercept(eax, ebx, ecx, edx);
+ hvm_cpuid(*eax, eax, ebx, ecx, edx);
return X86EMUL_OKAY;
}
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index afd14c4..862ab76 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -906,12 +906,7 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
ASSERT(v->domain == current->domain);
hvm_cpuid(0x80000000, &level, NULL, NULL, NULL);
if ( (level >> 16) == 0x8000 && level > 0x80000000 )
- {
- unsigned int dummy;
-
- level = 0x80000001;
- hvm_funcs.cpuid_intercept(&level, &dummy, &ext1_ecx, &ext1_edx);
- }
+ hvm_cpuid(0x80000001, NULL, NULL, &ext1_ecx, &ext1_edx);
}
else
{
@@ -3676,6 +3671,12 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
if ( !(hvm_pae_enabled(v) || hvm_long_mode_enabled(v)) )
*edx &= ~cpufeat_mask(X86_FEATURE_PSE36);
}
+
+ /* SYSCALL is hidden outside of long mode on Intel. */
+ if ( d->arch.x86_vendor == X86_VENDOR_INTEL &&
+ !hvm_long_mode_enabled(v))
+ *edx &= ~cpufeat_mask(X86_FEATURE_SYSCALL);
+
break;
case 0x80000007:
@@ -3700,6 +3701,14 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
*ebx &= hvm_featureset[FEATURESET_e8b];
break;
+
+ case 0x8000001c:
+ if ( !(v->arch.xcr0 & XSTATE_LWP) )
+ *eax = 0;
+ else if ( cpu_has_svm && cpu_has_lwp )
+ /* Turn on available bit and other features specified in lwp_cfg. */
+ *eax = (*edx & v->arch.hvm_svm.guest_lwp_cfg) | 1;
+ break;
}
}
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index c9dbbea..0668717 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1562,41 +1562,6 @@ static void svm_fpu_dirty_intercept(void)
vmcb_set_cr0(vmcb, vmcb_get_cr0(vmcb) & ~X86_CR0_TS);
}
-static void svm_cpuid_intercept(
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- unsigned int input = *eax;
- struct vcpu *v = current;
-
- hvm_cpuid(input, eax, ebx, ecx, edx);
-
- switch (input) {
- case 0x8000001c:
- {
- /* LWP capability CPUID */
- uint64_t lwp_cfg = v->arch.hvm_svm.guest_lwp_cfg;
-
- if ( cpu_has_lwp )
- {
- if ( !(v->arch.xcr0 & XSTATE_LWP) )
- {
- *eax = 0x0;
- break;
- }
-
- /* turn on available bit and other features specified in lwp_cfg */
- *eax = (*edx & lwp_cfg) | 0x00000001;
- }
- break;
- }
- default:
- break;
- }
-
- HVMTRACE_5D (CPUID, input, *eax, *ebx, *ecx, *edx);
-}
-
static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
{
unsigned int eax, ebx, ecx, edx, inst_len;
@@ -1609,7 +1574,8 @@ static void svm_vmexit_do_cpuid(struct cpu_user_regs *regs)
ecx = regs->ecx;
edx = regs->edx;
- svm_cpuid_intercept(&eax, &ebx, &ecx, &edx);
+ hvm_cpuid(regs->_eax, &eax, &ebx, &ecx, &edx);
+ HVMTRACE_5D(CPUID, regs->_eax, eax, ebx, ecx, edx);
regs->eax = eax;
regs->ebx = ebx;
@@ -2253,7 +2219,6 @@ static struct hvm_function_table __initdata svm_function_table = {
.init_hypercall_page = svm_init_hypercall_page,
.event_pending = svm_event_pending,
.invlpg = svm_invlpg,
- .cpuid_intercept = svm_cpuid_intercept,
.wbinvd_intercept = svm_wbinvd_intercept,
.fpu_dirty_intercept = svm_fpu_dirty_intercept,
.msr_read_intercept = svm_msr_read_intercept,
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 2238d74..5a73076 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -73,9 +73,6 @@ static void vmx_install_vlapic_mapping(struct vcpu *v);
static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr);
static void vmx_update_guest_efer(struct vcpu *v);
static void vmx_update_guest_vendor(struct vcpu *v);
-static void vmx_cpuid_intercept(
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx);
static void vmx_wbinvd_intercept(void);
static void vmx_fpu_dirty_intercept(void);
static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content);
@@ -2166,7 +2163,6 @@ static struct hvm_function_table __initdata vmx_function_table = {
.invlpg = vmx_invlpg,
.cpu_up = vmx_cpu_up,
.cpu_down = vmx_cpu_down,
- .cpuid_intercept = vmx_cpuid_intercept,
.wbinvd_intercept = vmx_wbinvd_intercept,
.fpu_dirty_intercept = vmx_fpu_dirty_intercept,
.msr_read_intercept = vmx_msr_read_intercept,
@@ -2402,30 +2398,6 @@ static void vmx_fpu_dirty_intercept(void)
}
}
-static void vmx_cpuid_intercept(
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx)
-{
- unsigned int input = *eax;
- struct vcpu *v = current;
-
- hvm_cpuid(input, eax, ebx, ecx, edx);
-
- switch ( input )
- {
- case 0x80000001:
- /* SYSCALL is visible iff running in long mode. */
- if ( hvm_long_mode_enabled(v) )
- *edx |= cpufeat_mask(X86_FEATURE_SYSCALL);
- else
- *edx &= ~(cpufeat_mask(X86_FEATURE_SYSCALL));
-
- break;
- }
-
- HVMTRACE_5D (CPUID, input, *eax, *ebx, *ecx, *edx);
-}
-
static int vmx_do_cpuid(struct cpu_user_regs *regs)
{
unsigned int eax, ebx, ecx, edx;
@@ -2445,7 +2417,8 @@ static int vmx_do_cpuid(struct cpu_user_regs *regs)
leaf = regs->eax;
subleaf = regs->ecx;
- vmx_cpuid_intercept(&eax, &ebx, &ecx, &edx);
+ hvm_cpuid(leaf, &eax, &ebx, &ecx, &edx);
+ HVMTRACE_5D(CPUID, leaf, eax, ebx, ecx, edx);
regs->eax = eax;
regs->ebx = ebx;
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 7e7462e..8e366c0 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -169,9 +169,6 @@ struct hvm_function_table {
unsigned int (*get_insn_bytes)(struct vcpu *v, uint8_t *buf);
/* Instruction intercepts: non-void return values are X86EMUL codes. */
- void (*cpuid_intercept)(
- unsigned int *eax, unsigned int *ebx,
- unsigned int *ecx, unsigned int *edx);
void (*wbinvd_intercept)(void);
void (*fpu_dirty_intercept)(void);
int (*msr_read_intercept)(unsigned int msr, uint64_t *msr_content);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-16 12:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 12:31 [PATCH for-4.9 0/6] Introductory cleanup for CPUID phase 2 work Andrew Cooper
2016-11-16 12:31 ` [PATCH 1/6] xen/x86: Add a helper to calculate family/model/stepping information Andrew Cooper
2016-11-16 12:49 ` Jan Beulich
2016-11-16 12:50 ` Andrew Cooper
2016-11-16 12:31 ` [PATCH 2/6] x86/vpmu: Move vpmu_do_cpuid() handling into {pv, hvm}_cpuid() Andrew Cooper
2016-11-16 12:53 ` Jan Beulich
2016-11-16 13:01 ` Andrew Cooper
2016-11-16 13:34 ` Jan Beulich
2016-11-17 5:21 ` Tian, Kevin
2016-11-17 10:52 ` Jan Beulich
2016-11-16 12:31 ` [PATCH 3/6] x86/vpmu: Remove core2_no_vpmu_ops Andrew Cooper
2016-11-16 13:09 ` Jan Beulich
2016-11-16 16:27 ` Boris Ostrovsky
2016-11-16 17:04 ` Andrew Cooper
2016-11-16 17:09 ` Boris Ostrovsky
2016-11-16 17:08 ` Andrew Cooper
2016-11-17 5:29 ` Tian, Kevin
2016-11-16 12:31 ` Andrew Cooper [this message]
2016-11-16 15:20 ` [PATCH 4/6] x86/hvm: Move hvm_funcs.cpuid_intercept() handling into hvm_cpuid() Jan Beulich
2016-11-16 17:07 ` Andrew Cooper
2016-11-17 10:54 ` Jan Beulich
2016-11-16 16:40 ` Boris Ostrovsky
2016-11-16 17:10 ` Andrew Cooper
2016-11-16 17:34 ` Boris Ostrovsky
2016-11-16 17:34 ` Andrew Cooper
2016-11-16 17:45 ` Boris Ostrovsky
2016-11-17 5:41 ` Tian, Kevin
2016-11-16 12:31 ` [PATCH 5/6] x86/time: Move cpuid_time_leaf() handling into cpuid_hypervisor_leaves() Andrew Cooper
2016-11-16 15:47 ` Jan Beulich
2016-11-16 12:31 ` [PATCH 6/6] x86/hvm: Move hvm_hypervisor_cpuid_leaf() " Andrew Cooper
2016-11-16 15:53 ` Jan Beulich
2016-11-16 17:11 ` Andrew Cooper
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=1479299510-700-5-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=suravee.suthikulpanit@amd.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).