From nobody Thu Apr 2 10:57:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1771588671; cv=none; d=zohomail.com; s=zohoarc; b=C1qoqWa87NxGHB34av1K2EhVIq6kQEc2soj+xm3/I7p02dV+yh7TA/l00qyf61GxCg0ZusByl+vqvLG9MJIqpc7doRz/stHpyoKBQT/4SIx782jmSGrsA+nbR4N8tI02+gDfsCmmDZZU9wvujy2cUOH8kfYTHkLCeqE5o6/kJsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771588671; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pemrUBU8/rbjL9/zoZ7MkscMiByl7zJxATlK5nEq+x0=; b=hyYkr/u/zqdf5lr+kPyzmAhsZlE95ao5sFWFNmfsZ6sa83MZGkjHHGhxjZXj86kvklk0IjVa0AMF5o5+PNj3MHd1k5taE5bIMyfumSqJh5VYxfqi66CB62pX6UW2pOI6lXCE0ZizjGgqYZcNWmd5GTLXKh/mpPMK477huzqIeFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771588671817241.79065800162232; Fri, 20 Feb 2026 03:57:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vtP89-0004Gk-0m; Fri, 20 Feb 2026 06:57:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vtP87-0004GN-Ux for qemu-devel@nongnu.org; Fri, 20 Feb 2026 06:57:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vtP85-0001jr-QU for qemu-devel@nongnu.org; Fri, 20 Feb 2026 06:57:07 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-RHRrsO1NMc2NH1ARmzoHAw-1; Fri, 20 Feb 2026 06:57:04 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4836ff58111so25136455e9.1 for ; Fri, 20 Feb 2026 03:57:03 -0800 (PST) Received: from rh.fritz.box (p200300f6af2d8700b4c2d356c3fafe63.dip0.t-ipconnect.de. [2003:f6:af2d:8700:b4c2:d356:c3fa:fe63]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a316c2aasm66102295e9.0.2026.02.20.03.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Feb 2026 03:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771588625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pemrUBU8/rbjL9/zoZ7MkscMiByl7zJxATlK5nEq+x0=; b=QLygrL0TLerEzkxui2QbWtXytAqrfG5undZnHEoD1njQdRnrmwPB1/wEmQRFpdglcG7XnZ FSbxdJ4gycRf3m5ufDu4rMN8q1GV16WFUSgMU1dnhbr5s/++tnY2BZ56hgWXatF/a8S7GI 5Iw5XFVnWs+W9BYQMpw6N6wFMadzbgQ= X-MC-Unique: RHRrsO1NMc2NH1ARmzoHAw-1 X-Mimecast-MFC-AGG-ID: RHRrsO1NMc2NH1ARmzoHAw_1771588623 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1771588623; x=1772193423; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pemrUBU8/rbjL9/zoZ7MkscMiByl7zJxATlK5nEq+x0=; b=PSWvVhdSDCOchAv2ZzUrhItPTNSGSae8347hZQ55juPzuB/rXKvWHifXn6hF9Sm4Sq g2RH49bmisMaRDXwx9KCX4Vi+dAZ7Gviu5rmd2ugZPGzfqK41qca3sgjWwr8K+vyrJVt g/+PWvV4TgHSiI9VRiULQIOlYrQrfwY9QfxFA0xoiGeBQAC7qvKC0rNFllu+/WPT+CVD l5rp55hK6Ou2fnRoNuYA/IOFXV9yxhnytWBMqlc1+DPH2bXKzYV5+VTRs3YkJokyTOr3 OAJWvBQkKfdVhBPq51ENWpBuQzXaGSJtMGwCYg6+U3H4gM+5JCSjNkETsPap8wByu3sX Dc2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771588623; x=1772193423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pemrUBU8/rbjL9/zoZ7MkscMiByl7zJxATlK5nEq+x0=; b=RO9xRye4PhcmNrQWnuakP9iGQXbZDU/mFcKUSZZKvr5XiaZwnr+mA/hdAHMS8Wm/gq ydFwwRrrJ3RvuBFy1zCDPvboLnktK1SOGJ4aURUXnLcDubY73EltV/P5P3DKEImmX9tY uLSH0XNErR+t782S/h3RbszZMKrsinZ2/W6PNoq41tNoXtUPdHV35QDqAIPaCMyv++rp fSIV5lTNj9fnTnnjFxCc7g9Mn4lj1itGbHoQWiLxAq/sK4eEi3TKUgOeWlL0jMrp4LYn Ho+e7+YY6G7B9GPqdrmH17SpVQWytUZmDd7W/0dATDWB+tB4hScRGq7Mn3E7zKrvS8Xe n8Og== X-Forwarded-Encrypted: i=1; AJvYcCU834aPgrJY3dKMdBEj/EBuX1h/D5vrQTRswBXGcKlP9L9oKnsh8Dc+kBLgMkQ55BOSHFDMb+K1AY/d@nongnu.org X-Gm-Message-State: AOJu0Yx6ZmwYDQo8M905jYzossxq6Vm8wRi/ABvl7m2kndMpSAFmvWCi vMokRuAeUAwOOPTGmov48Msh9ZV+wUozRWN6ZB4W0m6/uxbG2lceU19iNM68GBSX4udsd7p3Fus 0kjxodyUidqY796sU19+QSIHMrD25qAiZTq1YhAXOIe6iEgruLFvps5Bj X-Gm-Gg: AZuq6aLhS8juw3p36W2o6akMK0pq3mNxjFfB4v5U0lh62IfMSe0KsbQ7dH3Gam9NaLU FwGIrJPxrc+ut3Yj85El9uadfYko1S9n9NIlZQNqNdoZqfZ393yKszlO7v/PncA+f6MdCFY9J8r qeVy3aSnQkwvBnOOTS8q0RCPC8AsvunzfQCq2fQwwKSXUSiGqsHTAZ14JHYTD8PbxKmrwO+WfMj yMAGvUb+Dknw4uNzdNwtR5VqPeIza0Lg4EnZsr08aXhSTMHPsDXSEtP1Mb9bWCqvJx2lcOZklyo G7uJbN1npUqEFw9d8NRf4j4AEC+hSGVTv98pm2ZwHQops06gOySOKzxa9bfr7hOBdM5qj6+ZIci 65q0GoBQ9I9VzBRmwXHfhGG7NIXcYBArhq3PJIU2Ky/AKvfaAmxxGEAxYDM2UFXiqkqS7gJ5wYZ vfmKEQSZPd X-Received: by 2002:a05:600c:a087:b0:483:71f7:2794 with SMTP id 5b1f17b1804b1-48398a54b94mr145228655e9.15.1771588622596; Fri, 20 Feb 2026 03:57:02 -0800 (PST) X-Received: by 2002:a05:600c:a087:b0:483:71f7:2794 with SMTP id 5b1f17b1804b1-48398a54b94mr145228175e9.15.1771588622099; Fri, 20 Feb 2026 03:57:02 -0800 (PST) From: Sebastian Ott To: peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: eric.auger@redhat.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, pbonzini@redhat.com, qemu-arm@nongnu.org, Sebastian Ott Subject: [PATCH v6 1/1] target/arm/kvm: add kvm-psci-version vcpu property Date: Fri, 20 Feb 2026 12:56:56 +0100 Message-ID: <20260220115656.4831-2-sebott@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260220115656.4831-1-sebott@redhat.com> References: <20260220115656.4831-1-sebott@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=sebott@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.045, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771588674485158500 Content-Type: text/plain; charset="utf-8" Provide a kvm specific vcpu property to override the default (as of kernel v6.13 that would be PSCI v1.3) PSCI version emulated by kvm. Current valid values are: 0.1, 0.2, 1.0, 1.1, 1.2, and 1.3 Note: in order to support PSCI v0.1 we need to drop vcpu initialization with KVM_CAP_ARM_PSCI_0_2 in that case. Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Sebastian Ott --- docs/system/arm/cpu-features.rst | 11 ++++++++ target/arm/cpu.c | 8 +++++- target/arm/kvm.c | 48 ++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-feature= s.rst index 3db1f19401..ce19ae6a04 100644 --- a/docs/system/arm/cpu-features.rst +++ b/docs/system/arm/cpu-features.rst @@ -204,6 +204,17 @@ the list of KVM VCPU features and their descriptions. the guest scheduler behavior and/or be exposed to the guest userspace. =20 +``kvm-psci-version`` + Set the Power State Coordination Interface (PSCI) firmware ABI version + that KVM provides to the guest. By default KVM will use the newest + version that it knows about (which is PSCI v1.3 in Linux v6.13). + + You only need to set this if you want to be able to migrate this + VM to a host machine running an older kernel that does not + recognize the PSCI version that this host's kernel defaults to. + + Current valid values are: 0.1, 0.2, 1.0, 1.1, 1.2, and 1.3. + TCG VCPU Features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 10f8280eef..60f391651d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1144,7 +1144,13 @@ static void arm_cpu_initfn(Object *obj) * picky DTB consumer will also provide a helpful error message. */ cpu->dtb_compatible =3D "qemu,unknown"; - cpu->psci_version =3D QEMU_PSCI_VERSION_0_1; /* By default assume PSCI= v0.1 */ + if (!kvm_enabled()) { + /* By default KVM will use the newest PSCI version that it knows a= bout. + * This can be changed using the kvm-psci-version property. + * For others assume PSCI v0.1 by default. + */ + cpu->psci_version =3D QEMU_PSCI_VERSION_0_1; + } cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; =20 if (tcg_enabled() || hvf_enabled()) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ded582e0da..5453460965 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -485,6 +485,28 @@ static void kvm_steal_time_set(Object *obj, bool value= , Error **errp) ARM_CPU(obj)->kvm_steal_time =3D value ? ON_OFF_AUTO_ON : ON_OFF_AUTO_= OFF; } =20 +static char *kvm_get_psci_version(Object *obj, Error **errp) +{ + ARMCPU *cpu =3D ARM_CPU(obj); + + return g_strdup_printf("%d.%d", + (int) PSCI_VERSION_MAJOR(cpu->psci_version), + (int) PSCI_VERSION_MINOR(cpu->psci_version)); +} + +static void kvm_set_psci_version(Object *obj, const char *value, Error **e= rrp) +{ + ARMCPU *cpu =3D ARM_CPU(obj); + uint16_t maj, min; + + if (sscanf(value, "%hd.%hd", &maj, &min) !=3D 2) { + error_setg(errp, "Invalid PSCI version."); + return; + } + + cpu->psci_version =3D PSCI_VERSION(maj, min); +} + /* KVM VCPU properties should be prefixed with "kvm-". */ void kvm_arm_add_vcpu_properties(ARMCPU *cpu) { @@ -506,6 +528,12 @@ void kvm_arm_add_vcpu_properties(ARMCPU *cpu) kvm_steal_time_set); object_property_set_description(obj, "kvm-steal-time", "Set off to disable KVM steal time."); + + object_property_add_str(obj, "kvm-psci-version", kvm_get_psci_version, + kvm_set_psci_version); + object_property_set_description(obj, "kvm-psci-version", + "Set PSCI version. " + "Valid values are 0.1, 0.2, 1.0, 1.1, = 1.2, 1.3"); } =20 bool kvm_arm_pmu_supported(void) @@ -1976,8 +2004,12 @@ int kvm_arch_init_vcpu(CPUState *cs) if (cs->start_powered_off) { cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_POWER_OFF; } - if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { - cpu->psci_version =3D QEMU_PSCI_VERSION_0_2; + if (cpu->psci_version !=3D QEMU_PSCI_VERSION_0_1 && + kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { + /* + * Versions >=3D v0.2 are backward compatible with v0.2 + * omit the feature flag for v0.1 . + */ cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PSCI_0_2; } if (!arm_feature(env, ARM_FEATURE_AARCH64)) { @@ -2015,6 +2047,18 @@ int kvm_arch_init_vcpu(CPUState *cs) } } =20 + if (cpu->psci_version) { + psciver =3D cpu->psci_version; + ret =3D kvm_set_one_reg(cs, KVM_REG_ARM_PSCI_VERSION, &psciver); + if (ret) { + error_report("KVM in this kernel does not support PSCI version= %d.%d", + (int) PSCI_VERSION_MAJOR(psciver), + (int) PSCI_VERSION_MINOR(psciver)); + error_printf("Consider setting the kvm-psci-version property o= n the " + "migration source.\n"); + return ret; + } + } /* * KVM reports the exact PSCI version it is implementing via a * special sysreg. If it is present, use its contents to determine --=20 2.52.0