All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4
@ 2023-01-24 22:35 Krister Johansen
  2023-01-25  6:57 ` Jan Beulich
  2023-01-25 18:45 ` [PATCH v2] " Krister Johansen
  0 siblings, 2 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-24 22:35 UTC (permalink / raw)
  To: Jan Beulich, Andrew Cooper, Roger Pau Monné, Wei Liu
  Cc: xen-devel, Juergen Gross, Boris Ostrovsky, David Reaver

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@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
 xen/include/public/arch-x86/cpuid.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index 7ecd16ae05..97dc970417 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -71,6 +71,12 @@
  *             EDX: shift amount for tsc->ns conversion
  * 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_EMULATE   (1u)
+#define XEN_CPUID_TSC_MODE_NOEMULATE (2u)
 
 /*
  * Leaf 5 (0x40000x04)
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-24 22:35 [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4 Krister Johansen
@ 2023-01-25  6:57 ` Jan Beulich
  2023-01-25 18:31   ` Krister Johansen
  2023-01-25 18:45 ` [PATCH v2] " Krister Johansen
  1 sibling, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2023-01-25  6:57 UTC (permalink / raw)
  To: Krister Johansen
  Cc: xen-devel, Juergen Gross, Boris Ostrovsky, David Reaver,
	Andrew Cooper, Roger Pau Monné,
	Wei Liu

On 24.01.2023 23:35, Krister Johansen wrote:
> --- a/xen/include/public/arch-x86/cpuid.h
> +++ b/xen/include/public/arch-x86/cpuid.h
> @@ -71,6 +71,12 @@
>   *             EDX: shift amount for tsc->ns conversion
>   * 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_EMULATE   (1u)
> +#define XEN_CPUID_TSC_MODE_NOEMULATE (2u)

This could do with a blank line between the two groups. You're also
missing mode 3. Plus, as a formal remark, please follow patch
submission rules: They are sent To: the list, with maintainers on
Cc:.

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-25  6:57 ` Jan Beulich
@ 2023-01-25 18:31   ` Krister Johansen
  0 siblings, 0 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-25 18:31 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Juergen Gross, Boris Ostrovsky, David Reaver,
	Andrew Cooper, Roger Pau Monné,
	Wei Liu

On Wed, Jan 25, 2023 at 07:57:16AM +0100, Jan Beulich wrote:
> On 24.01.2023 23:35, Krister Johansen wrote:
> > --- a/xen/include/public/arch-x86/cpuid.h
> > +++ b/xen/include/public/arch-x86/cpuid.h
> > @@ -71,6 +71,12 @@
> >   *             EDX: shift amount for tsc->ns conversion
> >   * 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_EMULATE   (1u)
> > +#define XEN_CPUID_TSC_MODE_NOEMULATE (2u)
> 
> This could do with a blank line between the two groups. You're also
> missing mode 3. Plus, as a formal remark, please follow patch
> submission rules: They are sent To: the list, with maintainers on
> Cc:.

Thanks for the feedback.  I'll make those changes.

My apologies for the breach etiquette, and thank you for the reminder
about the norms.  I'll correct the To: and CC: headers on the next go
around.

-K


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-24 22:35 [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4 Krister Johansen
  2023-01-25  6:57 ` Jan Beulich
@ 2023-01-25 18:45 ` Krister Johansen
  2023-01-26  8:57   ` Jan Beulich
  2023-01-26  9:57   ` Jan Beulich
  1 sibling, 2 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-25 18:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver

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@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
v2.1:
  - Correct In-Reply-To header for proper threading
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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index 7ecd16ae05..090f7f0034 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -72,6 +72,14 @@
  * 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_EMULATE           (1u)
+#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
+#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
+
 /*
  * Leaf 5 (0x40000x04)
  * HVM-specific features
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-25 18:45 ` [PATCH v2] " Krister Johansen
@ 2023-01-26  8:57   ` Jan Beulich
  2023-01-26 17:54     ` Krister Johansen
  2023-01-26  9:57   ` Jan Beulich
  1 sibling, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2023-01-26  8:57 UTC (permalink / raw)
  To: Krister Johansen
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On 25.01.2023 19:45, Krister Johansen wrote:
> v2:
>   - Fix whitespace between comment and #defines (feedback from Jan Beulich)

Hmm, ...

> --- a/xen/include/public/arch-x86/cpuid.h
> +++ b/xen/include/public/arch-x86/cpuid.h
> @@ -72,6 +72,14 @@
>   * 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_EMULATE           (1u)
> +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
> +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)

... while I'm fine with the leading blank line, what my earlier comment was
about really are the two separate blocks of #define-s (the flag bits and the
modes). I'll take care of this while committing; with the adjustment

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-25 18:45 ` [PATCH v2] " Krister Johansen
  2023-01-26  8:57   ` Jan Beulich
@ 2023-01-26  9:57   ` Jan Beulich
  2023-01-26 18:02     ` Krister Johansen
  1 sibling, 1 reply; 16+ messages in thread
From: Jan Beulich @ 2023-01-26  9:57 UTC (permalink / raw)
  To: Krister Johansen
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On 25.01.2023 19:45, Krister Johansen wrote:
> --- a/xen/include/public/arch-x86/cpuid.h
> +++ b/xen/include/public/arch-x86/cpuid.h
> @@ -72,6 +72,14 @@
>   * 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_EMULATE           (1u)
> +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
> +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)

Actually I think we'd better stick to the names found in asm/time.h
(and then replace their uses, dropping the #define-s there). If you
agree, I'd be happy to make the adjustment while committing.

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-26  8:57   ` Jan Beulich
@ 2023-01-26 17:54     ` Krister Johansen
  0 siblings, 0 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-26 17:54 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On Thu, Jan 26, 2023 at 09:57:43AM +0100, Jan Beulich wrote:
> On 25.01.2023 19:45, Krister Johansen wrote:
> > v2:
> >   - Fix whitespace between comment and #defines (feedback from Jan Beulich)
> 
> Hmm, ...
> 
> > --- a/xen/include/public/arch-x86/cpuid.h
> > +++ b/xen/include/public/arch-x86/cpuid.h
> > @@ -72,6 +72,14 @@
> >   * 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_EMULATE           (1u)
> > +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
> > +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
> 
> ... while I'm fine with the leading blank line, what my earlier comment was
> about really are the two separate blocks of #define-s (the flag bits and the
> modes). I'll take care of this while committing; with the adjustment
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Sorry I miunderstood, and thanks for being willing to fix this up
while committing.

-K


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-26  9:57   ` Jan Beulich
@ 2023-01-26 18:02     ` Krister Johansen
  2023-01-27  7:16       ` Jan Beulich
  0 siblings, 1 reply; 16+ messages in thread
From: Krister Johansen @ 2023-01-26 18:02 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Krister Johansen, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On Thu, Jan 26, 2023 at 10:57:01AM +0100, Jan Beulich wrote:
> On 25.01.2023 19:45, Krister Johansen wrote:
> > --- a/xen/include/public/arch-x86/cpuid.h
> > +++ b/xen/include/public/arch-x86/cpuid.h
> > @@ -72,6 +72,14 @@
> >   * 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_EMULATE           (1u)
> > +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
> > +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
> 
> Actually I think we'd better stick to the names found in asm/time.h
> (and then replace their uses, dropping the #define-s there). If you
> agree, I'd be happy to make the adjustment while committing.

Just to confirm, this would be moving these:

   #define TSC_MODE_DEFAULT          0
   #define TSC_MODE_ALWAYS_EMULATE   1
   #define TSC_MODE_NEVER_EMULATE    2
   
To cpuid.h?  I'm generally fine with this.  I don't see anything in
Linux that's using these names.  The only question I have is whether
we'd still want to prefix the names with XEN so that if they're pulled
in to Linux it's clear that the define is Xen specific?  E.g. something
like this perhaps?

   #define XEN_TSC_MODE_DEFAULT          0
   #define XEN_TSC_MODE_ALWAYS_EMULATE   1
   #define XEN_TSC_MODE_NEVER_EMULATE    2

That does increase the number of files we'd need to touch to make the
change, though. (And the other defines in that file all start with
XEN_CPUID).

Though, if you mean doing it this way:

   #define XEN_CPUID_TSC_MODE_DEFAULT          0
   #define XEN_CPUID_TSC_MODE_ALWAYS_EMULATE   1
   #define XEN_CPUID_TSC_MODE_NEVER_EMULATE    2
 
then no objection to that at all.  Apologies for overlooking the naming
overlap when I put this together the first time.

-K


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-26 18:02     ` Krister Johansen
@ 2023-01-27  7:16       ` Jan Beulich
  2023-01-27 18:37         ` Krister Johansen
  2023-01-27 18:51         ` [PATCH v3] " Krister Johansen
  0 siblings, 2 replies; 16+ messages in thread
From: Jan Beulich @ 2023-01-27  7:16 UTC (permalink / raw)
  To: Krister Johansen
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On 26.01.2023 19:02, Krister Johansen wrote:
> On Thu, Jan 26, 2023 at 10:57:01AM +0100, Jan Beulich wrote:
>> On 25.01.2023 19:45, Krister Johansen wrote:
>>> --- a/xen/include/public/arch-x86/cpuid.h
>>> +++ b/xen/include/public/arch-x86/cpuid.h
>>> @@ -72,6 +72,14 @@
>>>   * 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_EMULATE           (1u)
>>> +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
>>> +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
>>
>> Actually I think we'd better stick to the names found in asm/time.h
>> (and then replace their uses, dropping the #define-s there). If you
>> agree, I'd be happy to make the adjustment while committing.
> 
> Just to confirm, this would be moving these:
> 
>    #define TSC_MODE_DEFAULT          0
>    #define TSC_MODE_ALWAYS_EMULATE   1
>    #define TSC_MODE_NEVER_EMULATE    2
>    
> To cpuid.h?  I'm generally fine with this.  I don't see anything in
> Linux that's using these names.  The only question I have is whether
> we'd still want to prefix the names with XEN so that if they're pulled
> in to Linux it's clear that the define is Xen specific?  E.g. something
> like this perhaps?
> 
>    #define XEN_TSC_MODE_DEFAULT          0
>    #define XEN_TSC_MODE_ALWAYS_EMULATE   1
>    #define XEN_TSC_MODE_NEVER_EMULATE    2
> 
> That does increase the number of files we'd need to touch to make the
> change, though. (And the other defines in that file all start with
> XEN_CPUID).
> 
> Though, if you mean doing it this way:
> 
>    #define XEN_CPUID_TSC_MODE_DEFAULT          0
>    #define XEN_CPUID_TSC_MODE_ALWAYS_EMULATE   1
>    #define XEN_CPUID_TSC_MODE_NEVER_EMULATE    2
>  
> then no objection to that at all.  Apologies for overlooking the naming
> overlap when I put this together the first time.

Yes, it's the last variant you list that I was after. And I'd be okay to
leave dropping the so far private constants to a separate follow-on patch.

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-27  7:16       ` Jan Beulich
@ 2023-01-27 18:37         ` Krister Johansen
  2023-01-27 18:51         ` [PATCH v3] " Krister Johansen
  1 sibling, 0 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-27 18:37 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On Fri, Jan 27, 2023 at 08:16:18AM +0100, Jan Beulich wrote:
> On 26.01.2023 19:02, Krister Johansen wrote:
> > On Thu, Jan 26, 2023 at 10:57:01AM +0100, Jan Beulich wrote:
> >> On 25.01.2023 19:45, Krister Johansen wrote:
> >>> --- a/xen/include/public/arch-x86/cpuid.h
> >>> +++ b/xen/include/public/arch-x86/cpuid.h
> >>> @@ -72,6 +72,14 @@
> >>>   * 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_EMULATE           (1u)
> >>> +#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
> >>> +#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
> >>
> >> Actually I think we'd better stick to the names found in asm/time.h
> >> (and then replace their uses, dropping the #define-s there). If you
> >> agree, I'd be happy to make the adjustment while committing.
> > 
> > Just to confirm, this would be moving these:
> > 
> >    #define TSC_MODE_DEFAULT          0
> >    #define TSC_MODE_ALWAYS_EMULATE   1
> >    #define TSC_MODE_NEVER_EMULATE    2
> >    
> > To cpuid.h?  I'm generally fine with this.  I don't see anything in
> > Linux that's using these names.  The only question I have is whether
> > we'd still want to prefix the names with XEN so that if they're pulled
> > in to Linux it's clear that the define is Xen specific?  E.g. something
> > like this perhaps?
> > 
> >    #define XEN_TSC_MODE_DEFAULT          0
> >    #define XEN_TSC_MODE_ALWAYS_EMULATE   1
> >    #define XEN_TSC_MODE_NEVER_EMULATE    2
> > 
> > That does increase the number of files we'd need to touch to make the
> > change, though. (And the other defines in that file all start with
> > XEN_CPUID).
> > 
> > Though, if you mean doing it this way:
> > 
> >    #define XEN_CPUID_TSC_MODE_DEFAULT          0
> >    #define XEN_CPUID_TSC_MODE_ALWAYS_EMULATE   1
> >    #define XEN_CPUID_TSC_MODE_NEVER_EMULATE    2
> >  
> > then no objection to that at all.  Apologies for overlooking the naming
> > overlap when I put this together the first time.
> 
> Yes, it's the last variant you list that I was after. And I'd be okay to
> leave dropping the so far private constants to a separate follow-on patch.

Ok, thanks. I'll send you a v3 that makes these changes, unless you've
already fixed this up and committed the v2.  In that case, feel free to
disregard.

-K


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-27  7:16       ` Jan Beulich
  2023-01-27 18:37         ` Krister Johansen
@ 2023-01-27 18:51         ` Krister Johansen
  2023-01-30  8:22           ` Jan Beulich
  1 sibling, 1 reply; 16+ messages in thread
From: Krister Johansen @ 2023-01-27 18:51 UTC (permalink / raw)
  To: xen-devel
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver

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@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
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..3fbd912dcd 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_NEVER_EMULATE_TSC_AUX (3u)
+
 /*
  * Leaf 5 (0x40000x04)
  * HVM-specific features
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-27 18:51         ` [PATCH v3] " Krister Johansen
@ 2023-01-30  8:22           ` Jan Beulich
  2023-01-30 17:43             ` Krister Johansen
  2023-01-30 17:44             ` [PATCH v4] " Krister Johansen
  0 siblings, 2 replies; 16+ messages in thread
From: Jan Beulich @ 2023-01-30  8:22 UTC (permalink / raw)
  To: Krister Johansen
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On 27.01.2023 19:51, Krister Johansen wrote:
> --- 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_NEVER_EMULATE_TSC_AUX (3u)

While perhaps it doesn't matter much with the mode no longer supported,
I'd prefer if here we used the original name (PVRDTSCP) as well.
Preferably with that adjustment (which once again I'd be happy to do
while committing, albeit I'd like to wait with that until osstest is in
a better mood again)
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-30  8:22           ` Jan Beulich
@ 2023-01-30 17:43             ` Krister Johansen
  2023-01-30 17:44             ` [PATCH v4] " Krister Johansen
  1 sibling, 0 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-30 17:43 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

Hi Jan,

On Mon, Jan 30, 2023 at 09:22:11AM +0100, Jan Beulich wrote:
> On 27.01.2023 19:51, Krister Johansen wrote:
> > --- 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_NEVER_EMULATE_TSC_AUX (3u)
> 
> While perhaps it doesn't matter much with the mode no longer supported,
> I'd prefer if here we used the original name (PVRDTSCP) as well.
> Preferably with that adjustment (which once again I'd be happy to do
> while committing, albeit I'd like to wait with that until osstest is in
> a better mood again)
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks for the additional feedback.  I'll send you a v4 that makes the
requested modification.

-K


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-30  8:22           ` Jan Beulich
  2023-01-30 17:43             ` Krister Johansen
@ 2023-01-30 17:44             ` Krister Johansen
  2023-01-31  8:42               ` Jan Beulich
  1 sibling, 1 reply; 16+ messages in thread
From: Krister Johansen @ 2023-01-30 17:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver

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@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
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



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v4] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-30 17:44             ` [PATCH v4] " Krister Johansen
@ 2023-01-31  8:42               ` Jan Beulich
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Beulich @ 2023-01-31  8:42 UTC (permalink / raw)
  To: Krister Johansen
  Cc: Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver, xen-devel

On 30.01.2023 18:44, Krister Johansen wrote:
> 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@suse.com/
> Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
> Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>

As said:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4
  2023-01-24 22:35 [PATCH] perf/util: Symbol lookup can fail if multiple segmets match stext Krister Johansen
@ 2023-01-25 18:33 ` Krister Johansen
  0 siblings, 0 replies; 16+ messages in thread
From: Krister Johansen @ 2023-01-25 18:33 UTC (permalink / raw)
  To: xen-devel
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Wei Liu, Juergen Gross, Boris Ostrovsky, David Reaver

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@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index 7ecd16ae05..090f7f0034 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -72,6 +72,14 @@
  * 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_EMULATE           (1u)
+#define XEN_CPUID_TSC_MODE_NOEMULATE         (2u)
+#define XEN_CPUID_TSC_MODE_NOEMULATE_TSC_AUX (3u)
+
 /*
  * Leaf 5 (0x40000x04)
  * HVM-specific features
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-31  8:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 22:35 [PATCH] xen/x86: public: add TSC defines for cpuid leaf 4 Krister Johansen
2023-01-25  6:57 ` Jan Beulich
2023-01-25 18:31   ` Krister Johansen
2023-01-25 18:45 ` [PATCH v2] " Krister Johansen
2023-01-26  8:57   ` Jan Beulich
2023-01-26 17:54     ` Krister Johansen
2023-01-26  9:57   ` Jan Beulich
2023-01-26 18:02     ` Krister Johansen
2023-01-27  7:16       ` Jan Beulich
2023-01-27 18:37         ` Krister Johansen
2023-01-27 18:51         ` [PATCH v3] " Krister Johansen
2023-01-30  8:22           ` Jan Beulich
2023-01-30 17:43             ` Krister Johansen
2023-01-30 17:44             ` [PATCH v4] " Krister Johansen
2023-01-31  8:42               ` Jan Beulich
2023-01-24 22:35 [PATCH] perf/util: Symbol lookup can fail if multiple segmets match stext Krister Johansen
2023-01-25 18:33 ` [PATCH v2] xen/x86: public: add TSC defines for cpuid leaf 4 Krister Johansen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.