From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120453; cv=none; d=zohomail.com; s=zohoarc; b=hROjNF23mmExrnlcGRgn/DCUpkomb9jIhoD8d+XH1G2Pr8XFzoxEXDp2uh8ksUmEvnvvOd3MvT91AhqExe950eO3g76mjfnsv1wswNCOwW49Nv5w/hOwaIqZMX2aVgwtO2oeDZDBEmExNX8X0Gq7kWTazDsteibs67xcczesm1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120453; 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=QtnPnkI6JE32KFQWMPapGJT07TBBs4s4tJxaXGLRcDU=; b=eOO6WonB5qioxUgzP2nz8v32Ix01mQDeAZqMp3L7EwGy3/5RPR6jzC1DlsKtVqAFjR+bD8cf+p8OenNkROZVBTXW6m1ECvT/UvyQkXeUbIdTkP0hiLnMBme/cPcstjqe6prXzgQ8qg/e4w5g6rmGfmKhL0WAzUdW6CKVVOpjPfU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120453332115.54030078519406; Mon, 6 Mar 2023 08:34:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrM-0003zO-No; Mon, 06 Mar 2023 10:34:45 -0500 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 1pZCrJ-0003yS-P7 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:41 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrH-00027u-Qf for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:41 -0500 Received: by mail-wm1-x329.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so8464475wmb.5 for ; Mon, 06 Mar 2023 07:34:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QtnPnkI6JE32KFQWMPapGJT07TBBs4s4tJxaXGLRcDU=; b=pOWJX9VVpK0P+zxEZLty06XBiWsbP9i7kHlMDtDABGAZlPCe5E4Tgt5WgwTx+okZqv BlshPaWjS3Cx/0PGMe0KJmTYVdvAWZhOLXe8Igix6JqnbczjVLvjIEAnCTevzh6j8Gug /GDMRNYlXAeMmjzSipQRPlIWypodpo7qeWm7ags+8splIBFI9eMzBemj+aJwTELFkm/K X3lEk2mCWI6CEy0UCcL8FyCSTSVG+mM+jKZY9UjENBpSpN77zdAYS3budCHhqzDObcwz SDFcfbgsW/8WReIngxbhREBYL9EqNzFnPmCsP8tnBAJmB6/oBvCgOHnrPMuJEL8bE+wG /9VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QtnPnkI6JE32KFQWMPapGJT07TBBs4s4tJxaXGLRcDU=; b=FewK8OvmJjh4s8d3um0exMSaVuqe/SVpX0Jx+M3Vuqf3iWYsEjgYCY2DIFfZjGxXbi NLDAaNK8vih77Iyqg1SFasDobl/IdLwYYXfDnAgyjBNbn+qv5XTBaibtYFbCXxj36bEW DkhXoiZ0sH3VhcJe+EZdnrduzMZCD9NeF6P4I5GunTD1Jxz0pU6EzRLjoMBRLag5CclY gTz+kNquInIQH0ilznQmlKWX8JtzfSJD4mPpbHfUR/uW82AMS0XeMbWkikePBbbF3a99 C4YNPFW4pSTWBlzMISE2UnLakQomUjpKc3DAG8AizSLqRbB4jBxWiahEfEN1B7zIfBxD B1JQ== X-Gm-Message-State: AO0yUKW5LTpbLyl/pPjMREuLuCGPh2D+w60POZvs53cEGa2x1+fVFppd 6uAxMWFoYnW1EPFUonZJC70MHi29Flqz8lKzsCo= X-Google-Smtp-Source: AK7set83iLAYTM/TwsWdUzlkzhYCl1+G1eZj3GQQBcpKuowzHUNVwke1DP+0XBeDRxpap+RUaIDHyA== X-Received: by 2002:a05:600c:19cf:b0:3e7:772d:22de with SMTP id u15-20020a05600c19cf00b003e7772d22demr9494889wmq.30.1678116878561; Mon, 06 Mar 2023 07:34:38 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/21] target/arm: Normalize aarch64 gdbstub get/set function names Date: Mon, 6 Mar 2023 15:34:15 +0000 Message-Id: <20230306153435.490894-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120453713100001 From: Richard Henderson Make the form of the function names between fp and sve the same: - arm_gdb_*_svereg -> aarch64_gdb_*_sve_reg. - aarch64_fpu_gdb_*_reg -> aarch64_gdb_*_fpu_reg. Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 8 ++++---- target/arm/gdbstub.c | 9 +++++---- target/arm/gdbstub64.c | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 3c7341e7741..f99d0d98413 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1344,10 +1344,10 @@ static inline uint64_t pmu_counter_mask(CPUARMState= *env) } =20 #ifdef TARGET_AARCH64 -int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg); -int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); -int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); -int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); +int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); +int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); +int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); +int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg); void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 2f806512d0a..cf1c01e3cf5 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -466,12 +466,13 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - gdb_register_coprocessor(cs, arm_gdb_get_svereg, arm_gdb_set_s= vereg, - arm_gen_dynamic_svereg_xml(cs, cs->gd= b_num_regs), + int nreg =3D arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs); + gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, + aarch64_gdb_set_sve_reg, nreg, "sve-registers.xml", 0); } else { - gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, - aarch64_fpu_gdb_set_reg, + gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg, + aarch64_gdb_set_fpu_reg, 34, "aarch64-fpu.xml", 0); } #endif diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 07a6746944d..c598cb03759 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -72,7 +72,7 @@ int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) return 0; } =20 -int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg) { switch (reg) { case 0 ... 31: @@ -92,7 +92,7 @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray = *buf, int reg) } } =20 -int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg) { switch (reg) { case 0 ... 31: @@ -116,7 +116,7 @@ int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *= buf, int reg) } } =20 -int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu =3D env_archcpu(env); =20 @@ -164,7 +164,7 @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *bu= f, int reg) return 0; } =20 -int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) { ARMCPU *cpu =3D env_archcpu(env); =20 --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120094; cv=none; d=zohomail.com; s=zohoarc; b=ZscLDo7kbrofM7mSs0WmSGpzGrqLrK3Vo6GuCpthpvD4aox+rK0RCWwPtgfdAwW6PI5g3LtTteOjl5175Zamu5QUYfi/WDbrmyKI6XBGLqbSpgexDVuVGuvnFHopozo0Qv3HnTuA0k9HLAwYiiVQIoQLjKgVTl8U8AQkLpz/kY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120094; 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=8pZNSlYZUhjpU3KiX8JJtXqrL7cmbP2NKCT1L8eto8M=; b=h3DdokhdMhnIqf2Wko8ELyXMf+7ksyH/fIGnSEcaGoZKbIgL08711zVpbm+bQ2R0KSRfKe4n3l1qYyQcKUutBNhGXF2EZc0FzRdv9u4hHZMDCC1bHJxidu9iqOssoAoCBwfPRzdgeElvGNX4j2C4XtIxYRi10TRCu/PjDo0VXlg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167812009448948.821128979249806; Mon, 6 Mar 2023 08:28:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrO-00041v-K4; Mon, 06 Mar 2023 10:34:46 -0500 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 1pZCrK-0003ye-OU for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:42 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrI-000282-Rm for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:42 -0500 Received: by mail-wm1-x32c.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so8464513wmb.5 for ; Mon, 06 Mar 2023 07:34:40 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8pZNSlYZUhjpU3KiX8JJtXqrL7cmbP2NKCT1L8eto8M=; b=TsasPpompzW0mfG7eMwo4DHYiJezGDsyiK8ppkTy3fVSNGAs557SlAL4X+lSIEV9vK 0fVjHnetIJNt2IZgas7V4NDiAL9czYZfRsGXpaLdbHOs/kYlqaWweHxQiUbIllIok8uX 9vmyFo23huG8Ty6pag9G/GGQWOvANRFOU1ckKyzqYphMgC/wTz1XWLXmE6pywNyeiIuY ulx7bjJCuzWXa+tbNA5YOxvMQRoYDsPWRTBHSj3n4w7ZNqpFEKhhHGlL5H/CUUK9tYKq kX6XR3WHC9zjg8wXacK1luSaJLuHdZ1M8Uuxy1NkVSHMd4ZtiyfUtUeqxt9eDlUwJ7JF 0jTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8pZNSlYZUhjpU3KiX8JJtXqrL7cmbP2NKCT1L8eto8M=; b=4XAC4elTTYhmcAut+G1sjeyisDzvqyY/ClNZWC4NHnoscABEiMldxTTaEWJlQXxe7C v33kLOS4xIDcv/PHpsbjV0OU7um+es6jBBUnfOzNQUVnhhw7qrZ53GaqHXdVV6TOZPfk 5QHhkmuSXMHU/lvrMpQNQ0Vlnu4DaaSUPDw3Uj0RN/evOV5jo2W/2UlG5IjQQVv6WqFN wuAQXuV543QRsU96dRwxCt4riOeIDobyeNR06sQ0T8ro3ZS+QHFbw9SmHuivei+AJCqV wd6l84msK6LoO8kzciSLMK3s+gZUpvNkW83ZWMgS/514gT8btJNLYPorZfM5Tzg+pvxP aa5g== X-Gm-Message-State: AO0yUKU92q4T/yzVpiv+z0z9TigmTkEmc+xUuhwmXy4au8C4s9YdTd5F QyFp1hR5cSpE7hNy0RYVNNmXV8w872q4OKXk9Eg= X-Google-Smtp-Source: AK7set9Jthh7+o7U+REuZACUKDFFrBKPpwRPk5TGGkHE0vd+Z+PW+PovDRd+x/ki2rA0ZJfM/nw/Lw== X-Received: by 2002:a05:600c:468b:b0:3df:fcbd:3159 with SMTP id p11-20020a05600c468b00b003dffcbd3159mr7488934wmo.3.1678116879255; Mon, 06 Mar 2023 07:34:39 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/21] target/arm: Unexport arm_gen_dynamic_sysreg_xml Date: Mon, 6 Mar 2023 15:34:16 +0000 Message-Id: <20230306153435.490894-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120095990100003 From: Richard Henderson This function is not used outside gdbstub.c. Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 1 - target/arm/gdbstub.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 787121694c5..209800d50df 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1116,7 +1116,6 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t= *buf, int reg); * Helpers to dynamically generates XML descriptions of the sysregs * and SVE registers. Returns the number of registers in each set. */ -int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); =20 /* Returns the dynamically generated XML for the gdb stub. diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index cf1c01e3cf5..52581e9784c 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -305,7 +305,7 @@ static void arm_register_sysreg_for_xml(gpointer key, g= pointer value, } } =20 -int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) +static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120950; cv=none; d=zohomail.com; s=zohoarc; b=LMvj7zQr1lowgcBB6tBNRT4HAa6YcFJ7roPCWKbstuA4uvTX+SF/jesT7IOpNwl/v3xs/V0k1n4zDh+1x7pbiLyumx8klBib8Hbp8LwPDbyoCVUulKJ2EoSu0n54shuUaNqnmI0vHSrspsyDW/2qFv5pm859xQYZLb9MTPMEsmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120950; 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=ZMWtEOLAgQgDEm/tR2wSYNPZ7HSsKw5Qp0kP2ZEcS2A=; b=R2QFA6nblyJQ4wDMBIv6905qQ4/qX9lSjxcQGwqbag3zXP8cQAg8oeerDvIarZFccMfWb/hnSAqquYQUrxv11yl3BWYnmMixXxes8D91GyqTBl/EEiR+f9Fd4YC7BPppdvlOAJMegei77PKaBpCMIKTCIFdRrWmaMsVHzh5f0JQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167812095020815.753826055487593; Mon, 6 Mar 2023 08:42:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrR-00043q-LX; Mon, 06 Mar 2023 10:34:49 -0500 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 1pZCrM-0003z7-77 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:44 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrJ-000289-Cx for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:43 -0500 Received: by mail-wm1-x334.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so5452263wmq.1 for ; Mon, 06 Mar 2023 07:34:40 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZMWtEOLAgQgDEm/tR2wSYNPZ7HSsKw5Qp0kP2ZEcS2A=; b=O2eM7//WNEzI/g1/CT9G4OzYWhlVKhH34Goj5eUu6vOxi0MT+Z0JIeaN7kiza0n3c5 KE9MjmkI53Ga5wkBr2O6C0W/PJboO3l4F2VzZlKqq49/Blk57LOuIyA20EnXKW6HEIbG QdkxissVqTjfONQ8jqMhMBymRkdaLEWxXMwdOeX80QL4DJmjgI9+SKhvUsgzL6tlQwQb ohUIPFYOr7cyNVasxx7Y6UtsM0sTPjnPyO5BORTBIBaHEd0TVaOgcnKYFAHE5jRISfD3 y8xmV43BcfJTBTt8xuPlPoj6CmthTrHRKmPKRx6IrqWc2/qACkrT2SCX+3ZANjP4FWQD JyNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZMWtEOLAgQgDEm/tR2wSYNPZ7HSsKw5Qp0kP2ZEcS2A=; b=JGZHXKSlnAODREagdpotUACpdOFTTTC4wTiTxFWEaFpo/64KaXERdkyTAkmoOzyOcR P7R91qTViqWLshLZ7rBZ5ffo/3cHt9Iu1I58AnnJWtm43aREd9EMPlO6cU7oWeaQleHW 5i3XpEo+IuRRtlFBJ/fz92bp/FpIg+FqHbkZ/3+PhLHBLbQHiDr0jsNytoCBwk4hRxdn XFKCabx0u1qobAbebUqK67vewpSJQtYxsZWD4taYDNRPODpLOEflpki0kjZCYbjRc+MW 7aNT+bXefvJegC4NOeUZPKCnU+2IUQwbU/8Ci4SCGngfJBYoo4Rm07ExRBCT1MRbuOWu F6gA== X-Gm-Message-State: AO0yUKWCj63pxBCZgoCDEZvOxR9UGxcPfp0l9uVUJBPL1A8i1obmRMom 27TWoik6b2L9DkWMr32Zq73KuA5/1q+rvSQMnyA= X-Google-Smtp-Source: AK7set9G1c8Q/fdH4iCRGhyyTrDYrNxM87uAJLTny8SYF7GHFX2aeaV7UeH4ErkJqsmfhLyL89btcQ== X-Received: by 2002:a05:600c:4f8f:b0:3e2:1d3d:ec41 with SMTP id n15-20020a05600c4f8f00b003e21d3dec41mr7326216wmq.20.1678116880076; Mon, 06 Mar 2023 07:34:40 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/21] target/arm: Move arm_gen_dynamic_svereg_xml to gdbstub64.c Date: Mon, 6 Mar 2023 15:34:17 +0000 Message-Id: <20230306153435.490894-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120950764100001 From: Richard Henderson The function is only used for aarch64, so move it to the file that has the other aarch64 gdbstub stuff. Move the declaration to internals.h. Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 6 --- target/arm/internals.h | 1 + target/arm/gdbstub.c | 120 ----------------------------------------- target/arm/gdbstub64.c | 118 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 126 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 209800d50df..379e74d1f99 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1112,12 +1112,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *c= pu, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 -/* - * Helpers to dynamically generates XML descriptions of the sysregs - * and SVE registers. Returns the number of registers in each set. - */ -int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); - /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL * if the XML name doesn't match the predefined one. diff --git a/target/arm/internals.h b/target/arm/internals.h index f99d0d98413..15988768be3 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1344,6 +1344,7 @@ static inline uint64_t pmu_counter_mask(CPUARMState *= env) } =20 #ifdef TARGET_AARCH64 +int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 52581e9784c..bf8aff78241 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -322,126 +322,6 @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, i= nt base_reg) return cpu->dyn_sysreg_xml.num; } =20 -struct TypeSize { - const char *gdb_type; - int size; - const char sz, suffix; -}; - -static const struct TypeSize vec_lanes[] =3D { - /* quads */ - { "uint128", 128, 'q', 'u' }, - { "int128", 128, 'q', 's' }, - /* 64 bit */ - { "ieee_double", 64, 'd', 'f' }, - { "uint64", 64, 'd', 'u' }, - { "int64", 64, 'd', 's' }, - /* 32 bit */ - { "ieee_single", 32, 's', 'f' }, - { "uint32", 32, 's', 'u' }, - { "int32", 32, 's', 's' }, - /* 16 bit */ - { "ieee_half", 16, 'h', 'f' }, - { "uint16", 16, 'h', 'u' }, - { "int16", 16, 'h', 's' }, - /* bytes */ - { "uint8", 8, 'b', 'u' }, - { "int8", 8, 'b', 's' }, -}; - - -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; - g_autoptr(GString) ts =3D g_string_new(""); - int i, j, bits, reg_width =3D (cpu->sve_max_vq * 128); - info->num =3D 0; - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); - - /* First define types and totals in a whole VL */ - for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - int count =3D reg_width / vec_lanes[i].size; - g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suff= ix); - g_string_append_printf(s, - "", - ts->str, vec_lanes[i].gdb_type, count); - } - /* - * Now define a union for each size group containing unsigned and - * signed and potentially float versions of each size from 128 to - * 8 bits. - */ - for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; - g_string_append_printf(s, "", suf[i]); - for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { - if (vec_lanes[j].size =3D=3D bits) { - g_string_append_printf(s, "", - vec_lanes[j].suffix, - vec_lanes[j].sz, vec_lanes[j].suffi= x); - } - } - g_string_append(s, ""); - } - /* And now the final union of unions */ - g_string_append(s, ""); - for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; - g_string_append_printf(s, "", - suf[i], suf[i]); - } - g_string_append(s, ""); - - /* Finally the sve prefix type */ - g_string_append_printf(s, - "", - reg_width / 8); - - /* Then define each register in parts for each vq */ - for (i =3D 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); - info->num++; - } - /* fpscr & status registers */ - g_string_append_printf(s, "", base_reg++); - g_string_append_printf(s, "", base_reg++); - info->num +=3D 2; - - for (i =3D 0; i < 16; i++) { - g_string_append_printf(s, - "", - i, cpu->sve_max_vq * 16, base_reg++); - info->num++; - } - g_string_append_printf(s, - "", - cpu->sve_max_vq * 16, base_reg++); - g_string_append_printf(s, - "", - base_reg++); - info->num +=3D 2; - g_string_append_printf(s, ""); - cpu->dyn_svereg_xml.desc =3D g_string_free(s, false); - - return cpu->dyn_svereg_xml.num; -} - - const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) { ARMCPU *cpu =3D ARM_CPU(cs); diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index c598cb03759..59fb5465d5c 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -209,3 +209,121 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t= *buf, int reg) =20 return 0; } + +struct TypeSize { + const char *gdb_type; + short size; + char sz, suffix; +}; + +static const struct TypeSize vec_lanes[] =3D { + /* quads */ + { "uint128", 128, 'q', 'u' }, + { "int128", 128, 'q', 's' }, + /* 64 bit */ + { "ieee_double", 64, 'd', 'f' }, + { "uint64", 64, 'd', 'u' }, + { "int64", 64, 'd', 's' }, + /* 32 bit */ + { "ieee_single", 32, 's', 'f' }, + { "uint32", 32, 's', 'u' }, + { "int32", 32, 's', 's' }, + /* 16 bit */ + { "ieee_half", 16, 'h', 'f' }, + { "uint16", 16, 'h', 'u' }, + { "int16", 16, 'h', 's' }, + /* bytes */ + { "uint8", 8, 'b', 'u' }, + { "int8", 8, 'b', 's' }, +}; + +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + GString *s =3D g_string_new(NULL); + DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; + g_autoptr(GString) ts =3D g_string_new(""); + int i, j, bits, reg_width =3D (cpu->sve_max_vq * 128); + info->num =3D 0; + g_string_printf(s, ""); + g_string_append_printf(s, "= "); + g_string_append_printf(s, ""); + + /* First define types and totals in a whole VL */ + for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { + int count =3D reg_width / vec_lanes[i].size; + g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suff= ix); + g_string_append_printf(s, + "", + ts->str, vec_lanes[i].gdb_type, count); + } + /* + * Now define a union for each size group containing unsigned and + * signed and potentially float versions of each size from 128 to + * 8 bits. + */ + for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { + const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; + g_string_append_printf(s, "", suf[i]); + for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { + if (vec_lanes[j].size =3D=3D bits) { + g_string_append_printf(s, "", + vec_lanes[j].suffix, + vec_lanes[j].sz, vec_lanes[j].suffi= x); + } + } + g_string_append(s, ""); + } + /* And now the final union of unions */ + g_string_append(s, ""); + for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { + const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; + g_string_append_printf(s, "", + suf[i], suf[i]); + } + g_string_append(s, ""); + + /* Finally the sve prefix type */ + g_string_append_printf(s, + "", + reg_width / 8); + + /* Then define each register in parts for each vq */ + for (i =3D 0; i < 32; i++) { + g_string_append_printf(s, + "", + i, reg_width, base_reg++); + info->num++; + } + /* fpscr & status registers */ + g_string_append_printf(s, "", base_reg++); + g_string_append_printf(s, "", base_reg++); + info->num +=3D 2; + + for (i =3D 0; i < 16; i++) { + g_string_append_printf(s, + "", + i, cpu->sve_max_vq * 16, base_reg++); + info->num++; + } + g_string_append_printf(s, + "", + cpu->sve_max_vq * 16, base_reg++); + g_string_append_printf(s, + "", + base_reg++); + info->num +=3D 2; + g_string_append_printf(s, ""); + info->desc =3D g_string_free(s, false); + + return info->num; +} --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120924; cv=none; d=zohomail.com; s=zohoarc; b=lOsOhMn7wre9XYCZMW8rq9bTQvT0AmL2qEZEMi4OJv2zVSlNKjyQc5AabKXea93whZMStTcL71x5XBQUdsMqhtBYL8adLQpa59Fa7wtbt3Sn1XTIhjg2TniC9CXmyNE3+vljRkbdYhl5TrCbtZyV+HNY1YOzphsIPZFhFP9WTa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120924; h=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=8bAF/+U7+nkoPmy+fZgk3AeR5JQZaU99p3R4ntkDnNU=; b=F80cPPxdMFipSe/5axLDwuRgGBBFdW2uSjaV/GLV53KHKHnjAZQkpjffdwrFO/yO1FC4WqrdBldzyX555X1qLb2bf4csJGNi7xYX1l4cu7AaE24a5HV1goqA945Q1C7ngy6wdHiMqctFLS0/uTtAUuvRGL6DB/xFD9WBJqvDA6g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120924087796.8248694485073; Mon, 6 Mar 2023 08:42:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrR-00043l-30; Mon, 06 Mar 2023 10:34:49 -0500 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 1pZCrM-0003z6-6O for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:44 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrK-00028L-77 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:43 -0500 Received: by mail-wm1-x32f.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso5467690wmo.0 for ; Mon, 06 Mar 2023 07:34:41 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8bAF/+U7+nkoPmy+fZgk3AeR5JQZaU99p3R4ntkDnNU=; b=Dkky7gUrzcEWSXGjEMozIBcvTKfNE1Ag5nCsAKtOnsJEd3q73uG03BK5CAq9lQBZc5 vjXs4rTPwe+ZtEPKoNjluBBK7BPP6HeTeVrzwLN2E5EqQnO6Yz9brAGbjdlNiGJ7DoRD nqUZq+9qEGvE1+0h6Zd2Wf3PD18bGrxbbbAIiMz5XCAw+zAxDxArWozweNbPgKTtQ9O5 q/uXLSSDADcXS+txFbPjesEyZhp+/79nyIallseiZzdQpdGoAZceQhNSe22oBU3kCQ3F 1KPquURsQ+9mbsHPmRaVMwL4jY7Ka4dp8hkCn/Nn6aiB7NZu1b81KOb4crGaDSYUDAbx 1qLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8bAF/+U7+nkoPmy+fZgk3AeR5JQZaU99p3R4ntkDnNU=; b=JX1lxGDxVNuEVswPDIeTva6nW1v7kvOOJIT+BV4ZcTg9CDnsPGqgrS+oGQxqCOJzbR T4gZ0F/bTfSrtPLR+0abI6yKoU3ouVbuqwLk5Oosha8jou1ZZEdRFAAuulyINVyFz4qA Qc3gLn24WIOLjt17XWIhlwnLr2q4ZwLCmjOmzrViXpicb70rEgbJjTVHg4/IsnU+eLxy HLH+zmzfZgwwrO8vfYfrR2ufgNw58qVi+EbDJnO54wVhtSDTspNsuh0ZOtz28Pl/YCa5 GJ2raomfYfgCWelJdb+Bpw4oEX8mv4vGl+pGTyyQEPg2OGx3BKgIJ5JBN/4oJxnLGtUE g82g== X-Gm-Message-State: AO0yUKVHXLgXXC09HBjcYyY+qezaP0Wi4S1M1KZ8hqQBdA5IqzbaVWT0 rbCRdQG2nWfFQUxQtDoSiwV411uXBIIqbgYuZJ8= X-Google-Smtp-Source: AK7set8yGtaibLnED2wx17y88GwUwTIb8ldddR+t4hn8OuSTr8heectsPmOarQtKB75Fq1JzgBXnNw== X-Received: by 2002:a05:600c:4e8b:b0:3eb:3b7e:7b82 with SMTP id f11-20020a05600c4e8b00b003eb3b7e7b82mr9759701wmq.27.1678116880821; Mon, 06 Mar 2023 07:34:40 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/21] target/arm: Split out output_vector_union_type Date: Mon, 6 Mar 2023 15:34:18 +0000 Message-Id: <20230306153435.490894-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120924595100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Create a subroutine for creating the union of unions of the various type sizes that a vector may contain. Reviewed-by: Fabiano Rosas Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 83 +++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 59fb5465d5c..811833d8dec 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -210,44 +210,39 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t= *buf, int reg) return 0; } =20 -struct TypeSize { - const char *gdb_type; - short size; - char sz, suffix; -}; - -static const struct TypeSize vec_lanes[] =3D { - /* quads */ - { "uint128", 128, 'q', 'u' }, - { "int128", 128, 'q', 's' }, - /* 64 bit */ - { "ieee_double", 64, 'd', 'f' }, - { "uint64", 64, 'd', 'u' }, - { "int64", 64, 'd', 's' }, - /* 32 bit */ - { "ieee_single", 32, 's', 'f' }, - { "uint32", 32, 's', 'u' }, - { "int32", 32, 's', 's' }, - /* 16 bit */ - { "ieee_half", 16, 'h', 'f' }, - { "uint16", 16, 'h', 'u' }, - { "int16", 16, 'h', 's' }, - /* bytes */ - { "uint8", 8, 'b', 'u' }, - { "int8", 8, 'b', 's' }, -}; - -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +static void output_vector_union_type(GString *s, int reg_width) { - ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; + struct TypeSize { + const char *gdb_type; + short size; + char sz, suffix; + }; + + static const struct TypeSize vec_lanes[] =3D { + /* quads */ + { "uint128", 128, 'q', 'u' }, + { "int128", 128, 'q', 's' }, + /* 64 bit */ + { "ieee_double", 64, 'd', 'f' }, + { "uint64", 64, 'd', 'u' }, + { "int64", 64, 'd', 's' }, + /* 32 bit */ + { "ieee_single", 32, 's', 'f' }, + { "uint32", 32, 's', 'u' }, + { "int32", 32, 's', 's' }, + /* 16 bit */ + { "ieee_half", 16, 'h', 'f' }, + { "uint16", 16, 'h', 'u' }, + { "int16", 16, 'h', 's' }, + /* bytes */ + { "uint8", 8, 'b', 'u' }, + { "int8", 8, 'b', 's' }, + }; + + static const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; + g_autoptr(GString) ts =3D g_string_new(""); - int i, j, bits, reg_width =3D (cpu->sve_max_vq * 128); - info->num =3D 0; - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); + int i, j, bits; =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { @@ -263,7 +258,6 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_r= eg) * 8 bits. */ for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; g_string_append_printf(s, "", suf[i]); for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size =3D=3D bits) { @@ -277,11 +271,24 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base= _reg) /* And now the final union of unions */ g_string_append(s, ""); for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; g_string_append_printf(s, "", suf[i], suf[i]); } g_string_append(s, ""); +} + +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + GString *s =3D g_string_new(NULL); + DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; + int i, reg_width =3D (cpu->sve_max_vq * 128); + info->num =3D 0; + g_string_printf(s, ""); + g_string_append_printf(s, "= "); + g_string_append_printf(s, ""); + + output_vector_union_type(s, reg_width); =20 /* Finally the sve prefix type */ g_string_append_printf(s, --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120059; cv=none; d=zohomail.com; s=zohoarc; b=cu4R4/8UZplfOmB448l6KXX5dKg7McO593u1N34wY/3Le2zxg3H63wn58bikFDR+OAHuiQkuhs4t/HDcbNhk6eRg0rdAepIWAy+s1fywJu9/9udou8uAHpODPEDTR3YzPlPX3CwMGgR6SLQtclsfT09DLT295gG7h/50TS74qh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120059; 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=OVuuzGVy3oGWRblHp623aytTERnHyys4g3WWhXo/bgU=; b=BTLTD2OO1m+Denz+3rXIqWr7ZlRObP79frsJwrVzcpj8r5VkAUnBfFK6Alf1fUXAOT58z1Pj2Z8/ZVx61hQdX7XeQbW4MVTLIxabQr3Srd2WcnxHJMUQ2kI/tSsnFxjglw4jYeOpJHTwPc5Yy23Y1NUo0gy1GlrUyA0o+t1i0DU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120059973403.05422648372905; Mon, 6 Mar 2023 08:27:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrO-000426-Ny; Mon, 06 Mar 2023 10:34:46 -0500 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 1pZCrM-0003z8-EP for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:44 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrK-00027j-Ew for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:44 -0500 Received: by mail-wm1-x331.google.com with SMTP id c18so5930869wmr.3 for ; Mon, 06 Mar 2023 07:34:41 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OVuuzGVy3oGWRblHp623aytTERnHyys4g3WWhXo/bgU=; b=YwZx5vNQQamsQ05ROLsyC37KPYTxAh+4NSf1jO54ckLX7vTCB5JHD1rAawtOwcmZR/ zTObyWDvimiClSGQVTEozVE9r8xRkCMwQM3rsVXrATgvwtd2yCPy+ao16lZ51XsQpE+m g/Dg7Fq2AhSDMMgbdqOgY7iAhBKhHg8txTu/ePQ9BZR5pRVgaGQI/5NwPiUU4HByI3Cq Wn1sjc29XF1ycycmz1/QrZ7J5afngIo5cTPg9GTkJ3QI2MOZY3eqDwohn+GVU7HAL+Sk qRzH186OSzASSa+Oec/zXj3ldbDw+SoOT0lGuFLOhiqzKStwJqvXHnp1lmWDuAcwMKo5 jZrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OVuuzGVy3oGWRblHp623aytTERnHyys4g3WWhXo/bgU=; b=CImLrqzx0llrCAdS7X6oYouR1mf8f3l/kvKgfe4QDmug9oJaGqgxMp6FSoZh1pG7EN VxSOigGwAUpISKItvaggCTyp5cn6AK3W3H4o/7kGi/r7Cv6CxHVquHNWhdP/ePrsekIL 4rnbFPu7sdTwU6I3UHpp/vHGp3faxQx3ZcwxVMj+mUmAFByg7xrK8yhMdan0Qzl+Q8Vh X6bykIsVMbHFcTflFkrIPT6djhS5eD99u8CYQdSdZkR2mQIzKQ1H0+d2OdHXAchFO+3C FQjo2aYHjtppVpfld7I1VUPi92oftt+agA3oZHFfPtEXnDvzzNc/RooPpT4DY6eh8C7e 7sJg== X-Gm-Message-State: AO0yUKVvs67Pj1PtwIAl7w1atnKdx3r870lk82e98ura4X4C2REnvW8i wLjpb+Mw/PZFXeF1txvMmtTPKfKPil1ttiSPLc0= X-Google-Smtp-Source: AK7set9uPr9HyI+UV5E/4rw4c8VlrFOlgbtti87Bgcd011DeilrIsdIEboJljeZ2mBnnE4tHV2hQfg== X-Received: by 2002:a05:600c:4751:b0:3eb:578d:decb with SMTP id w17-20020a05600c475100b003eb578ddecbmr8957015wmo.28.1678116881496; Mon, 06 Mar 2023 07:34:41 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/21] target/arm: Simplify register counting in arm_gen_dynamic_svereg_xml Date: Mon, 6 Mar 2023 15:34:19 +0000 Message-Id: <20230306153435.490894-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120061837100005 From: Richard Henderson Rather than increment base_reg and num, compute num from the change to base_reg at the end. Clean up some nearby comments. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 811833d8dec..070ba20d991 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -277,32 +277,35 @@ static void output_vector_union_type(GString *s, int = reg_width) g_string_append(s, ""); } =20 -int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; - int i, reg_width =3D (cpu->sve_max_vq * 128); - info->num =3D 0; + int reg_width =3D cpu->sve_max_vq * 128; + int base_reg =3D orig_base_reg; + int i; + g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, ""); =20 + /* Create the vector union type. */ output_vector_union_type(s, reg_width); =20 - /* Finally the sve prefix type */ + /* Create the predicate vector type. */ g_string_append_printf(s, "", reg_width / 8); =20 - /* Then define each register in parts for each vq */ + /* Define the vector registers. */ for (i =3D 0; i < 32; i++) { g_string_append_printf(s, "", i, reg_width, base_reg++); - info->num++; } + /* fpscr & status registers */ g_string_append_printf(s, "", base_reg++); - info->num +=3D 2; =20 + /* Define the predicate registers. */ for (i =3D 0; i < 16; i++) { g_string_append_printf(s, "", i, cpu->sve_max_vq * 16, base_reg++); - info->num++; } g_string_append_printf(s, "", cpu->sve_max_vq * 16, base_reg++); + + /* Define the vector length pseudo-register. */ g_string_append_printf(s, "", base_reg++); - info->num +=3D 2; - g_string_append_printf(s, ""); - info->desc =3D g_string_free(s, false); =20 + g_string_append_printf(s, ""); + + info->desc =3D g_string_free(s, false); + info->num =3D base_reg - orig_base_reg; return info->num; } --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120885; cv=none; d=zohomail.com; s=zohoarc; b=JM0mABct7XAMMjlOx0CE+VlccrwMWqLgevvLFlsPOR4f09wGCSEge/uPlUb+NyLa3xBTfb0sf1fFPWGqvpTfEgwKFMvMXqsvz2zk75K6brPyuIcmqXYZeR5tpYdokNR8gpvao2Z78xbUTEB+KXsOL/ASZfMhJc5JAR7avLUI9sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120885; 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=2EZepXHVNHsTCEeO8kyZwd8UEJgQUx+jjexWm4MPlBw=; b=kcRlDRTYG1DGEs/nfVda7C6iD6JZtx3necjvACBYfXseNG3f5HQ5mir/4sZZnZ/iSuRHs4JDYv/EznJZIBmBoaZ7IfvTSMLIpO4htr7QKl6kKzaB7XNFrMR3N7HfYmosJkc7dhZ6j3VUdX2xeewIvnX3XpsQECeypBO6EJdL7z0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120885287837.8186624212332; Mon, 6 Mar 2023 08:41:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrR-00043p-Fd; Mon, 06 Mar 2023 10:34:49 -0500 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 1pZCrN-00040o-Ho for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:45 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrL-000295-Tq for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:45 -0500 Received: by mail-wr1-x433.google.com with SMTP id t15so9252080wrz.7 for ; Mon, 06 Mar 2023 07:34:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2EZepXHVNHsTCEeO8kyZwd8UEJgQUx+jjexWm4MPlBw=; b=PQmWaTU4Qglh1zEkTq5ZBkIafrLG0TrnJ6PTRbF0JiloSQE+qc2umpV4LRz6naYcUs +tuzobRJh7o/biIDHR5/LHUt+UygUvWhK1ezJJMAKLCFB3tXf4KXkxVR2s+xEPLFycbn utoRJ3nqDRPopx27zJHo8/rWsnkwdGF3BkGIsFGWayw5MxaWYyYSw6aLCVF+HRvxGsL3 6T+y8MhfNx8AsoI3gVQers1zSL7RwYIdUUat/V5Z+gSf/wUTfnCCz7ENjS3kszKxe+qZ Ty3ICaIx9fcl6ueKz7mhliP2HUNbBSyvh5KXCWBIxy9OgH3ASR++Avz+FhJuEyW5g0xu 4DZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2EZepXHVNHsTCEeO8kyZwd8UEJgQUx+jjexWm4MPlBw=; b=8DgTbAIil1V6be8ecsrcjR6tYj1XKS365Bk49T9Henf95BF5qhLRId0rxZhMtNAvxQ /wLpTznLsQ6KGm9uytr7mQrGjGSWZWylQXjqeP3LYUSvl5ZD5UbZHISFeebLGhCFiVXN xeC3nH/OYUD3VSi2/1b5fwsTdfwdlCsnS0Aj3b8k9d4/fTyylSFyNpypcb5BhZIx/RNp ckMNB0wvHEzGd9YTuZE4y6CVL69PnHgmqW4SJQA1oJcoXG0ox559Pmqbx/It8im9os6J bhbm8MMgI2u/1Icdd83AZKIpb5PzcJu5i3q+B1QdOCkgMAllV3my/ELlSacK1LO0HTHi a84w== X-Gm-Message-State: AO0yUKWpJo/jzYFDa0WUGD09LSyw3fZHpNQuoW17S3M3XgeLAwgmEMZq bNh4fo6TtAax37ezZyVga8Rgbv5eiuvfRW5T/OI= X-Google-Smtp-Source: AK7set838/1ppyEwQ+MnPRih1cXX4aYgXY5e1d50/9cKFJt/3tb76eF/S3DQ56NvuRQ4sb7ila//Eg== X-Received: by 2002:adf:e30d:0:b0:2c5:3cd2:b8e with SMTP id b13-20020adfe30d000000b002c53cd20b8emr7316506wrj.1.1678116882284; Mon, 06 Mar 2023 07:34:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/21] target/arm: Hoist pred_width in arm_gen_dynamic_svereg_xml Date: Mon, 6 Mar 2023 15:34:20 +0000 Message-Id: <20230306153435.490894-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120887162100001 From: Richard Henderson Reviewed-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 070ba20d991..895e19f0845 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -283,6 +283,7 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_b= ase_reg) GString *s =3D g_string_new(NULL); DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; int reg_width =3D cpu->sve_max_vq * 128; + int pred_width =3D cpu->sve_max_vq * 16; int base_reg =3D orig_base_reg; int i; =20 @@ -319,13 +320,13 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig= _base_reg) g_string_append_printf(s, "", - i, cpu->sve_max_vq * 16, base_reg++); + i, pred_width, base_reg++); } g_string_append_printf(s, "", - cpu->sve_max_vq * 16, base_reg++); + pred_width, base_reg++); =20 /* Define the vector length pseudo-register. */ g_string_append_printf(s, --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120570; cv=none; d=zohomail.com; s=zohoarc; b=n3VC4ZrDGXCZ78oFck7ZLIXe8CJL8TX+wT224Wmmq4OLYa9vKxmuQCF0Jr1NfqnA/NQDJgwsaT8NVGeV4qMfEmio29vmoLCB/sVIBOvxojV+fTA+zdH83tQgJzUn3Nhkb7hNPHtv/hSFxaD3i7qGPXzaaEM+8hzu+A16zsIDRt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120570; h=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=kjhOQG1dHhfG5ep4fgX9p4eWjfIzvLEZJBm1JipGe8s=; b=c49XOm9h431C3X7zBcznGw/n51CqNgEAszuu/hQpayeLYXUhwhLeSFYAGgCYpltldqefotpZTAsEXHlD7OSesFV1HqlDY9v7RjvIKQwjSd0u+XNQvGY+P0mJ/bo/ZrGJ+LsZwWLCcub04RsF5wF0V5I/+pN51L7IakFeKhnwRyI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120570208433.50063575884224; Mon, 6 Mar 2023 08:36:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrS-000449-21; Mon, 06 Mar 2023 10:34:50 -0500 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 1pZCrN-00041i-Un for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:45 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrM-00029G-9L for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:45 -0500 Received: by mail-wm1-x332.google.com with SMTP id ay29-20020a05600c1e1d00b003e9f4c2b623so8471017wmb.3 for ; Mon, 06 Mar 2023 07:34:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kjhOQG1dHhfG5ep4fgX9p4eWjfIzvLEZJBm1JipGe8s=; b=OVck0MjtX2WWDnjkRgPx7z43pynLd8A6fdy/nhD2oNAvCtwR3JRm7O9QFKb8p4j0Xv RW5jC9QKV44aCy6BF52sSTzUjfSlNTgE0a38ohgF1v7fTS6wN4RxkOSFXvFObJX+l8dt eONzcxAnxLfod8vAoYpPqsOVO0x/URPVcDgsKsQU8l3c8yyMrnovlpOceua4HHra816T p/5wJ1PfcuOarzrrAlQMaxVK5OcjCmFUFLOjt0xQP8GCl1EFsCw0t94gqxIN6199Sk0a bWjXdMejY37156oQDeXL2xbaut+z4S9z02isn6uhfN4ND2vUNIjW6OqFtq9knGXdBsQQ BXWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kjhOQG1dHhfG5ep4fgX9p4eWjfIzvLEZJBm1JipGe8s=; b=Nf59WTzGZFMQYSPjPqJCGqSHKeno+FQcDWphnLIhyusoHfEB7o6Ngd4lnKtN3iMOZA R4zO1qGgyfCLYCBr0g545iKQSlgQK/8YjGgvmMSofwJQ8cGFkvuYohBtDi6C+RlMEK84 VPjJYCDfl8HvN2q3VY7hr+IsOX55aDOvQKsWzmotwM5HJYTJA6qCk3LLmKKZ+izv1G34 uMJgyeFZ1GuFDfCfR9mHyoalsTtO4kw02CyyBvMaOj/Fy7lCJsPuo3PczzZT0HVr6L9e jdrNsrsY7vaNLILIzbfUCFiN+M36NmufUG/fMkkh72hdVS3dKnc5psjCVu56xUMLjEFr EfuA== X-Gm-Message-State: AO0yUKVSwQK5+8eM3YqpZKQObcd6OAL9cGdpB5zvJ0WpCZYNrvU25omK tV9Pjy4tTicfbXhSzp55tvjD8Cq2k72NJg1+QjY= X-Google-Smtp-Source: AK7set8LG9gx0avPzFItyR6QJFfgX1wwVucnBvbsX9YNLFWJLGcZtyX0DZUCbC00GCTgygsYGOHGVQ== X-Received: by 2002:a05:600c:3505:b0:3ea:f883:53ea with SMTP id h5-20020a05600c350500b003eaf88353eamr9042060wmq.7.1678116883013; Mon, 06 Mar 2023 07:34:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/21] target/arm: Fix svep width in arm_gen_dynamic_svereg_xml Date: Mon, 6 Mar 2023 15:34:21 +0000 Message-Id: <20230306153435.490894-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120571154100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Define svep based on the size of the predicates, not the primary vector registers. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 895e19f0845..d0e1305f6fc 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -297,7 +297,7 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_b= ase_reg) /* Create the predicate vector type. */ g_string_append_printf(s, "", - reg_width / 8); + pred_width / 8); =20 /* Define the vector registers. */ for (i =3D 0; i < 32; i++) { --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120602; cv=none; d=zohomail.com; s=zohoarc; b=EsoVfruekepWC/xw30ctfuZ9YEjo5E7kuE5qFnWKdeB6GmyfF366iVmkhb9z2/iVsfli7xJxB8Eao9F1VP84Uqo8pgcDSY3kaCyCGYYWNbXQtngcSGLwspdVgOKP2vcVMEEy+vnPe8r28+jUmHMMWlQFhbwoneTliNvQE/NaQv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120602; 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=uh6QfKjLKU2APYmm6FnQ7PvwealPEo6i3D3sw7iDPnk=; b=W+OchXXCWZN34DyttY9aUHtgtZdXjD9J6/jOcgweKTme+2cRqiPSoa7b4/bT3vKtVAWg77w3UNCUywWfn/im9lQ1WCVkUnVOd5I+OXP9AuYcy6f88BEwvKAt0V3TLL2lCjpi0ZMyKW3i5rhkp8AHJNCbiomWiffGVysOvEY3r84= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120602139557.2864278518433; Mon, 6 Mar 2023 08:36:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrS-000454-Og; Mon, 06 Mar 2023 10:34:50 -0500 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 1pZCrP-00042Y-0o for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:47 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrN-00029T-8x for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:46 -0500 Received: by mail-wm1-x32c.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so8488476wms.2 for ; Mon, 06 Mar 2023 07:34:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uh6QfKjLKU2APYmm6FnQ7PvwealPEo6i3D3sw7iDPnk=; b=mLhF93HLBI6t5MQPAWOvt7LOIM6ie9Z8gi4lPMuzAPh9ogihOdIZtJ8XiQO7rWo5A6 m8kVfcZASW411GPXOgnnl2eaU26wgPHJnWqrw5Q1fdVcso9jOq5pv0uCsm+WsibsSS/J EtyUDwAF2W7mecegzSZXDTC9/phfg2ra2Mi8aYwD/V/r0by0+uriC6QSV9CVOg2Gfdnf h4frv/gJISHgU3JGCNDuSJmRYsetAdIqtOwGwO7teAo3RfaUC1zOKRxsVxusXI13sWnP /2gjN4kk2TmHDZioIthKKCtW1/UBxSUwiz+4tkHrfgirDJ9iPKIjm7wyKq2sIniII0kb WHsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uh6QfKjLKU2APYmm6FnQ7PvwealPEo6i3D3sw7iDPnk=; b=D+qXzvmXwRd27DOv4hVVEx6TmzZhI7lhmGTPA9vHdG6vm3xTzBV6/n7huuI12gnb/P Tl1hJ/q9qWHegUM2AgPnr3gbjOXdlayz0XlNcZ6KVz0H9CThy4tNj12Ble/9Ijn8ornk kHfZD5eDfA4bIVI5BQ+kb2gQzfbBPKnAPeCc/Txr4otNyLV/bIARi0z35HWC3hnAK5Ng vyutx69Wei6mqRQiaMVSjfhiAyMGeTyVeKkl5sOO/+tgWCrAMRBtsD+x1ihskDOR07yV rGfZFfsHvuFfPAgiWBlZKxxrTcrRvaTQ29FUooc9EoDQReA/27KrW9rE3SrGtGbb2hTG /rbA== X-Gm-Message-State: AO0yUKW02BMHsU2bVU1/yDK7Jibsa18JCcgPc9G9NSuBPxf7HhK3/KlG SgZeJxO/UidDUwe31oU7Xpyp34uxk9g1goa8/kw= X-Google-Smtp-Source: AK7set8xZNN9A9T2Ro0m2jRq6tlgLTpYzsCrHZt2cvF229yotgiayTKvkNSEG/at73GPOPoQ2zXkHA== X-Received: by 2002:a05:600c:4e90:b0:3ea:bc08:42ad with SMTP id f16-20020a05600c4e9000b003eabc0842admr9425544wmq.2.1678116883754; Mon, 06 Mar 2023 07:34:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/21] target/arm: Add name argument to output_vector_union_type Date: Mon, 6 Mar 2023 15:34:22 +0000 Message-Id: <20230306153435.490894-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120603398100001 From: Richard Henderson This will make the function usable between SVE and SME. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-9-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index d0e1305f6fc..36166bf81eb 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -210,7 +210,8 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *= buf, int reg) return 0; } =20 -static void output_vector_union_type(GString *s, int reg_width) +static void output_vector_union_type(GString *s, int reg_width, + const char *name) { struct TypeSize { const char *gdb_type; @@ -240,39 +241,38 @@ static void output_vector_union_type(GString *s, int = reg_width) }; =20 static const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; - - g_autoptr(GString) ts =3D g_string_new(""); int i, j, bits; =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - int count =3D reg_width / vec_lanes[i].size; - g_string_printf(ts, "svev%c%c", vec_lanes[i].sz, vec_lanes[i].suff= ix); g_string_append_printf(s, - "", - ts->str, vec_lanes[i].gdb_type, count); + "", + name, vec_lanes[i].sz, vec_lanes[i].suffix, + vec_lanes[i].gdb_type, reg_width / vec_lane= s[i].size); } + /* * Now define a union for each size group containing unsigned and * signed and potentially float versions of each size from 128 to * 8 bits. */ for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - g_string_append_printf(s, "", suf[i]); + g_string_append_printf(s, "", name, suf[i]); for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size =3D=3D bits) { - g_string_append_printf(s, "", - vec_lanes[j].suffix, + g_string_append_printf(s, "", + vec_lanes[j].suffix, name, vec_lanes[j].sz, vec_lanes[j].suffi= x); } } g_string_append(s, ""); } + /* And now the final union of unions */ - g_string_append(s, ""); + g_string_append_printf(s, "", name); for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { - g_string_append_printf(s, "", - suf[i], suf[i]); + g_string_append_printf(s, "= ", + suf[i], name, suf[i]); } g_string_append(s, ""); } @@ -292,7 +292,7 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_b= ase_reg) g_string_append_printf(s, ""); =20 /* Create the vector union type. */ - output_vector_union_type(s, reg_width); + output_vector_union_type(s, reg_width, "svev"); =20 /* Create the predicate vector type. */ g_string_append_printf(s, --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678121297; cv=none; d=zohomail.com; s=zohoarc; b=Dg1Z1FyNHW2wPtqQr2X/kA574orm1okbSJFSMY5Z7dFDsPqw6uecTdSDGBkFq2K121mRIneXI8joMhnhw0av1tlFDgyf/tQXiJKuHTRmPh0ONSZzdBrnBegMn740/NFAmdO3qFa9hbxRssNrAu06FZHQwJvzxUHBStr44wqd+Mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678121297; h=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=8RypxeqHCkWrvhM6v/ukjoIBfsmqrjlJlNPR4BkYcx0=; b=f/QWopy/ttkKdCZ9ncLFvbL11hcGjwnC9QTnpxUwToo04BHKteo8XvCtvTOOD4o98iDZAbGwMurzFuU832P603sE4w3+fMgud/Jyl/nqoBZoxvxMGF+E5iqUErfPL3zuyMNOF8Y5mLBMx0RT3DXsZpBlC91/s5RmpVs2JmUqSrA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678121297657708.5036774619014; Mon, 6 Mar 2023 08:48:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrQ-00043K-Aw; Mon, 06 Mar 2023 10:34:48 -0500 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 1pZCrP-000433-Hr for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:47 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrN-00029m-Tu for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:47 -0500 Received: by mail-wm1-x332.google.com with SMTP id k37so5970158wms.0 for ; Mon, 06 Mar 2023 07:34:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8RypxeqHCkWrvhM6v/ukjoIBfsmqrjlJlNPR4BkYcx0=; b=NsNUnGuyUFxD5ZETY4XHduffwIAYUWimVXUoAXkLBIstrQvQKhMBtrIRYgw8wT09aK KPbwkqtzESTDTZ3pBYzddLgksHZnmeyo2BBZAdc8jEM3tmAHOU2caUrPyL+2laEmDOVG nyYbE3mfJqYeuxWSSaehlX+YLV0OXWVMNgp8y20yB06ksHMzWe8x3Paa0EIsnpYOONN8 aqG7NiNzGUqOq+f6He4Q1bwUWhdI5jDVn/OA/YmhW+y0Xb/7LaQXSNaA/tTX0x17q32l 0LxQYnScMlVYz+7PbU/Ar4jIqT7mdeQ12WKrmGReyl2PGQrHXgmk+UgzOFWFw6B9PeQo GtQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8RypxeqHCkWrvhM6v/ukjoIBfsmqrjlJlNPR4BkYcx0=; b=WT7aFl+1bvOzYf4pP4gsP88iEiupraTgzB8zusMDnWVKTOyyZDBgNUgEHQKjTk12Z1 PawSwMsQvL5JolBtGb5kZiN9nDBtxcGDOGVqFwSCY93/za3CmqIHdChzUMUUhY3dOhXJ arpHX7xbxM8JRF3CtegalgfELyxX26S+ZaLJnmMdBWgnjydg5qJVt3sAByW3fTcFU400 pgbS8AMutTKX+VG6D2S7zxd2cLTKcR7V45i3n50SmTHLDhmML/2bDS1TnoKYds19IVPm 0VnQLoBFQMd/ZtfFB8a9v8byOYcACuqOVIvxEMtq50Av8eiljsMvjtaN246S85CCU51/ Vqew== X-Gm-Message-State: AO0yUKVX6FYMIYlQIm0M0a07+jt6pSNGQHZ7vMKOrPNshU28KtMGSaSZ MtTcKY5WIeAW0O1NvvCsEcmyJ8Opimx6TEuhaZM= X-Google-Smtp-Source: AK7set+TdY2r7oyhgfMCNELcy7l1HAbwtLeSAHJjlr30WDSy48YixMRGKbBfvxJI8ll6jszk8ldyOw== X-Received: by 2002:a05:600c:4511:b0:3ea:e554:7808 with SMTP id t17-20020a05600c451100b003eae5547808mr9638293wmo.19.1678116884554; Mon, 06 Mar 2023 07:34:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/21] target/arm: Simplify iteration over bit widths Date: Mon, 6 Mar 2023 15:34:23 +0000 Message-Id: <20230306153435.490894-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678121298497100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Order suf[] by the log8 of the width. Use ARRAY_SIZE instead of hard-coding 128. This changes the order of the union definitions, but retains the order of the union-of-union members. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/gdbstub64.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 36166bf81eb..3d9e9e97c86 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -240,8 +240,8 @@ static void output_vector_union_type(GString *s, int re= g_width, { "int8", 8, 'b', 's' }, }; =20 - static const char suf[] =3D { 'q', 'd', 's', 'h', 'b' }; - int i, j, bits; + static const char suf[] =3D { 'b', 'h', 's', 'd', 'q' }; + int i, j; =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { @@ -256,7 +256,9 @@ static void output_vector_union_type(GString *s, int re= g_width, * signed and potentially float versions of each size from 128 to * 8 bits. */ - for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { + for (i =3D 0; i < ARRAY_SIZE(suf); i++) { + int bits =3D 8 << i; + g_string_append_printf(s, "", name, suf[i]); for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size =3D=3D bits) { @@ -270,7 +272,7 @@ static void output_vector_union_type(GString *s, int re= g_width, =20 /* And now the final union of unions */ g_string_append_printf(s, "", name); - for (bits =3D 128, i =3D 0; bits >=3D 8; bits /=3D 2, i++) { + for (i =3D ARRAY_SIZE(suf) - 1; i >=3D 0; i--) { g_string_append_printf(s, "= ", suf[i], name, suf[i]); } --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678123324; cv=none; d=zohomail.com; s=zohoarc; b=Nctj57s2f0ggQE7tSsgEqHf3FTCgGpU8IYtTOCmEjJQbHJUtAj1pNo+vmcFxnA0WVp0WYyV5HSY0PRaoOkdyqzqYNfdBdqZbP1RRnp8MaIglCfUUmOOHn0op16w0aGlqJfV46KO3qfZmYs3hPgAAzmmfcJ9FkhYMrRHHlWkGzzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678123324; h=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=n3nNUjZBhON55v351EAFbDNEjPLJymf5+GUgr1/Qymw=; b=TDImeVR1igaVNlY8RGAXghYG1/TPDWGHUB8XJlwRk9DZiKlLpZyyfxnGSYACK5lAsbJ8tjYsu8jei2H1BHzR3kHN879pSLqE4SXxcrtqsU0qV0LxfkIf3zKJq+jX8rnmerZ6L0OPnYc1r57fRC2PAKjMASqBjJ+PRsPCfk66od4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16781233243521004.3590118615031; Mon, 6 Mar 2023 09:22:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrT-00045D-9G; Mon, 06 Mar 2023 10:34:51 -0500 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 1pZCrQ-00043S-DC for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:48 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrO-00029y-Kh for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:48 -0500 Received: by mail-wr1-x42c.google.com with SMTP id h11so9258499wrm.5 for ; Mon, 06 Mar 2023 07:34:46 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=n3nNUjZBhON55v351EAFbDNEjPLJymf5+GUgr1/Qymw=; b=aYAg5obJhI8y9PrLC7CL0XW5lLkP8E8jSM+gK+VEZEVOjdT9D60a8CnkQdS/73Gs/8 4eib76uVstmW4KXf69WtHV+hc+E9k5ft86Qnape5VvYZ7lmol8a+1YZgykaCjRR1c7Bt 1CTbOrn+S+gbvENcSukKAy0l/pq2JHRBHy0GKMsC/UDRxNdEzRzx+NGPwj2bVd53pDPf fdlRUbb70Jnti6oHMOUT9CL/jZrhngvktAXkxmjrUhUlLiHUztnGJTceGUXCR5K8lcQz 2BTpLgmG8X3lfLZrLDwudBiIWNhurhCPChCxRtzFnZfG3OXC6hkVJJvGXUH1iWWUqqC7 xwdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n3nNUjZBhON55v351EAFbDNEjPLJymf5+GUgr1/Qymw=; b=2cEIvqqMXwCRo57489ujTJlJdyqJqGXnXKqlHIHVNAGHDS+M4O7Y5yw8xPqoNZ4SY+ 6X8wt+ELXIsCkW+z4mO4O8J7rG1RdwlhZu8EtkbDls749WCTWsLyUsKu7/kMf91p+50X jIeek0LrFQ02iwQV0L5z4pRgva9YXmJ8bbZpPXZkpWeCq9ch0L94o/GY8zGlZdWJmiXU bgTP4mpUV5EH3xn+UgSwQgHRHDBABaNwIN55aeBdrinXHB58l5E9HNQFJfdhuzBVM3fI zCtxHxsOvpufbaMIpXPd6gE5JBezcMOex6xS1+3k4K88IpLo87A3S2dwppk7WiKSR6yx CGXg== X-Gm-Message-State: AO0yUKUsB4WAWrRWVcD7Cs5ApscscceObjAcoR2k/VZd3JDoWvX0Hv9i Qfh5kzSwsKGDCo60PNybrQNL310qp8msGDzFp8U= X-Google-Smtp-Source: AK7set/X8NdWN/H3YK3g4yJlkweU2QN7iQk3mpSXMvQ1cwWViB6OO5Ns8O+MYxppmffNZdirH4XITQ== X-Received: by 2002:a5d:4dc5:0:b0:2c5:55cf:b1ab with SMTP id f5-20020a5d4dc5000000b002c555cfb1abmr5985682wru.48.1678116885353; Mon, 06 Mar 2023 07:34:45 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/21] target/arm: Create pauth_ptr_mask Date: Mon, 6 Mar 2023 15:34:24 +0000 Message-Id: <20230306153435.490894-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678123325408100005 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Keep the logic for pauth within pauth_helper.c, and expose a helper function for use with the gdbstub pac extension. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-11-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 10 ++++++++++ target/arm/tcg/pauth_helper.c | 26 ++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 15988768be3..c891c7a3831 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1368,6 +1368,16 @@ int exception_target_el(CPUARMState *env); bool arm_singlestep_active(CPUARMState *env); bool arm_generate_debug_exceptions(CPUARMState *env); =20 +/** + * pauth_ptr_mask: + * @env: cpu context + * @ptr: selects between TTBR0 and TTBR1 + * @data: selects between TBI and TBID + * + * Return a mask of the bits of @ptr that contain the authentication code. + */ +uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data); + /* Add the cpreg definitions for debug related system registers */ void define_debug_regs(ARMCPU *cpu); =20 diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index d0483bf051e..20f347332dc 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -339,14 +339,32 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64= _t ptr, uint64_t modifier, return pac | ext | ptr; } =20 -static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) +static uint64_t pauth_ptr_mask_internal(ARMVAParameters param) { - /* Note that bit 55 is used whether or not the regime has 2 ranges. */ - uint64_t extfield =3D sextract64(ptr, 55, 1); int bot_pac_bit =3D 64 - param.tsz; int top_pac_bit =3D 64 - 8 * param.tbi; =20 - return deposit64(ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield= ); + return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit); +} + +static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) +{ + uint64_t mask =3D pauth_ptr_mask_internal(param); + + /* Note that bit 55 is used whether or not the regime has 2 ranges. */ + if (extract64(ptr, 55, 1)) { + return ptr | mask; + } else { + return ptr & ~mask; + } +} + +uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data) +{ + ARMMMUIdx mmu_idx =3D arm_stage1_mmu_idx(env); + ARMVAParameters param =3D aa64_va_parameters(env, ptr, mmu_idx, data); + + return pauth_ptr_mask_internal(param); } =20 static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifi= er, --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678119884; cv=none; d=zohomail.com; s=zohoarc; b=ar7Bkx25CIZtj0RPmosqx29LuceZ3K0VizW828P19TIvExexCF54swiLniKEBMHqMwjUa0/fC9FI5RsC7gRVtWooH109cLBVUbf6Js6Z0w2/AQvacD4XWzTWRFhTNF3T7T2uCvPJDk1QQpHjZHNaQrqY1hbnahmFuQHqcwB2W2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678119884; h=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=/AQejgWbtYpiD7FfeheRyQLSBVKA3u2JfApjtw1egSo=; b=lotv035HJ+QbtbhES+UarB2jgwVXxIN1PZmrbv7aQ6Um6Nq3kvG5BFUuWdJMJ+hr6Q+bJebEwMHw69FtDuVqpD0w+lTc9VdBJvlZeNh3TuoB1riL7FA0suANGyFl5h/0YkuxYnN2JaabdONS3rU1pMOzqHdn5UkpwHBKDAG01Zc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167811988455537.95832225779134; Mon, 6 Mar 2023 08:24:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrX-0004C9-Io; Mon, 06 Mar 2023 10:34:55 -0500 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 1pZCrV-00046b-8J for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:53 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrP-0002AE-FA for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:52 -0500 Received: by mail-wr1-x433.google.com with SMTP id g3so9256975wri.6 for ; Mon, 06 Mar 2023 07:34:47 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/AQejgWbtYpiD7FfeheRyQLSBVKA3u2JfApjtw1egSo=; b=h/7DbJ/WqGPvlNyK1ZS/5tIo+vk7LYypiNUjZuhp5MDedp0XLS+7f7nsRLVfmrjNfZ ul8CQ+1FEMuYU8KnZ9EEnYwCyKiiUpcwB46+5bCdtzd/FJfNOaRUponedGkczUbQxINV AtNjnYrP299W7H0LtrKG3MsVFs54CclHjGYu6QiBdnPtcAemejXkkqVpAIwGY3BVa1oD bTMs7PjJUTm/BQ03J9P0lpvt2XUOXRlsf2rAGSOGa8BZo1eLoRIecxXCwqhncAsIm4z6 1b/hHYqXV/FKwujpWI28aPSX/qzLGaysEkbAbrOoNoSLZtLVg2/+wgAZI6o4mr8EXhGQ gMFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/AQejgWbtYpiD7FfeheRyQLSBVKA3u2JfApjtw1egSo=; b=xLbUNeJhGJV7QDLR2HIB8uVdlnEbWX0iqseK5IioGNwaUK8XxxmTmecRWgCLVVb+jr kEcqaBsHKmaNeluWe1mC0D9WPheutMvvAA5N+HEIosO3TjBW2kRWRYIxsKJX0cgoVIbZ n1369ASiEo3ESIz562WXItR7kIdb0HEt12+bzieugh2mlmSux0CHA/1Z6XwI1ztBALxc VjbuF5AA2wtsP9gfRXT2ymcFFjphrt+4EsKWya4Ww+NIxm53J7XUd9nI1rkn5nhW+4PW OyTBxMGJEkHBak3NdfOwa8gTQpJQuVSA6Op5tv+pz3YzF8JnBz2HQMN8M8bv5jxIq99s wpeA== X-Gm-Message-State: AO0yUKXT21ApHQPaoGlN9zRfjlZ4KfivVeKEsFT/97iJM3g+S771BQm9 P/2657jHHqKyjjuzVG9Vd1sh+0pmSmwOyNBHKfM= X-Google-Smtp-Source: AK7set8fr5yFO86JQIoK0b8/5vcUdZm8B3Ya5ITUZEXcD6jWevNm3yrCUHVVFzpSQUl5r3lPHo7S1A== X-Received: by 2002:a5d:6545:0:b0:2c7:cc8:782c with SMTP id z5-20020a5d6545000000b002c70cc8782cmr10516590wrv.1.1678116886102; Mon, 06 Mar 2023 07:34:46 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/21] target/arm: Implement gdbstub pauth extension Date: Mon, 6 Mar 2023 15:34:25 +0000 Message-Id: <20230306153435.490894-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678119885383100002 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The extension is primarily defined by the Linux kernel NT_ARM_PAC_MASK ptrace register set. The original gdb feature consists of two masks, data and code, which are used to mask out the authentication code within a pointer. Following discussion with Luis Machado, add two more masks in order to support pointers within the high half of the address space (i.e. TTBR1 vs TTBR0). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1105 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- configs/targets/aarch64-linux-user.mak | 2 +- configs/targets/aarch64-softmmu.mak | 2 +- configs/targets/aarch64_be-linux-user.mak | 2 +- target/arm/internals.h | 2 ++ target/arm/gdbstub.c | 5 ++++ target/arm/gdbstub64.c | 34 +++++++++++++++++++++++ gdb-xml/aarch64-pauth.xml | 15 ++++++++++ 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 gdb-xml/aarch64-pauth.xml diff --git a/configs/targets/aarch64-linux-user.mak b/configs/targets/aarch= 64-linux-user.mak index db552f18390..ba8bc5fe3fd 100644 --- a/configs/targets/aarch64-linux-user.mak +++ b/configs/targets/aarch64-linux-user.mak @@ -1,6 +1,6 @@ TARGET_ARCH=3Daarch64 TARGET_BASE_ARCH=3Darm -TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml +TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-x= ml/aarch64-pauth.xml TARGET_HAS_BFLT=3Dy CONFIG_SEMIHOSTING=3Dy CONFIG_ARM_COMPATIBLE_SEMIHOSTING=3Dy diff --git a/configs/targets/aarch64-softmmu.mak b/configs/targets/aarch64-= softmmu.mak index d489e6da830..b4338e95680 100644 --- a/configs/targets/aarch64-softmmu.mak +++ b/configs/targets/aarch64-softmmu.mak @@ -1,5 +1,5 @@ TARGET_ARCH=3Daarch64 TARGET_BASE_ARCH=3Darm TARGET_SUPPORTS_MTTCG=3Dy -TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-x= ml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sy= sregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-prof= ile-mve.xml +TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-x= ml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sy= sregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-prof= ile-mve.xml gdb-xml/aarch64-pauth.xml TARGET_NEED_FDT=3Dy diff --git a/configs/targets/aarch64_be-linux-user.mak b/configs/targets/aa= rch64_be-linux-user.mak index dc78044fb15..acb5620cdbf 100644 --- a/configs/targets/aarch64_be-linux-user.mak +++ b/configs/targets/aarch64_be-linux-user.mak @@ -1,7 +1,7 @@ TARGET_ARCH=3Daarch64 TARGET_BASE_ARCH=3Darm TARGET_BIG_ENDIAN=3Dy -TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml +TARGET_XML_FILES=3D gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-x= ml/aarch64-pauth.xml TARGET_HAS_BFLT=3Dy CONFIG_SEMIHOSTING=3Dy CONFIG_ARM_COMPATIBLE_SEMIHOSTING=3Dy diff --git a/target/arm/internals.h b/target/arm/internals.h index c891c7a3831..dda89aa5dff 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1349,6 +1349,8 @@ int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteAr= ray *buf, int reg); int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg); +int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg); +int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg); void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index bf8aff78241..062c8d447a0 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -355,6 +355,11 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cp= u) aarch64_gdb_set_fpu_reg, 34, "aarch64-fpu.xml", 0); } + if (isar_feature_aa64_pauth(&cpu->isar)) { + gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg, + aarch64_gdb_set_pauth_reg, + 4, "aarch64-pauth.xml", 0); + } #endif } else { if (arm_feature(env, ARM_FEATURE_NEON)) { diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 3d9e9e97c86..3bee892fb76 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -210,6 +210,40 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t = *buf, int reg) return 0; } =20 +int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg) +{ + switch (reg) { + case 0: /* pauth_dmask */ + case 1: /* pauth_cmask */ + case 2: /* pauth_dmask_high */ + case 3: /* pauth_cmask_high */ + /* + * Note that older versions of this feature only contained + * pauth_{d,c}mask, for use with Linux user processes, and + * thus exclusively in the low half of the address space. + * + * To support system mode, and to debug kernels, two new regs + * were added to cover the high half of the address space. + * For the purpose of pauth_ptr_mask, we can use any well-formed + * address within the address space half -- here, 0 and -1. + */ + { + bool is_data =3D !(reg & 1); + bool is_high =3D reg & 2; + uint64_t mask =3D pauth_ptr_mask(env, -is_high, is_data); + return gdb_get_reg64(buf, mask); + } + default: + return 0; + } +} + +int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg) +{ + /* All pseudo registers are read-only. */ + return 0; +} + static void output_vector_union_type(GString *s, int reg_width, const char *name) { diff --git a/gdb-xml/aarch64-pauth.xml b/gdb-xml/aarch64-pauth.xml new file mode 100644 index 00000000000..24af5f903c1 --- /dev/null +++ b/gdb-xml/aarch64-pauth.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678123322; cv=none; d=zohomail.com; s=zohoarc; b=eZN4oiMiMNgTllCj5ezGI6ec2BddhxQO1YEZdf97I5h/enyx5/FZ4L329J/HL35HI1fLw91wN/w3qA+s0u4V6p2ZxFjMSsOnExiApFblTSPVfSoLsjtJ2pGcGZk+DccZlqMD4hUF1wwnOgpd9xWDd4u2C+/YlmW084pTFOuSxkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678123322; 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=7zDGynslJU4b+FRAwgcAI/YIPi0m+DP8+CtCFF4RjQo=; b=KoHl26Hge9rMJ7K2Sz3i9FMEM/usbXIabnMQ6iaQbKHJ0N5cbe7+Qh+ZXvOATcZ2L8Xjnsw2T8cAHi10ohfBfici1BbpOEw0r9GTo//fNYuhvCDfy/rAHU/ZalNUBLdnpuuer0v4lH3mV71B2GggN2yAafDg3+DmmI17Km9Ujmk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678123322902333.3268171774298; Mon, 6 Mar 2023 09:22:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrT-00045V-Lf; Mon, 06 Mar 2023 10:34:51 -0500 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 1pZCrS-000448-04 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:50 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrQ-0002At-9N for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:49 -0500 Received: by mail-wm1-x32e.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so5441626wmi.3 for ; Mon, 06 Mar 2023 07:34:47 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7zDGynslJU4b+FRAwgcAI/YIPi0m+DP8+CtCFF4RjQo=; b=RPPRzob5zs5tkt/8nf/YsDMV/82t16+udjpVuEU0lfsa2bjIl/UbH7+UpwGDlcVWuE r86NOEZcHwqJ9Eps0hOBZKUb8o0uSc7I/8BI6pGhnhjLt3lR3d2J9cxk4c1pDgFKPcIi JbhUP/j6kZXhOW7t3Jqevz4fNbS4BNmXS5BV2L9MxYGb95YIdwnhDcjaRzVu682HeLmg gJ5gWG9GbV+n1nd+aofMGCjKS9ejgq+0m3SCLuMc0fXmte/JQc5c9AaCSorEQaBNt1NX i0bhrciFCzOzcCUz+EF5zKEyQvYnn8jn43u0oyetXK9TiZavplLdbxsilDz/5PgF3/Fs i0Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7zDGynslJU4b+FRAwgcAI/YIPi0m+DP8+CtCFF4RjQo=; b=TwLocXsK30CSPqtfcPEhm9rHhWhb8Gel73smXy4NK8DEoNer46OHOkzV/VHL8YqRmL JWTcZ+kYj3Xd5ZyfUmgbLqN73Qycse6jd429WsoDfvfu9ON2kRBINxukNBWafm+NnQI+ EX3mrgwPA7w2yeoRDMdPMZH7oLwoKHwlreSWzSFE4sDP8A6x1Pw3N1EpQMID77YPkQKH 9ZpMW1isKUfbHOq8LlsBH1HgeWtjyXP87L5CGiBHLUBdenSKd32+gopzMn35OGZjJnFN nqpz+R07JBDG2JSKs7kRJc8dTsXFwoKkhBY8K5+ByVyS1kL7IGLZEZG1MeUXn1aMt8X1 TU8A== X-Gm-Message-State: AO0yUKUGEyRgeV+fqWejajsn8vWBTndJLjbYJPlJAWh7i9k68DHe+uUC w+zOV6TVMybArQuf7LtJRtzxC9Riqbun7elEPkA= X-Google-Smtp-Source: AK7set9jk0qCH+oah7jWv/uCHkGWdyQ21kYmYrijoskIVFpzChziDdFOSXSvzCHcQwvdQ+epLZZO0Q== X-Received: by 2002:a7b:cb01:0:b0:3ea:d611:f8 with SMTP id u1-20020a7bcb01000000b003ead61100f8mr10229648wmj.38.1678116886909; Mon, 06 Mar 2023 07:34:46 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/21] target/arm: Export arm_v7m_mrs_control Date: Mon, 6 Mar 2023 15:34:26 +0000 Message-Id: <20230306153435.490894-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678123323453100001 From: David Reiss Allow the function to be used outside of m_helper.c. Rename with an "arm_" prefix. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Reiss Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-13-richard.henderson@linaro.org [rth: Split out of a larger patch] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- target/arm/internals.h | 3 +++ target/arm/tcg/m_helper.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index dda89aa5dff..086e88e2377 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1357,6 +1357,9 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp= ); void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); #endif =20 +/* Read the CONTROL register as the MRS instruction would. */ +uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure); + #ifdef CONFIG_USER_ONLY static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } #else diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index f94e87e7289..03be79e7bfa 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -56,7 +56,7 @@ static uint32_t v7m_mrs_xpsr(CPUARMState *env, uint32_t r= eg, unsigned el) return xpsr_read(env) & mask; } =20 -static uint32_t v7m_mrs_control(CPUARMState *env, uint32_t secure) +uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure) { uint32_t value =3D env->v7m.control[secure]; =20 @@ -93,7 +93,7 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) case 0 ... 7: /* xPSR sub-fields */ return v7m_mrs_xpsr(env, reg, 0); case 20: /* CONTROL */ - return v7m_mrs_control(env, 0); + return arm_v7m_mrs_control(env, 0); default: /* Unprivileged reads others as zero. */ return 0; @@ -2465,7 +2465,7 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t r= eg) case 0 ... 7: /* xPSR sub-fields */ return v7m_mrs_xpsr(env, reg, el); case 20: /* CONTROL */ - return v7m_mrs_control(env, env->v7m.secure); + return arm_v7m_mrs_control(env, env->v7m.secure); case 0x94: /* CONTROL_NS */ /* * We have to handle this here because unprivileged Secure code --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678121256; cv=none; d=zohomail.com; s=zohoarc; b=dYSivkn+0BLv2HuRX/Nqbrq+mWsOjBeZwMyFKaeKBOLFHkc5zlyrzGdlAF9ErT0yn85Ei+8XUvQq7sSMWLSK6sb6kb93waazhQ19PlkkMNlOHR0Sr22U4qrF0mQ6lcFFCm/L5XVQ27sNXc6QssiDx3pSXFrE3AYa9s7tUMdbQs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678121256; 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=O+ujOWWybD9KNJcAQ8vS9zB0/hV+GpzXbwAmASVSlKM=; b=fgY9TiS2hi8YgdZwBgFHiZ97O/k/BmJsDlfEMTVyZERbdSpzTGJ2+jARWuxx9nWEiZ9ZRB3O5n/8OpbwgenRKXFbMLTzJEvcmpufsSBLnN5ToZV87m4nts0cM69Fl6PH6Fwdx6SnvwIPQmiC+OCzkBJj1hktz7kOmUuS3wrR474= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678121256167155.3334215903718; Mon, 6 Mar 2023 08:47:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrV-00046X-7x; Mon, 06 Mar 2023 10:34:53 -0500 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 1pZCrS-000455-QU for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:50 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrQ-0002BG-VA for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:50 -0500 Received: by mail-wm1-x32f.google.com with SMTP id p16so5911115wmq.5 for ; Mon, 06 Mar 2023 07:34:48 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O+ujOWWybD9KNJcAQ8vS9zB0/hV+GpzXbwAmASVSlKM=; b=O1fUZYsNbUOIuxp8faCHqwRLvdIuKDFWtWoocdh459b2HpXMGMecBu10H0CpVmR0TQ evZI/ET7ntu7QIzWskkE8PIwighCtcvT293DM5j3d4uRsfBJJ/noESnzpWGuswTx1T1z ezh18juQXSk/eKnTzvfJGaBRiU8k0dZ0z1Kb/3VGPFn1AzZB9E2ENK1ESLkqq8hR/YR9 K3DGmOPfqSB1EYlqHBR7yxPc9/flmcgA+NfLRT6GJa0phZiVOgdHSvfjRT7CELVlWpok wT2xfsIuN6vPVUZZvOgi8XMmqNazf02W2MtmIZvl4VUt2gfNMQrAb4Qlb8HKK1q31BcB TAsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O+ujOWWybD9KNJcAQ8vS9zB0/hV+GpzXbwAmASVSlKM=; b=WlbBen/oLW9HTke7AYogFvC64m1XFsjLV8jVRjz9lwXv5F3CzlgiUW6nMGxJLPoZx9 hkSDRVojzp0WEo8dKAD0+QXR2x6bG0Mtp5/7JsAoOPRyhBJKUYpIoJLInnW/j92FpPfb 8bzmoNjl2COtIlWimpYLEkHR3k3TWaSWi6zh08NZPmuJflEFjGGJ1Ip+1r10WsfpCV+/ 7AUeyXDs7wW1I7jHDxHv4KUqEt747WaHzMYcRIZwpTWOaToI0pMvXJDkIS1qT3knW2eL cBNPUVpXtn1eil66XKLl6VSs4mgY3cRZ7TJTkgGpMuvVSxldwNG/Git5NnLQeg4HN3lI uwEg== X-Gm-Message-State: AO0yUKXLZHgHevHyc0kyi3MB6lXkrYRbMbcM2oJ3gqhtxqkEtDqT0VaI Uf5q74y0ccCLQngFE93z6s5lNJ5D0YBLCrW+88E= X-Google-Smtp-Source: AK7set9KH1iQrAwB7HuiGerR7fDzyXUATLabC9RMZjlFd0a0R7ZGDpVVaCJ4swpieK8yIZI55oZElQ== X-Received: by 2002:a05:600c:1d09:b0:3eb:3945:d3f4 with SMTP id l9-20020a05600c1d0900b003eb3945d3f4mr10317130wms.2.1678116887643; Mon, 06 Mar 2023 07:34:47 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/21] target/arm: Export arm_v7m_get_sp_ptr Date: Mon, 6 Mar 2023 15:34:27 +0000 Message-Id: <20230306153435.490894-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678121258167100003 From: David Reiss Allow the function to be used outside of m_helper.c. Move to be outside of ifndef CONFIG_USER_ONLY block. Rename from get_v7m_sp_ptr. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Reiss Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-14-richard.henderson@linaro.org [rth: Split out of a larger patch] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- target/arm/internals.h | 10 +++++ target/arm/tcg/m_helper.c | 84 +++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 086e88e2377..b1ef05963f8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1360,6 +1360,16 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp= ); /* Read the CONTROL register as the MRS instruction would. */ uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure); =20 +/* + * Return a pointer to the location where we currently store the + * stack pointer for the requested security state and thread mode. + * This pointer will become invalid if the CPU state is updated + * such that the stack pointers are switched around (eg changing + * the SPSEL control bit). + */ +uint32_t *arm_v7m_get_sp_ptr(CPUARMState *env, bool secure, + bool threadmode, bool spsel); + #ifdef CONFIG_USER_ONLY static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } #else diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 03be79e7bfa..081fc3f5f75 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -650,42 +650,6 @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) arm_rebuild_hflags(env); } =20 -static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool thread= mode, - bool spsel) -{ - /* - * Return a pointer to the location where we currently store the - * stack pointer for the requested security state and thread mode. - * This pointer will become invalid if the CPU state is updated - * such that the stack pointers are switched around (eg changing - * the SPSEL control bit). - * Compare the v8M ARM ARM pseudocode LookUpSP_with_security_mode(). - * Unlike that pseudocode, we require the caller to pass us in the - * SPSEL control bit value; this is because we also use this - * function in handling of pushing of the callee-saves registers - * part of the v8M stack frame (pseudocode PushCalleeStack()), - * and in the tailchain codepath the SPSEL bit comes from the exception - * return magic LR value from the previous exception. The pseudocode - * opencodes the stack-selection in PushCalleeStack(), but we prefer - * to make this utility function generic enough to do the job. - */ - bool want_psp =3D threadmode && spsel; - - if (secure =3D=3D env->v7m.secure) { - if (want_psp =3D=3D v7m_using_psp(env)) { - return &env->regs[13]; - } else { - return &env->v7m.other_sp; - } - } else { - if (want_psp) { - return &env->v7m.other_ss_psp; - } else { - return &env->v7m.other_ss_msp; - } - } -} - static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, uint32_t *pvec) { @@ -810,8 +774,8 @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t= lr, bool dotailchain, !mode; =20 mmu_idx =3D arm_v7m_mmu_idx_for_secstate_and_priv(env, M_REG_S, pr= iv); - frame_sp_p =3D get_v7m_sp_ptr(env, M_REG_S, mode, - lr & R_V7M_EXCRET_SPSEL_MASK); + frame_sp_p =3D arm_v7m_get_sp_ptr(env, M_REG_S, mode, + lr & R_V7M_EXCRET_SPSEL_MASK); want_psp =3D mode && (lr & R_V7M_EXCRET_SPSEL_MASK); if (want_psp) { limit =3D env->v7m.psplim[M_REG_S]; @@ -1656,10 +1620,8 @@ static void do_v7m_exception_exit(ARMCPU *cpu) * use 'frame_sp_p' after we do something that makes it invalid. */ bool spsel =3D env->v7m.control[return_to_secure] & R_V7M_CONTROL_= SPSEL_MASK; - uint32_t *frame_sp_p =3D get_v7m_sp_ptr(env, - return_to_secure, - !return_to_handler, - spsel); + uint32_t *frame_sp_p =3D arm_v7m_get_sp_ptr(env, return_to_secure, + !return_to_handler, spse= l); uint32_t frameptr =3D *frame_sp_p; bool pop_ok =3D true; ARMMMUIdx mmu_idx; @@ -1965,7 +1927,7 @@ static bool do_v7m_function_return(ARMCPU *cpu) threadmode =3D !arm_v7m_is_handler_mode(env); spsel =3D env->v7m.control[M_REG_S] & R_V7M_CONTROL_SPSEL_MASK; =20 - frame_sp_p =3D get_v7m_sp_ptr(env, true, threadmode, spsel); + frame_sp_p =3D arm_v7m_get_sp_ptr(env, true, threadmode, spsel); frameptr =3D *frame_sp_p; =20 /* @@ -2900,3 +2862,39 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t a= ddr, uint32_t op) } =20 #endif /* !CONFIG_USER_ONLY */ + +uint32_t *arm_v7m_get_sp_ptr(CPUARMState *env, bool secure, bool threadmod= e, + bool spsel) +{ + /* + * Return a pointer to the location where we currently store the + * stack pointer for the requested security state and thread mode. + * This pointer will become invalid if the CPU state is updated + * such that the stack pointers are switched around (eg changing + * the SPSEL control bit). + * Compare the v8M ARM ARM pseudocode LookUpSP_with_security_mode(). + * Unlike that pseudocode, we require the caller to pass us in the + * SPSEL control bit value; this is because we also use this + * function in handling of pushing of the callee-saves registers + * part of the v8M stack frame (pseudocode PushCalleeStack()), + * and in the tailchain codepath the SPSEL bit comes from the exception + * return magic LR value from the previous exception. The pseudocode + * opencodes the stack-selection in PushCalleeStack(), but we prefer + * to make this utility function generic enough to do the job. + */ + bool want_psp =3D threadmode && spsel; + + if (secure =3D=3D env->v7m.secure) { + if (want_psp =3D=3D v7m_using_psp(env)) { + return &env->regs[13]; + } else { + return &env->v7m.other_sp; + } + } else { + if (want_psp) { + return &env->v7m.other_ss_psp; + } else { + return &env->v7m.other_ss_msp; + } + } +} --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678118087; cv=none; d=zohomail.com; s=zohoarc; b=c49AVY3mrvvo+93/9jYcDCBcvVPT/Ko+JWisccJOlUArAqO48/FocwSgj5RI26RBh0DdmgtEhbkIUvbdQaYCOMfnTu9Hy9l9flf1cyp7H5LgSVVEyBCkezpZs8g5D6HNY5gxE440WplqKOwB5WNdyYS0sXxmocVheTjqPe53f98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678118087; h=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=giRxJaHKMC7HAYy/Ff4KTNN2PtdjEIM4re8VlfvNXuI=; b=ZNsERPPA/QZdEbfK0YqxhOEbA73vUnPHoherb9CWESHPg0HzTHUpJhWL8TWtkEzeWHKoIR6XEOgjD9T8cKMPpQIY00GwNVzCRCQ/CqztA5SGD3JkRyM1Q8dPxiggc2TiG+FgtLG7nIEWJhIEiLaayMvLqDwg7dhl1bgWIR+/VfE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678118087600610.7023947307638; Mon, 6 Mar 2023 07:54:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrY-0004ET-Cm; Mon, 06 Mar 2023 10:34:56 -0500 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 1pZCrT-00045b-MV for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:51 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrR-0002BY-Mw for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:51 -0500 Received: by mail-wm1-x332.google.com with SMTP id p26so5916996wmc.4 for ; Mon, 06 Mar 2023 07:34:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=giRxJaHKMC7HAYy/Ff4KTNN2PtdjEIM4re8VlfvNXuI=; b=kvanG4h0rFHwCOUAJ/pApEInoXuYQ7CH19Gzg5GpJQc2aO9Pvivj9FIZ73zSbezOAi rTAQldN5L/+KbexSCjhorKRnkJm/QnxpMTrzoRLWKTgsqpiVmgoJt85wt1g+gOp8EWA0 zJ80/rkfqmxAIKcSAXyVMIh8447ZuSVYahHTDjVcSS6zK0EfwWv3E6/CvBs6Bl9MnEyL h0A5L/+LO0N0nkPnwdUrRHIKiWMsVi78AUaOr4oemuQrmn8UC1quRLjWjUEhSEU87VmP nXhUMzqHW/ohkV5XDymA6mFpbyehKhfRPqDhsFH6SkLwM7mur/JIo5CvO/Rt1qcjy1wV S6FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=giRxJaHKMC7HAYy/Ff4KTNN2PtdjEIM4re8VlfvNXuI=; b=1P8f4GBz0l56dQ/KfHEVobT8gJdGPBsAF+gjja9LF2kY1oWR2g/1tGw+tbQXPWS3pQ tMnxLm0usBRcLV8BADk2fX0l5TTS28lDuEV8lvlXRbhuEdCqD9BWO6AR+fsNZOXnBC6I JYvA5liKBtUAicKQuVOtWMik+1MOwz7cH1xl6NnWUHweBoUOympS8A1oPPeSxby6G2o+ ZilJi+RcyGqEBQayolqrhw766aobYutvrOS2gJrLt1LMzmNAtBghelxl1btmTKZkEW9E zW/zEspso+/0vWQ8yMGUdD3nS1AGx5dS/fAbPeKylToEFxRpxtq7C7yr41neMQvgTKXG 9yKA== X-Gm-Message-State: AO0yUKXZE52Y8ANnm6OnNMBmSpy47SZGf/WsFhvLPemSOg9FdyoFe6ZA drkxI7Qgu5uGLRlwHXWl6Yiysuz3C6icyr5bbM8= X-Google-Smtp-Source: AK7set8jiEF6grlY6n+OvX7pn8ILIxBQFes4Cu6vC59ZDHEdNOgEw72d8jdwQ91HFglMe7boBufKFA== X-Received: by 2002:a05:600c:198e:b0:3c6:e61e:ae71 with SMTP id t14-20020a05600c198e00b003c6e61eae71mr10603176wmq.1.1678116888368; Mon, 06 Mar 2023 07:34:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/21] target/arm: Implement gdbstub m-profile systemreg and secext Date: Mon, 6 Mar 2023 15:34:28 +0000 Message-Id: <20230306153435.490894-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678118088048100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The upstream gdb xml only implements {MSP,PSP}{,_NS,S}, but go ahead and implement the other system registers as well. Since there is significant overlap between the two, implement them with common code. The only exception is the systemreg view of CONTROL, which merges the banked bits as per MRS. Signed-off-by: David Reiss Signed-off-by: Richard Henderson Message-id: 20230227213329.793795-15-richard.henderson@linaro.org [rth: Substatial rewrite using enumerator and shared code.] Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 + target/arm/gdbstub.c | 178 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 379e74d1f99..c4bd22808ce 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -869,6 +869,8 @@ struct ArchCPU { =20 DynamicGDBXMLInfo dyn_sysreg_xml; DynamicGDBXMLInfo dyn_svereg_xml; + DynamicGDBXMLInfo dyn_m_systemreg_xml; + DynamicGDBXMLInfo dyn_m_secextreg_xml; =20 /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 062c8d447a0..3f799f5d058 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -322,6 +322,164 @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, i= nt base_reg) return cpu->dyn_sysreg_xml.num; } =20 +typedef enum { + M_SYSREG_MSP, + M_SYSREG_PSP, + M_SYSREG_PRIMASK, + M_SYSREG_CONTROL, + M_SYSREG_BASEPRI, + M_SYSREG_FAULTMASK, + M_SYSREG_MSPLIM, + M_SYSREG_PSPLIM, +} MProfileSysreg; + +static const struct { + const char *name; + int feature; +} m_sysreg_def[] =3D { + [M_SYSREG_MSP] =3D { "msp", ARM_FEATURE_M }, + [M_SYSREG_PSP] =3D { "psp", ARM_FEATURE_M }, + [M_SYSREG_PRIMASK] =3D { "primask", ARM_FEATURE_M }, + [M_SYSREG_CONTROL] =3D { "control", ARM_FEATURE_M }, + [M_SYSREG_BASEPRI] =3D { "basepri", ARM_FEATURE_M_MAIN }, + [M_SYSREG_FAULTMASK] =3D { "faultmask", ARM_FEATURE_M_MAIN }, + [M_SYSREG_MSPLIM] =3D { "msplim", ARM_FEATURE_V8 }, + [M_SYSREG_PSPLIM] =3D { "psplim", ARM_FEATURE_V8 }, +}; + +static uint32_t *m_sysreg_ptr(CPUARMState *env, MProfileSysreg reg, bool s= ec) +{ + uint32_t *ptr; + + switch (reg) { + case M_SYSREG_MSP: + ptr =3D arm_v7m_get_sp_ptr(env, sec, false, true); + break; + case M_SYSREG_PSP: + ptr =3D arm_v7m_get_sp_ptr(env, sec, true, true); + break; + case M_SYSREG_MSPLIM: + ptr =3D &env->v7m.msplim[sec]; + break; + case M_SYSREG_PSPLIM: + ptr =3D &env->v7m.psplim[sec]; + break; + case M_SYSREG_PRIMASK: + ptr =3D &env->v7m.primask[sec]; + break; + case M_SYSREG_BASEPRI: + ptr =3D &env->v7m.basepri[sec]; + break; + case M_SYSREG_FAULTMASK: + ptr =3D &env->v7m.faultmask[sec]; + break; + case M_SYSREG_CONTROL: + ptr =3D &env->v7m.control[sec]; + break; + default: + return NULL; + } + return arm_feature(env, m_sysreg_def[reg].feature) ? ptr : NULL; +} + +static int m_sysreg_get(CPUARMState *env, GByteArray *buf, + MProfileSysreg reg, bool secure) +{ + uint32_t *ptr =3D m_sysreg_ptr(env, reg, secure); + + if (ptr =3D=3D NULL) { + return 0; + } + return gdb_get_reg32(buf, *ptr); +} + +static int arm_gdb_get_m_systemreg(CPUARMState *env, GByteArray *buf, int = reg) +{ + /* + * Here, we emulate MRS instruction, where CONTROL has a mix of + * banked and non-banked bits. + */ + if (reg =3D=3D M_SYSREG_CONTROL) { + return gdb_get_reg32(buf, arm_v7m_mrs_control(env, env->v7m.secure= )); + } + return m_sysreg_get(env, buf, reg, env->v7m.secure); +} + +static int arm_gdb_set_m_systemreg(CPUARMState *env, uint8_t *buf, int reg) +{ + return 0; /* TODO */ +} + +static int arm_gen_dynamic_m_systemreg_xml(CPUState *cs, int orig_base_reg) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + GString *s =3D g_string_new(NULL); + int base_reg =3D orig_base_reg; + int i; + + g_string_printf(s, ""); + g_string_append_printf(s, "= "); + g_string_append_printf(s, "\n"); + + for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { + if (arm_feature(env, m_sysreg_def[i].feature)) { + g_string_append_printf(s, + "\n", + m_sysreg_def[i].name, base_reg++); + } + } + + g_string_append_printf(s, ""); + cpu->dyn_m_systemreg_xml.desc =3D g_string_free(s, false); + cpu->dyn_m_systemreg_xml.num =3D base_reg - orig_base_reg; + + return cpu->dyn_m_systemreg_xml.num; +} + +#ifndef CONFIG_USER_ONLY +/* + * For user-only, we see the non-secure registers via m_systemreg above. + * For secext, encode the non-secure view as even and secure view as odd. + */ +static int arm_gdb_get_m_secextreg(CPUARMState *env, GByteArray *buf, int = reg) +{ + return m_sysreg_get(env, buf, reg >> 1, reg & 1); +} + +static int arm_gdb_set_m_secextreg(CPUARMState *env, uint8_t *buf, int reg) +{ + return 0; /* TODO */ +} + +static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + GString *s =3D g_string_new(NULL); + int base_reg =3D orig_base_reg; + int i; + + g_string_printf(s, ""); + g_string_append_printf(s, "= "); + g_string_append_printf(s, "= \n"); + + for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { + g_string_append_printf(s, + "\n", + m_sysreg_def[i].name, base_reg++); + g_string_append_printf(s, + "\n", + m_sysreg_def[i].name, base_reg++); + } + + g_string_append_printf(s, ""); + cpu->dyn_m_secextreg_xml.desc =3D g_string_free(s, false); + cpu->dyn_m_secextreg_xml.num =3D base_reg - orig_base_reg; + + return cpu->dyn_m_secextreg_xml.num; +} +#endif + const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) { ARMCPU *cpu =3D ARM_CPU(cs); @@ -330,6 +488,12 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, cons= t char *xmlname) return cpu->dyn_sysreg_xml.desc; } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { return cpu->dyn_svereg_xml.desc; + } else if (strcmp(xmlname, "arm-m-system.xml") =3D=3D 0) { + return cpu->dyn_m_systemreg_xml.desc; +#ifndef CONFIG_USER_ONLY + } else if (strcmp(xmlname, "arm-m-secext.xml") =3D=3D 0) { + return cpu->dyn_m_secextreg_xml.desc; +#endif } return NULL; } @@ -389,4 +553,18 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cp= u) arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_re= gs), "system-registers.xml", 0); =20 + if (arm_feature(env, ARM_FEATURE_M)) { + gdb_register_coprocessor(cs, + arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, + arm_gen_dynamic_m_systemreg_xml(cs, cs->gdb_num_regs), + "arm-m-system.xml", 0); +#ifndef CONFIG_USER_ONLY + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + gdb_register_coprocessor(cs, + arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, + arm_gen_dynamic_m_secextreg_xml(cs, cs->gdb_num_regs), + "arm-m-secext.xml", 0); + } +#endif + } } --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678121130; cv=none; d=zohomail.com; s=zohoarc; b=mEsXb5m55BRniDoZARQvzaLJ3vMziVnGwkzeADI7JSv+0/v41y6dFuCM88vidmBzN9ugZAN/Mr6fQXnF8H+HRo5IJLC3ck4ElaZCX+g/klZsoqrTHh82JH4JGExXsbJwwn1XpQ+aE1/+pIRRQU8udWEu57QdkGegdKRbE0JYk54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678121130; h=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=u60JaY9ygpTLAXRdoEzrXQjDtvq2cbnHTzXyUO3Dx2k=; b=M7pPOYPTJP6ctJ5RLytFFS0+rda/NQXYzGHX8TKRmweNI7MQ1r2Hp0fSwJ8JTgv3oby/kVC+2cmLgRqoV+AujHAb2Hg/UwgHGwaZjK9GNcDq87lqfoYYH42wi9KXSFae3MQN/rjgVG5Ii/krCARkEcr1lG/k/7xZ2x2Di1hqzEE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678121130054564.6148071540908; Mon, 6 Mar 2023 08:45:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrV-00046a-8j; Mon, 06 Mar 2023 10:34:53 -0500 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 1pZCrT-00045F-C2 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:51 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrR-000289-Po for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:51 -0500 Received: by mail-wm1-x334.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so5452513wmq.1 for ; Mon, 06 Mar 2023 07:34:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=u60JaY9ygpTLAXRdoEzrXQjDtvq2cbnHTzXyUO3Dx2k=; b=l+ngQyuN2Nkwv4wODitLUNgMP3+oHoTXVXjM2RmZK5t3vUmGLUJYB7LwgzKlkVykKK BdYjOqWuT6gTy5VdkdYPjLhmcndfgXqsDgDbyHx5Yd6OWiWupU95uJKMZdHakkcvVfb1 QHWJnhVwVlmi7c8wwbH4V+Fw6gy5iM2p8SBIUhiH+w+Zb26jFJvO42UWChtq4TKEwZu2 6yb9HKYbekiUKyZPCBfUqrk4zRbyAgzxPWXDRt6vxdeaMTMDgbEkY9UfZrYKxycxJuQg R1BGrxTckzsT6axfqMwO21zVEDk6kSMHhxutB4pw1FoQi0yTanBrFJqipN54rA3+bz8k Vmug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u60JaY9ygpTLAXRdoEzrXQjDtvq2cbnHTzXyUO3Dx2k=; b=zGlsLfVSVOxpIIM9T1x3wzqQ7tSG/qUP9AjbweosqpO6275Zl30+trniFdnaDM/eCV 1jp7Ax7nkIBQ5qqVxEYFr7HEbVsRolwQjLiV42THl7wrHkp2HN3tmH1Xz6kITxX7CxjM dVTfiWlZl9gGAKbPkor3FyJOAJPzBLDy52e13rDS8vzDhJH2pChttGmpJo8M7eBbQ2zp A8mJTPmi/K5Kb7EJo2YFfVEgyiakmhA9emZXjLVcurUprmtDU0FeF11so0begNJXP6Zf GGOnSQnUKg5o3JislHhKAVS6IJ6seiubW2hJb8dwRUVPuYVBJJjzxY35DURZZjOQ+P/I 6QVg== X-Gm-Message-State: AO0yUKVSWnsS/reegbCumvzBZbmQxq43KHkhc7pTV/1Te5+ZjnVK8R57 k23mVXUjAjcBv5apGqH1pMXRjAsl7d9Z+byQkMg= X-Google-Smtp-Source: AK7set+CeeNXPs5l6p+mgANrCU5efmxuAxEFI9MtQ6NP3VaNheHNgDi0mtmqZCL1s5M7mDYtJiUfqA== X-Received: by 2002:a05:600c:35d5:b0:3eb:3945:d3fd with SMTP id r21-20020a05600c35d500b003eb3945d3fdmr9598810wmq.14.1678116889120; Mon, 06 Mar 2023 07:34:49 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/21] target/arm: Handle m-profile in arm_is_secure Date: Mon, 6 Mar 2023 15:34:29 +0000 Message-Id: <20230306153435.490894-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678121131157100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1421 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227225832.816605-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c4bd22808ce..ab187012770 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2421,6 +2421,9 @@ static inline bool arm_is_el3_or_mon(CPUARMState *env) /* Return true if the processor is in secure state */ static inline bool arm_is_secure(CPUARMState *env) { + if (arm_feature(env, ARM_FEATURE_M)) { + return env->v7m.secure; + } if (arm_is_el3_or_mon(env)) { return true; } --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678118611; cv=none; d=zohomail.com; s=zohoarc; b=WiTCQhGpbtLYjYAJQyLL+0Es3mCyZTmG4c7blX9F2jP8iq36Y5rDWM4kolenYTtPrO8MFOJgsK7Ip840nmCS5hLIRKX++h1h80q0YK4zD2JXz6LLjRJYfgvAZf/0k5pJYK90vG8+5BPWTsaTW+VFvAje7vHhHomXZiA+SXIaqys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678118611; h=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=HHkN0SaKlHUsXAIviWEKUhzT0wyDiiGZB3JY5pWTgTI=; b=oCDqjD/qZ5dJrUIqIGMSB32133eeN8DjAIiSMQsffIwuwQLj9n/3IDyLIcOXhX7In+xeVXI930VVyC7JVlJeNI+2hUYSPrCRqT2ZYnt5C8siU8RdaYFFv2SGN7D9dXdJUfjcUmJenlGVh5qm32W7eUCm/QjQkdthXF5CQ96BO14= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678118611022625.6667472361137; Mon, 6 Mar 2023 08:03:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrZ-0004HM-65; Mon, 06 Mar 2023 10:34:57 -0500 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 1pZCrU-00046G-Ny for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:52 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrT-0002Bu-7D for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:52 -0500 Received: by mail-wm1-x330.google.com with SMTP id az36so5941282wmb.1 for ; Mon, 06 Mar 2023 07:34:50 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HHkN0SaKlHUsXAIviWEKUhzT0wyDiiGZB3JY5pWTgTI=; b=dP5zC1iNrsuWI7pMVkf4zh6lHRd19MUCBb8yXi36U9PBfYVbJ5F0IPcMd8VsbMeJDg 91ZIVtxRculFy+N08jc3Vw+GbqhAsY6ojGGERjo22ByI3v1w3nRPr4aYUeEhpZHPB71b TZAjct2a+LVSJTbCbuxgczvvccA9G1klDo5epPktqTF7N/fbkvtFnniLYN9c2ZezqXZS lkBIlSAwdyfpVOlBrFGsNKoRVJAGbQXHsnc28g+nRaZsSMCtwJK9v62S+6sXUZvUkFoj EEL9Vn983LAVKn1nTvqqvBVn/Kr8Uw8ZmVL0HNpBDpWPIfpNsnw6wnrDTnJLlLMZidDI h/GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HHkN0SaKlHUsXAIviWEKUhzT0wyDiiGZB3JY5pWTgTI=; b=n6U3d6nkjGH3zDPMpay3/RP56qGgBojCp+KO/MOGG2Gh8YIvaPlGpI/3Dj3JU9FLCK sCXItucH8L6MfWPVGfHG7S0ICppxhcrA1cJWQOigLDNHQuPn/G9QHqDEN9mo3V+PUSxT rbA1PJ5jtZ6Pi+ooyRCMusX+/MyyAz27vBiyh0749dqeAYgJOIrFpBhRsATYOTFKI3AF G9ajlzNJ8YWzXW8cNMfKlrikiG3EQXA08etDVyYNPz2+/4JkHJVaVPISxDA2Op2Ym1nL InGh4dLgw1Bf+sJnDyZahqjQf5zwIfaeKPvv7WrnkdvSD0/+RzOmQSIDYkE4OLaryLK5 VrTA== X-Gm-Message-State: AO0yUKWMQhegJqdSUZhCyLYFtJsxrJBzZDEHR42VyC0ETexoR07m/qUu kwDQ70qrMFkkB1Ijj8iK7WT9kQlpVWGqs+FJIXo= X-Google-Smtp-Source: AK7set/qWv3hGmbXB8i/Er3t0jbJfAzAhSv4o5asSG41+1AnSL41l2xyl5ADFQTtMx0ku6Drrxc1wg== X-Received: by 2002:a05:600c:35cf:b0:3d0:6a57:66a5 with SMTP id r15-20020a05600c35cf00b003d06a5766a5mr9449125wmq.0.1678116889851; Mon, 06 Mar 2023 07:34:49 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/21] target/arm: Stub arm_hcr_el2_eff for m-profile Date: Mon, 6 Mar 2023 15:34:30 +0000 Message-Id: <20230306153435.490894-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678118729115100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson M-profile doesn't have HCR_EL2. While we could test features before each call, zero is a generally safe return value to disable the code in the caller. This test is required to avoid an assert in arm_is_secure_below_el3. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227225832.816605-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 82c546f11a9..2297626bfb3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5787,6 +5787,9 @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, b= ool secure) =20 uint64_t arm_hcr_el2_eff(CPUARMState *env) { + if (arm_feature(env, ARM_FEATURE_M)) { + return 0; + } return arm_hcr_el2_eff_secstate(env, arm_is_secure_below_el3(env)); } =20 --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120456; cv=none; d=zohomail.com; s=zohoarc; b=EIfGiM7SYSI0gS1xPtp1CWlnnxYMPVTe96mYOGCtJ8ZTcxVU2KLNVlLwQk0COXHNjReGdZPGz1HgySYvoUJFD8eFl5iwXPZ3GL7pqSCfkiWpBKDcMqHQfhJUGg4/cLP+c7u4pj2PM0O2RhQrYtJlkY1a7L/Q/oc77p/vfJ9ukTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120456; 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=eHmyDubzG8vE68B58KfrFN1VX33V9Ex12FkKohFAAaY=; b=GlES2S41q62VbEwcxb5PzN+J9NsudFqbUSzmEqT4VrL3kHJjqGivvjJu9jfgkuo+REitJcUlS3zfEbs3k6V3/VRRIRItqgzgHBCL17wVAAlbYBbCjDMZi6lar8U3wUC3sk6fVIdvTAG/K7u5q3J3YniS74aFaVDmf+1htKC8zUU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120456856778.7250105636259; Mon, 6 Mar 2023 08:34:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrW-0004By-Ty; Mon, 06 Mar 2023 10:34:54 -0500 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 1pZCrU-00046H-QP for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:52 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrT-00028L-9G for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:52 -0500 Received: by mail-wm1-x32f.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso5467969wmo.0 for ; Mon, 06 Mar 2023 07:34:50 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eHmyDubzG8vE68B58KfrFN1VX33V9Ex12FkKohFAAaY=; b=OXxTZSsN+9Uq1p+GthgrpcYWolXQ8Uni5ioudhBRcG27bn7Y5ivdYOCa81dTuxhZZk erhRoQEcs91g2ZgsdAG+v+lSCbT1ISaZQD52UpAP/IVB4TFZpLz4pYA9USf8KHIvSNth UFmul2XzotIay2r4yuXMaAghABls9H5HCgHqvNKUrcxzP4RkOrGsLQLXa5Fg3Kn4Uecw ABnn7zZmEwcDlip17FIo9hYuq+SB7J0yiL12H5zVUpobS+/CM6B+s2P0fXqmIv/XH+71 cQJr8Swu1epwlSOqIX6w4K85sLeErwfvdnECVQp3MguG8OpjSJRy5XvDw7WTU63Ar/z1 BFGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eHmyDubzG8vE68B58KfrFN1VX33V9Ex12FkKohFAAaY=; b=VVL+Na7T60cJgzVYdZ4Y4gVV8TOHaPRhmF4Uvj3RI+gWX90jS/toCPFAuYyTLjRAb3 zXq2sq38Pq1a8jMa7PHNohLLp6RRe6tg2fne+PscP9ZVvKfBf3+P29EGh9Rwn/ovkh6Y PyEKyPFK8xAJdhYHBBAJD50EE2adVjfzbbA02Zp94YHWvOcAnE8Uqef4hoFcFumGrm8i PXm/2igiANAyFfHzz8gx4ve7bh/zZPi13KrJwTghJUP3D9WKBRd+0PUi+R9nnjIzOR7A VumTHkR/dM8wE0nxDbODDwHzvB7NvsvPNKW58pP2UWluEz8IqTT8D0yGJCQ6NZezFR1u +JAg== X-Gm-Message-State: AO0yUKU758Viw3oAHQNMHygPwee/Fv0c9v9yKfoMfdFlZ+55bPjNxdYt gsDLyK1g4rNue3Uj9ur01RVrPC6BXegMHKPtVd8= X-Google-Smtp-Source: AK7set/XqQFCpfnv4NFf3QAbySfAk2t9R40reFtXU8AKlzk51M+fRnx1lFEStrMJX/MRgB48yBNoIg== X-Received: by 2002:a1c:f714:0:b0:3dc:433a:e952 with SMTP id v20-20020a1cf714000000b003dc433ae952mr9368835wmh.33.1678116890580; Mon, 06 Mar 2023 07:34:50 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/21] target/arm: Diagnose incorrect usage of arm_is_secure subroutines Date: Mon, 6 Mar 2023 15:34:31 +0000 Message-Id: <20230306153435.490894-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120457831100007 From: Richard Henderson In several places we use arm_is_secure_below_el3 and arm_is_el3_or_mon separately from arm_is_secure. These functions make no sense for m-profile, and would indicate prior incorrect feature testing. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20230227225832.816605-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ab187012770..c097cae9882 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2384,7 +2384,8 @@ static inline int arm_feature(CPUARMState *env, int f= eature) void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); =20 #if !defined(CONFIG_USER_ONLY) -/* Return true if exception levels below EL3 are in secure state, +/* + * Return true if exception levels below EL3 are in secure state, * or would be following an exception return to that level. * Unlike arm_is_secure() (which is always a question about the * _current_ state of the CPU) this doesn't care about the current @@ -2392,6 +2393,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **e= rrp); */ static inline bool arm_is_secure_below_el3(CPUARMState *env) { + assert(!arm_feature(env, ARM_FEATURE_M)); if (arm_feature(env, ARM_FEATURE_EL3)) { return !(env->cp15.scr_el3 & SCR_NS); } else { @@ -2405,6 +2407,7 @@ static inline bool arm_is_secure_below_el3(CPUARMStat= e *env) /* Return true if the CPU is AArch64 EL3 or AArch32 Mon */ static inline bool arm_is_el3_or_mon(CPUARMState *env) { + assert(!arm_feature(env, ARM_FEATURE_M)); if (arm_feature(env, ARM_FEATURE_EL3)) { if (is_a64(env) && extract32(env->pstate, 2, 2) =3D=3D 3) { /* CPU currently in AArch64 state and EL3 */ --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678118138; cv=none; d=zohomail.com; s=zohoarc; b=RiBDcDDBEPv84qJmvge2gNX67FqlKCch0DPDLtB9lcObHd48egK5+OnEiEEjH7FFdBFxv/8YWKPDDqC2nijRsXnCAzSaaQh2K4QTbxBnAPz+xVS5GUE2OZuvlWwwhHEi6gLKmQ8cmh7y6b6/OWRrux+6l2RsOWJr2RQ+TmYbu7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678118138; h=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=oM4iaq8anTSh1Jn8Mdn2lpnjy/er2PGT5FuI/Av5T4w=; b=JAxYALHKTmgmEf1VDAvCxPSnmGeYtLsnrK6hMy9KNk01ScRvgJuDD8kcFfJZFi6gceWFxuR6yM4M1BuUb4LEc+VP0QYyswfIOsk0XmL4ewWtQNDbI9H/qTa8GDwd7/7wol5UOZTi9gjhTVZysuHujZ1HLCifjQ68ETjAWaZbm80= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678118138486729.7241599226417; Mon, 6 Mar 2023 07:55:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrY-0004G1-Mr; Mon, 06 Mar 2023 10:34:56 -0500 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 1pZCrW-0004BD-KI for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:54 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrU-0002CN-LD for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:54 -0500 Received: by mail-wm1-x32f.google.com with SMTP id d41-20020a05600c4c2900b003e9e066550fso5432713wmp.4 for ; Mon, 06 Mar 2023 07:34:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oM4iaq8anTSh1Jn8Mdn2lpnjy/er2PGT5FuI/Av5T4w=; b=DTlBZTk5H+x4iQnizfBciUiEbzN6320886uNX/vksW0KWaUBrfhH6ofk1nYCefxrq9 tKYt0jwD2WpKW+owsO465cW73fB50wq+q0VagklvHVDelySRJccKOZl8f3RL0KVm+cBv E4dNuRNca+R9AYrk9h5G2WG50wBBeMGRt/oileqceH8NtpSIKknvOm/uXYpAfo+8i6Xv YGGM4vEa63LG7fHC8wx0fGj/EU06/Kc9fTp8tiL4RuAQrCfyZ6Lu35iHiq4dmMhW4IGP FSqlWiAEsreB6KduzeNTTqIaghqDtyU1+1U54xSQxNqaaIbhjjxo+880lNyvP7Wr3NLp JSOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oM4iaq8anTSh1Jn8Mdn2lpnjy/er2PGT5FuI/Av5T4w=; b=ks6eesXgFWH6Q1aB/j16lPpG14e0P3RbU6XCIPOGEEs4oaLT0vqRw4N+B3E0OzttYf J+PQBkIahEtiAHg8oEcvyjrmhxEDPviYhcpyFJmflMMZAi0iLwVBhib86lGHJvIHzpV0 pgtpYKYGv8Bd8/Pz5YDkFBPtAgChRAcOv5dEWH+TwjY4sPj9YFAfl/V+noQmaho9mzaw HznipCvOU5/bEJfWj2WV2mR1Lj2xpPTLU4cdUkv4hKw+JIQymov/80f63W/XV17VN9Mn lCl0+aoyPYmYA3u9AJNkTl6mmbyt6eKxTPowBSWscgpqU6Ao7I/hS0Ypu+gLcACgFQKl HwnQ== X-Gm-Message-State: AO0yUKWCbkpy3QsTsdbRBWb8Kjn0FYP+8jH8yvlYaYB7sHz3GiKTzpp3 o6XXDlmnS1tdLUuRR6FYIIr+FEKNTPMkS1GzF4c= X-Google-Smtp-Source: AK7set9AvSyzH0CIREuEjFr2/XO1el1KJWIDk2uJUTm+8A4O2p69gwP22cuzAewn9HMN6ufiNPmwVA== X-Received: by 2002:a05:600c:1d09:b0:3eb:3945:d3f4 with SMTP id l9-20020a05600c1d0900b003eb3945d3f4mr10317302wms.2.1678116891346; Mon, 06 Mar 2023 07:34:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/21] target/arm: Rewrite check_s2_mmu_setup Date: Mon, 6 Mar 2023 15:34:32 +0000 Message-Id: <20230306153435.490894-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678118140431100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Integrate neighboring code from get_phys_addr_lpae which computed starting level, as it is easier to validate when doing both at the same time. Mirror the checks at the start of AArch{64,32}.S2Walk, especially S2InvalidSL and S2InconsistentSL. This reverts 49ba115bb74, which was incorrect -- there is nothing in the ARM pseudocode that depends on TxSZ, i.e. outputsize; the pseudocode is consistent in referencing PAMax. Fixes: 49ba115bb74 ("target/arm: Pass outputsize down to check_s2_mmu_setup= ") Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230227225832.816605-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 173 ++++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 76 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8541ef56d61..ec3f51782aa 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1081,70 +1081,119 @@ static ARMVAParameters aa32_va_parameters(CPUARMSt= ate *env, uint32_t va, * check_s2_mmu_setup * @cpu: ARMCPU * @is_aa64: True if the translation regime is in AArch64 state - * @startlevel: Suggested starting level - * @inputsize: Bitsize of IPAs + * @tcr: VTCR_EL2 or VSTCR_EL2 + * @ds: Effective value of TCR.DS. + * @iasize: Bitsize of IPAs * @stride: Page-table stride (See the ARM ARM) * - * Returns true if the suggested S2 translation parameters are OK and - * false otherwise. + * Decode the starting level of the S2 lookup, returning INT_MIN if + * the configuration is invalid. */ -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) +static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, + bool ds, int iasize, int stride) { - const int grainsize =3D stride + 3; - int startsizecheck; - - /* - * Negative levels are usually not allowed... - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which - * begins with level -1. Note that previous feature tests will have - * eliminated this combination if it is not enabled. - */ - if (level < (inputsize =3D=3D 52 && stride =3D=3D 9 ? -1 : 0)) { - return false; - } - - startsizecheck =3D inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } + int sl0, sl2, startlevel, granulebits, levels; + int s1_min_iasize, s1_max_iasize; =20 + sl0 =3D extract32(tcr, 6, 2); if (is_aa64) { + /* + * AArch64.S2InvalidTxSZ: While we checked tsz_oob near the top of + * get_phys_addr_lpae, that used aa64_va_parameters which apply + * to aarch64. If Stage1 is aarch32, the min_txsz is larger. + * See AArch64.S2MinTxSZ, where min_tsz is 24, translated to + * inputsize is 64 - 24 =3D 40. + */ + if (iasize < 40 && !arm_el_is_aa64(&cpu->env, 1)) { + goto fail; + } + + /* + * AArch64.S2InvalidSL: Interpretation of SL depends on the page s= ize, + * so interleave AArch64.S2StartLevel. + */ switch (stride) { - case 13: /* 64KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 42)) { - return false; + case 9: /* 4KB */ + /* SL2 is RES0 unless DS=3D1 & 4KB granule. */ + sl2 =3D extract64(tcr, 33, 1); + if (ds && sl2) { + if (sl0 !=3D 0) { + goto fail; + } + startlevel =3D -1; + } else { + startlevel =3D 2 - sl0; + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + if (!cpu_isar_feature(aa64_st, cpu)) { + goto fail; + } + startlevel =3D 3; + break; + } } break; - case 11: /* 16KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 40)) { - return false; + case 11: /* 16KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 42) { + goto fail; + } + break; + case 3: + if (!ds) { + goto fail; + } + break; } + startlevel =3D 3 - sl0; break; - case 9: /* 4KB Pages. */ - if (level =3D=3D 0 && outputsize <=3D 42) { - return false; + case 13: /* 64KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + goto fail; } + startlevel =3D 3 - sl0; break; default: g_assert_not_reached(); } - - /* Inputsize checks. */ - if (inputsize > outputsize && - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. = */ - return false; - } } else { - /* AArch32 only supports 4KB pages. Assert on that. */ + /* + * Things are simpler for AArch32 EL2, with only 4k pages. + * There is no separate S2InvalidSL function, but AArch32.S2Walk + * begins with walkparms.sl0 in {'1x'}. + */ assert(stride =3D=3D 9); - - if (level =3D=3D 0) { - return false; + if (sl0 >=3D 2) { + goto fail; } + startlevel =3D 2 - sl0; } - return true; + + /* AArch{64,32}.S2InconsistentSL are functionally equivalent. */ + levels =3D 3 - startlevel; + granulebits =3D stride + 3; + + s1_min_iasize =3D levels * stride + granulebits + 1; + s1_max_iasize =3D s1_min_iasize + (stride - 1) + 4; + + if (iasize >=3D s1_min_iasize && iasize <=3D s1_max_iasize) { + return startlevel; + } + + fail: + return INT_MIN; } =20 /** @@ -1300,38 +1349,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, */ level =3D 4 - (inputsize - 4) / stride; } else { - /* - * For stage 2 translations the starting level is specified by the - * VTCR_EL2.SL0 field (whose interpretation depends on the page si= ze) - */ - uint32_t sl0 =3D extract32(tcr, 6, 2); - uint32_t sl2 =3D extract64(tcr, 33, 1); - int32_t startlevel; - bool ok; - - /* SL2 is RES0 unless DS=3D1 & 4kb granule. */ - if (param.ds && stride =3D=3D 9 && sl2) { - if (sl0 !=3D 0) { - level =3D 0; - goto do_translation_fault; - } - startlevel =3D -1; - } else if (!aarch64 || stride =3D=3D 9) { - /* AArch32 or 4KB pages */ - startlevel =3D 2 - sl0; - - if (cpu_isar_feature(aa64_st, cpu)) { - startlevel &=3D 3; - } - } else { - /* 16KB or 64KB pages */ - startlevel =3D 3 - sl0; - } - - /* Check that the starting level is valid. */ - ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride, outputsize); - if (!ok) { + int startlevel =3D check_s2_mmu_setup(cpu, aarch64, tcr, param.ds, + inputsize, stride); + if (startlevel =3D=3D INT_MIN) { + level =3D 0; goto do_translation_fault; } level =3D startlevel; --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678117971; cv=none; d=zohomail.com; s=zohoarc; b=QCelleG62Gry+o0u95kUApRDnMkMZl1AXCepynz/WutbLab3MXhkGFztK+Wn0LnwFLGdPckoElRgO8NVhUArP/YfYBB4qI7bnBxcPQWmQbobnKpf/QdSeZgrUWctr10vMHIns0C2fHWN4RhJoPJUMMOz6L980wyVpSyKXU+OCE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678117971; 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=4qRma+FaBHwuFNRAoeQ01NejW3D8pi+OySt7ClbAjqQ=; b=grvneznaym4gNCaJYnS0OZgMxs7mjF7304e+G5SDq2mw0kBMPToh1A2VhgVe0WkJppKIWPtxScgXbM7IilxEybExPKRl9M44QjtmTeI4HpI2J52pEhVWVW4q+VqVDClitxrQ8j7Vno6iP46cHkfchiss8NZ79+hTE25BD5Q/T5g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678117971515841.0815962723408; Mon, 6 Mar 2023 07:52:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCrY-0004GJ-QJ; Mon, 06 Mar 2023 10:34:56 -0500 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 1pZCrX-0004CO-BB for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:55 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrV-0002CT-Ah for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:55 -0500 Received: by mail-wr1-x435.google.com with SMTP id e13so9229767wro.10 for ; Mon, 06 Mar 2023 07:34:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4qRma+FaBHwuFNRAoeQ01NejW3D8pi+OySt7ClbAjqQ=; b=eGOJnN8O4hnnSifLG90yJFBZ6Y8AV9HqmgS5h114aVnu2vBARpwkbIEAhG6eN8T4Ry Ezk0Jr7l1du43AqVCvXMS/eQ80JjgUXr4OUPtoAusONic05zcHoB9IXX6qJnkswXGUQq hFkyregVZppw+KpbXz4WvixZxOt9LWNul2g7Uybbib87wwZlMi8NDqtMyIHSlrs0wB4L eKbwj4g93ff34zHbDOMfgMltEzeWtxgmdIJJ69c8+5d+UkG7/Q8Czo5V11lIJAiB2T12 WsL+3q8kVCRGS8vKG/N38hO1WlEeg2nV4zl6x9wNumZeCyjHprQkhFOPy+2XEkuu6bpC Kv6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4qRma+FaBHwuFNRAoeQ01NejW3D8pi+OySt7ClbAjqQ=; b=ztg4RrqsxrPqKX3UqocnoJaSGrr7oDf5LUbcuhI86nHnnYQATSqwKgr0YLf2zINgIO 2wEOKkcyKP0Q5rNZJVd95Pg9HCeyuyiq23+1z47a3ErUTnWg4DhtnvUYoObHZoDlEjk3 rs30ruhv7LXd6FvQ3SpPAt4ktIrrupF8Eb1VUOy/1mshJooOSSzy9iwv3SvOIDZGlSvI H6DQYthsi1B2f0HK2YqejODqlAwMecrkAwRYpOU5P+l7xpxR9vhV3DCdlS6UR4Kjj484 sQaC/n2tlPX9+JHJjNcalAiC0SfmVYma09yZ36g0HC13EzAXNhLdb2q3FusHlxHpA7aQ MHGA== X-Gm-Message-State: AO0yUKXfPHx3oGDxjiWmTJAroeYKy3TvkBnklwvxv0zEaS2vG/I7/i17 1Y5xrKctZo/KEM79noFXJC3UGoMDjGAWrTei8Lg= X-Google-Smtp-Source: AK7set+nZWihpINJpyFe/J3RxmgxkEQy9tCQgisc1irJ9dRVKXOy+JRIcEw22SU3MYL/t2U36c2PWA== X-Received: by 2002:adf:ef84:0:b0:2c7:e406:67d8 with SMTP id d4-20020adfef84000000b002c7e40667d8mr7779486wro.35.1678116892064; Mon, 06 Mar 2023 07:34:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/21] hw: arm: Support direct boot for Linux/arm64 EFI zboot images Date: Mon, 6 Mar 2023 15:34:33 +0000 Message-Id: <20230306153435.490894-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678117973462100003 From: Ard Biesheuvel Fedora 39 will ship its arm64 kernels in the new generic EFI zboot format, using gzip compression for the payload. For doing EFI boot in QEMU, this is completely transparent, as the firmware or bootloader will take care of this. However, for direct kernel boot without firmware, we will lose the ability to boot such distro kernels unless we deal with the new format directly. EFI zboot images contain metadata in the header regarding the placement of the compressed payload inside the image, and the type of compression used. This means we can wire up the existing gzip support without too much hassle, by parsing the header and grabbing the payload from inside the loaded zboot image. Cc: Peter Maydell Cc: Alex Benn=C3=A9e Cc: Richard Henderson Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Ard Biesheuvel Message-id: 20230303160109.3626966-1-ardb@kernel.org Reviewed-by: Peter Maydell [PMM: tweaked comment formatting, fixed checkpatch nits] Signed-off-by: Peter Maydell --- include/hw/loader.h | 19 ++++++++++ hw/arm/boot.c | 6 +++ hw/core/loader.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/include/hw/loader.h b/include/hw/loader.h index 1384796a4b3..c4c14170ea3 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -86,6 +86,25 @@ ssize_t load_image_gzipped_buffer(const char *filename, = uint64_t max_sz, uint8_t **buffer); ssize_t load_image_gzipped(const char *filename, hwaddr addr, uint64_t max= _sz); =20 +/** + * unpack_efi_zboot_image: + * @buffer: pointer to a variable holding the address of a buffer containi= ng the + * image + * @size: pointer to a variable holding the size of the buffer + * + * Check whether the buffer contains a EFI zboot image, and if it does, ex= tract + * the compressed payload and decompress it into a new buffer. If successf= ul, + * the old buffer is freed, and the *buffer and size variables pointed to = by the + * function arguments are updated to refer to the newly populated buffer. + * + * Returns 0 if the image could not be identified as a EFI zboot image. + * Returns -1 if the buffer contents were identified as a EFI zboot image,= but + * unpacking failed for any reason. + * Returns the size of the decompressed payload if decompression was perfo= rmed + * successfully. + */ +ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size); + #define ELF_LOAD_FAILED -1 #define ELF_LOAD_NOT_ELF -2 #define ELF_LOAD_WRONG_ARCH -3 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 1e021c4a340..50e5141116b 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -926,6 +926,12 @@ static uint64_t load_aarch64_image(const char *filenam= e, hwaddr mem_base, return -1; } size =3D len; + + /* Unpack the image if it is a EFI zboot image */ + if (unpack_efi_zboot_image(&buffer, &size) < 0) { + g_free(buffer); + return -1; + } } =20 /* check the arm64 magic header value -- very old kernels may not have= it */ diff --git a/hw/core/loader.c b/hw/core/loader.c index 173f8f67f6e..cd53235fed9 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -857,6 +857,97 @@ ssize_t load_image_gzipped(const char *filename, hwadd= r addr, uint64_t max_sz) return bytes; } =20 +/* The PE/COFF MS-DOS stub magic number */ +#define EFI_PE_MSDOS_MAGIC "MZ" + +/* + * The Linux header magic number for a EFI PE/COFF + * image targetting an unspecified architecture. + */ +#define EFI_PE_LINUX_MAGIC "\xcd\x23\x82\x81" + +/* + * Bootable Linux kernel images may be packaged as EFI zboot images, which= are + * self-decompressing executables when loaded via EFI. The compressed payl= oad + * can also be extracted from the image and decompressed by a non-EFI load= er. + * + * The de facto specification for this format is at the following URL: + * + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /drivers/firmware/efi/libstub/zboot-header.S + * + * This definition is based on Linux upstream commit 29636a5ce87beba. + */ +struct linux_efi_zboot_header { + uint8_t msdos_magic[2]; /* PE/COFF 'MZ' magic number */ + uint8_t reserved0[2]; + uint8_t zimg[4]; /* "zimg" for Linux EFI zboot imag= es */ + uint32_t payload_offset; /* LE offset to compressed payload= */ + uint32_t payload_size; /* LE size of the compressed paylo= ad */ + uint8_t reserved1[8]; + char compression_type[32]; /* Compression type, NUL terminate= d */ + uint8_t linux_magic[4]; /* Linux header magic */ + uint32_t pe_header_offset; /* LE offset to the PE header */ +}; + +/* + * Check whether *buffer points to a Linux EFI zboot image in memory. + * + * If it does, attempt to decompress it to a new buffer, and free the old = one. + * If any of this fails, return an error to the caller. + * + * If the image is not a Linux EFI zboot image, do nothing and return succ= ess. + */ +ssize_t unpack_efi_zboot_image(uint8_t **buffer, int *size) +{ + const struct linux_efi_zboot_header *header; + uint8_t *data =3D NULL; + int ploff, plsize; + ssize_t bytes; + + /* ignore if this is too small to be a EFI zboot image */ + if (*size < sizeof(*header)) { + return 0; + } + + header =3D (struct linux_efi_zboot_header *)*buffer; + + /* ignore if this is not a Linux EFI zboot image */ + if (memcmp(&header->msdos_magic, EFI_PE_MSDOS_MAGIC, 2) !=3D 0 || + memcmp(&header->zimg, "zimg", 4) !=3D 0 || + memcmp(&header->linux_magic, EFI_PE_LINUX_MAGIC, 4) !=3D 0) { + return 0; + } + + if (strcmp(header->compression_type, "gzip") !=3D 0) { + fprintf(stderr, + "unable to handle EFI zboot image with \"%.*s\" compressio= n\n", + (int)sizeof(header->compression_type) - 1, + header->compression_type); + return -1; + } + + ploff =3D ldl_le_p(&header->payload_offset); + plsize =3D ldl_le_p(&header->payload_size); + + if (ploff < 0 || plsize < 0 || ploff + plsize > *size) { + fprintf(stderr, "unable to handle corrupt EFI zboot image\n"); + return -1; + } + + data =3D g_malloc(LOAD_IMAGE_MAX_GUNZIP_BYTES); + bytes =3D gunzip(data, LOAD_IMAGE_MAX_GUNZIP_BYTES, *buffer + ploff, p= lsize); + if (bytes < 0) { + fprintf(stderr, "failed to decompress EFI zboot image\n"); + g_free(data); + return -1; + } + + g_free(*buffer); + *buffer =3D g_realloc(data, bytes); + *size =3D bytes; + return bytes; +} + /* * Functions for reboot-persistent memory regions. * - used for vga bios and option roms. --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120427; cv=none; d=zohomail.com; s=zohoarc; b=B5mIoFHE8OrAsqTgnjBpUOrV0m3X2ApLKEpNU24o8BpFssqKZ46MZSKSlWNOKU84uu5PZkLVF2QOhaYdVDezacoqyEBsNPt1XSq5G68JyCIkIxuJdY+QHYG8fFlwvVzty5BEuh2B+itOuTFT/b0N3dBfmX2PEXojZnZ3KWzkOCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120427; h=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=qP31mD2ZS9cywB36oY9I1cHer7hGLsKWqOnGtaEqcws=; b=ldI/i8raCgYkUzewO2LicmDS79XpKf63Hre7ip6oqXfXSnmDmMdWC/4Ie8ZRrwIIl2ySl2wuAYOzAXluJ8su5MIlwwm3OtgEHxv9dKC3ZsPirdw48GrBFG/9vDaqLva2DUP5U0+MOqYPU2vhD7acH31JWx1xFU0KKE8ZkSTnUsA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120427510874.2041230751258; Mon, 6 Mar 2023 08:33:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCra-0004IU-N3; Mon, 06 Mar 2023 10:34:58 -0500 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 1pZCrY-0004Fi-93 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:56 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrW-0002Cr-CL for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:55 -0500 Received: by mail-wm1-x332.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso8471109wmi.4 for ; Mon, 06 Mar 2023 07:34:53 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qP31mD2ZS9cywB36oY9I1cHer7hGLsKWqOnGtaEqcws=; b=KY8Jxcs3UI0Nm+W1ZrckE00wI8UrOmssOijRD/rDNJi6UukE6VY6aYr/3D0qemNh44 R/Tfqio2nFd9bJicIkloKYVYX3fmsFZdJ4at5VKzhr070OOfxnOQUctCYPKWo2f0yaF3 HEh+InizFxQS+yJk+3tglKVoPZDwVtFMMV+0ASDhYUoBrHxiXvTsT5olhN/ZVIFj1vbK 5YPoF2+k7nvaExv1ud16mr47Rj2mK86kKCdVv2rBSjvo9Q2+GHyeaz5tjcs86Ml19Dqe 5PnwDSeTRp/xyToe6oJQw2fDhAOmKz53TNqx7q3GpdWIbA1gwbhdbonMPhI3O4WBLjRz s2Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qP31mD2ZS9cywB36oY9I1cHer7hGLsKWqOnGtaEqcws=; b=ZDWDDi7pnJOSJox3WjQ58HdY1obdt4iB9joCz3aY86gWbX0voQa2ioWqzyQnICATef LofMp+PGqmSbK65B8sD/1wZLGMnbk6xJskCQBDH/oCN8P1y2uONesiy1UEZmwbDKob6J Ej+4WD9JK8bOp5yvz0av9qJ5bQJTQCfGYfIklvNN+N5mFjGZvp64prhsukHVJOLz2wFm 7AfaXgsRgnOfezTWA2z36343rXcypzODSUq/igRhoyZK/pVD1cA7tnsoYXn//KU1cGtB xOb8b28DWkUMFEXIOyxXP2rCrItOVuJ+XLYGxJMjKdVcxIo20wqhvBqIVzJIshnLs3Li MhRw== X-Gm-Message-State: AO0yUKUxNCXt3O6A/RCc/vUW1NMhPYTvcnDEJtWDaBoMe43HUfB1fT3q 93mS7LHtW99K9vHunIq2mvI7JrRoUQLWHPit/bE= X-Google-Smtp-Source: AK7set+o86oKnYHiiP6uJAFFrg2nwrB3uNakmqdBUuYWRUs7bcxJuAHoOxJQk1oSjhQ7Ur/gTgqPzg== X-Received: by 2002:a05:600c:4f15:b0:3eb:3998:36fa with SMTP id l21-20020a05600c4f1500b003eb399836famr9643198wmq.29.1678116892965; Mon, 06 Mar 2023 07:34:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/21] hw: allwinner-i2c: Fix TWI_CNTR_INT_FLAG on SUN6i SoCs Date: Mon, 6 Mar 2023 15:34:34 +0000 Message-Id: <20230306153435.490894-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120429634100003 Content-Type: text/plain; charset="utf-8" From: qianfan Zhao TWI_CNTR_INT_FLAG is W1C(write 1 to clear and write 0 has non-effect) register on SUN6i based SoCs, we should lower interrupt when the guest set this bit. The linux kernel will hang in irq handler(mv64xxx_i2c_intr) if no device connected on the i2c bus, next is the trace log: allwinner_i2c_write write CNTR(0x0c): 0xc4 A_ACK BUS_EN INT_EN allwinner_i2c_write write CNTR(0x0c): 0xcc A_ACK INT_FLAG BUS_EN INT_EN allwinner_i2c_read read CNTR(0x0c): 0xcc A_ACK INT_FLAG BUS_EN INT_EN allwinner_i2c_read read STAT(0x10): 0x20 STAT_M_ADDR_WR_NACK allwinner_i2c_write write CNTR(0x0c): 0x54 A_ACK M_STP BUS_EN allwinner_i2c_write write CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN allwinner_i2c_read read CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN allwinner_i2c_read read STAT(0x10): 0xf8 STAT_IDLE allwinner_i2c_write write CNTR(0x0c): 0x54 A_ACK M_STP BUS_EN allwinner_i2c_write write CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN allwinner_i2c_read read CNTR(0x0c): 0x4c A_ACK INT_FLAG BUS_EN allwinner_i2c_read read STAT(0x10): 0xf8 STAT_IDLE ... Fix it. Signed-off-by: qianfan Zhao Reviewed-by: Strahinja Jankovic Tested-by: Strahinja Jankovic Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/i2c/allwinner-i2c.h | 6 ++++++ hw/i2c/allwinner-i2c.c | 26 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h index 4f378b86ba1..0e325d265ee 100644 --- a/include/hw/i2c/allwinner-i2c.h +++ b/include/hw/i2c/allwinner-i2c.h @@ -28,6 +28,10 @@ #include "qom/object.h" =20 #define TYPE_AW_I2C "allwinner.i2c" + +/** Allwinner I2C sun6i family and newer (A31, H2+, H3, etc) */ +#define TYPE_AW_I2C_SUN6I TYPE_AW_I2C "-sun6i" + OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C) =20 #define AW_I2C_MEM_SIZE 0x24 @@ -50,6 +54,8 @@ struct AWI2CState { uint8_t srst; uint8_t efr; uint8_t lcr; + + bool irq_clear_inverted; }; =20 #endif /* ALLWINNER_I2C_H */ diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c index a4359658362..f24c3ac6f0c 100644 --- a/hw/i2c/allwinner-i2c.c +++ b/hw/i2c/allwinner-i2c.c @@ -357,10 +357,16 @@ static void allwinner_i2c_write(void *opaque, hwaddr = offset, s->stat =3D STAT_FROM_STA(STAT_IDLE); s->cntr &=3D ~TWI_CNTR_M_STP; } - if ((s->cntr & TWI_CNTR_INT_FLAG) =3D=3D 0) { - /* Interrupt flag cleared */ + + if (!s->irq_clear_inverted && !(s->cntr & TWI_CNTR_INT_FLAG)) { + /* Write 0 to clear this flag */ + qemu_irq_lower(s->irq); + } else if (s->irq_clear_inverted && (s->cntr & TWI_CNTR_INT_FL= AG)) { + /* Write 1 to clear this flag */ + s->cntr &=3D ~TWI_CNTR_INT_FLAG; qemu_irq_lower(s->irq); } + if ((s->cntr & TWI_CNTR_A_ACK) =3D=3D 0) { if (STAT_TO_STA(s->stat) =3D=3D STAT_M_DATA_RX_ACK) { s->stat =3D STAT_FROM_STA(STAT_M_DATA_RX_NACK); @@ -451,9 +457,25 @@ static const TypeInfo allwinner_i2c_type_info =3D { .class_init =3D allwinner_i2c_class_init, }; =20 +static void allwinner_i2c_sun6i_init(Object *obj) +{ + AWI2CState *s =3D AW_I2C(obj); + + s->irq_clear_inverted =3D true; +} + +static const TypeInfo allwinner_i2c_sun6i_type_info =3D { + .name =3D TYPE_AW_I2C_SUN6I, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(AWI2CState), + .instance_init =3D allwinner_i2c_sun6i_init, + .class_init =3D allwinner_i2c_class_init, +}; + static void allwinner_i2c_register_types(void) { type_register_static(&allwinner_i2c_type_info); + type_register_static(&allwinner_i2c_sun6i_type_info); } =20 type_init(allwinner_i2c_register_types) --=20 2.34.1 From nobody Mon Feb 9 20:18:19 2026 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1678120257; cv=none; d=zohomail.com; s=zohoarc; b=lzhwNkgeMTmbrN80mNLz0uH/tv/eYGtjYIY8kwKZiftptxvt1agtHXDDrJyxfRiPjcmJi2L+5mWX0UVduIeke4HSWb9beXzNaK5Frd9IKSaMLXGxy1mL4D1KQ8lfP2LLpJBc9hCiB/qNoTSKskIUITX9V8H7zi9IxMJba3eWj7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678120257; h=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=AGvJ/+azoSfvbLgBtU0OVWx+UNPYGoxdaOuHi65PSgM=; b=dR9DbET7hVig4LMJxICyaGwGBrt9iw3XEPQFpWkzR6wpi9539KRb1Jn6xCp4jfs+27sktkDU3F6/NVLSgs87jST3UiwaQvaPPRbsDhm89P+qrDa7CJCGdtvYZOarGJzm055yn1ThyVRZK4wlVAfUWyc36GnS3aEAf3i8Ybn7AyE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678120257668465.73166538801627; Mon, 6 Mar 2023 08:30:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZCra-0004I8-2Q; Mon, 06 Mar 2023 10:34:58 -0500 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 1pZCrY-0004Fh-8U for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:56 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZCrW-00029T-GC for qemu-devel@nongnu.org; Mon, 06 Mar 2023 10:34:55 -0500 Received: by mail-wm1-x32c.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so8488845wms.2 for ; Mon, 06 Mar 2023 07:34:54 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c444700b003eb0d6f48f3sm15287432wmn.27.2023.03.06.07.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678116893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AGvJ/+azoSfvbLgBtU0OVWx+UNPYGoxdaOuHi65PSgM=; b=fpbTlwWYYoWygDUytIlUL8CCvs8bPYKhK5NN4ia4MK5Wy09VMJswKAUagxwcz3M0E8 4L4QFT2MwMak3tX8HY1atnOoaaeiS6H1ziPZ+yNjiYY7F6/Djo9afh1jt+U8W4oyYkkL Ft51O6tz8kTQntzJOpRZ+BwIxxWtSMIXjNC7NsJawTT7TSDhg48yyZV1bgXTzgzlQKsf s6Si/lQ4+sAe1EhMXgBeBW45lJDuNFEVQrQh8BRufrzEAACyIgo9NUEzg+lXRifjBnol tt0QQthyFPC7x5W8Vfloz2I4MOp9QJJNbRKYdlBI3xAsfess1BBI+/B+b1Yaf09bBo6v yASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AGvJ/+azoSfvbLgBtU0OVWx+UNPYGoxdaOuHi65PSgM=; b=Y+/nep4cFlla+MGKiGhRK5lVuRNiy8ED5fIvveiVP+AtGsS0yBZQcclBvU2+/CnvV0 3u2jdqcJzQlqVnvDXWdArar196hbhrtqdcSLUPHMHTJkS5VX93lgfh/+sQltF/iIyWjL MSPZqTBgc69JGAGCYsE+P2dca6w69B7XQTfSWJkmcmXrA5bLJ+AJLx97XU0o+rreTq3t mNfpue7QVr77nInvPSkkDXb+tdoJ63t/h+D8HzahhLUrsS/cRYZZORdTcBNzl3NJdOCq OsHz455Mr7xS/RC48f8abyF4CMcF8mFlK+J/atm3cNKQ9yWPR5Do2ECU2xOjPSuLBDzy wvnA== X-Gm-Message-State: AO0yUKUYsmWyT7daNj+l8D+lj+GlV2cZlJgHc2MKEzG68UJYfaI0Mqvz XmRejM1VvZZa9D7yHG+0B7WBEOxvGrsStGB0E8U= X-Google-Smtp-Source: AK7set/Ov66OucYv2v4zPP+WCoooLMGeb86ORpi6mQZFUQLvSAdZxInYkUcpcUqetuLO3Bt2StW/lw== X-Received: by 2002:a05:600c:3153:b0:3ea:f73e:9d8c with SMTP id h19-20020a05600c315300b003eaf73e9d8cmr9960394wmo.16.1678116893785; Mon, 06 Mar 2023 07:34:53 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/21] hw: arm: allwinner-h3: Fix and complete H3 i2c devices Date: Mon, 6 Mar 2023 15:34:35 +0000 Message-Id: <20230306153435.490894-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306153435.490894-1-peter.maydell@linaro.org> References: <20230306153435.490894-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @linaro.org) X-ZM-MESSAGEID: 1678120257991100001 Content-Type: text/plain; charset="utf-8" From: qianfan Zhao Allwinner h3 has 4 twi(i2c) devices named twi0, twi1, twi2 and r_twi. The registers are compatible with TYPE_AW_I2C_SUN6I, write 1 to clear control register's INT_FLAG bit. Signed-off-by: qianfan Zhao Reviewed-by: Strahinja Jankovic Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/allwinner-h3.h | 6 ++++++ hw/arm/allwinner-h3.c | 29 +++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h index 1d7ce205890..59e0f822d2d 100644 --- a/include/hw/arm/allwinner-h3.h +++ b/include/hw/arm/allwinner-h3.h @@ -84,6 +84,8 @@ enum { AW_H3_DEV_UART3, AW_H3_DEV_EMAC, AW_H3_DEV_TWI0, + AW_H3_DEV_TWI1, + AW_H3_DEV_TWI2, AW_H3_DEV_DRAMCOM, AW_H3_DEV_DRAMCTL, AW_H3_DEV_DRAMPHY, @@ -93,6 +95,7 @@ enum { AW_H3_DEV_GIC_VCPU, AW_H3_DEV_RTC, AW_H3_DEV_CPUCFG, + AW_H3_DEV_R_TWI, AW_H3_DEV_SDRAM }; =20 @@ -133,6 +136,9 @@ struct AwH3State { AwSidState sid; AwSdHostState mmc0; AWI2CState i2c0; + AWI2CState i2c1; + AWI2CState i2c2; + AWI2CState r_twi; AwSun8iEmacState emac; AwRtcState rtc; GICState gic; diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index bfce3c8d92a..69d0ad6f50e 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -54,6 +54,8 @@ const hwaddr allwinner_h3_memmap[] =3D { [AW_H3_DEV_UART2] =3D 0x01c28800, [AW_H3_DEV_UART3] =3D 0x01c28c00, [AW_H3_DEV_TWI0] =3D 0x01c2ac00, + [AW_H3_DEV_TWI1] =3D 0x01c2b000, + [AW_H3_DEV_TWI2] =3D 0x01c2b400, [AW_H3_DEV_EMAC] =3D 0x01c30000, [AW_H3_DEV_DRAMCOM] =3D 0x01c62000, [AW_H3_DEV_DRAMCTL] =3D 0x01c63000, @@ -64,6 +66,7 @@ const hwaddr allwinner_h3_memmap[] =3D { [AW_H3_DEV_GIC_VCPU] =3D 0x01c86000, [AW_H3_DEV_RTC] =3D 0x01f00000, [AW_H3_DEV_CPUCFG] =3D 0x01f01c00, + [AW_H3_DEV_R_TWI] =3D 0x01f02400, [AW_H3_DEV_SDRAM] =3D 0x40000000 }; =20 @@ -107,8 +110,6 @@ struct AwH3Unimplemented { { "uart1", 0x01c28400, 1 * KiB }, { "uart2", 0x01c28800, 1 * KiB }, { "uart3", 0x01c28c00, 1 * KiB }, - { "twi1", 0x01c2b000, 1 * KiB }, - { "twi2", 0x01c2b400, 1 * KiB }, { "scr", 0x01c2c400, 1 * KiB }, { "gpu", 0x01c40000, 64 * KiB }, { "hstmr", 0x01c60000, 4 * KiB }, @@ -123,7 +124,6 @@ struct AwH3Unimplemented { { "r_prcm", 0x01f01400, 1 * KiB }, { "r_twd", 0x01f01800, 1 * KiB }, { "r_cir-rx", 0x01f02000, 1 * KiB }, - { "r_twi", 0x01f02400, 1 * KiB }, { "r_uart", 0x01f02800, 1 * KiB }, { "r_pio", 0x01f02c00, 1 * KiB }, { "r_pwm", 0x01f03800, 1 * KiB }, @@ -151,8 +151,11 @@ enum { AW_H3_GIC_SPI_UART2 =3D 2, AW_H3_GIC_SPI_UART3 =3D 3, AW_H3_GIC_SPI_TWI0 =3D 6, + AW_H3_GIC_SPI_TWI1 =3D 7, + AW_H3_GIC_SPI_TWI2 =3D 8, AW_H3_GIC_SPI_TIMER0 =3D 18, AW_H3_GIC_SPI_TIMER1 =3D 19, + AW_H3_GIC_SPI_R_TWI =3D 44, AW_H3_GIC_SPI_MMC0 =3D 60, AW_H3_GIC_SPI_EHCI0 =3D 72, AW_H3_GIC_SPI_OHCI0 =3D 73, @@ -227,7 +230,10 @@ static void allwinner_h3_init(Object *obj) =20 object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I); =20 - object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C); + object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C_SUN6I); + object_initialize_child(obj, "twi1", &s->i2c1, TYPE_AW_I2C_SUN6I); + object_initialize_child(obj, "twi2", &s->i2c2, TYPE_AW_I2C_SUN6I); + object_initialize_child(obj, "r_twi", &s->r_twi, TYPE_AW_I2C_SUN6I); } =20 static void allwinner_h3_realize(DeviceState *dev, Error **errp) @@ -432,6 +438,21 @@ static void allwinner_h3_realize(DeviceState *dev, Err= or **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI= 0)); =20 + sysbus_realize(SYS_BUS_DEVICE(&s->i2c1), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c1), 0, s->memmap[AW_H3_DEV_TWI1]= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c1), 0, + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI= 1)); + + sysbus_realize(SYS_BUS_DEVICE(&s->i2c2), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c2), 0, s->memmap[AW_H3_DEV_TWI2]= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c2), 0, + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI= 2)); + + sysbus_realize(SYS_BUS_DEVICE(&s->r_twi), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->r_twi), 0, s->memmap[AW_H3_DEV_R_TW= I]); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->r_twi), 0, + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_R_T= WI)); + /* Unimplemented devices */ for (i =3D 0; i < ARRAY_SIZE(unimplemented); i++) { create_unimplemented_device(unimplemented[i].device_name, --=20 2.34.1