Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECFA6606A32C for ; Thu, 3 Dec 2026 17:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VGKKDvxG Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZAMT-0001pk-F5; Thu, 03 Dec 2026 12:12:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZAMO-0001YK-TP for qemu-devel@nongnu.org; Thu, 03 Dec 2026 12:12:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZAMN-0006tg-4Z for qemu-devel@nongnu.org; Thu, 03 Dec 2026 12:12:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796317963; 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=EuJ2c/W2NNLtdbqRHoiSlhkpNRt9Kf5uiO8H//hTuRA=; b=VGKKDvxGEf+rJ9VhC323I4Tvfyyx1cxW5TTl/7REcnqZo5D/gi+9tYUyC+GbcHrGE2zMsN 2iQyTnCnSMS+Fz+V2Yq1RlSaeYztHQC1KiI6MeRNzTD+VmhWGlFhspbM253Rqh8GgJf4wW U8tqm5ecfh3zxFtrXjmkYoihwqjZE+0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-6-BrLvtDOuWTzsqBygCuAw-1; Thu, 3 Dec 2026 17:12:03 +0000 X-MC-Unique: 6-BrLvtDOuWTzsqBygCuAw-1 X-Mimecast-MFC-AGG-ID: 6-BrLvtDOuWTzsqBygCuAw_1796317901 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F2BE19146D5; Thu, 3 Dec 2026 17:11:41 +0000 (UTC) Received: from eauger-thinkpadp1gen8.rmtfr.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D43C7195605B; Thu, 3 Dec 2026 17:11:37 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shaju.abraham@nutanix.com, khushit.shah@nutanix.com, richard.henderson@linaro.org, pbonzini@redhat.com, skolothumtho@nvidia.com, philmd@oss.qualcomm.com Cc: armbru@redhat.com, mbawa@redhat.com, cohuck@redhat.com Subject: [PATCH v11 17/20] target/arm/cpu64: Add helper to test SYSREG props against a scratch vcpu Date: Thu, 3 Dec 2026 18:09:06 +0100 Message-ID: <20261203171020.2594683-18-eric.auger@redhat.com> In-Reply-To: <20261203171020.2594683-1-eric.auger@redhat.com> References: <20261203171020.2594683-1-eric.auger@redhat.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 3 X-Spam_score: 0.3 X-Spam_bar: / X-Spam_report: (0.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add kvm_idreg_write_scratch_vcpu helper that will be used by qmp_query_cpu_model_expansion code to test SYSREG settings against a scratch vcpu. As the scratch vcpu does not follow the kvm_create_vcpu() path, the kvm_fd is set by the expansion code. In the helper we assert it was properly set by the caller. Signed-off-by: Eric Auger --- v10 -> v11: - change the proto to remove the fd. The precondition is the kvm_fd has been set --- target/arm/kvm_arm.h | 3 +++ target/arm/kvm-stub.c | 6 ++++++ target/arm/kvm.c | 23 +++++++++++++++++++++++ target/arm/trace-events | 1 + 4 files changed, 33 insertions(+) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 9c7e7f654a..8d8700e499 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -14,6 +14,7 @@ #include "qapi/qapi-types-misc-arm.h" #include "system/kvm.h" #include "target/arm/cpu-qom.h" +#include "cpu-idregs.h" #define KVM_ARM_VGIC_V2 (1 << 0) #define KVM_ARM_VGIC_V3 (1 << 1) @@ -241,4 +242,6 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3); */ char *kvm_print_register_name(uint64_t regidx); +bool kvm_idreg_write_scratch_vcpu(ARMCPU *cpu, ARM64SysRegField *field, + uint64_t newfv, Error **errp); #endif diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c index 88cbe8d85c..029514a53d 100644 --- a/target/arm/kvm-stub.c +++ b/target/arm/kvm-stub.c @@ -119,3 +119,9 @@ char *kvm_print_register_name(uint64_t regidx) { g_assert_not_reached(); } + +bool kvm_idreg_write_scratch_vcpu(ARMCPU *cpu, ARM64SysRegField *field, + uint64_t newfv, Error **errp) +{ + g_assert_not_reached(); +} diff --git a/target/arm/kvm.c b/target/arm/kvm.c index a7f8f0c46b..4c3d69b7b2 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1313,6 +1313,29 @@ kvm_arm_set_idreg_field(ARMCPU *cpu, ARM64SysRegField *field, return 0; } +bool kvm_idreg_write_scratch_vcpu(ARMCPU *cpu, ARM64SysRegField *field, + uint64_t newfv, Error **errp) +{ + uint64_t appliedfv; + int ret; + + assert(CPU(cpu)->kvm_fd); + + if (!arm_cpu_validate_sysreg_prop(cpu, field, newfv, errp)) { + return false; + } + + ret = kvm_arm_set_idreg_field(cpu, field, newfv, &appliedfv, errp); + if (ret) { + return false; + } + + cpu->isar.idregs[field->index] = + deposit64(cpu->isar.idregs[field->index], + field->shift, field->length, appliedfv); + return true; +} + void kvm_arm_reset_vcpu(ARMCPU *cpu) { int ret; diff --git a/target/arm/trace-events b/target/arm/trace-events index fce80175e3..9179a90f6d 100644 --- a/target/arm/trace-events +++ b/target/arm/trace-events @@ -15,6 +15,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64 get_host_cpu_idregs(const char *name, uint64_t value) "scratch vcpu host value for %s is 0x%"PRIx64 kvm_arm_set_idreg_field(const char *reg_name, const char *field_name, uint64_t currentfv, uint64_t newfv, uint64_t appliedfv) "%s.%s current=0x%"PRIx64" new=0x%"PRIx64" applied=0x%"PRIx64 +kvm_arm_idreg_write_scratch_vcpu(const char *name, uint64_t oldfv, uint64_t newfv, uint64_t actualfv) "successful dry-run for %s old=0x%"PRIx64" new=0x%"PRIx64" actual=0x%"PRIx64 # cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64 -- 2.56.1