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

[PATCH v4] xen/x86: public: add TSC defines for cpuid leaf 4


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx>
  • Date: Mon, 30 Jan 2023 09:44:59 -0800
  • Arc-authentication-results: i=1; rspamd-5fb8f68d88-c76m6; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@xxxxxxxxxxxxxxxxxx
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1675100703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lzWbg7pH2Qdroe4uerh/jh+EVVJsKlEREiv+gIZXp/4=; b=E3tMINDvnoMbohYwJ2477XupHt22eo5PKXuXrCR80DCEOx6O3LtSpoKqYpU4NiSr/RvYAt r4cpur82sRhkJdBkIOFC/7Gi66WferqRwBCK3SM9C+Q8oICzA5CGBzIPGCgiMDnUeYAJbE V6mw+ksIgkXsy62qdb0SGeecvTs1vGQ7eyvAQyddDtewVg4mr+ChgDGZhn91JfEyBqrNCh jx7qO+h4ZCffvFpNK1LU3NCpDMNZhUlwfkgwaFgOa4TrU65P+nTr1yUEgdQAaKYTBzbroz 7YetaIDnEiEr9W0pxX/bLIvHwQ2mvbgfn/tKvqfZtdgjLFoRi9YmRb79+6T80Q==
  • Arc-seal: i=1; s=arc-2022; d=mailchannels.net; t=1675100703; a=rsa-sha256; cv=none; b=TrsAuql7YYd5WwaELsMFJyT20+05x1Vs+1TTMg+hWteoVNhAWBrrcFXxmL+JcXKac5FgI2 KpfLmxPZyGt1r9SovVmK6TVncc8fcwngR93Jq5g7oWxCaT0jgVUQ+lAiJlzK2OvcO116ui fWJ7SFGTd5I7ql4Xp1QLT+MGE4hNSHfcubF7ibOmWo5JMUXazub/w2BByBFTGvsulJS6mX Yp9VpKbVtrMf1Ip/aW/vPk/JWJLxkzvRQOJIOD2YVTMOm9O+6XvP6QUo0fwLK49RtRbUw4 TXp7h5xl/yX+WIoP+S/l0dDDmSNT/OZ8Hr0SFR+IT+bFp3zjnbU4Kp0DndtQUg==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, David Reaver <me@xxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 30 Jan 2023 17:45:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Cpuid leaf 4 contains information about how the state of the tsc, its
mode, and some additional information.  A commit that is queued for
linux would like to use this to determine whether the tsc mode has been
set to 'no emulation' in order to make some decisions about which
clocksource is more reliable.

Expose this information in the public API headers so that they can
subsequently be imported into linux and used there.

Link: 
https://lore.kernel.org/xen-devel/eda8d9f2-3013-1b68-0df8-64d7f13ee35e@xxxxxxxx/
Link: 
https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@xxxxxxxxxx/
Signed-off-by: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx>
---
v4
  - Rename TSC_MODE_NEVER_EMULATE_TSC_AUX to TSC_MODE_PVRDTSCP (feedback from
    Jan Buelich)
v3
  - Additional formating cleanups (feedback from Jan Buelich)
  - Ensure that TSC_MODE #defines match the names of those in time.h (feedback
    from Jan Buelich)
v2:
  - Fix whitespace between comment and #defines (feedback from Jan Beulich)
  - Add tsc mode 3: no emulate TSC_AUX (feedback from Jan Beulich)
---
 xen/include/public/arch-x86/cpuid.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/xen/include/public/arch-x86/cpuid.h 
b/xen/include/public/arch-x86/cpuid.h
index 7ecd16ae05..9d02f86564 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -72,6 +72,15 @@
  * Sub-leaf 2: EAX: host tsc frequency in kHz
  */
 
+#define XEN_CPUID_TSC_EMULATED               (1u << 0)
+#define XEN_CPUID_HOST_TSC_RELIABLE          (1u << 1)
+#define XEN_CPUID_RDTSCP_INSTR_AVAIL         (1u << 2)
+
+#define XEN_CPUID_TSC_MODE_DEFAULT               (0)
+#define XEN_CPUID_TSC_MODE_ALWAYS_EMULATE        (1u)
+#define XEN_CPUID_TSC_MODE_NEVER_EMULATE         (2u)
+#define XEN_CPUID_TSC_MODE_PVRDTSCP              (3u)
+
 /*
  * Leaf 5 (0x40000x04)
  * HVM-specific features
-- 
2.25.1




 


Rackspace

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