Introduce a new command line parameter, "suspendsteal", enabling the
guest to use MSR_KVM_SUSPEND_STEAL, which tells the host that it would
like host suspend duration to be included in steal time.
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
---
Documentation/admin-guide/kernel-parameters.txt | 5 +++++
arch/x86/kernel/kvm.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 07e22ba5bfe3..9a5490539bb2 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7074,6 +7074,11 @@
improve throughput, but will also increase the
amount of memory reserved for use by the client.
+ suspendsteal
+ [X86,PV_OPS]
+ Enable requesting the host to include the duration the
+ host was suspended in steal time. Disabled by default.
+
suspend.pm_test_delay=
[SUSPEND]
Sets the number of seconds to remain in a suspend test
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 921c1c783bc1..35d1bb2283c2 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -320,6 +320,18 @@ static void __init paravirt_ops_setup(void)
#endif
}
+static bool suspend_steal;
+
+static int __init suspendsteal_setup(char *s)
+{
+ if (kvm_para_has_feature(KVM_FEATURE_SUSPEND_STEAL))
+ suspend_steal = true;
+
+ return 0;
+}
+
+early_param("suspendsteal", suspendsteal_setup);
+
static void kvm_register_steal_time(void)
{
int cpu = smp_processor_id();
@@ -331,6 +343,9 @@ static void kvm_register_steal_time(void)
wrmsrq(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED));
pr_debug("stealtime: cpu %d, msr %llx\n", cpu,
(unsigned long long) slow_virt_to_phys(st));
+
+ if (suspend_steal)
+ wrmsrl(MSR_KVM_SUSPEND_STEAL, KVM_MSR_ENABLED);
}
static DEFINE_PER_CPU_DECRYPTED(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED;
--
2.50.0.727.gbf7dc18ff4-goog
On Tue, Jul 22, 2025, Suleiman Souhlal wrote:
> Introduce a new command line parameter, "suspendsteal", enabling the
> guest to use MSR_KVM_SUSPEND_STEAL, which tells the host that it would
> like host suspend duration to be included in steal time.
>
> Signed-off-by: Suleiman Souhlal <suleiman@google.com>
> ---
And then if we reuse MSR_KVM_STEAL_TIME:
---
Documentation/admin-guide/kernel-parameters.txt | 5 +++++
arch/x86/kernel/kvm.c | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 747a55abf494..8e80094317c3 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7178,6 +7178,11 @@
improve throughput, but will also increase the
amount of memory reserved for use by the client.
+ suspendsteal
+ [X86,PV_OPS]
+ Enable requesting the host to include the duration the
+ host was suspended in steal time. Disabled by default.
+
suspend.pm_test_delay=
[SUSPEND]
Sets the number of seconds to remain in a suspend test
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 8ae750cde0c6..1eea3e82c85b 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -71,6 +71,7 @@ static DEFINE_PER_CPU_READ_MOSTLY(bool, async_pf_enabled);
static DEFINE_PER_CPU_DECRYPTED(struct kvm_vcpu_pv_apf_data, apf_reason) __aligned(64);
DEFINE_PER_CPU_DECRYPTED(struct kvm_steal_time, steal_time) __aligned(64) __visible;
static int has_steal_clock = 0;
+static bool suspend_steal;
static int has_guest_poll = 0;
/*
@@ -320,6 +321,15 @@ static void __init paravirt_ops_setup(void)
#endif
}
+static int __init suspendsteal_setup(char *s)
+{
+ if (kvm_para_has_feature(KVM_FEATURE_SUSPEND_STEAL))
+ suspend_steal = true;
+
+ return 0;
+}
+early_param("suspendsteal", suspendsteal_setup);
+
static void kvm_register_steal_time(void)
{
int cpu = smp_processor_id();
@@ -328,7 +338,8 @@ static void kvm_register_steal_time(void)
if (!has_steal_clock)
return;
- wrmsrq(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED));
+ wrmsrq(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED) |
+ (suspend_steal ? KVM_STEAL_SUSPEND_TIME : 0));
pr_debug("stealtime: cpu %d, msr %llx\n", cpu,
(unsigned long long) slow_virt_to_phys(st));
}
--
© 2016 - 2026 Red Hat, Inc.