[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/time: use public interface TSC mode definitions


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 6 Feb 2023 13:31:23 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ut/YifaKxztSMJt+03Xs/uH6xYHPVthbAnNTIuGGt2Q=; b=mFr1sWS55kwe6+Bvokn4xGsSlPDoTHRkrtEEWDp5ZkhdPyy72qWr5/OeCWbcTDd7yvhvIO4W+jDRuXtH0Ohlc2vs1+aHRura9wV9AwsYd/OOndeET2Olxgw+PL+Be3QoRQRMCVbyVUcGQy3/gY+vUuSpS190hfXxmwEth8PEISOSWhjphB/MYdWIG+U7gWw1OdjRfsL3DFoUiq38sT+lyHGP1NwXFRrgzMISx0vdqefZoDYB59gFPqaYZ4nSCBowApQbGZKQTozg0jW8r+n1yeRhzzzO6+eIBTAwbOF5Sh/w/8LjNDiPI0271VfV6ylXkWuYOyIMLuwKTa9co0uuVw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V8NayQFp5KFcDVU8DDhsazdfj1truTFvURGmoO1s7XzVuTZUrGS3Edq4Qf0Hq0+ztPtOBet8U7k187fH8drp1cSyivs7UIszpdIt0BtiDEiHav2GDka3wKFEptJnp3HY2WVQuV4pmqMmB+V0+r0avsHyS/WXIlcoSOcFS4GOISSlzD969xZas5oR0pLtlSMAsR20VNcM0xyim1tr69ScOQ8k+7OrQ51vij/Z24VPfbYsKXzRDfj7oske0+wcO2M0q87LDK7B4dxqET98VM6PDQTgwR4RBrbS+8x1k7LpKMDIgp5Bju6INYY2/Mi62p+vqrj4qHJa2Yd+hImk5usIOQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 06 Feb 2023 12:31:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Now that they're properly represented in the public interface, let's do
away with our private #define-s.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -36,6 +36,7 @@
 #include <xen/wait.h>
 #include <xen/guest_access.h>
 #include <xen/livepatch.h>
+#include <public/arch-x86/cpuid.h>
 #include <public/sysctl.h>
 #include <public/hvm/hvm_vcpu.h>
 #include <asm/regs.h>
@@ -844,7 +845,7 @@ int arch_domain_create(struct domain *d,
     else
         ASSERT_UNREACHABLE(); /* Not HVM and not PV? */
 
-    if ( (rc = tsc_set_info(d, TSC_MODE_DEFAULT, 0, 0, 0)) != 0 )
+    if ( (rc = tsc_set_info(d, XEN_CPUID_TSC_MODE_DEFAULT, 0, 0, 0)) != 0 )
     {
         ASSERT_UNREACHABLE();
         goto fail;
--- a/xen/arch/x86/include/asm/time.h
+++ b/xen/arch/x86/include/asm/time.h
@@ -4,20 +4,6 @@
 
 #include <asm/msr.h>
 
-/*
- *  PV TSC emulation modes:
- *    0 = guest rdtsc/p executed natively when monotonicity can be guaranteed
- *         and emulated otherwise (with frequency scaled if necessary)
- *    1 = guest rdtsc/p always emulated at 1GHz (kernel and user)
- *    2 = guest rdtsc always executed natively (no monotonicity/frequency
- *         guarantees); guest rdtscp emulated at native frequency if
- *         unsupported by h/w, else executed natively
- *    3 = Removed, was PVRDTSCP.
- */
-#define TSC_MODE_DEFAULT          0
-#define TSC_MODE_ALWAYS_EMULATE   1
-#define TSC_MODE_NEVER_EMULATE    2
-
 typedef u64 cycles_t;
 
 extern bool disable_tsc_sync;
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -2545,13 +2545,13 @@ void tsc_get_info(struct domain *d, uint
     {
         uint64_t tsc;
 
-    case TSC_MODE_NEVER_EMULATE:
+    case XEN_CPUID_TSC_MODE_NEVER_EMULATE:
         *elapsed_nsec = *gtsc_khz = 0;
         break;
-    case TSC_MODE_DEFAULT:
+    case XEN_CPUID_TSC_MODE_DEFAULT:
         if ( d->arch.vtsc )
         {
-    case TSC_MODE_ALWAYS_EMULATE:
+    case XEN_CPUID_TSC_MODE_ALWAYS_EMULATE:
             *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
             *gtsc_khz = d->arch.tsc_khz;
             break;
@@ -2588,8 +2588,8 @@ int tsc_set_info(struct domain *d,
 
     switch ( tsc_mode )
     {
-    case TSC_MODE_DEFAULT:
-    case TSC_MODE_ALWAYS_EMULATE:
+    case XEN_CPUID_TSC_MODE_DEFAULT:
+    case XEN_CPUID_TSC_MODE_ALWAYS_EMULATE:
         d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
         d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
         set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000UL);
@@ -2601,12 +2601,12 @@ int tsc_set_info(struct domain *d,
          * When a guest is created, gtsc_khz is passed in as zero, making
          * d->arch.tsc_khz == cpu_khz. Thus no need to check incarnation.
          */
-        if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
+        if ( tsc_mode == XEN_CPUID_TSC_MODE_DEFAULT && host_tsc_is_safe() &&
              (d->arch.tsc_khz == cpu_khz ||
               (is_hvm_domain(d) &&
                hvm_get_tsc_scaling_ratio(d->arch.tsc_khz))) )
         {
-    case TSC_MODE_NEVER_EMULATE:
+    case XEN_CPUID_TSC_MODE_NEVER_EMULATE:
             d->arch.vtsc = 0;
             break;
         }
@@ -2674,7 +2674,8 @@ static void cf_check dump_softtsc(unsign
 
     for_each_domain ( d )
     {
-        if ( is_hardware_domain(d) && d->arch.tsc_mode == TSC_MODE_DEFAULT )
+        if ( is_hardware_domain(d) &&
+             d->arch.tsc_mode == XEN_CPUID_TSC_MODE_DEFAULT )
             continue;
         printk("dom%u%s: mode=%d",d->domain_id,
                 is_hvm_domain(d) ? "(hvm)" : "", d->arch.tsc_mode);



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.