]> xenbits.xensource.com Git - xen.git/commitdiff
x86/time: use public interface TSC mode definitions
authorJan Beulich <jbeulich@suse.com>
Mon, 6 Feb 2023 15:04:43 +0000 (16:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 6 Feb 2023 15:04:43 +0000 (16:04 +0100)
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@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/domain.c
xen/arch/x86/include/asm/time.h
xen/arch/x86/time.c

index d7a8237f01ab3ad60e0eede774e657a6f3e4dff7..a3c88cd729b9bba81524b5c75ed91d5939c981ea 100644 (file)
@@ -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;
index dc2e636916e6dfb1395122af2765be1b1d1b2eea..0d7989a1fe4a20e4ed699f9c367905cbbb5f028b 100644 (file)
@@ -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;
index 7bee4f784f1793a2fae755bde308a532a08f8f59..782b11c8a97ba5016dc5d464369f560324725542 100644 (file)
@@ -2545,13 +2545,13 @@ void tsc_get_info(struct domain *d, uint32_t *tsc_mode,
     {
         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(unsigned char key)
 
     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);