* [PATCH] x86/acrn: Set up timekeeping
@ 2022-08-04 5:59 Fei Li
2022-08-04 9:52 ` [tip: x86/platform] " tip-bot2 for Fei Li
2022-08-31 21:28 ` [PATCH] " Dave Hansen
0 siblings, 2 replies; 4+ messages in thread
From: Fei Li @ 2022-08-04 5:59 UTC (permalink / raw)
To: linux-kernel, x86
Cc: gregkh, tglx, mingo, bp, dave.hansen, hpa, yu1.wang,
conghui.chen, fei1.li
ACRN Hypervisor reports timing information via CPUID leaf 0x40000010.
Get the TSC and CPU frequency via CPUID leaf 0x40000010 and set the
kernel values accordingly.
Signed-off-by: Fei Li <fei1.li@intel.com>
Reviewed-by: Conghui <conghui.chen@intel.com>
---
arch/x86/include/asm/acrn.h | 14 ++++++++++++++
arch/x86/kernel/cpu/acrn.c | 3 +++
2 files changed, 17 insertions(+)
diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index e003a01b7c67..1dd14381bcb6 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -10,6 +10,15 @@
/* Bit 0 indicates whether guest VM is privileged */
#define ACRN_FEATURE_PRIVILEGED_VM BIT(0)
+/*
+ * Timing Information.
+ * This leaf returns the current TSC frequency in kHz.
+ *
+ * EAX: (Virtual) TSC frequency in kHz.
+ * EBX, ECX, EDX: RESERVED (reserved fields are set to zero).
+ */
+#define ACRN_CPUID_TIMING_INFO 0x40000010
+
void acrn_setup_intr_handler(void (*handler)(void));
void acrn_remove_intr_handler(void);
@@ -21,6 +30,11 @@ static inline u32 acrn_cpuid_base(void)
return 0;
}
+static inline unsigned long acrn_get_tsc_khz(void)
+{
+ return cpuid_eax(ACRN_CPUID_TIMING_INFO);
+}
+
/*
* Hypercalls for ACRN
*
diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
index 23f5f27b5a02..485441b7f030 100644
--- a/arch/x86/kernel/cpu/acrn.c
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -28,6 +28,9 @@ static void __init acrn_init_platform(void)
{
/* Setup the IDT for ACRN hypervisor callback */
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, asm_sysvec_acrn_hv_callback);
+
+ x86_platform.calibrate_tsc = acrn_get_tsc_khz;
+ x86_platform.calibrate_cpu = acrn_get_tsc_khz;
}
static bool acrn_x2apic_available(void)
base-commit: e0dccc3b76fb35bb257b4118367a883073d7390e
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip: x86/platform] x86/acrn: Set up timekeeping
2022-08-04 5:59 [PATCH] x86/acrn: Set up timekeeping Fei Li
@ 2022-08-04 9:52 ` tip-bot2 for Fei Li
2022-08-31 21:28 ` [PATCH] " Dave Hansen
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Fei Li @ 2022-08-04 9:52 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Fei Li, Ingo Molnar, Conghui, x86, linux-kernel
The following commit has been merged into the x86/platform branch of tip:
Commit-ID: 81a71f51b89e84f39df2a3b1daf4274ae6b7b194
Gitweb: https://git.kernel.org/tip/81a71f51b89e84f39df2a3b1daf4274ae6b7b194
Author: Fei Li <fei1.li@intel.com>
AuthorDate: Thu, 04 Aug 2022 13:59:03 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 04 Aug 2022 11:11:59 +02:00
x86/acrn: Set up timekeeping
ACRN Hypervisor reports timing information via CPUID leaf 0x40000010.
Get the TSC and CPU frequency via CPUID leaf 0x40000010 and set the
kernel values accordingly.
Signed-off-by: Fei Li <fei1.li@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Conghui <conghui.chen@intel.com>
Link: https://lore.kernel.org/r/20220804055903.365211-1-fei1.li@intel.com
---
arch/x86/include/asm/acrn.h | 14 ++++++++++++++
arch/x86/kernel/cpu/acrn.c | 3 +++
2 files changed, 17 insertions(+)
diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index e003a01..1dd1438 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -10,6 +10,15 @@
/* Bit 0 indicates whether guest VM is privileged */
#define ACRN_FEATURE_PRIVILEGED_VM BIT(0)
+/*
+ * Timing Information.
+ * This leaf returns the current TSC frequency in kHz.
+ *
+ * EAX: (Virtual) TSC frequency in kHz.
+ * EBX, ECX, EDX: RESERVED (reserved fields are set to zero).
+ */
+#define ACRN_CPUID_TIMING_INFO 0x40000010
+
void acrn_setup_intr_handler(void (*handler)(void));
void acrn_remove_intr_handler(void);
@@ -21,6 +30,11 @@ static inline u32 acrn_cpuid_base(void)
return 0;
}
+static inline unsigned long acrn_get_tsc_khz(void)
+{
+ return cpuid_eax(ACRN_CPUID_TIMING_INFO);
+}
+
/*
* Hypercalls for ACRN
*
diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
index 23f5f27..485441b 100644
--- a/arch/x86/kernel/cpu/acrn.c
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -28,6 +28,9 @@ static void __init acrn_init_platform(void)
{
/* Setup the IDT for ACRN hypervisor callback */
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, asm_sysvec_acrn_hv_callback);
+
+ x86_platform.calibrate_tsc = acrn_get_tsc_khz;
+ x86_platform.calibrate_cpu = acrn_get_tsc_khz;
}
static bool acrn_x2apic_available(void)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/acrn: Set up timekeeping
2022-08-04 5:59 [PATCH] x86/acrn: Set up timekeeping Fei Li
2022-08-04 9:52 ` [tip: x86/platform] " tip-bot2 for Fei Li
@ 2022-08-31 21:28 ` Dave Hansen
2022-09-01 7:02 ` Li, Fei1
1 sibling, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2022-08-31 21:28 UTC (permalink / raw)
To: Fei Li, linux-kernel, x86
Cc: gregkh, tglx, mingo, bp, dave.hansen, hpa, yu1.wang, conghui.chen
On 8/3/22 22:59, Fei Li wrote:
> +static inline unsigned long acrn_get_tsc_khz(void)
> +{
> + return cpuid_eax(ACRN_CPUID_TIMING_INFO);
> +}
> +
> /*
> * Hypercalls for ACRN
> *
> diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
> index 23f5f27b5a02..485441b7f030 100644
> --- a/arch/x86/kernel/cpu/acrn.c
> +++ b/arch/x86/kernel/cpu/acrn.c
> @@ -28,6 +28,9 @@ static void __init acrn_init_platform(void)
> {
> /* Setup the IDT for ACRN hypervisor callback */
> alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, asm_sysvec_acrn_hv_callback);
> +
> + x86_platform.calibrate_tsc = acrn_get_tsc_khz;
> + x86_platform.calibrate_cpu = acrn_get_tsc_khz;
> }
Could you take a sec and consider what 'static inline' does and means
and also what setting:
x86_platform.calibrate_cpu = acrn_get_tsc_khz;
does?
Using 'static inline' might compile, but it doesn't make sense.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] x86/acrn: Set up timekeeping
2022-08-31 21:28 ` [PATCH] " Dave Hansen
@ 2022-09-01 7:02 ` Li, Fei1
0 siblings, 0 replies; 4+ messages in thread
From: Li, Fei1 @ 2022-09-01 7:02 UTC (permalink / raw)
To: Hansen, Dave, linux-kernel, x86
Cc: gregkh, tglx, mingo, bp, dave.hansen, hpa, Wang, Yu1, Chen,
Conghui, Yin, Fengwei
> On 8/3/22 22:59, Fei Li wrote:
> > +static inline unsigned long acrn_get_tsc_khz(void) {
> > + return cpuid_eax(ACRN_CPUID_TIMING_INFO);
> > +}
> > +
> > /*
> > * Hypercalls for ACRN
> > *
> > diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
> > index 23f5f27b5a02..485441b7f030 100644
> > --- a/arch/x86/kernel/cpu/acrn.c
> > +++ b/arch/x86/kernel/cpu/acrn.c
> > @@ -28,6 +28,9 @@ static void __init acrn_init_platform(void) {
> > /* Setup the IDT for ACRN hypervisor callback */
> > alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
> > asm_sysvec_acrn_hv_callback);
> > +
> > + x86_platform.calibrate_tsc = acrn_get_tsc_khz;
> > + x86_platform.calibrate_cpu = acrn_get_tsc_khz;
> > }
>
> Could you take a sec and consider what 'static inline' does and means and also what setting:
>
> x86_platform.calibrate_cpu = acrn_get_tsc_khz;
>
> does?
>
> Using 'static inline' might compile, but it doesn't make sense.
>
Hi Dave
Thanks for your reply.
Yes, 'inline' doesn't make sense here.
Now this commit has been merged into the x86/platform branch of tip,
I will send a patch to remove 'inline' once this commit has been merged
into the master branch.
Thanks again.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-01 7:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 5:59 [PATCH] x86/acrn: Set up timekeeping Fei Li
2022-08-04 9:52 ` [tip: x86/platform] " tip-bot2 for Fei Li
2022-08-31 21:28 ` [PATCH] " Dave Hansen
2022-09-01 7:02 ` Li, Fei1
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).