Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADDFC377575 for ; Sat, 10 Oct 2026 13:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791639572; cv=none; b=uXa94sEYVtL6aBdy3AC32jIiYRscxVJFCvZCCl13QAZ8yk1XNo2+PAEoNR7sMArCjdnfAVy8jnWHupXpdb36Orv8DVmRGNSHTg7Dsvth0jluoTCIcZqOipsCtjDOaOaMhwtFQKG+r9rtae0CCXLvx9B0vY4ZCCha2zuFirHnZ88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791639572; c=relaxed/simple; bh=OGUmqoPLip8313/60nB8PrV7x/oqdS20wjv9SjM379E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=dfxjtnfzMxmwremyDiAU41HAvElSydVaXfxI9eiyL+HifWF2wdLfn3xQumQpUKsYOSrRKHM5iTXlVCfAGYGlqcz9pHSyTlxzrh9WFP4llGTKQjCilc2so4eL3Bo5+F2NR3T/m/YmlJpg2jWgpYO4jZ/PRnELFICUqumY7fQzTdw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MIVFUFhl; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MIVFUFhl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791639570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I182iXUY+xPUHsg/tWpxySUU31EcXiYq269W9BRBUwM=; b=MIVFUFhljsEeYFoiZghE5BgOaDHmGj/vSVplW1uYIXIb+sSrbI+ooJm8U7j7wyuT8Ml8aQ jWuku1leDVABWG3M7/uZOhiaI4NY3TKbIeQlnPBr3cnprWpZfYNwHCx9cb143jzykcLzIp yEtGnKkL+ApZng7MBJXykX8MJoc5pnM= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-546-bqol17HYOlSzvKJOAYfmiw-1; Sat, 10 Oct 2026 13:39:27 +0000 X-MC-Unique: bqol17HYOlSzvKJOAYfmiw-1 X-Mimecast-MFC-AGG-ID: bqol17HYOlSzvKJOAYfmiw_1791639565 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B2DE180ACC7; Sat, 10 Oct 2026 13:39:25 +0000 (UTC) Received: from laptop.redhat.corp (headnet03.pony-001.prod.iad2.dc.redhat.com [10.2.32.114]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7431930000E5; Sat, 10 Oct 2026 13:39:20 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, kvmarm@lists.linux.dev, peter.maydell@linaro.org, shaju.abraham@nutanix.com, khushit.shah@nutanix.com, yangjinqian1@huawei.com, cohuck@redhat.com, richard.henderson@linaro.org, sebott@redhat.com, skolothumtho@nvidia.com, philmd@oss.qualcomm.com Cc: maz@kernel.org, oliver.upton@linux.dev, pbonzini@redhat.com, armbru@redhat.com, berrange@redhat.com, abologna@redhat.com, jdenemar@redhat.com Subject: [PATCH v10 22/26] target/arm/kvm: Add an error handle to kvm_arm_create_scratch_host_vcpu Date: Sat, 10 Oct 2026 15:36:26 +0200 Message-ID: <20261010133725.642498-23-eric.auger@redhat.com> In-Reply-To: <20261010133725.642498-1-eric.auger@redhat.com> References: <20261010133725.642498-1-eric.auger@redhat.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-MFC-PROC-ID: GrkLf4KfOJRKISjmO1cA6mIG4gXvJgXASM4MqhPM8IE_1791639565 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true This allows to report a precise error message if any error occurs. Signed-off-by: Eric Auger --- target/arm/kvm_arm.h | 3 ++- target/arm/kvm.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 25a1dec095..ccab33e571 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -106,6 +106,7 @@ struct kvm_vcpu_init; * @init: filled in with the necessary values for creating a host * vcpu. If NULL is provided, will not init the vCPU (though the cpufd * will still be set up). + * @errp: Error handle * * Create a scratch vcpu in its own VM of the type preferred by the host * kernel (as would be used for '-cpu host'), for purposes of probing it @@ -115,7 +116,7 @@ struct kvm_vcpu_init; * false on failure (and fdarray and init are not valid). */ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, - struct kvm_vcpu_init *init); + struct kvm_vcpu_init *init, Error **errp); /** * kvm_arm_destroy_scratch_host_vcpu: diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 82ffcac7e3..1f6f9ba586 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -107,13 +107,14 @@ static int kvm_arm_vcpu_finalize(ARMCPU *cpu, int feature) } bool kvm_arm_create_scratch_host_vcpu(int *fdarray, - struct kvm_vcpu_init *init) + struct kvm_vcpu_init *init, Error **errp) { int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1; int max_vm_pa_size; kvmfd = qemu_open_old("/dev/kvm", O_RDWR); if (kvmfd < 0) { + error_setg(errp, "Failed opening /dev/kvm"); goto err; } max_vm_pa_size = ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_VM_IPA_SIZE); @@ -124,6 +125,7 @@ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size); } while (vmfd == -1 && errno == EINTR); if (vmfd < 0) { + error_setg(errp, "Failed creating the scratch VM"); goto err; } @@ -143,6 +145,7 @@ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, cpufd = ioctl(vmfd, KVM_CREATE_VCPU, 0); if (cpufd < 0) { + error_setg(errp, "Failed creating the scratch VCPU"); goto err; } @@ -156,12 +159,14 @@ bool kvm_arm_create_scratch_host_vcpu(int *fdarray, ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, &preferred); if (ret < 0) { + error_setg(errp, "Failed getting the preferred target"); goto err; } init->target = preferred.target; } ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); if (ret < 0) { + error_setg(errp, "Failed the init of the scratch vcpu"); goto err; } @@ -380,6 +385,7 @@ kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) bool el2_supported; bool pmu_supported = false; uint64_t features = 0; + Error *local_err = NULL; int err; ahcf->target = QEMU_KVM_ARM_TARGET_NONE; @@ -427,7 +433,8 @@ kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) features |= 1ULL << ARM_FEATURE_PMU; } - if (!kvm_arm_create_scratch_host_vcpu(fdarray, &init)) { + if (!kvm_arm_create_scratch_host_vcpu(fdarray, &init, &local_err)) { + error_report_err(local_err); return; } @@ -2838,8 +2845,10 @@ void arm_cpu_kvm_set_irq(void *arm_cpu, int irq, int level) void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3) { int fdarray[3]; + Error *err = NULL; - if (!kvm_arm_create_scratch_host_vcpu(fdarray, NULL)) { + if (!kvm_arm_create_scratch_host_vcpu(fdarray, NULL, &err)) { + error_report_err(err); return; } -- 2.53.0