public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next v2 0/2] x86/xen TSC related cleanups
@ 2023-02-22 17:54 Krister Johansen
  2023-02-22 17:54 ` [PATCH linux-next v2 1/2] xen: update arch/x86/include/asm/xen/cpuid.h Krister Johansen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Krister Johansen @ 2023-02-22 17:54 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, Jan Beulich, Boris Ostrovsky, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Marcelo Tosatti, Anthony Liguori, David Reaver, Brendan Gregg

Hi,
Enclosed please find a pair of patches that perform some additional cleanup
that was suggested by Boris, Jan and Thomas.

Specifically: this resync's arch/x86/include/asm/xen/cpuid.h from its
upstream source in the Xen tree, and then uses one of the new #define-s to
replace a constant in x86/xen/time.c that was previously only numerically
defined.  Pedantic code from v1 is dropped in favor of a more appropriate
return statement.

Changes from v1:

- Coding style fixup in arch/x86/xen/time.c (Feedback from Thomas Gleixner)


Krister Johansen (2):
  xen: update arch/x86/include/asm/xen/cpuid.h
  x86/xen/time: cleanup xen_tsc_safe_clocksource

 arch/x86/include/asm/xen/cpuid.h | 22 ++++++++++++++++++----
 arch/x86/xen/time.c              |  7 ++-----
 2 files changed, 20 insertions(+), 9 deletions(-)

-- 
2.25.1


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

* [PATCH linux-next v2 1/2] xen: update arch/x86/include/asm/xen/cpuid.h
  2023-02-22 17:54 [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Krister Johansen
@ 2023-02-22 17:54 ` Krister Johansen
  2023-02-22 17:54 ` [PATCH linux-next v2 2/2] x86/xen/time: cleanup xen_tsc_safe_clocksource Krister Johansen
  2023-02-23  5:43 ` [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Juergen Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Krister Johansen @ 2023-02-22 17:54 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, Jan Beulich, Boris Ostrovsky, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Marcelo Tosatti, Anthony Liguori, David Reaver, Brendan Gregg

Update arch/x86/include/asm/xen/cpuid.h from the Xen tree to get newest
definitions.  This picks up some TSC mode definitions and comment
formatting changes.

Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
 arch/x86/include/asm/xen/cpuid.h | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/xen/cpuid.h b/arch/x86/include/asm/xen/cpuid.h
index 6daa9b0c8d11..a3c29b1496c8 100644
--- a/arch/x86/include/asm/xen/cpuid.h
+++ b/arch/x86/include/asm/xen/cpuid.h
@@ -89,11 +89,21 @@
  * 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
  * Sub-leaf 0: EAX: Features
  * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
+ * Sub-leaf 0: ECX: domain id (iff EAX has XEN_HVM_CPUID_DOMID_PRESENT flag)
  */
 #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
 #define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
@@ -102,12 +112,16 @@
 #define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
 #define XEN_HVM_CPUID_DOMID_PRESENT    (1u << 4) /* domid is present in ECX */
 /*
- * Bits 55:49 from the IO-APIC RTE and bits 11:5 from the MSI address can be
- * used to store high bits for the Destination ID. This expands the Destination
- * ID field from 8 to 15 bits, allowing to target APIC IDs up 32768.
+ * With interrupt format set to 0 (non-remappable) bits 55:49 from the
+ * IO-APIC RTE and bits 11:5 from the MSI address can be used to store
+ * high bits for the Destination ID. This expands the Destination ID
+ * field from 8 to 15 bits, allowing to target APIC IDs up 32768.
  */
 #define XEN_HVM_CPUID_EXT_DEST_ID      (1u << 5)
-/* Per-vCPU event channel upcalls */
+/*
+ * Per-vCPU event channel upcalls work correctly with physical IRQs
+ * bound to event channels.
+ */
 #define XEN_HVM_CPUID_UPCALL_VECTOR    (1u << 6)
 
 /*
-- 
2.25.1


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

* [PATCH linux-next v2 2/2] x86/xen/time: cleanup xen_tsc_safe_clocksource
  2023-02-22 17:54 [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Krister Johansen
  2023-02-22 17:54 ` [PATCH linux-next v2 1/2] xen: update arch/x86/include/asm/xen/cpuid.h Krister Johansen
@ 2023-02-22 17:54 ` Krister Johansen
  2023-02-23  5:43 ` [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Juergen Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Krister Johansen @ 2023-02-22 17:54 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, Jan Beulich, Boris Ostrovsky, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Marcelo Tosatti, Anthony Liguori, David Reaver, Brendan Gregg

Modifies xen_tsc_safe_clocksource() to use newly defined constants from
arch/x86/include/asm/xen/cpuid.h.  This replaces a numeric value with
XEN_CPUID_TSC_MODE_NEVER_EMULATE, and deletes a comment that is now self
explanatory.

There should be no change in the function's behavior.

Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
---
 arch/x86/xen/time.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 95140609c8a8..94056013a2a4 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -20,6 +20,7 @@
 #include <asm/pvclock.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
+#include <asm/xen/cpuid.h>
 
 #include <xen/events.h>
 #include <xen/features.h>
@@ -495,11 +496,7 @@ static int __init xen_tsc_safe_clocksource(void)
 	/* Leaf 4, sub-leaf 0 (0x40000x03) */
 	cpuid_count(xen_cpuid_base() + 3, 0, &eax, &ebx, &ecx, &edx);
 
-	/* tsc_mode = no_emulate (2) */
-	if (ebx != 2)
-		return 0;
-
-	return 1;
+	return ebx == XEN_CPUID_TSC_MODE_NEVER_EMULATE;
 }
 
 static void __init xen_time_init(void)
-- 
2.25.1


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

* Re: [PATCH linux-next v2 0/2] x86/xen TSC related cleanups
  2023-02-22 17:54 [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Krister Johansen
  2023-02-22 17:54 ` [PATCH linux-next v2 1/2] xen: update arch/x86/include/asm/xen/cpuid.h Krister Johansen
  2023-02-22 17:54 ` [PATCH linux-next v2 2/2] x86/xen/time: cleanup xen_tsc_safe_clocksource Krister Johansen
@ 2023-02-23  5:43 ` Juergen Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Juergen Gross @ 2023-02-23  5:43 UTC (permalink / raw)
  To: Krister Johansen, xen-devel, linux-kernel
  Cc: Jan Beulich, Boris Ostrovsky, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Marcelo Tosatti, Anthony Liguori, David Reaver, Brendan Gregg


[-- Attachment #1.1.1: Type: text/plain, Size: 1014 bytes --]

On 22.02.23 18:54, Krister Johansen wrote:
> Hi,
> Enclosed please find a pair of patches that perform some additional cleanup
> that was suggested by Boris, Jan and Thomas.
> 
> Specifically: this resync's arch/x86/include/asm/xen/cpuid.h from its
> upstream source in the Xen tree, and then uses one of the new #define-s to
> replace a constant in x86/xen/time.c that was previously only numerically
> defined.  Pedantic code from v1 is dropped in favor of a more appropriate
> return statement.
> 
> Changes from v1:
> 
> - Coding style fixup in arch/x86/xen/time.c (Feedback from Thomas Gleixner)
> 
> 
> Krister Johansen (2):
>    xen: update arch/x86/include/asm/xen/cpuid.h
>    x86/xen/time: cleanup xen_tsc_safe_clocksource
> 
>   arch/x86/include/asm/xen/cpuid.h | 22 ++++++++++++++++++----
>   arch/x86/xen/time.c              |  7 ++-----
>   2 files changed, 20 insertions(+), 9 deletions(-)
> 

For both patches:

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

end of thread, other threads:[~2023-02-23  5:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-22 17:54 [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Krister Johansen
2023-02-22 17:54 ` [PATCH linux-next v2 1/2] xen: update arch/x86/include/asm/xen/cpuid.h Krister Johansen
2023-02-22 17:54 ` [PATCH linux-next v2 2/2] x86/xen/time: cleanup xen_tsc_safe_clocksource Krister Johansen
2023-02-23  5:43 ` [PATCH linux-next v2 0/2] x86/xen TSC related cleanups Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox