From nobody Tue Feb 10 04:03:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612705602; cv=none; d=zohomail.com; s=zohoarc; b=ihpnwPSSPKCl6/Y6FH2LmbYwaK2gUA5+8m/FMZWKDpjKosv4a+BGgUkKvgTAENJLH1s4vzUHsSc/qnpbnqH+/+Jkpfbh86f2Pi2zlxZpugPxaTVHn4wR12iEzzYfgDLOcH9jk2j2KyGGMspYGDurWBwuB5FZM30zE/bs3/CqAk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612705602; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U45UFktSBXsLwodYlUHIi/9W9W+dC+uO3Sc2pf7Dw34=; b=m5sVPKZqCJrqnYGwGgdquSO2KPSn/expsgaJAys+ONC2NI0Ua+bptSW4kgUa3ueVcwCC8CMKblF8sZNugfjoq0Nlpc2nk6pu8e1SAkMs4KcbasARfL1Vv2AVGwPdfVMWFvbtFIk8Yub+EWM0fa7nPcdxLfi5dO9D5cjkjZDPXUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612705602141138.49685074945205; Sun, 7 Feb 2021 05:46:42 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-gFIkWyeGN-e9WgAi71Wlrg-1; Sun, 07 Feb 2021 08:46:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 330F71005501; Sun, 7 Feb 2021 13:46:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A12160BF3; Sun, 7 Feb 2021 13:46:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C741C4E58E; Sun, 7 Feb 2021 13:46:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 117Dk9Do031814 for ; Sun, 7 Feb 2021 08:46:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F58319D9D; Sun, 7 Feb 2021 13:46:09 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F5A619D9C for ; Sun, 7 Feb 2021 13:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612705601; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=U45UFktSBXsLwodYlUHIi/9W9W+dC+uO3Sc2pf7Dw34=; b=bpJzJ5LCpOoEunYe7tLGiJuaJDs7Tylf8Qm07fBnD04Hos55fqrJ4UA11nJQ8fkFAnhd0E FracVe9u76GLlcWrA9gqDLtsf4HRgyBWYiJiUNo07/ytQo7CoUaWB3KnVd6lJvDtCW7Fvf vjQOqnOynDh25CMNjIRNmvgNvPQqW+8= X-MC-Unique: gFIkWyeGN-e9WgAi71Wlrg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] cpu: Only retrieve AT_HWCAP once Date: Sun, 7 Feb 2021 14:45:58 +0100 Message-Id: <20210207134559.72578-3-abologna@redhat.com> In-Reply-To: <20210207134559.72578-1-abologna@redhat.com> References: <20210207134559.72578-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" No need to fetch the same information twice. As a side effect, this solves a bug where, on platforms where elf_aux_info() is used instead of getauxval(), we would not make sure the CPUID feature is available before attempting to use it. Signed-off-by: Andrea Bolognani --- src/cpu/cpu_arm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index aa3e5d8980..71702dbc91 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -557,12 +557,19 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) size_t i; =20 # if defined(WITH_GETAUXVAL) - if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { + hwcaps =3D getauxval(AT_HWCAP); +# elif defined(WITH_ELF_AUX_INFO) + elf_aux_info(AT_HWCAP, &hwcaps, sizeof(u_long)); +# else +# error No routines to retrieve a value from the auxiliary vector +# endif + VIR_DEBUG("CPU flags read from register: 0x%016lx", hwcaps); + + if (!(hwcaps & HWCAP_CPUID)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CPUID registers unavailable")); return -1; } -# endif =20 /* read the cpuid data from MIDR_EL1 register */ asm("mrs %0, MIDR_EL1" : "=3Dr" (cpuid)); @@ -573,15 +580,6 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) /* parse the corresponding vendor_id bits */ data->vendor_id =3D (cpuid >> 24) & 0xff; =20 -# if defined(WITH_GETAUXVAL) - hwcaps =3D getauxval(AT_HWCAP); -# elif defined(WITH_ELF_AUX_INFO) - elf_aux_info(AT_HWCAP, &hwcaps, sizeof(u_long)); -# else -# error No routines to retrieve a value from the auxiliary vector -# endif - VIR_DEBUG("CPU flags read from register: 0x%016lx", hwcaps); - features =3D g_new0(char *, MAX_CPU_FLAGS + 1); =20 /* shift bit map mask to parse for CPU flags */ --=20 2.26.2