From nobody Sun Nov 24 07:18:08 2024 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=1725633283; cv=none; d=zohomail.com; s=zohoarc; b=LxHgjX4rWGzNjdPPQJCNtH40hYcxwX5uZlZoM8NA1NthOWblvy8gpsoG4L10ZEB5oXBpOKYAuRjOMZywx9Ki5HGje1nc2ojh4K5Qp6gmdfP4mWL77kSEUnxh8jz7R0DnZvd0Ae401IlI04dfo4AxI0fNtXkUzhfwnmOTudUqDUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725633283; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jMYYkx/opjLXIlYN94qCm43SuWEXEBRd8nT29zGh3do=; b=Ml4BAommW+4Ii3zQ4Gq1yqIccoVx8G/gv9UTbJInHFyHClwidbbTJnPdav5BsJWURGsSo/Os41+rsq5bQnn0T5GBqfileFph5X3zaadmrnSiRd6Ou/ydmqaqqp09UkGoIc9x7P6XyKTsnOWpNt1IVkf5o4jvOBVP0WhW0wqgy4c= 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 1725633283040532.653547258478; Fri, 6 Sep 2024 07:34:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sma25-0000Rj-LP; Fri, 06 Sep 2024 10:33:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sma24-0000Mn-EW for qemu-devel@nongnu.org; Fri, 06 Sep 2024 10:33:52 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sma22-00073F-Mf for qemu-devel@nongnu.org; Fri, 06 Sep 2024 10:33:52 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-206b9455460so17389095ad.0 for ; Fri, 06 Sep 2024 07:33:50 -0700 (PDT) Received: from amd.. ([2804:7f0:b401:42a1:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206ae913cf1sm43844425ad.28.2024.09.06.07.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 07:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725633229; x=1726238029; darn=nongnu.org; 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=jMYYkx/opjLXIlYN94qCm43SuWEXEBRd8nT29zGh3do=; b=NoCXtYndMT0kzc+U8GvdI4139C6RDwXjWWW4IV7n14KTChkHGH3KREy/xWcnc5eaNU Td/ewdx743XB7txjn2QCexZzpqznxHcSZev4S05If+KRwpiuKJqTLHZ3rSpRlMjYtAqI hmpFIewirP/EKbiVSgwU65yYNTscUd13ob8uags2/4OmogLltXKycV1rnHzRscJpkVXA E0y/xbxCU0/8c8hG2lxnsrFs6NLwevf4adrIX0QuZZSye537wg61L9q+5ipNxqSORI1Q zrcR32TXj20KY9AnRdzHKh7oAuOckF1JyoEZfuNZeBk47U2OyhXuGTPVhwZxDSFFjvNN 8hHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725633229; x=1726238029; 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=jMYYkx/opjLXIlYN94qCm43SuWEXEBRd8nT29zGh3do=; b=wG20wWjWW+ZQCN7gxcVTkLmlSBnybllKCPQJEaFnZ5GJgPWZNk01DmJOMGrfC+57dn S4TaU+58TI7VFBYR9cSs98VUFUGwbHIiOM25xp1zRUCCnMiIdztqEav7EqtgHhgxP6F0 87aJ9UBvyFSYhoXGIvHQrNy+uNCKsZuUDFVzChkM1WMD/np0xrwbrKwoWHHw8WdZa1Fv 9kZYTN6Z3ZVuLVrd+aYX2MSUib66d089Q/+wzQJuMJDCF9X35rOPNRwECDbVTrApHpCW 1xlaXqU0UaiLpvTjHfv3GEznCLXxyU0lc/YTcs/25T9mqCXOuzDT2jSqrMfUpAmDPpwW Qzfg== X-Gm-Message-State: AOJu0YzVu1ztGFag9vlrsBMRTblxa1fcct5mZCs/tFNusOZ3bXSB1Ae+ kQKA5wr5B2rCYzEQHqeyIx+XKMzgn716f/MoiclI2HNYSp+VtZvg/QIMKrkhMSWsiX4e6YhBxe1 L X-Google-Smtp-Source: AGHT+IEjhs2YapdOhibgn+FXYzTbNwU8R8TnoLmdzqAcgutgIjlYFK6nBCrRiVOE56yZrouC+gQ9+Q== X-Received: by 2002:a17:902:f54d:b0:206:b618:1d96 with SMTP id d9443c01a7336-206ee75720fmr41868055ad.0.1725633228918; Fri, 06 Sep 2024 07:33:48 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, philmd@linaro.org, alex.bennee@linaro.org, richard.henderson@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH v4 1/5] gdbstub: Use specific MMU index when probing MTE addresses Date: Fri, 6 Sep 2024 14:33:12 +0000 Message-Id: <20240906143316.657436-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906143316.657436-1-gustavo.romero@linaro.org> References: <20240906143316.657436-1-gustavo.romero@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=2607:f8b0:4864:20::636; envelope-from=gustavo.romero@linaro.org; helo=mail-pl1-x636.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1725633284614116600 Content-Type: text/plain; charset="utf-8" Use cpu_mmu_index() to determine the specific translation regime (MMU index) before probing addresses using allocation_tag_mem_probe(). Currently, the MMU index is hardcoded to 0 and only works for user mode. By obtaining the specific MMU index according to the translation regime, future use of the stubs relying on allocation_tag_mem_probe in other regimes will be possible, like in EL1. This commit also changes the ptr_size value passed to allocation_tag_mem_probe() from 8 to 1. The ptr_size parameter actually represents the number of bytes in the memory access (which can be as small as 1 byte), rather than the number of bits used in the address space pointed to by ptr. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- target/arm/gdbstub64.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 5221381cc8..85a19c14c7 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -435,6 +435,7 @@ static void handle_q_memtag(GArray *params, void *user_= ctx) { ARMCPU *cpu =3D ARM_CPU(user_ctx); CPUARMState *env =3D &cpu->env; + uint32_t mmu_index; =20 uint64_t addr =3D gdb_get_cmd_param(params, 0)->val_ull; uint64_t len =3D gdb_get_cmd_param(params, 1)->val_ul; @@ -458,8 +459,10 @@ static void handle_q_memtag(GArray *params, void *user= _ctx) gdb_put_packet("E03"); } =20 + /* Find out the current translation regime for probe. */ + mmu_index =3D cpu_mmu_index(env_cpu(env), false); /* Note that tags are packed here (2 tags packed in one byte). */ - tags =3D allocation_tag_mem_probe(env, 0, addr, MMU_DATA_LOAD, 8 /* 64= -bit */, + tags =3D allocation_tag_mem_probe(env, mmu_index, addr, MMU_DATA_LOAD,= 1, MMU_DATA_LOAD, true, 0); if (!tags) { /* Address is not in a tagged region. */ @@ -478,13 +481,16 @@ static void handle_q_isaddresstagged(GArray *params, = void *user_ctx) { ARMCPU *cpu =3D ARM_CPU(user_ctx); CPUARMState *env =3D &cpu->env; + uint32_t mmu_index; =20 uint64_t addr =3D gdb_get_cmd_param(params, 0)->val_ull; =20 uint8_t *tags; const char *reply; =20 - tags =3D allocation_tag_mem_probe(env, 0, addr, MMU_DATA_LOAD, 8 /* 64= -bit */, + /* Find out the current translation regime for probe. */ + mmu_index =3D cpu_mmu_index(env_cpu(env), false); + tags =3D allocation_tag_mem_probe(env, mmu_index, addr, MMU_DATA_LOAD,= 1, MMU_DATA_LOAD, true, 0); reply =3D tags ? "01" : "00"; =20 @@ -495,6 +501,7 @@ static void handle_Q_memtag(GArray *params, void *user_= ctx) { ARMCPU *cpu =3D ARM_CPU(user_ctx); CPUARMState *env =3D &cpu->env; + uint32_t mmu_index; =20 uint64_t start_addr =3D gdb_get_cmd_param(params, 0)->val_ull; uint64_t len =3D gdb_get_cmd_param(params, 1)->val_ul; @@ -527,8 +534,10 @@ static void handle_Q_memtag(GArray *params, void *user= _ctx) * Get all tags in the page starting from the tag of the start address. * Note that there are two tags packed into a single byte here. */ - tags =3D allocation_tag_mem_probe(env, 0, start_addr, MMU_DATA_STORE, - 8 /* 64-bit */, MMU_DATA_STORE, true, = 0); + /* Find out the current translation regime for probe. */ + mmu_index =3D cpu_mmu_index(env_cpu(env), false); + tags =3D allocation_tag_mem_probe(env, mmu_index, start_addr, MMU_DATA= _STORE, + 1, MMU_DATA_STORE, true, 0); if (!tags) { /* Address is not in a tagged region. */ gdb_put_packet("E04"); --=20 2.34.1