From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 5/6] x86/time: Move cpuid_time_leaf() handling into cpuid_hypervisor_leaves()
Date: Wed, 16 Nov 2016 12:31:49 +0000 [thread overview]
Message-ID: <1479299510-700-6-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.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/time.c | 36 ------------------------------------
xen/arch/x86/traps.c | 40 +++++++++++++++++++++++++++++++++++++---
xen/include/asm-x86/time.h | 3 ---
3 files changed, 37 insertions(+), 42 deletions(-)
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index dda89d8..79707df 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1938,42 +1938,6 @@ int host_tsc_is_safe(void)
return boot_cpu_has(X86_FEATURE_TSC_RELIABLE);
}
-void cpuid_time_leaf(uint32_t sub_idx, uint32_t *eax, uint32_t *ebx,
- uint32_t *ecx, uint32_t *edx)
-{
- struct domain *d = current->domain;
- uint64_t offset;
-
- switch ( sub_idx )
- {
- case 0: /* features */
- *eax = (!!d->arch.vtsc << 0) |
- (!!host_tsc_is_safe() << 1) |
- (!!boot_cpu_has(X86_FEATURE_RDTSCP) << 2);
- *ebx = d->arch.tsc_mode;
- *ecx = d->arch.tsc_khz;
- *edx = d->arch.incarnation;
- break;
- case 1: /* scale and offset */
- if ( !d->arch.vtsc )
- offset = d->arch.vtsc_offset;
- else
- /* offset already applied to value returned by virtual rdtscp */
- offset = 0;
- *eax = (uint32_t)offset;
- *ebx = (uint32_t)(offset >> 32);
- *ecx = d->arch.vtsc_to_ns.mul_frac;
- *edx = (s8)d->arch.vtsc_to_ns.shift;
- break;
- case 2: /* physical cpu_khz */
- *eax = cpu_khz;
- *ebx = *ecx = *edx = 0;
- break;
- default:
- *eax = *ebx = *ecx = *edx = 0;
- }
-}
-
/*
* called to collect tsc-related data only for save file or live
* migrate; called after last rdtsc is done on this incarnation
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index cdce72d..9be9fe3 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -922,9 +922,43 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
*ecx |= XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD;
break;
- case 3:
- *eax = *ebx = *ecx = *edx = 0;
- cpuid_time_leaf( sub_idx, eax, ebx, ecx, edx );
+ case 3: /* Time leaf. */
+ switch ( sub_idx )
+ {
+ case 0: /* features */
+ *eax = ((!!currd->arch.vtsc << 0) |
+ (!!host_tsc_is_safe() << 1) |
+ (!!boot_cpu_has(X86_FEATURE_RDTSCP) << 2));
+ *ebx = currd->arch.tsc_mode;
+ *ecx = currd->arch.tsc_khz;
+ *edx = currd->arch.incarnation;
+ break;
+
+ case 1: /* scale and offset */
+ {
+ uint64_t offset;
+
+ if ( !currd->arch.vtsc )
+ offset = currd->arch.vtsc_offset;
+ else
+ /* offset already applied to value returned by virtual rdtscp */
+ offset = 0;
+ *eax = (uint32_t)offset;
+ *ebx = (uint32_t)(offset >> 32);
+ *ecx = currd->arch.vtsc_to_ns.mul_frac;
+ *edx = (s8)currd->arch.vtsc_to_ns.shift;
+ break;
+ }
+
+ case 2: /* physical cpu_khz */
+ *eax = cpu_khz;
+ *ebx = *ecx = *edx = 0;
+ break;
+
+ default:
+ *eax = *ebx = *ecx = *edx = 0;
+ break;
+ }
break;
case 4:
diff --git a/xen/include/asm-x86/time.h b/xen/include/asm-x86/time.h
index 6d704b4..ef989a6 100644
--- a/xen/include/asm-x86/time.h
+++ b/xen/include/asm-x86/time.h
@@ -71,9 +71,6 @@ void force_update_vcpu_system_time(struct vcpu *v);
bool clocksource_is_tsc(void);
int host_tsc_is_safe(void);
-void cpuid_time_leaf(uint32_t sub_idx, uint32_t *eax, uint32_t *ebx,
- uint32_t *ecx, uint32_t *edx);
-
u64 stime2tsc(s_time_t stime);
struct time_scale;
--
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 ` [PATCH 4/6] x86/hvm: Move hvm_funcs.cpuid_intercept() handling into hvm_cpuid() Andrew Cooper
2016-11-16 15:20 ` 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 ` Andrew Cooper [this message]
2016-11-16 15:47 ` [PATCH 5/6] x86/time: Move cpuid_time_leaf() handling into cpuid_hypervisor_leaves() 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-6-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.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).