From: Haozhong Zhang Subject: [PATCH v2 08/14] x86/hvm: Collect information of TSC scaling ratio Date: Mon, 7 Dec 2015 04:58:43 +0800 Message-ID: <1449435529-12989-9-git-send-email-haozhong.zhang@intel.com> References: <1449435529-12989-1-git-send-email-haozhong.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1449435529-12989-1-git-send-email-haozhong.zhang@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Haozhong Zhang , Kevin Tian , Keir Fraser , Jan Beulich , Jun Nakajima , Andrew Cooper , Aravind Gopalakrishnan , Suravee Suthikulpanit , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org Both VMX TSC scaling and SVM TSC ratio use the 64-bit TSC scaling ratio, but the number of fractional bits of the ratio is different between VMX and SVM. This patch adds the architecture code to collect the number of fractional bits and other related information into fields of struct hvm_function_table so that they can be used in the common code. Signed-off-by: Haozhong Zhang --- xen/arch/x86/hvm/svm/svm.c | 7 +++++++ xen/include/asm-x86/hvm/hvm.h | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 3d22dfa..9f741d0 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1451,6 +1451,9 @@ const struct hvm_function_table * __init start_svm(void) if ( !cpu_has_svm_nrips ) clear_bit(SVM_FEATURE_DECODEASSISTS, &svm_feature_flags); + if ( cpu_has_tsc_ratio ) + svm_function_table.tsc_scaling_supported = 1; + #define P(p,s) if ( p ) { printk(" - %s\n", s); printed = 1; } P(cpu_has_svm_npt, "Nested Page Tables (NPT)"); P(cpu_has_svm_lbrv, "Last Branch Record (LBR) Virtualisation"); @@ -2271,6 +2274,10 @@ static struct hvm_function_table __initdata svm_function_table = { .nhvm_hap_walk_L1_p2m = nsvm_hap_walk_L1_p2m, .scale_tsc = svm_scale_tsc, + + .default_tsc_scaling_ratio = DEFAULT_TSC_RATIO, + .max_tsc_scaling_ratio = ~TSC_RATIO_RSVD_BITS, + .tsc_scaling_ratio_frac_bits = 32, }; void svm_vmexit_handler(struct cpu_user_regs *regs) diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index aba63ab..8b10a67 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -100,6 +100,18 @@ struct hvm_function_table { unsigned int hap_capabilities; /* + * Parameters of hardware-assisted TSC scaling. + */ + /* is TSC scaling supported? */ + bool_t tsc_scaling_supported; + /* number of bits of the fractional part of TSC scaling ratio */ + uint8_t tsc_scaling_ratio_frac_bits; + /* default TSC scaling ratio (no scaling) */ + uint64_t default_tsc_scaling_ratio; + /* maxmimum-allowed TSC scaling ratio */ + uint64_t max_tsc_scaling_ratio; + + /* * Initialise/destroy HVM domain/vcpu resources */ int (*domain_initialise)(struct domain *d); -- 2.6.3