From nobody Tue Oct 7 16:53:00 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64093273D8E for ; Wed, 9 Jul 2025 07:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752044708; cv=none; b=RJce0rOyM37R1sWoilaup8quL3NU3q9cGnnI5obJPxxtAP5Yi/s/Bypl/8mrYW6OotpBABmXZeBb8ww7yAbIz6lRlBHPo69oOToCbglt2SOjH2lta+mQ24b7mqgt56moTWI0CBqgfRcGVHPIVdm9ilTot9kO3eXtpNshTjhNVRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752044708; c=relaxed/simple; bh=bqDfiVKFuR+e8N7emCK6GdbPPlTbsBsyYl3PH3KjyJw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=lW//EAhFeRQ+q4AfHV9L6FmC7+uS7251jvfS/WEqaPQO6s7QhCKwJXITWWE30vRfz/iWOV8iGEXskLFPY7swHih/QPRDdCxfjjTAGJmgTGrlvVBw2zn7f/B4ycWpzygKuE3kuJgCP4G5x+bYl8j33016V/5MBppXRabLGqIzqVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--suleiman.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lGa5dMb4; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--suleiman.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lGa5dMb4" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e819e8eb985so6723034276.2 for ; Wed, 09 Jul 2025 00:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752044706; x=1752649506; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HaDQLHJuamQG+Oz/rXsc1nJQc3j6887WnfJ3FWY6wPY=; b=lGa5dMb4/QCskSc/99m9viQEHFXRqBqRbuSxe8xbbz1YtNKIQIHcB3SWi2d6gc03NM yjMjJYjLpL0efYbj12ikl3F9Vt1vpd40ZbT4SQEUyFezNUsZuxbxOO4foCxR9M6eeRDJ 0ddqiQYvYZsttyrpxusJBc1Lk8t31SSk11tb7LaEAQGqTgEeEUdjrQKl2FmJjeFNYvlx ZQx3s3C0sOEOxfUt+NQeDSIvkXR1lQGvJs7RuI4fVOKa7zt/5mQkLHPa+eI0mAKQuPkm PC5ZUj4H62nz3hRyxxrxayLIkoMo8SV9au9VXzGrTmwxQGpk0vde0OVl5yOU90R5uDLE Q7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752044706; x=1752649506; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HaDQLHJuamQG+Oz/rXsc1nJQc3j6887WnfJ3FWY6wPY=; b=YQof20no55mSfQRzCDj3jcdBEg1QRT8okt/xZkN0pxvncxUwvf388SctZHAgugPm/Z 2xsPwXV72k0tu7jX0qgFXTA5xPdNgcFbYrdvBjW15L3Y6ZNthkRF+gVKwBAg4BOn5/eq ze6dpMxVKqu7NYQwBXhp+ywjOHESuera3LjVJ4iAJH++yItwHKyFzXmqrsCN8/4iBiOV F1+AUfkD0UT2geOVV+o0ofdvmn5pf2eD14uVBdgzxug/b2uIa4/uvjmuKeLR29xpG0VI o1U74rgt5HVKoSlT5Y9OwaG/Lm8ElXcznpl4iCgZ0sbAPkru2cRysLuVOCQSeheUciXN tbGQ== X-Forwarded-Encrypted: i=1; AJvYcCVue7V/3kHRg9uYfKX1E0+7A9wOVFskBoPmdT/KkjWPUUlO4cb+uHnIe91jrkcE5wOzPlLrGO+tv9HrS84=@vger.kernel.org X-Gm-Message-State: AOJu0YzEtqm38ZYbyaxIw5TT7Ysyb9e2PbXL/uusdqAN1s06nWkx7D9p 0PcOIy2LMdmXvywYQqXuxTY7ZIed5esAnfTp8IYoa2Jf/zAKg3SDqmfObCv+AH7WecWCeNqfwZB iit3DjmsW0mvrag== X-Google-Smtp-Source: AGHT+IE5ZkJJrfChwxmjelv9TbY/xNBu5uRt03nGE+i4WAPwg6JLhbF8sllzldrGvtvYqXjNVHB2+Nx7G6uM6w== X-Received: from suleiman1.tok.corp.google.com ([2401:fa00:8f:203:a92c:694f:82fe:62a]) (user=suleiman job=sendgmr) by 2002:a05:6902:6c0e:b0:e89:883d:dd33 with SMTP id 3f1490d57ef6-e8b6e19fdcamr688276.5.1752044706399; Wed, 09 Jul 2025 00:05:06 -0700 (PDT) Date: Wed, 9 Jul 2025 16:04:50 +0900 In-Reply-To: <20250709070450.473297-1-suleiman@google.com> Message-Id: <20250709070450.473297-4-suleiman@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250709070450.473297-1-suleiman@google.com> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Subject: [PATCH v6 3/3] KVM: x86: Add "suspendsteal" cmdline to request host to add suspend duration in steal time From: Suleiman Souhlal To: Paolo Bonzini , Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Chao Gao , David Woodhouse , Sergey Senozhatsky , Konrad Rzeszutek Wilk , Tzung-Bi Shih , John Stultz , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, ssouhlal@freebsd.org, Suleiman Souhlal Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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/Documentatio= n/admin-guide/kernel-parameters.txt index f1f2c0874da9dd..9f5758ca8fadd5 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. =20 + 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=3D [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 921c1c783bc187..35d1bb2283c2c0 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 } =20 +static bool suspend_steal; + +static int __init suspendsteal_setup(char *s) +{ + if (kvm_para_has_feature(KVM_FEATURE_SUSPEND_STEAL)) + suspend_steal =3D true; + + return 0; +} + +early_param("suspendsteal", suspendsteal_setup); + static void kvm_register_steal_time(void) { int cpu =3D 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); } =20 static DEFINE_PER_CPU_DECRYPTED(unsigned long, kvm_apic_eoi) =3D KVM_PV_EO= I_DISABLED; --=20 2.50.0.727.gbf7dc18ff4-goog