From nobody Thu Apr 3 11:40:42 2025 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=1743011005; cv=none; d=zohomail.com; s=zohoarc; b=O0vXYgf0UlSPwcoejkE1HFQ/KA6rFROugcMOC6SCyVvrCdkk7OHh/Ab5OriGfBWMACOJf97E3pFuqacho/mIUVjhkjWIGlxnWcePGRpsnvA+XzbUoeLyDLZ7VMHv9nFUtoP+Gkg1tvVRFYaaI5NZthg+dATuQXNMOmil9Q4XFhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743011005; h=Content-Type: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=KhUgn4/7zQGJ2lgryJzEz6u4zhgrsTQVznT5OXMnSBY=; b=hLHSz6WUrt8E5VlBvIEN9M8VZ1HphYC6z+4bkQhiKzrrpj94gZG/MgxbKs8IEx8ue5aikMUT7VU/kONvhQ/c1W6FHAqjFuevPiS/Rx+OV1jjo2E3ZfvQ7k2GkBlF3nlrogburingIz9j6aNzyTYJ7Wv9iO/NIx939qCnAsp2+pU= 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 1743011005571178.44654916584705; Wed, 26 Mar 2025 10:43:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txUlC-0001LK-7j; Wed, 26 Mar 2025 13:41:50 -0400 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 1txUkd-00084H-L2 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 13:41:16 -0400 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 1txUka-0005ej-Av for qemu-devel@nongnu.org; Wed, 26 Mar 2025 13:41:15 -0400 Received: from mx-prod-mc-03.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-477-CQ6NefqcPT2EHJBqF-lQYw-1; Wed, 26 Mar 2025 13:41:08 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E382A19560B0; Wed, 26 Mar 2025 17:41:05 +0000 (UTC) Received: from gondolin.redhat.com (unknown [10.67.24.38]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04E6C180B489; Wed, 26 Mar 2025 17:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743010871; 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=KhUgn4/7zQGJ2lgryJzEz6u4zhgrsTQVznT5OXMnSBY=; b=EKsBbFQ1GaepJ4NC5P3ZpKmjjb8a4OGLglGLJP6atGv0Is9EdTBKdSn3ju1UJWmmGmaM+Q OyK+TpcTLbx9yvFytmdFIwVE/PTvA7HNGXed3VgoMiSS6gkfhtp0WaQ/ul4WN74ImqoAd5 waAU1z1G9ED4PhEVaz58AqykMtAqujE= X-MC-Unique: CQ6NefqcPT2EHJBqF-lQYw-1 X-Mimecast-MFC-AGG-ID: CQ6NefqcPT2EHJBqF-lQYw_1743010866 From: Cornelia Huck 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, richard.henderson@linaro.org, alex.bennee@linaro.org, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, shameerali.kolothum.thodi@huawei.com, armbru@redhat.com, berrange@redhat.com, abologna@redhat.com, jdenemar@redhat.com, agraf@csgraf.de Cc: shahuang@redhat.com, mark.rutland@arm.com, philmd@linaro.org, pbonzini@redhat.com, Cornelia Huck Subject: [PATCH for-10.1 v4 12/13] arm/cpu: Add sysreg generation scripts Date: Wed, 26 Mar 2025 18:37:22 +0100 Message-ID: <20250326173723.389988-13-cohuck@redhat.com> In-Reply-To: <20250326173723.389988-1-cohuck@redhat.com> References: <20250326173723.389988-1-cohuck@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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.129.124; envelope-from=cohuck@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.001, 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_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1743011007754019100 Content-Type: text/plain; charset="utf-8" From: Eric Auger Introduce scripts that automate the generation of system register definitions from a given linux source tree arch/arm64/tools/sysreg. Invocation of ./update-aarch64-sysreg-code.sh $PATH_TO_LINUX_SOURCE_TREE in scripts directory generates target/arm/cpu-sysregs.h.inc containing defines for all system registers. [CH: update to handle current kernel sysregs structure, and to emit the re-worked register structures; cpu properties will be added later] Reviewed-by: Sebastian Ott Signed-off-by: Eric Auger Signed-off-by: Cornelia Huck --- scripts/gen-cpu-sysregs-header.awk | 35 +++++++++++++++++++++++++++ scripts/update-aarch64-sysreg-code.sh | 25 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 scripts/gen-cpu-sysregs-header.awk create mode 100755 scripts/update-aarch64-sysreg-code.sh diff --git a/scripts/gen-cpu-sysregs-header.awk b/scripts/gen-cpu-sysregs-h= eader.awk new file mode 100755 index 000000000000..b6b207e3c0fd --- /dev/null +++ b/scripts/gen-cpu-sysregs-header.awk @@ -0,0 +1,35 @@ +#!/bin/awk -f +# SPDX-License-Identifier: GPL-2.0 +# gen-cpu-sysregs-header.awk: arm64 sysreg header include generator +# +# Usage: awk -f gen-cpu-sysregs-header.awk $LINUX_PATH/arch/arm64/tools/sy= sreg + +BEGIN { + print "" +} END { + print "" +} + +# skip blank lines and comment lines +/^$/ { next } +/^[\t ]*#/ { next } + +/^Sysreg\t/ || /^Sysreg /{ + + reg =3D $2 + op0 =3D $3 + op1 =3D $4 + crn =3D $5 + crm =3D $6 + op2 =3D $7 + + if (op0 =3D=3D 3 && (op1>=3D0 && op1<=3D3) && crn=3D=3D0 && (crm>=3D0 && = crm<=3D7) && (op2>=3D0 && op2<=3D7)) { + print "DEF("reg", "op0", "op1", "crn", "crm", "op2")" + } + next +} + +{ + /* skip all other lines */ + next +} diff --git a/scripts/update-aarch64-sysreg-code.sh b/scripts/update-aarch64= -sysreg-code.sh new file mode 100755 index 000000000000..721f41a9a516 --- /dev/null +++ b/scripts/update-aarch64-sysreg-code.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +# Update target/arm/cpu-sysregs.h +# from a linux source tree (arch/arm64/tools/sysreg) +# +# Copyright Red Hat, Inc. 2024 +# +# Authors: +# Eric Auger +# + +linux=3D"$1" +output=3D"$PWD" + +if [ -z "$linux" ] || ! [ -d "$linux" ]; then + cat << EOF +usage: update-aarch64-sysreg-code.sh LINUX_PATH + +LINUX_PATH Linux kernel directory to obtain the headers from +EOF + exit 1 +fi + +awk -f gen-cpu-sysregs-header.awk \ + $linux/arch/arm64/tools/sysreg > ../target/arm/cpu-sysregs.h.inc --=20 2.48.1