From nobody Sun Apr 28 10:01:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1594218790; cv=none; d=zohomail.com; s=zohoarc; b=XsgstdG54pAghXLMt6W8eMy9zvpcOjelRcp/rqiLHJesAcRvF/MAMObBpPGBjB5bQNkP+dhTqXZjATtKD6P5fhWvKdzQ4N0EE1s+eT38kaRQb5KyjsciRUdO+Mf2U+Ikm8yX4Np0IapJtePGKzxNTolSRmv2o3ekDZl+nyBL0x4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594218790; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=i+V43HGVcd679DiEc0LUXfIurtj/uYpbL5KImF+Kkq8=; b=au/iCOoBdsK991LZgVRwd2KI7pKWXKJUllnR0M23FxtYlguSf/mzYnXoOhUujCSF+ZY1llzZ8t2tkopN/wC3puPNXrlOIm7Ke4Me8wqt+KW8VHTr6PL9w0FAkarGV/xasfNjsC8T0Ipt5r8l5BGMBazi4GyiK+4yILImp8PojOc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594218790934397.45095564768974; Wed, 8 Jul 2020 07:33:10 -0700 (PDT) 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-76-zk5MZwnDOxCpmKDWB2GinQ-1; Wed, 08 Jul 2020 10:33:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0170E1054F8F; Wed, 8 Jul 2020 14:33:01 +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 91BB35C1D3; Wed, 8 Jul 2020 14:33:00 +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 E84BC93F63; Wed, 8 Jul 2020 14:32:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 068EScs0022996 for ; Wed, 8 Jul 2020 10:28:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 179202166BA0; Wed, 8 Jul 2020 14:28:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4F64201B152 for ; Wed, 8 Jul 2020 14:28:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B0BC924914 for ; Wed, 8 Jul 2020 14:28:35 +0000 (UTC) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-v_93rs2lPRue4wrYMZaXrQ-1; Wed, 08 Jul 2020 10:28:33 -0400 Received: by mail-lj1-f194.google.com with SMTP id h19so54537472ljg.13 for ; Wed, 08 Jul 2020 07:28:32 -0700 (PDT) Received: from kloomba.my.domain ([5.227.250.28]) by smtp.gmail.com with ESMTPSA id u7sm9092lfi.45.2020.07.08.07.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 07:28:30 -0700 (PDT) X-MC-Unique: zk5MZwnDOxCpmKDWB2GinQ-1 X-MC-Unique: v_93rs2lPRue4wrYMZaXrQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=i+V43HGVcd679DiEc0LUXfIurtj/uYpbL5KImF+Kkq8=; b=ZM9yzlSqfH91pU+0xLkuk476KO3RO5zttZCEdqw/Z/bOPnQCy8tAfjh+6yyDpO0AKZ GorWeW+wOF3jtxRdCJxXxkkz65nFlotxYytPwglufAv4gRl7oJ0LXWa2Is4mz6uGQFIc Elq/Ui8zKby1258g0Yz4dg6yiqXwxvWeLcXbgXTQWXOOea41/FK5n+xDQKMxkF1zF+x0 thLtKQIfteYnwifDXB0XJfZM86q1PHIndHvHLWmcdXzlWPG9hiRS409tHEfXIuRuE6vn vBtYT5kivl2KsjCKtCAsB0/21uSoqlnK4p/yS3i1G3C6+mYZShn8wScCEx4TkJo+bGLV GxFg== X-Gm-Message-State: AOAM532rt7NLOZ4rh5Cw7IIQyVsUB9KLVAR3znHXi+Bonulph9C5qed+ 2p5Su7ibq9Uj1ocFkS4QyuFQlYlUQV4= X-Google-Smtp-Source: ABdhPJzB/PScnCt6DYnoKhFUug4/K8otYFAK3WrEQryXven3k4JSONL7UBL2Stbc4dqAUmy9XZDRgw== X-Received: by 2002:a05:651c:32c:: with SMTP id b12mr34363976ljp.326.1594218511143; Wed, 08 Jul 2020 07:28:31 -0700 (PDT) From: Roman Bogorodskiy To: libvir-list@redhat.com Subject: [PATCH] cpu_arm: fix build on non-Linux Date: Wed, 8 Jul 2020 18:28:17 +0400 Message-Id: <20200708142817.854-1-bogorodskiy@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 08 Jul 2020 10:32:57 -0400 Cc: Roman Bogorodskiy 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.16 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 Content-Type: text/plain; charset="utf-8" - Add a check for asm/hwcap.h header presence, - Add a check for getauxval() function that is used on Linux, and for elf_aux_info() which is a FreeBSD equivalent. This is based on a patch submitted by Mikael Urankar in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247722. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- configure.ac | 3 +++ src/cpu/cpu_arm.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 79055db9b1..40a326c1aa 100644 --- a/configure.ac +++ b/configure.ac @@ -345,7 +345,9 @@ AC_CHECK_SIZEOF([long]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([\ + elf_aux_info \ fallocate \ + getauxval \ getegid \ geteuid \ getgid \ @@ -374,6 +376,7 @@ AC_CHECK_FUNCS_ONCE([\ =20 dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([\ + asm/hwcap.h \ ifaddrs.h \ libtasn1.h \ util.h \ diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index cd4f720c95..fbc363e9c7 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -22,7 +22,9 @@ =20 #include #if defined(__aarch64__) -# include +# if defined(HAVE_ASM_HWCAP_H) +# include +# endif # include #endif =20 @@ -518,11 +520,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) int cpu_feature_index =3D 0; size_t i; =20 +# if defined(HAVE_GETAUXVAL) if (!(getauxval(AT_HWCAP) & 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)); @@ -533,7 +537,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) /* parse the coresponding vendor_id bits */ data->vendor_id =3D (cpuid >> 24) & 0xff; =20 +# if defined(HAVE_GETAUXVAL) hwcaps =3D getauxval(AT_HWCAP); +# elif defined(HAVE_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); =20 features =3D g_new0(char *, MAX_CPU_FLAGS + 1); --=20 2.27.0