From patchwork Tue Feb 28 00:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 657463 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:1b90:b0:222:2e2e:b2c3 with SMTP id e16csp3395207lty; Mon, 27 Feb 2023 16:38:15 -0800 (PST) X-Google-Smtp-Source: AK7set+QvT6Wej+FhD2C9pzwl7IEpMnvAn102lfhUoSpwUTOVERbVkq9mbDp+FbfiTGjLWYITg2q X-Received: by 2002:a05:6214:e6b:b0:570:bf45:d6f7 with SMTP id jz11-20020a0562140e6b00b00570bf45d6f7mr2091488qvb.45.1677544695523; Mon, 27 Feb 2023 16:38:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677544695; cv=none; d=google.com; s=arc-20160816; b=KsBbJdFQ0v4XFXqDAJLXku8c2hXtklVNifVQ9LpXQ77y5zvqv76IEwBHxXSpiG8oMo GVdlaJ9cSz1Y+lmqMhV/55nFeLkIfc1aDkQo+IcygLWxxTwjfFOyGgRs+2ohos/n25E+ G7yuauFUqSN+4Ju0oOjDgygpSOVhAd+nt/jRPQuFk8m4efMituNLYCtGYrSD4ZWNsGHT RxQixaz0EcvxCE7FnPm4H76FP8aC0i1IovuqELaa8Iy+gOFHbjgB34TtsYKhY3SJYLsv /vwKu/kvY3Bt/nbwkIKKEzeM6d0I2q9vwFumsd3cgken+xrjyhQIkh+m3p4JOD+ItwrD NZcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hB69UJs6DFGk5NVC6xvA04dBA1lHgG7I+VN9AFpQB6Q=; b=NkASgZVqjdkbie+FFgDFow+ThAgFGJda4I+PIfnJsySwkKFRiuD6ZtocD8uZ9IRFhA MPfBMWviYsUawWdmd0JSBNHoNBxX3HU0YAeLTm3v8Z1YKZHTMp6cZDFQ+8U2afdjqA60 Cm493SJMMCn0jFdIvSkKhVbd++tmDMx2FSIikAufzhbeQsvx6ESZK0+sWAPOtVD58m5P WZr16TMfv3qeno1d3BRZbUIBaC8CZ60zB4ThnKnkncedK2Nc+wd7nHmG5DeLNLCy/d9p XY3KDGbCutQLSRMdnAzSBu9bpdD1IW0tz2POy2SkP9xFJT8m4ch+C1IBHmrxIc02p751 +Auw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M4nHd6R8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m10-20020a05620a24ca00b00742c6e17487si1676807qkn.206.2023.02.27.16.38.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 16:38:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M4nHd6R8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWnzh-0006TK-Mt; Mon, 27 Feb 2023 19:37:25 -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 1pWnzf-0006So-VB for qemu-devel@nongnu.org; Mon, 27 Feb 2023 19:37:23 -0500 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWnze-0001Y3-1R for qemu-devel@nongnu.org; Mon, 27 Feb 2023 19:37:23 -0500 Received: by mail-pj1-x1043.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so7961447pjp.2 for ; Mon, 27 Feb 2023 16:37:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hB69UJs6DFGk5NVC6xvA04dBA1lHgG7I+VN9AFpQB6Q=; b=M4nHd6R8BWQhOYrvrQ5nUXpXx6OfgqNQJ7qzcIVZzvk6JnPNYxVbd7QJxK1eBmQd4H DYARK/NUv6f+iqAqgmFZzOozKYUVDmfkr+0fXNUiSjl8hZVtGpDCNQKxWYnkPa8/UH94 acPvEfFYB+znDsoUeM8EK+jFnD/Es3fhLYFzjA+lTe2e1XQkrAiMtKlPy0f8LS8FGn7M Mp/p+FG8iOBWcagT5L0pOdSAw0mAlJ3bgpGiOt71yCLhRfIl8DF4yJMojMbstZRJOoTM 365oUlLhwbp/FHW2yt5eHSAe/x4vNM/5zPNIn7OQwUpkzB08zzGYvH2VkhX4SnM7y2+A Q3aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hB69UJs6DFGk5NVC6xvA04dBA1lHgG7I+VN9AFpQB6Q=; b=QDfuQoo2HnTO4KwYeaSfjqITu9PTmPkTt/CZEeEIzkoJCPnxLuYetA6bDtwNTJp6Y9 4q72OxGJZO9iJKXd2tjUXUeW6JrG1wQpmoPzIJ4p3orUCSeH5Zyizaq64Cxa4Gmw8y3Y 13cssME7i8diuFozPaQhZdhG/opCgtwG4UzXfjJTNdPHgT8BmjJP2b3Y68kD5XAVW0cz Xsmud4VjtMYtmg2wfO/Oz2RlisWwwPgLQZeIbC/Al93fLFTs0krRkAuJlX1N7dRGids1 5KWmxLQZAa2eGGv6xZVXNsdEDZbwF03B6nt2ixzgpp7EMa0hZLUfyrd3U49ukQJbQpRy lIdA== X-Gm-Message-State: AO0yUKV/2Ao089kUE6nqJX+i2Ym+kL2Qmjj9JbUpQ13kdyeidFMi/SLX 4SvLPV4EFfN4DTf3MSaSeGdqNfKrhYuNnQ6cpJJlOQ== X-Received: by 2002:a17:903:1c1:b0:19d:20f7:dafa with SMTP id e1-20020a17090301c100b0019d20f7dafamr838651plh.43.1677544640562; Mon, 27 Feb 2023 16:37:20 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id p19-20020a1709028a9300b0019cec7d88c3sm5192651plo.236.2023.02.27.16.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:37:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 3/3] target/arm: Support reading ZA[] from gdbstub Date: Mon, 27 Feb 2023 14:37:13 -1000 Message-Id: <20230228003713.861168-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230228003713.861168-1-richard.henderson@linaro.org> References: <20230228003713.861168-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1043.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Mirror the existing support for SVE. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 1 + target/arm/internals.h | 3 ++ target/arm/gdbstub.c | 8 ++++ target/arm/gdbstub64.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 6e97a256fb..9971280577 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -869,6 +869,7 @@ struct ArchCPU { DynamicGDBXMLInfo dyn_sysreg_xml; DynamicGDBXMLInfo dyn_svereg_xml; + DynamicGDBXMLInfo dyn_zareg_xml; DynamicGDBXMLInfo dyn_m_systemreg_xml; DynamicGDBXMLInfo dyn_m_secextreg_xml; diff --git a/target/arm/internals.h b/target/arm/internals.h index a03748aa10..a27e5b3f28 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1343,12 +1343,15 @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) #ifdef TARGET_AARCH64 int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); +int arm_gen_dynamic_zareg_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); 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); +int aarch64_gdb_get_za_reg(CPUARMState *env, GByteArray *buf, int reg); +int aarch64_gdb_set_za_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 3f799f5d05..60a9ade732 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -488,6 +488,8 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) return cpu->dyn_sysreg_xml.desc; } else if (strcmp(xmlname, "sve-registers.xml") == 0) { return cpu->dyn_svereg_xml.desc; + } else if (strcmp(xmlname, "za-registers.xml") == 0) { + return cpu->dyn_zareg_xml.desc; } else if (strcmp(xmlname, "arm-m-system.xml") == 0) { return cpu->dyn_m_systemreg_xml.desc; #ifndef CONFIG_USER_ONLY @@ -524,6 +526,12 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) aarch64_gdb_set_pauth_reg, 4, "aarch64-pauth.xml", 0); } + if (cpu_isar_feature(aa64_sme, cpu)) { + int nreg = arm_gen_dynamic_zareg_xml(cs, cs->gdb_num_regs); + gdb_register_coprocessor(cs, aarch64_gdb_get_za_reg, + aarch64_gdb_set_za_reg, nreg, + "za-registers.xml", 0); + } #endif } else { if (arm_feature(env, ARM_FEATURE_NEON)) { diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 3bee892fb7..9210d12c4e 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -244,6 +244,61 @@ int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg) return 0; } +static int max_svq(ARMCPU *cpu) +{ + return 32 - clz32(cpu->sme_vq.map); +} + +int aarch64_gdb_get_za_reg(CPUARMState *env, GByteArray *buf, int reg) +{ + ARMCPU *cpu = env_archcpu(env); + int max_vq = max_svq(cpu); + int cur_vq = EX_TBFLAG_A64(env->hflags, SVL) + 1; + int i; + + if (reg >= max_vq * 16) { + return 0; + } + + /* If ZA is unset, or reg out of range, the contents are zero. */ + if (FIELD_EX64(env->svcr, SVCR, ZA) && reg < cur_vq * 16) { + for (i = 0; i < cur_vq; i++) { + gdb_get_reg128(buf, env->zarray[reg].d[i * 2 + 1], + env->zarray[reg].d[i * 2]); + } + } else { + cur_vq = 0; + } + + for (i = cur_vq; i < max_vq; i++) { + gdb_get_reg128(buf, 0, 0); + } + + return max_vq * 16; +} + +int aarch64_gdb_set_za_reg(CPUARMState *env, uint8_t *buf, int reg) +{ + ARMCPU *cpu = env_archcpu(env); + uint64_t *p = (uint64_t *) buf; + int max_vq = max_svq(cpu); + int cur_vq = EX_TBFLAG_A64(env->hflags, SVL) + 1; + int i; + + if (reg >= max_vq * 16) { + return 0; + } + + /* If ZA is unset, or reg out of range, the contents are zero. */ + if (FIELD_EX64(env->svcr, SVCR, ZA) && reg < cur_vq * 16) { + for (i = 0; i < cur_vq; i++) { + env->zarray[reg].d[i * 2 + 1] = *p++; + env->zarray[reg].d[i * 2 + 0] = *p++; + } + } + return max_vq * 16; +} + static void output_vector_union_type(GString *s, int reg_width, const char *name) { @@ -376,3 +431,36 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) info->num = base_reg - orig_base_reg; return info->num; } + +/* + * Generate the xml for SME, with matrix size set to the maximum + * for the cpu. Returns the number of registers generated. + */ +int arm_gen_dynamic_zareg_xml(CPUState *cs, int base_reg) +{ + ARMCPU *cpu = ARM_CPU(cs); + GString *s = g_string_new(NULL); + int vq = max_svq(cpu); + int row_count = vq * 16; + int row_width = vq * 128; + int i; + + g_string_printf(s, ""); + g_string_append_printf(s, ""); + g_string_append_printf(s, ""); + + output_vector_union_type(s, row_width, "zav"); + + for (i = 0; i < row_count; i++) { + g_string_append_printf(s, + "", + i, row_width, base_reg + i); + } + + g_string_append_printf(s, ""); + + cpu->dyn_zareg_xml.num = row_count; + cpu->dyn_zareg_xml.desc = g_string_free(s, false); + return row_count; +}