From patchwork Fri Nov 3 19:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740705 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp7186wrr; Fri, 3 Nov 2023 13:00:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+PB3E165RB2pTVxDEytp+hThCX92rG3ps2RcgNjWp5oGW411i8lW4wBjlcJ9YiUQRRjpe X-Received: by 2002:a05:620a:3916:b0:77a:4aa:5507 with SMTP id qr22-20020a05620a391600b0077a04aa5507mr26691292qkn.1.1699041650193; Fri, 03 Nov 2023 13:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041650; cv=none; d=google.com; s=arc-20160816; b=N3h4OOTJj7DkAykmwIzFF+C0jrWdo2lPVaEbATCnWPDx4SNH76hT6jL/A1lYKTHDh9 K/JXeSbNXNtsBCb0kFeCTryk7oq5qOSCDxzNeTGHNh1SyIyOhf4wGF+GC2ASvVcLESTK DPOtn5V5Xg6/xVPsI2O7Gw4tU4ZrICh7lWTeYEzYKG3odx+B7jRV8Ki+OtNu9pXDDXAM cqEOdk9OGXYsnARAqrhibJZpwB+zoo5Ygy9ueA6ZiU23bpC1jRj5yg4idbIZ9WUzvRLr idnI7m/WttOKfqeRz7FlbYpDgSa7XeTSoxri/dm1gEgbnBhUhDD84ClAbnHVskMDg4yC gS4Q== 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=B8f4GTCXoafF/KsbNQ8bEyDSKUwReC+SK1TUkgZ9c4E=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=w4f1w2wYv4H45NuK8ZSB54dUdlYF+7+6BuTtEuTCMGloxq+CiGHkujpTEdDurJpf5s dVVJKDqJGV/kxdOtUj//6gZkqr1yQNU1aEYtmE9kUz/wqNG3vhNyAAVb3nYXl+oe+yaA BVEnpmIXUk4chNSw03uoFcQesPYtT5OSViGRR/X6FQrYSyB3rmFuY8BaS02NmI9DvmP+ A3BVB9lpTU1gvfl54la1insyDUYLAOy4llO5TJAV8pJzc9nWBYHpqV2kTivI7Wn7ONFK lvntDpSIl+weHWm0y70KzDs9BaZe4i+KJFej2ABcGruGv+NZgZQcuEIwnISBQJ63R+Fy EUNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yyiUJVCA; 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 rh6-20020a05620a8f0600b007758ffaef15si1864850qkn.522.2023.11.03.13.00.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:00:50 -0700 (PDT) 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=yyiUJVCA; 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 1qz0Kp-00082y-EO; Fri, 03 Nov 2023 16:00:03 -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 1qz0Kn-00081h-AP for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:01 -0400 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 1qz0Kl-0005K7-Ix for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:01 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-408382da7f0so18074665e9.0 for ; Fri, 03 Nov 2023 12:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041597; x=1699646397; 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=B8f4GTCXoafF/KsbNQ8bEyDSKUwReC+SK1TUkgZ9c4E=; b=yyiUJVCAbWpvx/rF4wb1moai1c8mFga3Qdn+mau3PtxuxulbuUrlrA4eSrEBm3Jc/6 a0XlFgPW3Tu58stVMrg8/a3yPWiyS3EMymhvrgAOrDk53B64gpI/FgMLmsDB6D9QDClk xXgbADJWva4VGlR3Zf1X7pWostwOvuad866Iz8A+9M5nW1H0Xspd5nWXKHTSqz98CceT ERO2uVMqyLadT6ZQM82cWsvPXNi8Ajc9h2YKfWB+fmR/M0Mg1UHGTbmTjlc427Itzpw0 AQ4ra0zcirV2hGajfRbMdBriwDBmZlfYGF8cohWJ0DGaFukCgm0ls9rlynkk1mAWx/y8 nCeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041597; x=1699646397; 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=B8f4GTCXoafF/KsbNQ8bEyDSKUwReC+SK1TUkgZ9c4E=; b=WMDJ5qA/4S/MRuR2VF1MD5rmhVR3UWx4frlLsrIzIrO21QL/EWXJT2youdaRjwkSmU BCybnZfqc5gMF1UUlRflFc61mbM2fgm62vvmljnUTIryBP8imOO7OumO8VZsn03PkMbi lNjZhFzJzN0ZPwHhgrlb3PKeKbW88x9FcHFc9e4+0zqDmZcljIjFndj3b5WrtB3n1uJJ OVsbDL+LXyFyioBt84Z9fJi1/LCXIxOpV0TrDQv0VgwP+gkpClklAj3GEfFfBLNz174d ox5Vb1JE/ueqwDWywSNJYyimmJOdnnpJ8eYufmk3MuYXMkcvsOrGwym7ykMHCKM0PyOY VgZg== X-Gm-Message-State: AOJu0YxJf779/EwvuMKflUyHwHfAfYhLjZ+mfuFWpDRl0+Ws30WYdyDj 5OxFzbAmIc7DSj2prPmtIVP3FA== X-Received: by 2002:a05:600c:4e91:b0:408:4918:590e with SMTP id f17-20020a05600c4e9100b004084918590emr17896853wmq.39.1699041597490; Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r18-20020a05600c35d200b00401e32b25adsm3557288wmq.4.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BDC2A65740; Fri, 3 Nov 2023 19:59:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 01/29] default-configs: Add TARGET_XML_FILES definition Date: Fri, 3 Nov 2023 19:59:28 +0000 Message-Id: <20231103195956.1998255-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki loongarch64-linux-user has references to XML files so include them. Fixes: d32688ecdb ("default-configs: Add loongarch linux-user support") Signed-off-by: Akihiko Odaki Message-Id: <20231030054834.39145-6-akihiko.odaki@daynix.com> Reviewed-by: Philippe Mathieu-Daudé --- configs/targets/loongarch64-linux-user.mak | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/targets/loongarch64-linux-user.mak b/configs/targets/loongarch64-linux-user.mak index 7d1b964020..43b8a2160f 100644 --- a/configs/targets/loongarch64-linux-user.mak +++ b/configs/targets/loongarch64-linux-user.mak @@ -1,3 +1,4 @@ # Default configuration for loongarch64-linux-user TARGET_ARCH=loongarch64 TARGET_BASE_ARCH=loongarch +TARGET_XML_FILES=gdb-xml/loongarch-base32.xml gdb-xml/loongarch-base64.xml gdb-xml/loongarch-fpu.xml From patchwork Fri Nov 3 19:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740720 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp10457wrr; Fri, 3 Nov 2023 13:06:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhjHPVGkR0mIXT+vIA3TZHyg1GP+9QGJfOx92CeA/Ms97l0PrsRho7K8SMt4BLwQFpCMxd X-Received: by 2002:ac8:570e:0:b0:41c:bc89:9cf5 with SMTP id 14-20020ac8570e000000b0041cbc899cf5mr28698738qtw.56.1699041996826; Fri, 03 Nov 2023 13:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041996; cv=none; d=google.com; s=arc-20160816; b=siwIJJR2lZnLN4Q5kpnTK6jWRed1gpQDWykAwdupjd7mpF9eLiMRM9AoTmYJND0sFM 573ki0MdnunwW989XR4WSUMEMqXwtabTvo0Vu/AKUdU8zlNOfXKIhpIkY+qEeZca9Men cYQiSrq7YVlD/SRaHCLZgD8ppDjGVv2U0wSW/fW4118fJFemm87U92iQJQD+2Pa1iPFn JKdHQWsn7W14DhzK8JmxLxB1nTSCXQ+AxQ64dVHfuzWlzadyy3EtcjETeBa6LwHygOtZ x2s19val7XDRyRTDmZgw8+ZtUgtnhpfpJ1jxNa6zAzhOlW069y6yOkEQeCaba7YIDoXk Hb3A== 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=CPYnsi2vv7vTp2m4L+dzwYGsIeLimoixnt1R7Ke6aYI=; fh=Kx2XI2Yx2wBtcq6Uh/oWjWfpY5DZOGguZfb2uQrLFXM=; b=dnYccS8/8Kds6Niu0MbjJUFjwvAcZxTH/8ICT5XAutfHAHDu+CEsy/ToyVJNWOcl6+ dMI6ZIvkSPh/64/2KZsFgpobk/xlLd+pfUsEBz/A6tyF5hzf3BpgHSznC4lm6LgjjzuZ U3QpxSAToiRhU4VRGemF0/Ri7jsd33x8mmKq5X3PMhlOPXOq18tJK/Bzac2v26zazz5H oXnjLcWavYUbUjiJa4xQEj/BYB6Q2/SZKfN/VcLEfUV2TM7YbxuWDbDEWMU32q8LETaS 2C9/ElAvbcznLhG87zGlfeYQac5COHIQLDEqS7l+o6esVbZF/2wVEG1zIOK8wboJd9S4 GjSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=izFMecW5; 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 o17-20020a05622a045100b0041cc447304asi2027658qtx.222.2023.11.03.13.06.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:06:36 -0700 (PDT) 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=izFMecW5; 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 1qz0L0-00088z-Oi; Fri, 03 Nov 2023 16:00:18 -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 1qz0Kt-00085E-3S for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:07 -0400 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 1qz0Km-0005KG-Ej for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:06 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40839652b97so18879945e9.3 for ; Fri, 03 Nov 2023 12:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041598; x=1699646398; 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=CPYnsi2vv7vTp2m4L+dzwYGsIeLimoixnt1R7Ke6aYI=; b=izFMecW5QboeUK3UzbGTXdwfwocJGjuq9j/8Tv0OM9wEkMzs3apMw00cDyCYmVoO9G uqSEWRK1Hn6VwPbl77s/I0DC04oQcFrmgPMXLRgO6T4pDdnb2tJX9HgFHgWq8z5aY7+a b43HWXD7Jw56uQsnK+BRd1UHdlH1BDSzyq8BbM9cvhEPHGjoZTw/ODcpKPzMHzyIiObO /jVMaf21q9Y7onejH9s8NcfrCnnTz7jChXkz3hYGqXcLpzDGFPZfWjUMlmsL0opzRMCu VhSUgObAsyGd9DB+MistL+qjhj6JLRm2g9jkh9R4ScUgVb4qDMAQTs0IFyUKbB4bvMZ6 5+8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041598; x=1699646398; 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=CPYnsi2vv7vTp2m4L+dzwYGsIeLimoixnt1R7Ke6aYI=; b=AzduH2ArbXX2B9nIq+vI84XYoqW2APdH1q6vbHN8fwmEoxnakdXZbeRyjnQQg3MadC SV4DNyO7xiZ6aG3OEObK5wNFGAW8vozeyfAAfWCZ7aLTI2soVV0iOljI1Hkupx/rVS0a AZegQTg/ZfAW9FrDbT5BeWqM9I3jfzviw48fTdHh0tGqVrmzOyaSpZPKXtHQAanc/WuC 2T0h8pTzcbpjwHDUFVbfOH4UnFoc2boYOAf6BghbmHRSCUxR9ONu2/fySCGdieFJRNcO MGYnMMoqFa4jNbKaNBPEDrWxPDbval8q1aSfeisDffnH7wau5jiGq/8B0NC3Sfaw5vLj Y6Hw== X-Gm-Message-State: AOJu0Yymn1M0SloN/QPCdFlAQ5F+bBkzqKorNLdtercTxzNbzemQz0Z2 SSHbJR87/rXIi5XU0ijE/KMJvQ== X-Received: by 2002:a05:600c:524a:b0:407:8459:2ef9 with SMTP id fc10-20020a05600c524a00b0040784592ef9mr19220943wmb.21.1699041597974; Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c12-20020a05600c0a4c00b0040775501256sm3595619wmq.16.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D47F865741; Fri, 3 Nov 2023 19:59:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik Subject: [PATCH 02/29] gdb-xml: fix duplicate register in arm-neon.xml Date: Fri, 3 Nov 2023 19:59:29 +0000 Message-Id: <20231103195956.1998255-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- gdb-xml/arm-neon.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb-xml/arm-neon.xml b/gdb-xml/arm-neon.xml index 9dce0a996f..d61f6b8549 100644 --- a/gdb-xml/arm-neon.xml +++ b/gdb-xml/arm-neon.xml @@ -76,7 +76,7 @@ - + From patchwork Fri Nov 3 19:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740718 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9639wrr; Fri, 3 Nov 2023 13:05:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5m1wjvREY3mx39YyTj7MDS9tGDS3q1zOCPY+iYDsgvIy0qrrBxKVosMeQgz4uZj4rWb6/ X-Received: by 2002:a05:620a:24c1:b0:774:2dc0:649b with SMTP id m1-20020a05620a24c100b007742dc0649bmr6396977qkn.18.1699041904225; Fri, 03 Nov 2023 13:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041904; cv=none; d=google.com; s=arc-20160816; b=LZmVVRnUivONM8KpbxfRjJN2argJ2vbx4p8BKvGeDO9wBW0OGt5U1cd9/2xtnqtE1Q 5nc1B+VwrHvCOOs+cU7+/6vmhpauQ3xcn3QgLH9ruWaB9TYPu+TINPLx5lhzpIzzWx/s jp2226F6qB1gdN7evz8jelHWzezCm1LBeYNQo0Qb6PozeQ6tv92EAWTKj37ZiuTooKx7 8xsiBO5PvM1QhxD2ycT1RMn/HSP/ezaIzBmhbwgvp3nHnfSNQ6tfG8pYfG7KFXjwQa/T xEY7n0Kwp6vkrFO3haYDKmUlAx6xwSpZINRPnICxSJqR1z8Yj7FhqfD4PfHXQd5RK8dz Tzpg== 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=KYZuWVa43D0DKc9oObff9+vpWR6o8oc5r5+fymGHhRI=; fh=Kx2XI2Yx2wBtcq6Uh/oWjWfpY5DZOGguZfb2uQrLFXM=; b=jyHUnmWTIpowDXyV8LAn3sK/msLcN06N1zPCvA+o6MGHfjKZ2p72nSRZ+LmYeZzyuW 6bAxqqo7E0EC+fpNTK4Ij7hpWfdfVQyY96XHHpDVkODqZlL7nzSpRrglHrqnW145Mplg J/O4eaLkD97zyJspBdvYl9xjFzmxw8gPfrKGUtC1voVqL/u7rC+rex3XzCnxBopX3ZJ7 elH50wRq4uvTSuWCHfqWrp47EkGR4JKJiyfM5RxwD6FJgLGxYw0I76MYpGyCtZ4BBhQR 4fvHgIientGQLyPUBWwlNSZaL0XkFmpS+iw8tHDFi8/Dnt/oZI8z4PJVDcQukYWoWTO3 4vdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cumF0FkW; 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 a12-20020a05620a438c00b00779ab3d4204si2069608qkp.648.2023.11.03.13.05.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:05:04 -0700 (PDT) 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=cumF0FkW; 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 1qz0LV-0008Rk-8f; Fri, 03 Nov 2023 16:00:45 -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 1qz0Kv-00088o-Pc for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:09 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kp-0005Ld-DJ for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:09 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32fb95dfe99so533096f8f.2 for ; Fri, 03 Nov 2023 13:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041601; x=1699646401; 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=KYZuWVa43D0DKc9oObff9+vpWR6o8oc5r5+fymGHhRI=; b=cumF0FkWaivF51fD/Urub2D1CpzAw2Dz6T1PT7trM7nguvlDlry20iSM0w+uGp9TYv NKJeE2aLI5aGWmXu9BWZDL2lD8nKbx+6NNCOnKU7vIP6X7a8Z/FdS8VVF4fmNtbq4wh6 VcifJETRim+/sVOHRSn60cmH0Ao/VOv+8AFNrXSRTQmhQCMSPPSIbeaZhzs4Y5lclwpf A3NSuEMbHghKZT1SWZnL/yPX+Js2p4n9EiZq2iOhM+lamFakVw+ymIL8X68zvkodAH2J zaRyCSOL+lr/B6n5YWVxXZbNonoT5ZNZvLjrEOJ/EEyPqHehzPcEJLfQ8HKstjtUTbdZ KGfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041601; x=1699646401; 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=KYZuWVa43D0DKc9oObff9+vpWR6o8oc5r5+fymGHhRI=; b=GylYoE9CjBVynD9scw4lGQRUzXbpgP1jobuZuUTUb+NKvbFDhp4XZdbVTbb4bN8+Ow lbiM7r1oOX8zx5vEtWVh5pAI1nKEbso1CyAZmrlksvJapfUhQ92u1t3vpxfegqfiHqMA IjLrph1sSawBX9qJJw/ZRCQzPqcQ2kh0H0iBfGuNeccH54BDAwvjCU9wb+yy0GyXvQNf TCsX0inzfmz3s3p98BO09WdvkPpLDm9h14ZgyNyLIeDaHUZAQuI6zmW11WAzJNrzZNri uU1ep+TEUhdFuHp6Y2qwFyOHsK139T7C/l4Fd8zFp813nAz9Xt4OmBBI18+xIG2TpWAO K3wQ== X-Gm-Message-State: AOJu0YzSg2Ra2+DS824x9+wE902KX19XdEbK7OFSAyAoY+PkbQeLfOAw 7QDpC5Q806atlQsGZmRuud/N8g== X-Received: by 2002:adf:f18f:0:b0:32f:bdb5:98b0 with SMTP id h15-20020adff18f000000b0032fbdb598b0mr1409673wro.66.1699041600885; Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r7-20020adff107000000b0032db8f7f378sm2625170wro.71.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EBCA865742; Fri, 3 Nov 2023 19:59:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik Subject: [PATCH 03/29] target/arm: hide the 32bit version of PAR from gdbstub Date: Fri, 3 Nov 2023 19:59:30 +0000 Message-Id: <20231103195956.1998255-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is a slightly hacky way to avoid duplicate PAR's in the system register XML we send to gdb which causes an alias. However the other alternative would be to post process ARMCPRegInfo once all registers have been defined looking for textual duplicates. And that seems like overkill. Signed-off-by: Alex Bennée --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5dc0d20a84..104f9378b4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3727,7 +3727,7 @@ static const ARMCPRegInfo vapa_cp_reginfo[] = { .access = PL1_RW, .resetvalue = 0, .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.par_s), offsetoflow32(CPUARMState, cp15.par_ns) }, - .writefn = par_write }, + .writefn = par_write, .type = ARM_CP_NO_GDB }, #ifndef CONFIG_USER_ONLY /* This underdecoding is safe because the reginfo is NO_RAW. */ { .name = "ATS", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = CP_ANY, From patchwork Fri Nov 3 19:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740714 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9246wrr; Fri, 3 Nov 2023 13:04:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvYRQSjRe9UP9Il8F0TK5swcuTLJHUiXfMZ6jc2ggfe6EL38tNF6xZSS54tDAiTLTH+6hr X-Received: by 2002:a1f:1e52:0:b0:49a:8237:c81 with SMTP id e79-20020a1f1e52000000b0049a82370c81mr22168005vke.13.1699041864274; Fri, 03 Nov 2023 13:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041864; cv=none; d=google.com; s=arc-20160816; b=bya0a5J+sof6Ko25E77ziKsXiLZo5L8qFnNjujhZ3EakoKY+P1BkCigrhng+64SSwZ DD8hAnNd+Nf5H417HeJHQ28hHwVjhXhE/ylTTkQ2jBt/y5XoduV65TcHuBAeRUPThzu0 v4zmCuauw/NOX97RXV61fAZD4/Cexlqy1+hquo6qS04espwO/Uy3lhWSG5PXl579kr4D L3XuJAUJSsF5dZCsyNwjr1VqFLp+UvIxekzvoFojh/yaPjNDQjH3pPtIgXHrJvQrBtMQ dzNwkPmzsYseDJDpjse1i7iCTdcSQtUAuRqwckK72QDEwkyVoS3nlBOBgKa0CKG2ZwjP ONyw== 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=BFMvrord6ftw6meFXnjRr6xGn8w/+aIYxd+SGyvGmrM=; fh=Kx2XI2Yx2wBtcq6Uh/oWjWfpY5DZOGguZfb2uQrLFXM=; b=zOceTeTioA9dtXPvwoPTSCfKBrf46fsF/IlrIvc0AmL/U2pGH1al/52TYrn3RnevZQ +7T4wnggGXZ8bHATcrLueMNhvkvh2rGHsm+BJFCWs0IcTtCJcWokCz6AX9sZ9rlod6uQ uDeu771meuP8aZyh3vIDDRUBkEODOvcrPM2DgLd96S2SSxmYAFSj41lp+BYL1eYCC74U KttOIaHj1rpY9ihvhFOxzIPcoxISsVbputIRiLtZt9JLpCq3MfJpc8ZZwzvgTXPSSOkh D9AqGgmB3MDDgFhcUIOrutqp9flDbQRYFEgCEDvZsLmcdiozvk3JnrrrBJLSkNbd9L6g m+xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GrGJv7UI; 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 pf2-20020a056214498200b006719629c973si2195677qvb.583.2023.11.03.13.04.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:04:24 -0700 (PDT) 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=GrGJv7UI; 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 1qz0Mc-0001VO-Uq; Fri, 03 Nov 2023 16:01:54 -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 1qz0L3-00089l-8S for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:18 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kp-0005LV-BV for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:16 -0400 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507a55302e0so3226721e87.0 for ; Fri, 03 Nov 2023 13:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041600; x=1699646400; 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=BFMvrord6ftw6meFXnjRr6xGn8w/+aIYxd+SGyvGmrM=; b=GrGJv7UITNHPg0ynahUsJ4rIAdwbeqhDZAhHY34+sKYX1xackDrYpqWoCsJxogAfcx hBXorNxP0/V5wWk1uQbz7h5DHzyUTZJSfgNwqXOMP9SD8tcVUJpNEwddibGJuO5YOFU+ vvw4WT/fstb7cl5wx39Zaze7zVXDQJVm1jCFzTs/fZ7kAPwlgDBnBSJQNvmYt23rIY8M kpJhqi2vsyX8ACMSF1pIepNbLV5tvkzTsds9/m+1rWuu60hmJVcaDL4CqSeM97G9SGgx JXwf7CGmdKoyfgNXHwd/3runu/4cgJ5u8IJkhtXmyS6+GiHveYI6BNFpR5owfatksiYX yFhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041600; x=1699646400; 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=BFMvrord6ftw6meFXnjRr6xGn8w/+aIYxd+SGyvGmrM=; b=hWEJJ40gpMZ6fae5Oj03HzcBgYhUl7B56UaM0VGcJBiLUiO095rD+JnWJZyJrqCDil dbgo7fssMgeeiSRF+eMtrIhk+fYeXgtoF5RpAil6Rl49svstOMweAkxKco9lym+kIrYK EdoUtRYYUPWnNhnU//34maA9t90JlLNb4LtH+SLJk4CNZTkBzUh8QT/JhA98Rg7Eb6Rp HQj/m4eU5hytQL9dZJbFsxw5cTdTjntMunUybNxtHCn/3A+aND34JUKPbPeWOtGXVzGr kD/Me+LBZWXtkRUgJJStmD2IPe5NBuzZaVDY4aD++4aodIPmfFsFBAbiga/WZTdZ4a/5 zskg== X-Gm-Message-State: AOJu0YxWp7xz37PAPDBitjGhzMSNPayF1mAUgdsqT09SvIlbKAd0TDgx R4WX5ItVCGYZqEcHp52kTkweBw== X-Received: by 2002:a05:6512:969:b0:509:377a:26d9 with SMTP id v9-20020a056512096900b00509377a26d9mr7454336lft.8.1699041600653; Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p12-20020adfe60c000000b0032d886039easm2608269wrm.14.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 12:59:57 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1004665743; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik Subject: [PATCH 04/29] target/arm: hide all versions of DBGD[RS]AR from gdbstub Date: Fri, 3 Nov 2023 19:59:31 +0000 Message-Id: <20231103195956.1998255-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x130.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This avoids two duplicates being presented to gdbstub. As the registers are RAZ anyway it is unlikely their value would be of use to someone using gdbstub anyway. Signed-off-by: Alex Bennée --- target/arm/debug_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index 79a3659c0c..dc783adba5 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -937,14 +937,14 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { */ { .name = "DBGDRAR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL0_R, .accessfn = access_tdra, - .type = ARM_CP_CONST, .resetvalue = 0 }, + .type = ARM_CP_CONST | ARM_CP_NO_GDB, .resetvalue = 0 }, { .name = "MDRAR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0, .access = PL1_R, .accessfn = access_tdra, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DBGDSAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL0_R, .accessfn = access_tdra, - .type = ARM_CP_CONST, .resetvalue = 0 }, + .type = ARM_CP_CONST | ARM_CP_NO_GDB, .resetvalue = 0 }, /* Monitor debug system control register; the 32-bit alias is DBGDSCRext. */ { .name = "MDSCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, @@ -1065,9 +1065,9 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { /* 64 bit access versions of the (dummy) debug registers */ { .name = "DBGDRAR", .cp = 14, .crm = 1, .opc1 = 0, - .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, + .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_64BIT | ARM_CP_NO_GDB, .resetvalue = 0 }, { .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0, - .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, + .access = PL0_R, .type = ARM_CP_CONST | ARM_CP_64BIT | ARM_CP_NO_GDB, .resetvalue = 0 }, }; static void dbgwvr_write(CPUARMState *env, const ARMCPRegInfo *ri, From patchwork Fri Nov 3 19:59:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740715 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9325wrr; Fri, 3 Nov 2023 13:04:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEB6e7xIpygwo4WL40FnB5bCt7zqNWDvPprMJ0Spd/zmCG5dtt2K6DRjsyz8GcXISXnH+2i X-Received: by 2002:a05:6808:10c4:b0:3b2:9d31:9d25 with SMTP id s4-20020a05680810c400b003b29d319d25mr28497715ois.31.1699041870946; Fri, 03 Nov 2023 13:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041870; cv=none; d=google.com; s=arc-20160816; b=Y38ZLjZabSzh5WMgQosuF5JDZeb4NzUn+TLaP0L9lnnbv3MsB5oQj7x3IP94WGfd2g RlsfLKjce2hUVzrtcMEC4/yg9s2lfpyQ6j84u9gnmjzsSNnunBduVcvj3aCcqnRw4HzC 12vRrFkV1pbjDWFqeoN1V74ba++zZJ7KXHazOQBIVD/AhH+cCZe3DVlJwnhXbbBTE3Gr EN7rv2PSIbC70SWXQoFpOm1gpUJ+1sTquEn1z1dxYDQUt4L0urNc4Co3BCoFxNRIJ/u9 7SeI5WqlL0oMfS5/jiliiTVB0i5m4dpbZtPPQSci5FQlHTmdJzIn+vmkfUjT4b9suQed EObw== 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=FOqnYMzgaGsmQAv+x6tXhfxA9uZJN4iQTJsdqhjfa28=; fh=Kx2XI2Yx2wBtcq6Uh/oWjWfpY5DZOGguZfb2uQrLFXM=; b=yXWRZGzAE3frL/lLvjkLPU3JWpyKrikjOjQz0Lbx9jZgqJnKW4BwAgvNrGo15vjklb Dz5IMIfHqcu1acQTXjGQKu+qexjh65MBU78TToHGQEBo7r70spn5g7nas1MpUAhk/jKH sxq3QN5YXFP54FUnnrod7SH/AlPIVViJjDbz5M4Hi1+H3OBbbm5R0gu2e7mE9jlaPoTI Bs1WDaEV1O8cAUgaNK7QwevI8dvGzP5ups3i14Ly0noK66I2P+AHXP19hBDf9yNp7V9M omNftcDcILOOapglS1RoOe7psVM0KPBhyvCo+HuudgaSfzQMZi9Oc6o0J50StAGKauwN xvOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XKIVIIeA; 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 y6-20020a05620a44c600b0076ef0da9545si2164229qkp.736.2023.11.03.13.04.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:04:30 -0700 (PDT) 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=XKIVIIeA; 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 1qz0Li-0000LB-UC; Fri, 03 Nov 2023 16:00:58 -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 1qz0L3-00089k-5Y for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:18 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kq-0005Nf-JA for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:11 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40836ea8cbaso17637465e9.0 for ; Fri, 03 Nov 2023 13:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041603; x=1699646403; 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=FOqnYMzgaGsmQAv+x6tXhfxA9uZJN4iQTJsdqhjfa28=; b=XKIVIIeAwb/pWmcOfETXO/HY2D3p/WyIr7W/m0acW/mR8ShxDR1FDhErXGAJRThTEJ c9hJdGaso1bHiB6cQiyz5FgDCJwzk9czmAmIR/FcW6zDPA9Y4TpSck5CPlC+MavBa5KP cT/JAsFdWtltqVkF65Sm7y95S6snYkH5LSdG6KenPq0piDjGtnrGg2flJziL87F/ptaR LoCUGmSP4z12jYB0iHOpN2lj7CYqUSmHSl+KGVUUfPqqVQNWQNy7IyS5f4MZbnwNbpQx VcQMF2oeI9urMfki+QdMXekf+EHu20c7nS3vp2UEP5lqMSi5GHO9NCLluagT+Fg4+L2j eKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041603; x=1699646403; 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=FOqnYMzgaGsmQAv+x6tXhfxA9uZJN4iQTJsdqhjfa28=; b=Z5s/SQp9vlmajFBF7f8RZQq96lizT+7qqrNnCw6NN6rVm+3K8fWl/SONhEnXwti9+k BXVsl2zrDVVJBdOKESRezXHpfUu3qYX6UC1Ju7vIhOxEsukrSCao+Uzezhv2GpDSX73c 1pU03/TDGa+BDZ3++o+4PZoyfTQrJe4hGlrhFTdBXw7xZVKgKxRcD3RiajfMMssCptto wxfswD6/u8PgyWOF/12csbnuCpe5lfVVXsezRliu4IUycp2Mn/z3069ZF6A+NVsqieZr KmpCQ0IXRAEvIMBd0wEbfFHC3ZRVi93H41azCaL0z3X8mEpDmsCSxVKCIBB1fUFEu3j+ +8Fg== X-Gm-Message-State: AOJu0YyBA2WXCUUCLUc9+mpF5XAZkLE+FkBijQrJs6a6p28l/KBoJn8L xkPHZHwZPF2nYKavss6/thg1dw== X-Received: by 2002:a05:600c:4687:b0:409:5a92:470c with SMTP id p7-20020a05600c468700b004095a92470cmr7452713wmo.13.1699041602815; Fri, 03 Nov 2023 13:00:02 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bh7-20020a05600c3d0700b00401b242e2e6sm3562227wmb.47.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 252A965744; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik Subject: [PATCH 05/29] target/arm: hide aliased MIDR from gdbstub Date: Fri, 3 Nov 2023 19:59:32 +0000 Message-Id: <20231103195956.1998255-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is just a constant alias register with the same value as the "other" MIDR so it serves no purpose being presented to gdbstub. Signed-off-by: Alex Bennée --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 104f9378b4..a681bcba62 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8993,7 +8993,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, }; ARMCPRegInfo id_v8_midr_alias_cp_reginfo = { - .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, + .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST | ARM_CP_NO_GDB, .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, .access = PL1_R, .resetvalue = cpu->midr }; From patchwork Fri Nov 3 19:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740726 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11685wrr; Fri, 3 Nov 2023 13:09:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHArwas/DtqgD+TIpePdGTEYhezey90N/iTEstb8RR2/BNL/1RFWRyHSQQ3rjjtARH/gUB8 X-Received: by 2002:a05:6214:242f:b0:66d:2435:b3f8 with SMTP id gy15-20020a056214242f00b0066d2435b3f8mr26823859qvb.4.1699042153466; Fri, 03 Nov 2023 13:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042153; cv=none; d=google.com; s=arc-20160816; b=YC2Oxek3WiL1lBmKR/gmXFiCaYztOfH5/roUUW0+1HbtRGGGmxdfPMZg7hUlZZOFBg S2AJ9FNsUabxwUT+g726OpDomFcdf58pW6GsyyoOX46Px84Ck/lBSlavt7nIMj9hLRG0 1uvtftmJFr5L9zbifNWfNy2IoehfnJQl6gW5ARnuh748GRp90yaXxmExkuPC0AfTVorz AhJX4sXRebJ//Nu/VHpfZCF63MoNQgrDyYHV+obI/E0bARjAn7AOYKCQRmLlIN+6uhWz lvp24GD31pzr8E3LCVFfWbHl7B03IlReu723+sH3j2gd3lrDrq1lODqa5LzXeCVtlUJ5 4PHg== 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=lbQqPl1wVNYxd0CzmxfNEkNdh3wsVxsN8qD8MQTh82Y=; fh=w70sb7pVibdp/YKDsKMIYzH2f9Q/geCF/huiBdtBKAs=; b=ZpaVka+BAHEsOhZiMmTYkse/SqcvMuZVUShxQPwl/+anaSW3E67bOr8akXj9lRWIib EGSBBORfU/K8F5swF0Fixhnjz86ZVtlCTa7LeoRVr0bsYirfnzK5e5azNPTErEOVS3n5 pbcd9FPARz08ab8IjiRnmhZSJ3IUdLV5On+rjAdlFBi5G8IxAk2fVCfhhD7lb1/onb7V piafUv3P758KndAUAKocjRbZC6adI4ANmdayyAvayUm2XrudAG73lX8eoDCG3qDto5Ye UtGYkTGGSr7aUqO9SlQw0KJHqA1rIk2So+NirwcSmF/gRzKvNt6dCdTRf/HRStQHGuP1 Ip/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y78hCaDA; 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 i15-20020a0cedcf000000b0065d7d4e6f49si2099059qvr.333.2023.11.03.13.09.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:13 -0700 (PDT) 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=Y78hCaDA; 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 1qz0MA-0000h7-Tz; Fri, 03 Nov 2023 16:01:27 -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 1qz0L4-0008BZ-O4 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:19 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kt-0005ZX-DV for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:17 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c50ec238aeso34775281fa.0 for ; Fri, 03 Nov 2023 13:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041605; x=1699646405; 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=lbQqPl1wVNYxd0CzmxfNEkNdh3wsVxsN8qD8MQTh82Y=; b=Y78hCaDASpWa5A9W2s217PIst86iYtoBQrOAh8i6JmCTqNRBV8jPJxlXUCbGtv+5NW F2Ik+y/nCXmaqfwpBGurZ6MHl4aDbti9uUoC7beeQQXI/Fg1KOsmzKRljiYcmLY+oc1R wnXrUImJti6EGVYaTUZ6oAzWDznkWRLc8dppQM+dxc6o6jahGCTiQDT19vczHlyOMOHy s8EXtfVLvyUejXwaUGecSkqHUgeQbmdF8gtpuoCd/Y6j2kQKv9eiSKrcUCewZywdAz4N dsm5RNO26fP1l9/RrsMN64j6OhjYNfmwnH/xfjvor3WPaOsSepDhbCBjTZefqdz6C8jG UqEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041605; x=1699646405; 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=lbQqPl1wVNYxd0CzmxfNEkNdh3wsVxsN8qD8MQTh82Y=; b=Bh41l38CNVcgJVZp/lWGEIbIt7RAHHxp9zR4IevCdK6mY6lTZ8PpaearKaIjaGf2Fg wzXIwOta2pfLtQeM+BQtg++KzS7TJm4ZFIthYlMhJ1+FAYl/Fy7TEzXz627aFGTP80QO r2G/HCTnQP0LFTD4iMX1gPU6olBQm2Gu6VgLMeg99y2IaWmsC8XkW5TyFO5i38V+Zcbd 71pLLgKtWWhYNZIPxSax0t4VqVzUWoHZDykT6xRVV7UibLiEyxS6V7NeJU9VvjRlGFpr a/NwzDJbmeFYPUUKDlITFJn2vKIH+v1q035auH/uJ38ynq7XurykmfGOYIXBSQe+GXRy 6xBg== X-Gm-Message-State: AOJu0YzyFTvtAsMUvljwD8TWeHj1Lsz8GD0to945eh+ZYAORPpA7dxOh y495i47z12SDKTy4hpVXN4waXA== X-Received: by 2002:a2e:be0c:0:b0:2c5:1bd9:f95c with SMTP id z12-20020a2ebe0c000000b002c51bd9f95cmr21692618ljq.53.1699041605096; Fri, 03 Nov 2023 13:00:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i20-20020a05600c355400b0040839fcb217sm3520792wmq.8.2023.11.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3C4AD65745; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki , Luis Machado Subject: [PATCH 06/29] tests/tcg: add an explicit gdbstub register tester Date: Fri, 3 Nov 2023 19:59:33 +0000 Message-Id: <20231103195956.1998255-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x231.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We already do a couple of "info registers" for specific tests but this is a more comprehensive multiarch test. It also has some output helpful for debugging the gdbstub by showing which XML features are advertised and what the underlying register numbers are. My initial motivation was to see if there are any duplicate register names exposed via the gdbstub while I was reviewing the proposed register interface for TCG plugins. Mismatches between the xml and remote-desc are reported for debugging but do not fail the test. Cc: Akihiko Odaki Cc: Luis Machado Signed-off-by: Alex Bennée Message-Id: <20231012170426.1335442-1-alex.bennee@linaro.org> --- v2 - remove python2 compat bits - add SPDX header, clean up comment lines - fix duplicate check - use field 6 (Rmt Nr) instead of field 1 (Nr) for cross-check - more useful output on finding a duplicates and missing regs - handle non-XML targets cleanly --- tests/tcg/multiarch/Makefile.target | 11 +- tests/tcg/multiarch/gdbstub/registers.py | 188 ++++++++++++++++++ .../multiarch/system/Makefile.softmmu-target | 13 +- 3 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/registers.py diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index f3bfaf1a22..d31ba8d6ae 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -93,12 +93,21 @@ run-gdbstub-thread-breakpoint: testthread --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \ hitting a breakpoint on non-main thread) + +run-gdbstub-registers: sha512 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \ + checking register enumeration) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support") endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ - run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint + run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ + run-gdbstub-registers # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/registers.py b/tests/tcg/multiarch/gdbstub/registers.py new file mode 100644 index 0000000000..2aa0c30165 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/registers.py @@ -0,0 +1,188 @@ +# Exercise the register functionality by exhaustively iterating +# through all supported registers on the system. +# +# This is launched via tests/guest-debug/run-test.py but you can also +# call it directly if using it for debugging/introspection: +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import gdb +import sys +import xml.etree.ElementTree as ET + +initial_vlen = 0 +failcount = 0 + +def report(cond, msg): + "Report success/fail of test." + if cond: + print("PASS: %s" % (msg)) + else: + print("FAIL: %s" % (msg)) + global failcount + failcount += 1 + + +def fetch_xml_regmap(): + """ + Iterate through the XML descriptions and validate. + + We check for any duplicate registers and report them. Return a + reg_map hash containing the names, regnums and initial values of + all registers. + """ + + # First check the XML descriptions we have sent. Most arches + # support XML but a few of the ancient ones don't in which case we + # need to gracefully fail. + + try: + xml = gdb.execute("maint print xml-tdesc", False, True) + except (gdb.error): + print("SKIP: target does not support XML") + return None + + total_regs = 0 + reg_map = {} + frame = gdb.selected_frame() + + tree = ET.fromstring(xml) + for f in tree.findall("feature"): + name = f.attrib["name"] + regs = f.findall("reg") + + total = len(regs) + total_regs += total + base = int(regs[0].attrib["regnum"]) + top = int(regs[-1].attrib["regnum"]) + + print(f"feature: {name} has {total} registers from {base} to {top}") + + for r in regs: + name = r.attrib["name"] + regnum = int(r.attrib["regnum"]) + value = frame.read_register(name).__str__() + entry = { "name": name, "initial": value, "regnum": regnum } + + if name in reg_map: + report(False, f"duplicate register {entry} vs {reg_map[name]}") + continue + + reg_map[name] = entry + + # Validate we match + report(total_regs == len(reg_map.keys()), + f"counted all {total_regs} registers in XML") + + return reg_map + +def crosscheck_remote_xml(reg_map): + """ + Cross-check the list of remote-registers with the XML info. + """ + + remote = gdb.execute("maint print remote-registers", False, True) + r_regs = remote.split("\n") + + total_regs = len(reg_map.keys()) + total_r_regs = 0 + + for r in r_regs: + fields = r.split() + # Some of the registers reported here are "pseudo" registers that + # gdb invents based on actual registers so we need to filter them + # out. + if len(fields) == 8: + r_name = fields[0] + r_regnum = int(fields[6]) + + # check in the XML + try: + x_reg = reg_map[r_name] + x_reg["seen"] = True + except KeyError: + report(False, "{r_name} not in XML description") + continue + + x_regnum = x_reg["regnum"] + if r_regnum != x_regnum: + report(False, f"{r_name} {r_regnum} == {x_regnum} (xml)") + else: + total_r_regs += 1 + + # Just print a mismatch in totals as gdb will filter out 64 bit + # registers on a 32 bit machine. Also print what is missing to + # help with debug. + if total_regs != total_r_regs: + print(f"xml-tdesc ({total_regs}) and remote-registers ({total_r_regs}) do not agree") + + for x_key in reg_map.keys(): + x_reg = reg_map[x_key] + if "seen" not in x_reg: + print(f"{x_reg} wasn't seen in remote-registers") + +def complete_and_diff(reg_map): + """ + Let the program run to (almost) completion and then iterate + through all the registers we know about and report which ones have + changed. + """ + # Let the program get to the end and we can check what changed + gdb.Breakpoint("_exit") + gdb.execute("continue") + + frame = gdb.selected_frame() + changed = 0 + + for e in reg_map.values(): + name = e["name"] + old_val = e["initial"] + + try: + new_val = frame.read_register(name).__str__() + except: + report(False, f"failed to read {name} at end of run") + continue + + if new_val != old_val: + print(f"{name} changes from {old_val} to {new_val}") + changed += 1 + + # as long as something changed we can be confident its working + report(changed > 0, f"{changed} registers were changed") + + +def run_test(): + "Run through the tests" + + reg_map = fetch_xml_regmap() + + if reg_map is not None: + crosscheck_remote_xml(reg_map) + complete_and_diff(reg_map) + + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + arch = inferior.architecture() + print("ATTACHED: %s" % arch.name()) +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +if gdb.parse_and_eval('$pc') == 0: + print("SKIP: PC not set") + exit(0) + +try: + run_test() +except (gdb.error): + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + pass + +print("All tests complete: %d failures" % failcount) +exit(failcount) diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg/multiarch/system/Makefile.softmmu-target index dee4f58dea..32dc0f9830 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -48,9 +48,20 @@ run-gdbstub-untimely-packet: hello $(call quiet-command, \ (! grep -Fq 'Packet instead of Ack, ignoring it' untimely-packet.gdb.err), \ "GREP", file untimely-packet.gdb.err) + +run-gdbstub-registers: memory + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) \ + --output $<.registers.gdb.out \ + --qargs \ + "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \ + softmmu gdbstub support) else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support") endif -MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-interrupt run-gdbstub-untimely-packet +MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-interrupt \ + run-gdbstub-untimely-packet run-gdbstub-registers From patchwork Fri Nov 3 19:59:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740708 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8198wrr; Fri, 3 Nov 2023 13:02:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd4QqcVKjpWY7iBudjje/We6DLBfaQMOFKnrdc0fSh+T+yJGvlyr+txL1L1WIg0lqKI2kj X-Received: by 2002:a05:620a:304:b0:77a:5112:c1de with SMTP id s4-20020a05620a030400b0077a5112c1demr7792300qkm.6.1699041753786; Fri, 03 Nov 2023 13:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041753; cv=none; d=google.com; s=arc-20160816; b=rfRKC+hIvY06BzDfqoWCR+GecJdC2ieS4gf6+NNJmK6AxWNPT50X4gywPmdaXDle9W nYRgGwUxUj5o9IMMJUf+sSlopq3PITuxn0R0VYtLptKb9nTg/NyFSdPj+Yaxb41bJSKB xsQ7nGP2gL7b8mSQ0hGK+GEZfjO9N5w5ZB4/GVmndhNY8LPHSQWTM23i/TnmjZnLHmOn MgDiEUV+i6xPntPvxJZenGjdm9e9/6fDP1weamj0mjto96FXbpx9TnM/dO5xSv+NiIVD aKMQyfEc0LFnvzlAcPj5d71sBghiyISoHy8+SBS/0ZSuaXFBRGx1If/zKYRgXRUrwloJ Jgyw== 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=65Q39Xa13SVlTaipeikSzc52X5lKj+6VWg/aEmU5DfA=; fh=Kx2XI2Yx2wBtcq6Uh/oWjWfpY5DZOGguZfb2uQrLFXM=; b=QaxD23r8pNIjt85jFt2+MCR58DjIvVBJBThH2/V96C0KgdAdMF15JHkRcjGlF1JQYt M6Zn05dzedqhsswhSBigyZFFibgBM1OpZYEBEqT6wC8CmfJ2ZuWwT0HgdHiUMAPRLk0W QSS4K34vSAV4G7qxhSzYEBJ4QhOh1ylW2qLMfj5M0KN5fWv1SAuvL7Jsh+Dlrl4mOO9V Ds+72cdG+4am0CtoCCZnaDu4iQeJZUVRulklnv+MiAyfk5AnLBN80Hpareh3UCOmLdGo gIPIReuRzJI3Nj1hlGxD3vH5K6g0iC+PGcOL4hvCAUIUXhadOmyjBf3GSfW/IHxpuFum CJEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S/5189rd"; 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 t15-20020a05620a450f00b007770bfd349fsi2169729qkp.603.2023.11.03.13.02.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:02:33 -0700 (PDT) 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="S/5189rd"; 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 1qz0La-0000GC-W8; Fri, 03 Nov 2023 16:00:51 -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 1qz0L2-00089Z-U2 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:18 -0400 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 1qz0Kr-0005Pg-2V for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:13 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32ded3eb835so1645395f8f.0 for ; Fri, 03 Nov 2023 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041603; x=1699646403; 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=65Q39Xa13SVlTaipeikSzc52X5lKj+6VWg/aEmU5DfA=; b=S/5189rdrzIODu6XJTAI8OjJ17L3wbY6u0e5W33XW1+CZD1BdBp39jqplM+Pml/8BP Ca9s1Be8kPQMtEn1lY7EL8q6oSDYetBEn/8pHP6v4lF0qZ6arzgfA3yqL+QumdV0Em2T RIZpQTRTlfW75DNot5v+idoFXyShv+D/PDFldBuCFzCvPkgEtcmoNbCOEN3E0YOezxye Xfv4YcXdpLFxdwUXQx6SnFAbfzdj/gsJjqIN5ORDOrleitsixBvA0VxDEZ0hLSvMeTiH /9NCmXQtG9AhMHOtu0kOr4aAzaa6d18WbaTh1wMiqRCMy/DDngWqEU4VP2hIVbfxP70c YIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041603; x=1699646403; 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=65Q39Xa13SVlTaipeikSzc52X5lKj+6VWg/aEmU5DfA=; b=PIEjfRhtNMbno7NJ7iEzT9soyIkHEMC8R91VO+LIHs5q20pLvqqNYLOHctnCRpHf+u Yu0Bd65Wqb2WjmV+CR/s2c1LtgPxjTqAzDl/sKOHc0IDGjq5Y+77mzH/6b4MT9dk5nm+ JoPFT+iq9+RHFQZgIG4JqfESax0yTrJ4btm1+eiir5VAGPJfe1ZDXUfnermAosgwnJEH 9fMbVBb2/wmsQKSnt5tyDzbfWUkzi5d3tZZe7NKGvth1WHUzZHfhgMyMmT5ATu8ih3Gm HNFYY80bfc63eToq1r7z6qBZvxhp22eaj9DQ1+psssemerGUDxI6EB2qDH/jEw9SC3Tv miLQ== X-Gm-Message-State: AOJu0YxQO6RXaQzTWyCk6m+2XLNek4MM+4bxWFvE5fXbJyqtA/iCOdk3 6gvuj/NMzLf+ZlaaJ6cf3412pA== X-Received: by 2002:a5d:67c7:0:b0:31a:d871:7ae7 with SMTP id n7-20020a5d67c7000000b0031ad8717ae7mr15801970wrw.29.1699041603100; Fri, 03 Nov 2023 13:00:03 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p12-20020adfe60c000000b0032d886039easm2608287wrm.14.2023.11.03.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5461F65746; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik Subject: [PATCH 07/29] tests/avocado: update the tcg_plugins test Date: Fri, 3 Nov 2023 19:59:34 +0000 Message-Id: <20231103195956.1998255-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There are a number of things that are broken on the test currently so lets fix that up: - replace retired Debian kernel for tuxrun_baseline one - remove "detected repeat instructions test" since ea185a55 - log total counted instructions/memory accesses Signed-off-by: Alex Bennée --- tests/avocado/tcg_plugins.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/avocado/tcg_plugins.py b/tests/avocado/tcg_plugins.py index 642d2e49e3..15fd87b2c1 100644 --- a/tests/avocado/tcg_plugins.py +++ b/tests/avocado/tcg_plugins.py @@ -54,13 +54,11 @@ def run_vm(self, kernel_path, kernel_command_line, class PluginKernelNormal(PluginKernelBase): def _grab_aarch64_kernel(self): - kernel_url = ('http://security.debian.org/' - 'debian-security/pool/updates/main/l/linux-signed-arm64/' - 'linux-image-4.19.0-12-arm64_4.19.152-1_arm64.deb') - kernel_sha1 = '2036c2792f80ac9c4ccaae742b2e0a28385b6010' - kernel_deb = self.fetch_asset(kernel_url, asset_hash=kernel_sha1) - kernel_path = self.extract_from_deb(kernel_deb, - "/boot/vmlinuz-4.19.0-12-arm64") + kernel_url = ('https://storage.tuxboot.com/20230331/arm64/Image') + kernel_sha256 = 'ce95a7101a5fecebe0fe630deee6bd97b32ba41bc8754090e9ad8961ea8674c7' + kernel_path = self.fetch_asset(kernel_url, + asset_hash=kernel_sha256, + algorithm = "sha256") return kernel_path def test_aarch64_virt_insn(self): @@ -88,6 +86,10 @@ def test_aarch64_virt_insn(self): m = re.search(br"insns: (?P\d+)", s) if "count" not in m.groupdict(): self.fail("Failed to find instruction count") + else: + count = int(m.group("count")) + self.log.info(f"Counted: {count} instructions") + def test_aarch64_virt_insn_icount(self): """ @@ -111,9 +113,13 @@ def test_aarch64_virt_insn_icount(self): with plugin_log as lf, \ mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s: - m = re.search(br"detected repeat execution @ (?P0x[0-9A-Fa-f]+)", s) - if m is not None and "addr" in m.groupdict(): - self.fail("detected repeated instructions") + + m = re.search(br"insns: (?P\d+)", s) + if "count" not in m.groupdict(): + self.fail("Failed to find instruction count") + else: + count = int(m.group("count")) + self.log.info(f"Counted: {count} instructions") def test_aarch64_virt_mem_icount(self): """ @@ -145,3 +151,5 @@ def test_aarch64_virt_mem_icount(self): callback = int(m[1]) if inline != callback: self.fail("mismatched access counts") + else: + self.log.info(f"Counted {inline} memory accesses") From patchwork Fri Nov 3 19:59:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740717 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9602wrr; Fri, 3 Nov 2023 13:05:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgETNRmBSMLcQPAEeRUbux50oWBS7VMLtUP7GLdYStkTsjma8sdr19B3NiQLzYy6P5pqqW X-Received: by 2002:a05:620a:f0d:b0:77a:1fc7:a5d4 with SMTP id v13-20020a05620a0f0d00b0077a1fc7a5d4mr20834009qkl.34.1699041900345; Fri, 03 Nov 2023 13:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041900; cv=none; d=google.com; s=arc-20160816; b=wHTNsi65BcArjihIMToaxvcfDSoY1Gqzlayh9qGsEOPeT6RzdrGz+jD49ZslEg0yDP XKHNsLXMWk425R4b0Yh4L5R4wspYZv2t1bxLJWsrckeqRXQYnH/UzHfrBIznOkTr7UAF oJJpHC0rBMa+J1IDLaO69IDUG/P45r9NnoLBIZdjLNoa9KmVQcGxLWXCbS77noFtWvuC ZR2XBUiZXZYJg5SOBMWuSlNmOkteFGwSjN2eQyN4DVLKpGHONDDxaWw3Du8cHd4AFsjv jr67P/EB4s/gepToPH9ROku2Y9XGrDRw+JCB3tEb/2DEvxl6cokbhmLDvvmVt+/7OVa2 zY6Q== 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=nHs8uYRqlPr3uWj0eKAFeFD0Mi/c0JJIrPkGWqnrLxr5DluUX8xxcy5jeZw9vykShY fW3AK8nHMMPnnwB46kKGTNteCOlpcqZeyIbZuGytWNLfONPotAsif2yeoqBcdF7fVLvY pq1aJ8sHn2iMEGk+/1luSF2FBJIM9AKbVzw/tT9BkYEloninVnhr8lCNQAC4SSdZW3vl yWAwXosiw7OBCHuXBLje/PzR4YeO7i69ndYjd4wXINtNUbhJSZ4FoE8xk5VZtgDsdSm0 lYzY5HLda1vxbnIrtBzYBRkr6i//zX/34piePgAYzPrf8+Kcv4zTQajf5zXQ4V6hYW0C 387g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uiu1e0lK; 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 pr13-20020a05620a86cd00b00776f8b50c40si2074614qkn.201.2023.11.03.13.05.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:05:00 -0700 (PDT) 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=Uiu1e0lK; 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 1qz0Lp-0000R6-0Q; Fri, 03 Nov 2023 16:01:05 -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 1qz0L6-0008E7-HZ for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:31 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kt-0005Zo-I4 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:19 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4084095722aso18038505e9.1 for ; Fri, 03 Nov 2023 13:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041605; x=1699646405; 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; b=Uiu1e0lKk26Ch7mB6iK5CApVrS6He7SykNOKdw3a8K78Guha2Vp+hXduSQxi5pmcKs U7Oa19GOg+8bZ3Th1l0N/PZiUCCd+mCodQLGz8MDA8sMiNymp+B5IANDQEcFIXRQoEIz cgRPD+qbHJjnuz27q1kVPX0mk8xqX5GvDAWVbpfS2QmLwUjeVSwSshmzzTx+r5HmNbdh kaiUW4KJNOq51ApccZ/DrJqBH5yidQqdJcL5E77ze7pTila/5dKhwG6BhH8piFZtIW2E uiC8nGjZJhZZO0TlHZ6iGjmRFOGH2kIV9ONBLFnUzha9pk1MWYRUzJtoWjtCcVyoViwC rZZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041605; x=1699646405; 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=gQBmthjE4Bad5l9sCVp+GlTua9zlFcXkP6f/oLdBKC4=; b=bgXKnwH9/CsGXxAfld0fewJuQWE/g+MdM8AMvB5yIAkVBRJ24a4hLfx+u5NHNId4Va x4aQBbwevaiObPGq9hQGi96Xd9EQAtFZ82iT+d95NTnsK09yXhvq6Dknm9s1Ruvt6Zgx WGvqpaLA3zpA9R+A74+o4AUGcBecple4+O12i7PQOvIlIspRiViI548xNpN6gHwoe02X PASwQq4b0hwuPa1OOm26NBqunCObQrYKO5lJo1jVVgOS86r5yUA7qoEgwhtJhzVvX1Hb 3n9mK65cFZDFyGOkuoHk82VPZzI/F0pc3vtD3ZLudj96XlGxDlqSezx6uifv9RTgyc4V Z+5w== X-Gm-Message-State: AOJu0Yz/ToXpqw61NgWnQ1TdNRw3XkhM0D5uII4Gfmh2iRr8NtZ+sAT3 Y4+MDJUHEklZ4KAoH+H/Ve4kCA== X-Received: by 2002:a05:600c:d8:b0:409:718b:33e0 with SMTP id u24-20020a05600c00d800b00409718b33e0mr2193666wmm.16.1699041605356; Fri, 03 Nov 2023 13:00:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c154e00b004097881d7a8sm385873wmg.0.2023.11.03.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6EDA865747; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 08/29] gdbstub: Add num_regs member to GDBFeature Date: Fri, 3 Nov 2023 19:59:35 +0000 Message-Id: <20231103195956.1998255-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Currently the number of registers exposed to GDB is written as magic numbers in code. Derive the number of registers GDB actually see from XML files to replace the magic numbers in code later. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-2-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 1 + scripts/feature_to_c.py | 46 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 1a01c35f8e..a43aa34dad 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,6 +13,7 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + int num_regs; } GDBFeature; diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index bcbcb83beb..e04d6b2df7 100644 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-or-later -import os, sys +import os, sys, xml.etree.ElementTree def writeliteral(indent, bytes): sys.stdout.write(' ' * indent) @@ -39,10 +39,52 @@ def writeliteral(indent, bytes): with open(input, 'rb') as file: read = file.read() + parser = xml.etree.ElementTree.XMLPullParser(['start', 'end']) + parser.feed(read) + events = parser.read_events() + event, element = next(events) + if event != 'start': + sys.stderr.write(f'unexpected event: {event}\n') + exit(1) + if element.tag != 'feature': + sys.stderr.write(f'unexpected start tag: {element.tag}\n') + exit(1) + + regnum = 0 + regnums = [] + tags = ['feature'] + for event, element in events: + if event == 'end': + if element.tag != tags[len(tags) - 1]: + sys.stderr.write(f'unexpected end tag: {element.tag}\n') + exit(1) + + tags.pop() + if element.tag == 'feature': + break + elif event == 'start': + if len(tags) < 2 and element.tag == 'reg': + if 'regnum' in element.attrib: + regnum = int(element.attrib['regnum']) + + regnums.append(regnum) + regnum += 1 + + tags.append(element.tag) + else: + raise Exception(f'unexpected event: {event}\n') + + if len(tags): + sys.stderr.write('unterminated feature tag\n') + exit(1) + + base_reg = min(regnums) + num_regs = max(regnums) - base_reg + 1 if len(regnums) else 0 + sys.stdout.write(' {\n') writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write('\n },\n') + sys.stdout.write(f',\n {num_regs},\n }},\n') sys.stdout.write(' { NULL }\n};\n') From patchwork Fri Nov 3 19:59:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740706 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8056wrr; Fri, 3 Nov 2023 13:02:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJDcYw9oXHJnknj22/UpOQD9QCVlxx96cuE6p0PrIgcSBlk+E8eC6k4K+xmLc8FedCTsHr X-Received: by 2002:a05:6214:2b97:b0:66d:9f09:b69c with SMTP id kr23-20020a0562142b9700b0066d9f09b69cmr21052970qvb.29.1699041741554; Fri, 03 Nov 2023 13:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041741; cv=none; d=google.com; s=arc-20160816; b=Vjc4zaxXt5E8vjY9DIRnxVxDrr590kf5GVi7//fyBKC7WvI9vd6KNyckCga/lM0Fep wg+Vt0iAT01jswyOMEZbhOj+IhwsbVdEb23DrMKOxgnvg3pFEvhsghMIZzhcWQJYihkM yUf63CPEOQRRERfAMfU6VODLKbUoRj/ATNF8sDvObtafleXT337QULov7OKKkfAf/4rc el+affzJ+Mj3y+uG9/hO2ae0UIeNaT50mS/DHsgEE8KjQ6oxe2pCjVo4+Gamvm52ISfZ XS5/ihYBNS7r0xkVJDCFmSKYU2PxWLnrnPHc+aRKo3PME8i/1wtHJeURNpD/JB+tpfOl eiYw== 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=Ghs3EgBAGw158emkMP9920C3Uw5NjJncCpRRWZMRiCQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=y7QwbLsaeK1flh3S/QTUuTGwI8sCXWGI9BzMSJ/v6kG9Hgd7lrv5JfuagAWt4JVq8R lmZYPL28V3GSPKDejzgKYuEk5LfadWtEKixOYXOCJsavkaJgrDDXl9dUeZ/jWWhC6V1x b7hp9swl0550AUXkj1c3hArSdO0gdaOj4C0KWmsPT+SmZtYnPANCMcUr+TJmHcBXanVQ ylJhAiE7SDygLUj7Kiwcr4XQinPCdR1c/UmpJIUPwpWq03VUx9XFrOyrPSjpllAt8sUA V/EDTgklUJgCNdhTpR/2fRgdIcfwHrRzICwEmefxgSJXNFYn/XKUFkQNxSc8qfG5xXUo I/Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJZ+yODm; 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 p8-20020a0cfd88000000b0065b176ed459si1925622qvr.154.2023.11.03.13.02.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:02:21 -0700 (PDT) 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=iJZ+yODm; 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 1qz0LT-0008Py-Dt; Fri, 03 Nov 2023 16:00:45 -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 1qz0L3-00089i-4F for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:18 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kt-0005a8-Eb for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:16 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-407c3adef8eso21016705e9.2 for ; Fri, 03 Nov 2023 13:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041605; x=1699646405; 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=Ghs3EgBAGw158emkMP9920C3Uw5NjJncCpRRWZMRiCQ=; b=iJZ+yODmPaQB8LDfiQvHfif/WjF9FNaf0fXu6oYTXhBe7Flp1gXIeNSNp2G7cZXtBL oofsNV41BKwNkZCyRDx0UGJRn8bQlvkvNDIYtEH1hwXaqv+taQEzP2jP4KdPGNRIX50g iJcCbXo+2sGctHh0NRCy4VZDbL05F1ZalTqVjbp+ZeBcBJ921X4VxmLnPzxmr1NVOgUp tWRzHaicZgTCLUu2He/s9m3O/G8FQrIaJFr1syHOTOm+5qbkD+Vf4mXQlTveAdr5RXj3 JtPRtbvKUeHcnuuDCM75HCdch0uIko7Q3w/C4vqk/r9d0vlCsm3IE8JyUvHDEl+Xli3q cUrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041605; x=1699646405; 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=Ghs3EgBAGw158emkMP9920C3Uw5NjJncCpRRWZMRiCQ=; b=ufnjM59S45xmWqHYXkslZ2yPZMFPp6sByugdbBrW7mzFXPJT1qHFZ8jQ/CMFNn1XRR wI2zMi8yXD8z1DLhGkoPJpypGuB8PiBZK2dPxZwv/E5hYZx4pt70FOlKK79skMKSLt4r Matzw5ZKKx71h87KAN34JizkGmf/4D1t/ml7NpkvxhSW73bN5VJNlByps9+Odzl22uUR oV61KJSaNjr+sTshtECRtP+6bxCNV0seO8ER2OiR8lvcYZhXiOeFmN50pVb/yZXSN/h8 bGe6iiiorReLK03LepUEwrWIgPUaYKkOKyeiC3z6zjVnVBb3OPKuz/J2DGOaA0erNpT7 9dkw== X-Gm-Message-State: AOJu0YzJTq3ea11Mc33721IDKz1TJhujRJ4AOMKIZgDNn5H5bkGDBypJ 1J0fkUilVk+eA/5wnIqsc4OU+Q== X-Received: by 2002:adf:e312:0:b0:31a:d4e4:4f63 with SMTP id b18-20020adfe312000000b0031ad4e44f63mr14339234wrj.18.1699041605580; Fri, 03 Nov 2023 13:00:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o25-20020a5d58d9000000b0032db430fb9bsm2584236wrf.68.2023.11.03.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8A23765748; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 09/29] gdbstub: Introduce gdb_find_static_feature() Date: Fri, 3 Nov 2023 19:59:36 +0000 Message-Id: <20231103195956.1998255-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki This function is useful to determine the number of registers exposed to GDB from the XML name. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20231025093128.33116-3-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 8 ++++++++ gdbstub/gdbstub.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index a43aa34dad..7fe00506c7 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -44,6 +44,14 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); +/** + * gdb_find_static_feature() - Find a static feature. + * @xmlname: The name of the XML. + * + * Return: The static feature. + */ +const GDBFeature *gdb_find_static_feature(const char *xmlname); + void gdb_set_stop_cpu(CPUState *cpu); /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 29540a0284..ae24c4848f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -422,6 +422,19 @@ static const char *get_feature_xml(const char *p, const char **newp, return NULL; } +const GDBFeature *gdb_find_static_feature(const char *xmlname) +{ + const GDBFeature *feature; + + for (feature = gdb_static_features; feature->xmlname; feature++) { + if (!strcmp(feature->xmlname, xmlname)) { + return feature; + } + } + + g_assert_not_reached(); +} + static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); From patchwork Fri Nov 3 19:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740710 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8338wrr; Fri, 3 Nov 2023 13:02:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi+V7pW2UmY8tvg9X1lH8TywrHRjXu+Fs0d3tf+aZmRSiv07w6fNTGWT4B0ugLcENL4nQ+ X-Received: by 2002:a05:620a:1a91:b0:778:8ce0:221a with SMTP id bl17-20020a05620a1a9100b007788ce0221amr25073042qkb.63.1699041765227; Fri, 03 Nov 2023 13:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041765; cv=none; d=google.com; s=arc-20160816; b=s363olYvtZn4xZKTDaRmRWKUjvC3rVC7SXRKjnT9pFND4KVS+vif662b0LUvr41NNf H4pgUM1YoGrbJ5OxMvMGl55K2gFDkQZsIGjPyMSifOibcIJUxDCng3d+MTyxF8daJTRo V4hwDDPgLjFaYjWmuyz2ZK1190fv386Okgo+meywlCsaaaeZAEcZSW1XkJ/rGjgpzIgi 6X/f2chrzVnpOzZ1XNiHx/xB+xVax3azYgqCPAqPJheiH/txogF21c2fXJjlecg0jM3a 3S+iaf4l9pF4fVCcIoeEOYgJpP5ozajw2R8c7sOy0Gz1ZqTB/8LIKJCHdnCTQQdgdOQT tmGA== 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=xDHxhqQ2TRgZnPkoBNWcXo2iYA2BIDMte92mKl4hAgo=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=LhtZ1++OGqaorll+vYyqhctK/GfGjb7pGb4T9brHqtl1U3uoT2F7mxyNE63k5Ie9hB sixjFP6yHKNP9ilyNOuFpPWocKwuJKprDrG1jtv7VUD1rO9qpwTBCv9l7KsoeeuJGTmF JucU/KLoo5NNN/k9uZ0XEoXB7ikg6IFD3k5twTmirmZz3AAvJfkvPodHpANERwlC98UK w9lUWIGr5T/JZ6Ra1+PYRVW479djvlwo4tiE7jnyPyUVURoR8bASqqz9ph5divqhCirx 5OKk/TCTW5vjmwZhVTAezNMulIeJjL5Cl7uciOuDA1DG5Dq3ZPiyzwuEfVPNkfUE1xeN fosA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PATGqExd; 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 h6-20020a05620a400600b007680efd52bdsi2109313qko.368.2023.11.03.13.02.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:02:45 -0700 (PDT) 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=PATGqExd; 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 1qz0Mm-00021e-Cq; Fri, 03 Nov 2023 16:02:04 -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 1qz0LA-0008ET-Cz for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:32 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Kv-0005bV-Fz for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:23 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5079f3f3d7aso3164441e87.1 for ; Fri, 03 Nov 2023 13:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041608; x=1699646408; 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=xDHxhqQ2TRgZnPkoBNWcXo2iYA2BIDMte92mKl4hAgo=; b=PATGqExd/YclyT1IGLFHKhfMqpTJAQTZsxRtbw2iZo8mUpGukn/rjv0OtTk90vB8fi CAqj6un1VsoI6XLEHoC495Ej52mvj/32N/PZmt/Do6mPtfClQkzPgvo9u6xOxsDX/Z0h 4TjQm4hIqLVg0s5kHYeGA45VIgKVBn9VoxMdgCqv+MxNnUTJBujaIocmtiOmu/P9fwfr kvn571x86AIRIXbjkWgGu2+x4oKcVSOedegES59yDCai3KN3xQuXa4kFijwD7nAozOOE DcfzKH9KfREpLZSezj/qRF9dthRhvjRfyxSbvUst+z4Tx2YtuiZTI9SF9pPvxM4qcY6s 1FBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041608; x=1699646408; 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=xDHxhqQ2TRgZnPkoBNWcXo2iYA2BIDMte92mKl4hAgo=; b=q2loOLwxFQL7bPJXxqnW6IllaDs1XYhQWkeB28cSyXi+OkiAqUweInzwO+tzyWkm5T +qHJCvW5N5exgBRb7Lw4Z6mDSrblfEfhkRv1n0IUjrXKujKURsdcNunHSsFHovE4s9bO tpe8oBr020adbmwq5wIKjKCWc4TJGEv0KuT7aDstBc4DiYkITeMdD28Z8JgIEccTVta7 ffkGKPbr0ropM5pjrXBLLx2Qv5zWAPu0aaICish6/Z06ksgobjNKv0192/rj6aLgpla0 Fumow3Mkp1GCulbl3OXofO4x/5B+gkRwsLDNx8mQd5wkW3EWp4RX1oqf3BGdGCFKJS79 +ahQ== X-Gm-Message-State: AOJu0YwZpqeXsdoYBewGIjXuTDmbIC2UCnG0TT+4bKNIM0U2VQwgGtPN 1sjS7MpS5SNFGUe5HBDf7xieWA== X-Received: by 2002:a05:6512:3f0f:b0:509:2b81:fc40 with SMTP id y15-20020a0565123f0f00b005092b81fc40mr12879285lfa.9.1699041607681; Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h17-20020adff4d1000000b0031c52e81490sm2624408wrp.72.2023.11.03.12.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:00 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A551965740; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 10/29] gdbstub: Introduce GDBFeatureBuilder Date: Fri, 3 Nov 2023 19:59:37 +0000 Message-Id: <20231103195956.1998255-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki GDBFeatureBuilder unifies the logic to generate dynamic GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson Message-Id: <20231025093128.33116-4-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 50 ++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 7fe00506c7..d8a3c56fa2 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -16,6 +16,12 @@ typedef struct GDBFeature { int num_regs; } GDBFeature; +typedef struct GDBFeatureBuilder { + GDBFeature *feature; + GPtrArray *xml; + int base_reg; +} GDBFeatureBuilder; + /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -44,6 +50,50 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); +/** + * gdb_feature_builder_init() - Initialize GDBFeatureBuilder. + * @builder: The builder to be initialized. + * @feature: The feature to be filled. + * @name: The name of the feature. + * @xmlname: The name of the XML. + * @base_reg: The base number of the register ID. + */ +void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, + const char *name, const char *xmlname, + int base_reg); + +/** + * gdb_feature_builder_append_tag() - Append a tag. + * @builder: The builder. + * @format: The format of the tag. + * @...: The values to be formatted. + */ +void G_GNUC_PRINTF(2, 3) +gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, + const char *format, ...); + +/** + * gdb_feature_builder_append_reg() - Append a register. + * @builder: The builder. + * @name: The register's name; it must be unique within a CPU. + * @bitsize: The register's size, in bits. + * @regnum: The offset of the register's number in the feature. + * @type: The type of the register. + * @group: The register group to which this register belongs; it can be NULL. + */ +void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, + const char *name, + int bitsize, + int regnum, + const char *type, + const char *group); + +/** + * gdb_feature_builder_end() - End building GDBFeature. + * @builder: The builder. + */ +void gdb_feature_builder_end(const GDBFeatureBuilder *builder); + /** * gdb_find_static_feature() - Find a static feature. * @xmlname: The name of the XML. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ae24c4848f..ebb912da1b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -422,6 +422,71 @@ static const char *get_feature_xml(const char *p, const char **newp, return NULL; } +void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, + const char *name, const char *xmlname, + int base_reg) +{ + char *header = g_markup_printf_escaped( + "" + "" + "", + name); + + builder->feature = feature; + builder->xml = g_ptr_array_new(); + g_ptr_array_add(builder->xml, header); + builder->base_reg = base_reg; + feature->xmlname = xmlname; + feature->num_regs = 0; +} + +void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, + const char *format, ...) +{ + va_list ap; + va_start(ap, format); + g_ptr_array_add(builder->xml, g_markup_vprintf_escaped(format, ap)); + va_end(ap); +} + +void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, + const char *name, + int bitsize, + int regnum, + const char *type, + const char *group) +{ + if (builder->feature->num_regs < regnum) { + builder->feature->num_regs = regnum; + } + + if (group) { + gdb_feature_builder_append_tag( + builder, + "", + name, bitsize, builder->base_reg + regnum, type, group); + } else { + gdb_feature_builder_append_tag( + builder, + "", + name, bitsize, builder->base_reg + regnum, type); + } +} + +void gdb_feature_builder_end(const GDBFeatureBuilder *builder) +{ + g_ptr_array_add(builder->xml, (void *)""); + g_ptr_array_add(builder->xml, NULL); + + builder->feature->xml = g_strjoinv(NULL, (void *)builder->xml->pdata); + + for (guint i = 0; i < builder->xml->len - 2; i++) { + g_free(g_ptr_array_index(builder->xml, i)); + } + + g_ptr_array_free(builder->xml, TRUE); +} + const GDBFeature *gdb_find_static_feature(const char *xmlname) { const GDBFeature *feature; From patchwork Fri Nov 3 19:59:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740709 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8209wrr; Fri, 3 Nov 2023 13:02:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaDG8l4hjR8itXQxQiuP7Uiiaq4HDmvx/wuUTHHCPTK3Bb22ugpIk7UxX7eHV5EHKPEkS3 X-Received: by 2002:a05:622a:144b:b0:417:b7c7:5a2b with SMTP id v11-20020a05622a144b00b00417b7c75a2bmr27501195qtx.37.1699041754269; Fri, 03 Nov 2023 13:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041754; cv=none; d=google.com; s=arc-20160816; b=QtXfCMyQqvdmysvgCApYN1aoC8bbvr8Vh4gY7e1lem9668Liw9EFtG1sPBPJwSEbUS EeTtt7mdjLEMvVxWKR1alo5fL4+bWgckDBEX1Mxe2qjtGr6tgfwAqf4SWrMBGMsyOUSh c24I42+JX3GWWCwU9G1QUbB+kxZ6WoviMS0aUfMF+QPtnkflkBTpBXtJpjgnpQpV+19I 7aubLZXpVKDdULg5CyXByTdV/eF3WRVt2bLUfNUS/W8gQgH7l7AwE6etZ6DuLrbQkFLk W2ogRxf8ds09cPW05Y2IrW97TY7e/SoFCsvmGfo+T9WoPNHK8yYdlaiCc4GQY0Z6hD0u qBqA== 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=I6ZdZXVf8zbHMQ5jQX6q/WC2X+NjiI2uI+fSV5Wp30s=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=Ox+ZmFkdbmUWoZ68SGUlQ8QURW6riTPxkqq4L7D0yghJtZLFesxY7S22z3ljND1ct6 vLisG4KdJkBAqmyhSNRwNS6O3sde6FOtRIrelwgDyXtZTb1C672KZjTyB0sC7Xq6gMYJ 0w6PbWeaB1TQDMB4tlbewo7vY/pUPCC609sMBTIFq4G0yD6s33gWD/O3mHOtR7N6ETRH tJAOpWye282bP2svPYn0Zb7yk8Gz4DKwkfYS7qg/4PTe2606jB5wbSHgAfCU2iTv+plu n8rdgseDUhBT7Jfa2C1T1tekUTBDrL7/sdEP6YcGvvpdI5On12Eax/eqy2fjj9jTDXVO BLDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O8KgB/2W"; 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 o17-20020a05622a045100b0041cc447304asi2023469qtx.222.2023.11.03.13.02.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:02:34 -0700 (PDT) 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="O8KgB/2W"; 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 1qz0Mm-00021u-DV; Fri, 03 Nov 2023 16:02:04 -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 1qz0LH-0008I2-Cm for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:32 -0400 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 1qz0L2-0005dw-Cq for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:30 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4084e49a5e5so21060965e9.3 for ; Fri, 03 Nov 2023 13:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041612; x=1699646412; 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=I6ZdZXVf8zbHMQ5jQX6q/WC2X+NjiI2uI+fSV5Wp30s=; b=O8KgB/2W9W2sjj1QN4IiUHczdAzdwFhfVtssbWzgLO/IXTuO4W8zqoCMkYd4yxc3mM pEQrbl/Z/OFR0+SMTmGUtOA1gX0j0pnzGwzqux32AuJTyYplH3CTrho9nDLkZXwyDwso ccLc+tfm4dQX7A4YF2Cr+fnjqFw7kUJctR2RQi0E2sSyrPM4A/i+yRxu0Ig0QxwAmtUn uCjeC9m48QO1+qd8KUW0C5Jert5CZq1XOOyXFsfWwde3nrDIGYSr6wwdhUem2qQoNWco CoT0sUjtN0vYG03ezd0afMNx//iLWFtoD1Fj0N0EhiacoP9lsc1P9/0KaFEHMwFW5zbT 3bfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041612; x=1699646412; 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=I6ZdZXVf8zbHMQ5jQX6q/WC2X+NjiI2uI+fSV5Wp30s=; b=ZKzw9vTowq9z/X96dV0IbRjUPU6eYiBZW4bRaaAa0LiJoHcn20eoEgKNfdMNC+f9nm eou1sdzsv+eC6IszWsj2yX2WcmJ1BAU5afnQ+pxI+K0K6D0XGwxkYd35aF1AxE20veHq OmJ1YS57hHo6bvwMjKw67qZgJv+cX/WdOIhXGb01S1EYb+46SVYOZV7KrDvDlnFvNwGe sOSY2pgO5mgUUhQhuy29432uNxuQHz4gjNMWdOtITHnE5k3Ih9QqxaNAIYS6vXunRgxU mAY2K4KT605daoWblHboOuX5FtuV9me39URLGjUGVlk4qngtkdrw6VmDiCQLnzrRVFqa rf7g== X-Gm-Message-State: AOJu0YwvG9+HrEQ+vR5wxe9+eciKSiJnF/Zx1FJbB3jA/UCOKC+vRUIw 5RNFjCiPfEIcOa+JJzHgQCz7Lw== X-Received: by 2002:a05:600c:1f87:b0:409:5a92:470e with SMTP id je7-20020a05600c1f8700b004095a92470emr7309692wmb.28.1699041612409; Fri, 03 Nov 2023 13:00:12 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003feae747ff2sm3388427wmf.35.2023.11.03.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C276665749; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 11/29] target/arm: Use GDBFeature for dynamic XML Date: Fri, 3 Nov 2023 19:59:38 +0000 Message-Id: <20231103195956.1998255-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Acked-by: Richard Henderson Message-Id: <20231025093128.33116-5-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- target/arm/cpu.h | 21 +++--- target/arm/internals.h | 2 +- target/arm/gdbstub.c | 142 ++++++++++++++++++++--------------------- target/arm/gdbstub64.c | 95 +++++++++++++-------------- 4 files changed, 123 insertions(+), 137 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d51dfe48db..2549681367 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -25,6 +25,7 @@ #include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qapi/qapi-types-common.h" /* ARM processors have a weak memory model */ @@ -136,23 +137,21 @@ enum { */ /** - * DynamicGDBXMLInfo: - * @desc: Contains the XML descriptions. - * @num: Number of the registers in this XML seen by GDB. + * DynamicGDBFeatureInfo: + * @desc: Contains the feature descriptions. * @data: A union with data specific to the set of registers * @cpregs_keys: Array that contains the corresponding Key of * a given cpreg with the same order of the cpreg * in the XML description. */ -typedef struct DynamicGDBXMLInfo { - char *desc; - int num; +typedef struct DynamicGDBFeatureInfo { + GDBFeature desc; union { struct { uint32_t *keys; } cpregs; } data; -} DynamicGDBXMLInfo; +} DynamicGDBFeatureInfo; /* CPU state for each instance of a generic timer (in cp15 c14) */ typedef struct ARMGenericTimer { @@ -880,10 +879,10 @@ struct ArchCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; - DynamicGDBXMLInfo dyn_sysreg_xml; - DynamicGDBXMLInfo dyn_svereg_xml; - DynamicGDBXMLInfo dyn_m_systemreg_xml; - DynamicGDBXMLInfo dyn_m_secextreg_xml; + DynamicGDBFeatureInfo dyn_sysreg_feature; + DynamicGDBFeatureInfo dyn_svereg_feature; + DynamicGDBFeatureInfo dyn_m_systemreg_feature; + DynamicGDBFeatureInfo dyn_m_secextreg_feature; /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; diff --git a/target/arm/internals.h b/target/arm/internals.h index c837506e44..989416e613 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1440,7 +1440,7 @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) } #ifdef TARGET_AARCH64 -int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); +GDBFeature *arm_gen_dynamic_svereg_feature(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 28f546a5ff..5949adfb31 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -26,11 +26,11 @@ #include "cpu-features.h" #include "cpregs.h" -typedef struct RegisterSysregXmlParam { +typedef struct RegisterSysregFeatureParam { CPUState *cs; - GString *s; + GDBFeatureBuilder builder; int n; -} RegisterSysregXmlParam; +} RegisterSysregFeatureParam; /* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expect whatever the target description contains. Due to a historical mishap @@ -216,7 +216,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; - key = cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; + key = cpu->dyn_sysreg_feature.data.cpregs.keys[reg]; ri = get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -233,34 +233,32 @@ static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, +static void arm_gen_one_feature_sysreg(GDBFeatureBuilder *builder, + DynamicGDBFeatureInfo *dyn_feature, ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize, int regnum) + int bitsize, int n) { - g_string_append_printf(s, "name); - g_string_append_printf(s, " bitsize=\"%d\"", bitsize); - g_string_append_printf(s, " regnum=\"%d\"", regnum); - g_string_append_printf(s, " group=\"cp_regs\"/>"); - dyn_xml->data.cpregs.keys[dyn_xml->num] = ri_key; - dyn_xml->num++; + gdb_feature_builder_append_reg(builder, ri->name, bitsize, n, + "int", "cp_regs"); + + dyn_feature->data.cpregs.keys[n] = ri_key; } -static void arm_register_sysreg_for_xml(gpointer key, gpointer value, - gpointer p) +static void arm_register_sysreg_for_feature(gpointer key, gpointer value, + gpointer p) { uint32_t ri_key = (uintptr_t)key; ARMCPRegInfo *ri = value; - RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p; - GString *s = param->s; + RegisterSysregFeatureParam *param = p; ARMCPU *cpu = ARM_CPU(param->cs); CPUARMState *env = &cpu->env; - DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_sysreg_xml; + DynamicGDBFeatureInfo *dyn_feature = &cpu->dyn_sysreg_feature; if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state == ARM_CP_STATE_AA64) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, + ri, ri_key, 64, param->n++); } } else { if (ri->state == ARM_CP_STATE_AA32) { @@ -269,32 +267,32 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, + ri, ri_key, 64, param->n++); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, + ri, ri_key, 32, param->n++); } } } } } -static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) +static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUState *cs, int base_reg) { ARMCPU *cpu = ARM_CPU(cs); - GString *s = g_string_new(NULL); - RegisterSysregXmlParam param = {cs, s, base_reg}; - - cpu->dyn_sysreg_xml.num = 0; - cpu->dyn_sysreg_xml.data.cpregs.keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""); - g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m); - g_string_append_printf(s, ""); - cpu->dyn_sysreg_xml.desc = g_string_free(s, false); - return cpu->dyn_sysreg_xml.num; + RegisterSysregFeatureParam param = {cs}; + gsize num_regs = g_hash_table_size(cpu->cp_regs); + + gdb_feature_builder_init(¶m.builder, + &cpu->dyn_sysreg_feature.desc, + "org.qemu.gdb.arm.sys.regs", + "system-registers.xml", + base_reg); + cpu->dyn_sysreg_feature.data.cpregs.keys = g_new(uint32_t, num_regs); + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_feature, ¶m); + gdb_feature_builder_end(¶m.builder); + return &cpu->dyn_sysreg_feature.desc; } #ifdef CONFIG_TCG @@ -386,31 +384,29 @@ 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) +static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs, + int base_reg) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; - GString *s = g_string_new(NULL); - int base_reg = orig_base_reg; + GDBFeatureBuilder builder; + int reg = 0; int i; - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, "\n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_systemreg_feature.desc, + "org.gnu.gdb.arm.m-system", "arm-m-system.xml", + base_reg); for (i = 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++); + gdb_feature_builder_append_reg(&builder, m_sysreg_def[i].name, 32, + reg++, "int", NULL); } } - g_string_append_printf(s, ""); - cpu->dyn_m_systemreg_xml.desc = g_string_free(s, false); - cpu->dyn_m_systemreg_xml.num = base_reg - orig_base_reg; + gdb_feature_builder_end(&builder); - return cpu->dyn_m_systemreg_xml.num; + return &cpu->dyn_m_systemreg_feature.desc; } #ifndef CONFIG_USER_ONLY @@ -428,31 +424,31 @@ 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) +static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs, + int base_reg) { ARMCPU *cpu = ARM_CPU(cs); - GString *s = g_string_new(NULL); - int base_reg = orig_base_reg; + GDBFeatureBuilder builder; + char *name; + int reg = 0; int i; - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, "\n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_secextreg_feature.desc, + "org.gnu.gdb.arm.secext", "arm-m-secext.xml", + base_reg); for (i = 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++); + name = g_strconcat(m_sysreg_def[i].name, "_ns", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, reg++, + "int", NULL); + name = g_strconcat(m_sysreg_def[i].name, "_s", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, reg++, + "int", NULL); } - g_string_append_printf(s, ""); - cpu->dyn_m_secextreg_xml.desc = g_string_free(s, false); - cpu->dyn_m_secextreg_xml.num = base_reg - orig_base_reg; + gdb_feature_builder_end(&builder); - return cpu->dyn_m_secextreg_xml.num; + return &cpu->dyn_m_secextreg_feature.desc; } #endif #endif /* CONFIG_TCG */ @@ -462,14 +458,14 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) ARMCPU *cpu = ARM_CPU(cs); if (strcmp(xmlname, "system-registers.xml") == 0) { - return cpu->dyn_sysreg_xml.desc; + return cpu->dyn_sysreg_feature.desc.xml; } else if (strcmp(xmlname, "sve-registers.xml") == 0) { - return cpu->dyn_svereg_xml.desc; + return cpu->dyn_svereg_feature.desc.xml; } else if (strcmp(xmlname, "arm-m-system.xml") == 0) { - return cpu->dyn_m_systemreg_xml.desc; + return cpu->dyn_m_systemreg_feature.desc.xml; #ifndef CONFIG_USER_ONLY } else if (strcmp(xmlname, "arm-m-secext.xml") == 0) { - return cpu->dyn_m_secextreg_xml.desc; + return cpu->dyn_m_secextreg_feature.desc.xml; #endif } return NULL; @@ -487,7 +483,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg = arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs); + int nreg = arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_regs)->num_regs; gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, aarch64_gdb_set_sve_reg, nreg, "sve-registers.xml", 0); @@ -533,20 +529,20 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) 1, "arm-m-profile-mve.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), + arm_gen_dynamic_sysreg_feature(cs, cs->gdb_num_regs)->num_regs, "system-registers.xml", 0); #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { 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_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs)->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_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs)->num_regs, "arm-m-secext.xml", 0); } #endif diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index d7b79a6589..5286d5c604 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -247,7 +247,7 @@ int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -static void output_vector_union_type(GString *s, int reg_width, +static void output_vector_union_type(GDBFeatureBuilder *builder, int reg_width, const char *name) { struct TypeSize { @@ -282,10 +282,10 @@ static void output_vector_union_type(GString *s, int reg_width, /* First define types and totals in a whole VL */ for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, - "", - name, vec_lanes[i].sz, vec_lanes[i].suffix, - vec_lanes[i].gdb_type, reg_width / vec_lanes[i].size); + gdb_feature_builder_append_tag( + builder, "", + name, vec_lanes[i].sz, vec_lanes[i].suffix, + vec_lanes[i].gdb_type, reg_width / vec_lanes[i].size); } /* @@ -296,86 +296,77 @@ static void output_vector_union_type(GString *s, int reg_width, for (i = 0; i < ARRAY_SIZE(suf); i++) { int bits = 8 << i; - g_string_append_printf(s, "", name, suf[i]); + gdb_feature_builder_append_tag(builder, "", + name, suf[i]); for (j = 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size == bits) { - g_string_append_printf(s, "", - vec_lanes[j].suffix, name, - vec_lanes[j].sz, vec_lanes[j].suffix); + gdb_feature_builder_append_tag( + builder, "", + vec_lanes[j].suffix, name, + vec_lanes[j].sz, vec_lanes[j].suffix); } } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } /* And now the final union of unions */ - g_string_append_printf(s, "", name); + gdb_feature_builder_append_tag(builder, "", name); for (i = ARRAY_SIZE(suf) - 1; i >= 0; i--) { - g_string_append_printf(s, "", - suf[i], name, suf[i]); + gdb_feature_builder_append_tag(builder, + "", + suf[i], name, suf[i]); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } -int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int base_reg) { ARMCPU *cpu = ARM_CPU(cs); - GString *s = g_string_new(NULL); - DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; int reg_width = cpu->sve_max_vq * 128; int pred_width = cpu->sve_max_vq * 16; - int base_reg = orig_base_reg; + GDBFeatureBuilder builder; + char *name; + int reg = 0; int i; - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_svereg_feature.desc, + "org.gnu.gdb.aarch64.sve", "sve-registers.xml", + base_reg); /* Create the vector union type. */ - output_vector_union_type(s, reg_width, "svev"); + output_vector_union_type(&builder, reg_width, "svev"); /* Create the predicate vector type. */ - g_string_append_printf(s, - "", - pred_width / 8); + gdb_feature_builder_append_tag( + &builder, "", + pred_width / 8); /* Define the vector registers. */ for (i = 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); + name = g_strdup_printf("z%d", i); + gdb_feature_builder_append_reg(&builder, name, reg_width, reg++, + "svev", NULL); } /* fpscr & status registers */ - g_string_append_printf(s, "", base_reg++); - g_string_append_printf(s, "", base_reg++); + gdb_feature_builder_append_reg(&builder, "fpsr", 32, reg++, + "int", "float"); + gdb_feature_builder_append_reg(&builder, "fpcr", 32, reg++, + "int", "float"); /* Define the predicate registers. */ for (i = 0; i < 16; i++) { - g_string_append_printf(s, - "", - i, pred_width, base_reg++); + name = g_strdup_printf("p%d", i); + gdb_feature_builder_append_reg(&builder, name, pred_width, reg++, + "svep", NULL); } - g_string_append_printf(s, - "", - pred_width, base_reg++); + gdb_feature_builder_append_reg(&builder, "ffr", pred_width, reg++, + "svep", "vector"); /* Define the vector length pseudo-register. */ - g_string_append_printf(s, - "", - base_reg++); + gdb_feature_builder_append_reg(&builder, "vg", 64, reg++, "int", NULL); - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); - info->desc = g_string_free(s, false); - info->num = base_reg - orig_base_reg; - return info->num; + return &cpu->dyn_svereg_feature.desc; } From patchwork Fri Nov 3 19:59:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740713 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8811wrr; Fri, 3 Nov 2023 13:03:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG87JFZnhQm5tAAOnV1+4ZCHpGB+IfG/e+ttyCNAWp3CEgUDPmW36NQ+wfOnkwXLfM07sOM X-Received: by 2002:a05:622a:1889:b0:412:206b:92e6 with SMTP id v9-20020a05622a188900b00412206b92e6mr27404410qtc.16.1699041811323; Fri, 03 Nov 2023 13:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041811; cv=none; d=google.com; s=arc-20160816; b=w4VLsBM9/NlfoOJYvy6JGhqLz4tgBHZvltI2hM3CkwbLXXlByBo4onA/s4EjfFvAH9 g+45r/6jW6dTXDSizIgF+OsBJDmFZmgFbXZQBnKEbr12fajkOsU+8XtGr9MtgvPQEc9z dulXJpLcOKOOSYuNeoXKLjfKtaKKY0V1uMP8ZwqohMjzOoXY+cveEtNOlOsAEiIzqoLd G5LVH5xGNF8Pu1favVSkaGM+pnGXzCxMrlYMxwYspFGudb3slUp719pkZ5T3RcCzbdZL gmFipS4D2JLndlhHB4lFDf4eKxQHEOXjHavGQfWZ0QOlgZFfZa7r6Uv+Xf/NZBnqFVHh +xQQ== 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=cDWGHdPMpdzCMh0e0ct++StXGDV+9flttHjLf4z+BtHjPGRPEsv0Q4ND4TauS7K6ET hgg4TajZUuGqNWe8nCZxvxCnlF79KywNW+MyblGjVQbRUJFcGp/hs9re5UWIRjAmromB 3YGLsN/DIHQDqSbBpsAokRWn3BgJHoBa1m8bhMLnYMHa7l9wcopaWqcY6B/awNe18B5J IDApir7N0ALuhdJqqXpjmeuGX7IznGLRe0TSkG3yikBqn1j0lm/xBA7tyfLzkyy0YL6+ p52NH+XSJjGKpzFdVLrKWhxT2JpA1IAxdEkCxMZ6vKnby3O5IKb7NJM0WB1ylQKFPo/k YG4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mww7gUgO; 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 i19-20020ac85e53000000b00405533726dbsi1967420qtx.150.2023.11.03.13.03.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:03:31 -0700 (PDT) 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=mww7gUgO; 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 1qz0MZ-0001Bf-Jd; Fri, 03 Nov 2023 16:01:51 -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 1qz0LG-0008Hq-9P for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:32 -0400 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 1qz0L2-0005cj-D9 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:29 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4081ccf69dcso21150315e9.0 for ; Fri, 03 Nov 2023 13:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041609; x=1699646409; 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; b=mww7gUgOyHdVCbjP3vcFYVs36ETybl1Ci1hDFmZYiLaV8nQ6kEhGZR6/VEVo4IJcaQ l+jMy+gs0Djns9vML9+x+WvYRbn+uz0u1um6PuuWX43QNko/BdgDAGklLPIZb8XKRKHj k+OeigBtSQrCA+honaLzVCjNEynZBAIMGHOT8O5onoK8zgYZARHqYPQcwJ5QldGpgGGd TipngmjqikQyc9Sk1UgMlh6getOQ3eyVJYy/Lopfh0zntO+7frX6M/wL6g/Or6otlT8x FBWR5HrXlAgL2+HEnXWsXnLrGrXQTm/SHEavQH1fTGKw1yCuA85H/OZvMIB4HssdGETl drfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041609; x=1699646409; 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; b=wFM0tCuoyqclsHIsmGubmxc2Dy/mzh4M8WNXOuLC1PwiO52jFbrlpno/cSvO9omeXq TvJFUwQyvu0O58ARCio9VpRNTtGTOnqw4To7DcRpbPvbQSVrO1vKsxf5gnz0Oq6YFuh2 rCFznPGIpXLDj6USEIE1p5f2HKHbbuEf4AgHcHE7du2w9AnU7YFbsrK/r4uSmt/Vq2jA JjzxziHUNNfKUCd1zDOymbsNF0ifzJxYlcaP+ZYH2QgNftenxaijp5vdh6YTds8NDUMS GcwHw/zvtQSmScUOaNseYJpNrD/1eRnJPNFP6STcR18pEXNuasp7Rij7a+xU2Q4nrL0P jxqQ== X-Gm-Message-State: AOJu0Yy+T+7RzuH5g5iBuFrpe1EWy+NhPb5faA+G4SKKavhQzKHrohkP KaUyzW7crD+XevHZmGM4+qpj2Q== X-Received: by 2002:adf:f309:0:b0:32f:7d50:62f8 with SMTP id i9-20020adff309000000b0032f7d5062f8mr3477316wro.3.1699041609574; Fri, 03 Nov 2023 13:00:09 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h16-20020a05600004d000b0032dbf99bf4fsm2658778wri.89.2023.11.03.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DBB06656E5; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 12/29] target/ppc: Use GDBFeature for dynamic XML Date: Fri, 3 Nov 2023 19:59:39 +0000 Message-Id: <20231103195956.1998255-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson Message-Id: <20231025093128.33116-6-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- target/ppc/cpu-qom.h | 4 ++-- target/ppc/cpu.h | 1 - target/ppc/cpu_init.c | 4 ---- target/ppc/gdbstub.c | 51 ++++++++++++++++--------------------------- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index be33786bd8..8d5ebba5d3 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -20,6 +20,7 @@ #ifndef QEMU_PPC_CPU_QOM_H #define QEMU_PPC_CPU_QOM_H +#include "exec/gdbstub.h" #include "hw/core/cpu.h" #include "qom/object.h" @@ -186,8 +187,7 @@ struct PowerPCCPUClass { int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; #ifndef CONFIG_USER_ONLY - unsigned int gdb_num_sprs; - const char *gdb_spr_xml; + GDBFeature gdb_spr; #endif const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 30392ebeee..848062bc9f 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1384,7 +1384,6 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu); const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 40fe14a6c2..a0178c3ce8 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6682,10 +6682,6 @@ static void init_ppc_proc(PowerPCCPU *cpu) /* PowerPC implementation specific initialisations (SPRs, timers, ...) */ (*pcc->init_proc)(env); -#if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); -#endif - /* MSR bits & flags consistency checks */ if (env->msr_mask & (1 << 25)) { switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ec5731e5d6..e3be3dbd10 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -300,15 +300,23 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n) } #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +static void gdb_gen_spr_feature(CPUState *cs) { - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); + PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; - GString *xml; - char *spr_name; + GDBFeatureBuilder builder; unsigned int num_regs = 0; int i; + if (pcc->gdb_spr.xml) { + return; + } + + gdb_feature_builder_init(&builder, &pcc->gdb_spr, + "org.qemu.power.spr", "power-spr.xml", + cs->gdb_num_regs); + for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr = &env->spr_cb[i]; @@ -326,35 +334,13 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) */ spr->gdb_id = num_regs; num_regs++; - } - - if (pcc->gdb_spr_xml) { - return; - } - xml = g_string_new(""); - g_string_append(xml, ""); - g_string_append(xml, ""); - - for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { - ppc_spr_t *spr = &env->spr_cb[i]; - - if (!spr->name) { - continue; - } - - spr_name = g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, ""); + gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name, -1), + TARGET_LONG_BITS, num_regs, + "int", "spr"); } - g_string_append(xml, ""); - - pcc->gdb_num_sprs = num_regs; - pcc->gdb_spr_xml = g_string_free(xml, false); + gdb_feature_builder_end(&builder); } const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -362,7 +348,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); if (strcmp(xml_name, "power-spr.xml") == 0) { - return pcc->gdb_spr_xml; + return pcc->gdb_spr.xml; } return NULL; } @@ -599,7 +585,8 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) 32, "power-vsx.xml", 0); } #ifndef CONFIG_USER_ONLY + gdb_gen_spr_feature(cs); gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_num_sprs, "power-spr.xml", 0); + pcc->gdb_spr.num_regs, "power-spr.xml", 0); #endif } From patchwork Fri Nov 3 19:59:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740719 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp10416wrr; Fri, 3 Nov 2023 13:06:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvkVbRBDSoeBga+WHRKXOACsIZeVcGBKU1aqwTlbUgoxQ8WBOQGL2RvCK8oGpT3TeEgpuO X-Received: by 2002:a05:6808:f8e:b0:3ae:2850:b481 with SMTP id o14-20020a0568080f8e00b003ae2850b481mr24712127oiw.17.1699041991499; Fri, 03 Nov 2023 13:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041991; cv=none; d=google.com; s=arc-20160816; b=B9XjC9w01H+IonAgHie9/IV5VO7J+aF2ud99MIm4+x/QYIBjT59343dlE+umGHZqhY Zxruqmi+L6LnU/pHuIa6xmxzlB33N3ESFsw2EhzpSmu4V+lyC9rPsHz5SIEjZKYkuTRg nFHLcwbpwWDKPL7Izv2xkW1LtUA/XAfmESewpJZwY539ZldMdlZjMX3Opun0YIkxz1hT xrjZb603WPA34eDsl3RVH1ninV4Egu++QUNWn8OHjB6XwTvHE4sgpDvpnkL4rV4IHelR 9u3USEes02GHXh8gcpqTMwM85Lb5YedUFMSqmnxdaaX7RO4JilUYHb7PgK/zY4Q2sKAE Beag== 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=2daYKoCYbXKpU+kh59PSiqlCJ7T8HheNmZ+WwAdhREk=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=XK2Lox+TSVD46dgBPr4R9b2NZhFB1qo67ROuOls0YLtL0wZrvyG0BeuKuzR4Jdx61F 0WsRT/f+GNsZ/3441UIzCy7FhyaV/9snmhCS8PDxOTvMCqtN6Xq8QY02ZD77SCtFr5On w1V5zM9J6u6+ev2Bt2q1yobDs4HBqhw3K50LGdMmGroY2Oji1NZ7pHnI4OoIZgeq5z0y 16LO51B/0FsjItPLqFp/BR+CL5FlaOL8WOfL4/R2M57jkn0eyhj13Oiqf7BVIAcWPPfq wPxn9CjyPAAhqlyoFDcnW5SwWFE7JMjOprnMxPIlVSP6M8CmGyYCoDZ94WrPyBuNdRSe E7fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BQa7ullc; 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 ro21-20020a05620a399500b007788fb75a90si1942647qkn.620.2023.11.03.13.06.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:06:31 -0700 (PDT) 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=BQa7ullc; 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 1qz0Mp-0002Gx-9d; Fri, 03 Nov 2023 16:02:07 -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 1qz0LR-0008S3-CT for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:43 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0L8-0005cs-7r for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:41 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-408425c7c10so18027665e9.0 for ; Fri, 03 Nov 2023 13:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041610; x=1699646410; 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=2daYKoCYbXKpU+kh59PSiqlCJ7T8HheNmZ+WwAdhREk=; b=BQa7ullci6QBmmw+y7eU4k/7G5paFqKjhBqsxeviO5aVh901vqwZDlsNb6L2Y91Rbt 4yl9Iz2BJWNZMZ1ueCeQtI9H3aSBqSyVP/BA98KhniEwS6gprU2Jn0L72Io82RD8pYa9 +eDxMewHGxDOpE3rh9FnIuYvmQebnJzSsrOlRtVGproQMMQeiMUnpiY2sJCeT0tEKmMT h9ililQC6j59D+Sf8HvKue1RUwuY4Wr1nUDWV4/Zk96Vh2ybyCcd9+MU4337QUHi8ZLR F4Cpa8yijqC8wIClo1c1zDGjnTv8eTtHwuce1JXBKnjYmdq6Nt2H6UpBqm5JEx/8kcqh GoPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041610; x=1699646410; 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=2daYKoCYbXKpU+kh59PSiqlCJ7T8HheNmZ+WwAdhREk=; b=iWnX/5DDAo0iHJk+uK009b20rdLJbuSTiaGJhqxSJ7Vyj3vEtsPwPmWDvne6yrb11I AsY2mU4d2i2wskOacwGghXgqsZc64NJzkn7EFZgKNsQA1n3nDbfSlv+neWFRcAW5yG1T cXc269IcA7XMJiDEc6T1rbXSrasmV/jLSDi/oLFDbu6FAWaKy4Tc2TdhY1C598qY9oRF ZYuKnib5U9SQcBra7H9C38WLzVBE6dwmOALMEme5ubSi5QmERG2854KCRxFPr1TIQzX+ /r43GFFrqvDtiNw0ORYWaXJd8o94hrHbOXN2JYC23VAWJ+LMzFno5MadKA8rhmHB/r8+ 7c2w== X-Gm-Message-State: AOJu0Yx6G4te/jEcZ5HYSHGsi9I90CtNbpkwcoAmTfilqFXhDAXZ0aIa ypTCa45Qxliq3HB/bRwZfbATiw== X-Received: by 2002:a5d:6789:0:b0:32f:ace2:15ac with SMTP id v9-20020a5d6789000000b0032face215acmr3848664wru.59.1699041609805; Fri, 03 Nov 2023 13:00:09 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p12-20020adfe60c000000b0032d886039easm2608394wrm.14.2023.11.03.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 03FEB6574A; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 13/29] target/riscv: Use GDBFeature for dynamic XML Date: Fri, 3 Nov 2023 19:59:40 +0000 Message-Id: <20231103195956.1998255-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-7-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- target/riscv/cpu.h | 5 +-- target/riscv/cpu.c | 4 +-- target/riscv/gdbstub.c | 79 +++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 48 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index f8ffa5ee38..73ec1d3b79 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -24,6 +24,7 @@ #include "hw/registerfields.h" #include "hw/qdev-properties.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qemu/cpu-float.h" #include "qom/object.h" #include "qemu/int128.h" @@ -395,8 +396,8 @@ struct ArchCPU { CPURISCVState env; - char *dyn_csr_xml; - char *dyn_vreg_xml; + GDBFeature dyn_csr_feature; + GDBFeature dyn_vreg_feature; /* Configuration Settings */ RISCVCPUConfig cfg; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ac4a6c7eec..5200fba9b9 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1421,9 +1421,9 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) RISCVCPU *cpu = RISCV_CPU(cs); if (strcmp(xmlname, "riscv-csr.xml") == 0) { - return cpu->dyn_csr_xml; + return cpu->dyn_csr_feature.xml; } else if (strcmp(xmlname, "riscv-vector.xml") == 0) { - return cpu->dyn_vreg_xml; + return cpu->dyn_vreg_feature.xml; } return NULL; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 524bede865..a3ac0212d1 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -212,12 +212,13 @@ static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n) return 0; } -static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) +static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; - GString *s = g_string_new(NULL); + GDBFeatureBuilder builder; riscv_csr_predicate_fn predicate; + const char *name; int bitsize = 16 << env->misa_mxl_max; int i; @@ -230,9 +231,9 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) bitsize = 64; } - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_csr_feature, + "org.gnu.gdb.riscv.csr", "riscv-csr.xml", + base_reg); for (i = 0; i < CSR_TABLE_SIZE; i++) { if (env->priv_ver < csr_ops[i].min_priv_ver) { @@ -240,72 +241,64 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) } predicate = csr_ops[i].predicate; if (predicate && (predicate(env, i) == RISCV_EXCP_NONE)) { - if (csr_ops[i].name) { - g_string_append_printf(s, "", base_reg + i); + + gdb_feature_builder_append_reg(&builder, name, bitsize, i, + "int", NULL); } } - g_string_append_printf(s, ""); - - cpu->dyn_csr_xml = g_string_free(s, false); + gdb_feature_builder_end(&builder); #if !defined(CONFIG_USER_ONLY) env->debugger = false; #endif - return CSR_TABLE_SIZE; + return &cpu->dyn_csr_feature; } -static int ricsv_gen_dynamic_vector_xml(CPUState *cs, int base_reg) +static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) { RISCVCPU *cpu = RISCV_CPU(cs); - GString *s = g_string_new(NULL); - g_autoptr(GString) ts = g_string_new(""); + GDBFeatureBuilder builder; int reg_width = cpu->cfg.vlen; - int num_regs = 0; int i; - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_vreg_feature, + "org.gnu.gdb.riscv.vector", "riscv-vector.xml", + base_reg); /* First define types and totals in a whole VL */ for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { int count = reg_width / vec_lanes[i].size; - g_string_printf(ts, "%s", vec_lanes[i].id); - g_string_append_printf(s, - "", - ts->str, vec_lanes[i].gdb_type, count); + gdb_feature_builder_append_tag( + &builder, "", + vec_lanes[i].id, vec_lanes[i].gdb_type, count); } /* Define unions */ - g_string_append_printf(s, ""); + gdb_feature_builder_append_tag(&builder, ""); for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, "", - vec_lanes[i].suffix, - vec_lanes[i].id); + gdb_feature_builder_append_tag(&builder, + "", + vec_lanes[i].suffix, vec_lanes[i].id); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(&builder, ""); /* Define vector registers */ for (i = 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); - num_regs++; + gdb_feature_builder_append_reg(&builder, g_strdup_printf("v%d", i), + reg_width, i, "riscv_vector", "vector"); } - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); - cpu->dyn_vreg_xml = g_string_free(s, false); - return num_regs; + return &cpu->dyn_vreg_feature; } void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) @@ -320,10 +313,9 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) 32, "riscv-32bit-fpu.xml", 0); } if (env->misa_ext & RVV) { - int base_reg = cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_xml(cs, base_reg), + ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs)->num_regs, "riscv-vector.xml", 0); } switch (env->misa_mxl_max) { @@ -343,9 +335,8 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) } if (cpu->cfg.ext_icsr) { - int base_reg = cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_xml(cs, base_reg), + riscv_gen_dynamic_csr_feature(cs, cs->gdb_num_regs)->num_regs, "riscv-csr.xml", 0); } } From patchwork Fri Nov 3 19:59:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740725 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11641wrr; Fri, 3 Nov 2023 13:09:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpgwdXgoY+wL2uxzam39o8nyEdz43zXUyt7bW6j73GKjQgF67bVpMr/EvwBftEp5a2jHK7 X-Received: by 2002:a25:da91:0:b0:da0:6179:4294 with SMTP id n139-20020a25da91000000b00da061794294mr22264568ybf.32.1699042149536; Fri, 03 Nov 2023 13:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042149; cv=none; d=google.com; s=arc-20160816; b=eDe6Ln6bCruFUpqGDNqU8E9DmqvOVcrsaD7hn6cR/AFsdXMh//x6avjGSwOwLvTdBV ZAqYVLzXhex8EHuFTyq745nbbhskYq44EMzptS7cin8lOpE6C7wkGKBNO0gizdOYJSZQ rc8lD8N/MyeAZxsIOhcDSV8K58+e6im4DI5Gg6wz9hhiGIUUXXAHw9q24aD4CL8d/EiM 4dH/vlczOocIkNd/Wx20rzSDWstzf0JWEHZNcCCfA3Xv5h8Tr0JriqJb2DkmQoiYKRoG gFQLg/AL1H7LfzUVWpeecYp7QE63lpaF3VF4iwMRcezxZx0tv67hOWjiE8/ukq4Lhrps rwGA== 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=JYbkUjVq9RNE+8AbKBffKyD0vwuSD5cxgVIZT+QQCq8=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=g31HJTEU805tARTARa4hPSocwXOTrhbpCDu/oZqxmCY+UUMdgYlCbxZKOljBWM8HZ0 4WiWz2+T81+g2s0PI/eKTgB11dQQD5tnR9sbiKoFz5rDZv5MjxmEHf8HeRnFspAjX74F IqK2QYQWB7SZjLBJZbQOJRfnNBN8ahs3CVyf9d3+dTfdPpmGfYrgjYV38XhDyXfWt/z+ PIt60S+PRvRSDJelRdKNaMqzvSzttU3uTjmtIS6WS+wLKDvCNxKODnfijfkznqk099bJ BY+urktKUqlGf6ga2dLDx8cUZtflLSxXvEjXqgMq2Gby9SUr21EGFQ8LK2XPBXP83mtd uxSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DxhzuKOn; 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 c22-20020a05622a025600b00417a65a82besi1980728qtx.414.2023.11.03.13.09.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:09 -0700 (PDT) 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=DxhzuKOn; 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 1qz0Mu-0002ll-OQ; Fri, 03 Nov 2023 16:02:12 -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 1qz0LS-0008TB-MW for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:44 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0L8-0005cU-76 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:42 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40850b244beso17967215e9.2 for ; Fri, 03 Nov 2023 13:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041609; x=1699646409; 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=JYbkUjVq9RNE+8AbKBffKyD0vwuSD5cxgVIZT+QQCq8=; b=DxhzuKOn84PVFoP0MHRHU02K/lk/paELXdBIvaiESNbyulFwygClNgbQXQs7InkVOy yIcWA1WHzr6YkOiAW2tIv4yBceXFkteTHiW2dmsjnNKos2zDShgz37W0PoUf0WMY3FsG 2ZvLUsSDMAu9YkMNqeIbU7lPWbZAjk9nWZQRBdmZg6g91pguOoGtDud+pgSuZjZwQcHk 0eiye4rRrKbEJm33STfqiAu+391Rf+IWiPWT8G6An+9haFNBXZlDEmWt/uHjC8sZ0AcS UIWnpa7CIIADOaSNBvGvokErmjpGk49wUDsVy0Vm3GcHqM1u92fakCqdaiL4KouwC47Y meYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041609; x=1699646409; 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=JYbkUjVq9RNE+8AbKBffKyD0vwuSD5cxgVIZT+QQCq8=; b=vRwrmxmHL2yU6eP+0Qf/uKoqEQayurzFdl5ZayG4eZQdlZAJPky5vH1UPJ0MrAJPvh 53FTyr3p48csUzNNyGp+CnNZlLjzirQ0PWIqdar2VUIQALDmWaxWUXAD6sLtYtsCatjj 6CNcq9R9zvikMLGlsSUL2AyJa77Et82FVgN+zj6TpX6r2rRVs/Ug1+4JrRa7zQywSgUI 3VGlufJeeskEvwExcYzElBEOLmjeTWDHRIJ2RHXpC5kvkpUSjCXXkaIPnRYNS8QpxGUM sxkgsm2OtCH9LIKCFo7jFNpijgrWjTJKEk6yJWRIIGV0eYt0E1Jb+MK8dOext3WLONVd YRag== X-Gm-Message-State: AOJu0YwvwX5kA6Lasy2cMVQ3zcO8UjkX5LocQRA5QtB5/i3ZUbhHuiPe LZe0iXdtf5gQW/B/aujnptmtpg== X-Received: by 2002:a05:600c:3b15:b0:405:4a78:a892 with SMTP id m21-20020a05600c3b1500b004054a78a892mr20694478wms.9.1699041609336; Fri, 03 Nov 2023 13:00:09 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r16-20020a05600c459000b003fefaf299b6sm3534917wmo.38.2023.11.03.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2664865741; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 14/29] gdbstub: Use GDBFeature for gdb_register_coprocessor Date: Fri, 3 Nov 2023 19:59:41 +0000 Message-Id: <20231103195956.1998255-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki This is a tree-wide change to introduce GDBFeature parameter to gdb_register_coprocessor(). The new parameter just replaces num_regs and xml parameters for now. GDBFeature will be utilized to simplify XML lookup in a following change. Signed-off-by: Akihiko Odaki Acked-by: Alex Bennée Message-Id: <20231025093128.33116-8-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 2 +- gdbstub/gdbstub.c | 13 +++++++------ target/arm/gdbstub.c | 35 +++++++++++++++++++---------------- target/hexagon/cpu.c | 3 +-- target/loongarch/gdbstub.c | 2 +- target/m68k/helper.c | 6 +++--- target/microblaze/cpu.c | 5 +++-- target/ppc/gdbstub.c | 11 ++++++----- target/riscv/gdbstub.c | 20 ++++++++++++-------- target/s390x/gdbstub.c | 28 +++++++--------------------- 10 files changed, 60 insertions(+), 65 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index d8a3c56fa2..ac6fce99a6 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -38,7 +38,7 @@ typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); */ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, - int num_regs, const char *xml, int g_pos); + const GDBFeature *feature, int g_pos); /** * gdbserver_start: start the gdb server diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ebb912da1b..67c6fd2609 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -544,7 +544,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, - int num_regs, const char *xml, int g_pos) + const GDBFeature *feature, int g_pos) { GDBRegisterState *s; guint i; @@ -553,7 +553,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i = 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, xml) == 0) { + if (strcmp(s->xml, feature->xmlname) == 0) { return; } } @@ -565,17 +565,18 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; - s->num_regs = num_regs; + s->num_regs = feature->num_regs; s->get_reg = get_reg; s->set_reg = set_reg; - s->xml = xml; + s->xml = feature->xml; /* Add to end of list. */ - cpu->gdb_num_regs += num_regs; + cpu->gdb_num_regs += feature->num_regs; if (g_pos) { if (g_pos != s->base_reg) { error_report("Error: Bad gdb register numbering for '%s', " - "expected %d got %d", xml, g_pos, s->base_reg); + "expected %d got %d", feature->xml, + g_pos, s->base_reg); } else { cpu->gdb_num_g_regs = cpu->gdb_num_regs; } diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 5949adfb31..f2b201d312 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -483,14 +483,14 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg = arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_regs)->num_regs; + GDBFeature *feature = arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_regs); gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, - aarch64_gdb_set_sve_reg, nreg, - "sve-registers.xml", 0); + aarch64_gdb_set_sve_reg, feature, 0); } else { gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg, aarch64_gdb_set_fpu_reg, - 34, "aarch64-fpu.xml", 0); + gdb_find_static_feature("aarch64-fpu.xml"), + 0); } /* * Note that we report pauth information via the feature name @@ -501,19 +501,22 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) 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); + gdb_find_static_feature("aarch64-pauth.xml"), + 0); } #endif } else { if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 49, "arm-neon.xml", 0); + gdb_find_static_feature("arm-neon.xml"), + 0); } else if (cpu_isar_feature(aa32_simd_r32, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 33, "arm-vfp3.xml", 0); + gdb_find_static_feature("arm-vfp3.xml"), + 0); } else if (cpu_isar_feature(aa32_vfp_simd, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 17, "arm-vfp.xml", 0); + gdb_find_static_feature("arm-vfp.xml"), 0); } if (!arm_feature(env, ARM_FEATURE_M)) { /* @@ -521,29 +524,29 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) * expose to gdb. */ gdb_register_coprocessor(cs, vfp_gdb_get_sysreg, vfp_gdb_set_sysreg, - 2, "arm-vfp-sysregs.xml", 0); + gdb_find_static_feature("arm-vfp-sysregs.xml"), + 0); } } if (cpu_isar_feature(aa32_mve, cpu) && tcg_enabled()) { gdb_register_coprocessor(cs, mve_gdb_get_reg, mve_gdb_set_reg, - 1, "arm-m-profile-mve.xml", 0); + gdb_find_static_feature("arm-m-profile-mve.xml"), + 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_feature(cs, cs->gdb_num_regs)->num_regs, - "system-registers.xml", 0); + arm_gen_dynamic_sysreg_feature(cs, cs->gdb_num_regs), + 0); #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { gdb_register_coprocessor(cs, arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, - arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs)->num_regs, - "arm-m-system.xml", 0); + arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs), 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_feature(cs, cs->gdb_num_regs)->num_regs, - "arm-m-secext.xml", 0); + arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs), 0); } #endif } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 1adc11b713..60d52e1e9d 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -342,8 +342,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp) gdb_register_coprocessor(cs, hexagon_hvx_gdb_read_register, hexagon_hvx_gdb_write_register, - NUM_VREGS + NUM_QREGS, - "hexagon-hvx.xml", 0); + gdb_find_static_feature("hexagon-hvx.xml"), 0); qemu_init_vcpu(cs); cpu_reset(cs); diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 5fc2f19e96..843a869450 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -118,5 +118,5 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env, void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs) { gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_fpu, - 41, "loongarch-fpu.xml", 0); + gdb_find_static_feature("loongarch-fpu.xml"), 0); } diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 0a1544cd68..675f2dcd5a 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -152,10 +152,10 @@ void m68k_cpu_init_gdb(M68kCPU *cpu) if (m68k_feature(env, M68K_FEATURE_CF_FPU)) { gdb_register_coprocessor(cs, cf_fpu_gdb_get_reg, cf_fpu_gdb_set_reg, - 11, "cf-fp.xml", 18); + gdb_find_static_feature("cf-fp.xml"), 18); } else if (m68k_feature(env, M68K_FEATURE_FPU)) { - gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, - m68k_fpu_gdb_set_reg, 11, "m68k-fp.xml", 18); + gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, m68k_fpu_gdb_set_reg, + gdb_find_static_feature("m68k-fp.xml"), 18); } /* TODO: Add [E]MAC registers. */ } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index bbb3335cad..1998f69828 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -297,8 +297,9 @@ static void mb_cpu_initfn(Object *obj) CPUMBState *env = &cpu->env; gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, - mb_cpu_gdb_write_stack_protect, 2, - "microblaze-stack-protect.xml", 0); + mb_cpu_gdb_write_stack_protect, + gdb_find_static_feature("microblaze-stack-protect.xml"), + 0); set_float_rounding_mode(float_round_nearest_even, &env->fp_status); diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index e3be3dbd10..09b852464f 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -570,23 +570,24 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) { if (pcc->insns_flags & PPC_FLOAT) { gdb_register_coprocessor(cs, gdb_get_float_reg, gdb_set_float_reg, - 33, "power-fpu.xml", 0); + gdb_find_static_feature("power-fpu.xml"), 0); } if (pcc->insns_flags & PPC_ALTIVEC) { gdb_register_coprocessor(cs, gdb_get_avr_reg, gdb_set_avr_reg, - 34, "power-altivec.xml", 0); + gdb_find_static_feature("power-altivec.xml"), + 0); } if (pcc->insns_flags & PPC_SPE) { gdb_register_coprocessor(cs, gdb_get_spe_reg, gdb_set_spe_reg, - 34, "power-spe.xml", 0); + gdb_find_static_feature("power-spe.xml"), 0); } if (pcc->insns_flags2 & PPC2_VSX) { gdb_register_coprocessor(cs, gdb_get_vsx_reg, gdb_set_vsx_reg, - 32, "power-vsx.xml", 0); + gdb_find_static_feature("power-vsx.xml"), 0); } #ifndef CONFIG_USER_ONLY gdb_gen_spr_feature(cs); gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_spr.num_regs, "power-spr.xml", 0); + &pcc->gdb_spr, 0); #endif } diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index a3ac0212d1..df2e6335b5 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -307,28 +307,32 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) CPURISCVState *env = &cpu->env; if (env->misa_ext & RVD) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-64bit-fpu.xml", 0); + gdb_find_static_feature("riscv-64bit-fpu.xml"), + 0); } else if (env->misa_ext & RVF) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-32bit-fpu.xml", 0); + gdb_find_static_feature("riscv-32bit-fpu.xml"), + 0); } if (env->misa_ext & RVV) { gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs)->num_regs, - "riscv-vector.xml", 0); + ricsv_gen_dynamic_vector_feature(cs, cs->gdb_num_regs), + 0); } switch (env->misa_mxl_max) { case MXL_RV32: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-32bit-virtual.xml", 0); + gdb_find_static_feature("riscv-32bit-virtual.xml"), + 0); break; case MXL_RV64: case MXL_RV128: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-64bit-virtual.xml", 0); + gdb_find_static_feature("riscv-64bit-virtual.xml"), + 0); break; default: g_assert_not_reached(); @@ -336,7 +340,7 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) if (cpu->cfg.ext_icsr) { gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_feature(cs, cs->gdb_num_regs)->num_regs, - "riscv-csr.xml", 0); + riscv_gen_dynamic_csr_feature(cs, cs->gdb_num_regs), + 0); } } diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 6fbfd41bc8..02c388dc32 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -69,8 +69,6 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) /* the values represent the positions in s390-acr.xml */ #define S390_A0_REGNUM 0 #define S390_A15_REGNUM 15 -/* total number of registers in s390-acr.xml */ -#define S390_NUM_AC_REGS 16 static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -98,8 +96,6 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_FPC_REGNUM 0 #define S390_F0_REGNUM 1 #define S390_F15_REGNUM 16 -/* total number of registers in s390-fpr.xml */ -#define S390_NUM_FP_REGS 17 static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -132,8 +128,6 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_V15L_REGNUM 15 #define S390_V16_REGNUM 16 #define S390_V31_REGNUM 31 -/* total number of registers in s390-vx.xml */ -#define S390_NUM_VREGS 32 static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) { @@ -172,8 +166,6 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) /* the values represent the positions in s390-cr.xml */ #define S390_C0_REGNUM 0 #define S390_C15_REGNUM 15 -/* total number of registers in s390-cr.xml */ -#define S390_NUM_C_REGS 16 #ifndef CONFIG_USER_ONLY static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) @@ -206,8 +198,6 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_VIRT_CPUTM_REGNUM 1 #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 -/* total number of registers in s390-virt.xml */ -#define S390_NUM_VIRT_REGS 4 static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n) { @@ -254,8 +244,6 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_VIRT_KVM_PFT_REGNUM 1 #define S390_VIRT_KVM_PFS_REGNUM 2 #define S390_VIRT_KVM_PFC_REGNUM 3 -/* total number of registers in s390-virt-kvm.xml */ -#define S390_NUM_VIRT_KVM_REGS 4 static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n) { @@ -303,8 +291,6 @@ static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_GS_GSD_REGNUM 1 #define S390_GS_GSSM_REGNUM 2 #define S390_GS_GSEPLA_REGNUM 3 -/* total number of registers in s390-gs.xml */ -#define S390_NUM_GS_REGS 4 static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -322,33 +308,33 @@ void s390_cpu_gdb_init(CPUState *cs) { gdb_register_coprocessor(cs, cpu_read_ac_reg, cpu_write_ac_reg, - S390_NUM_AC_REGS, "s390-acr.xml", 0); + gdb_find_static_feature("s390-acr.xml"), 0); gdb_register_coprocessor(cs, cpu_read_fp_reg, cpu_write_fp_reg, - S390_NUM_FP_REGS, "s390-fpr.xml", 0); + gdb_find_static_feature("s390-fpr.xml"), 0); gdb_register_coprocessor(cs, cpu_read_vreg, cpu_write_vreg, - S390_NUM_VREGS, "s390-vx.xml", 0); + gdb_find_static_feature("s390-vx.xml"), 0); gdb_register_coprocessor(cs, cpu_read_gs_reg, cpu_write_gs_reg, - S390_NUM_GS_REGS, "s390-gs.xml", 0); + gdb_find_static_feature("s390-gs.xml"), 0); #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, cpu_read_c_reg, cpu_write_c_reg, - S390_NUM_C_REGS, "s390-cr.xml", 0); + gdb_find_static_feature("s390-cr.xml"), 0); gdb_register_coprocessor(cs, cpu_read_virt_reg, cpu_write_virt_reg, - S390_NUM_VIRT_REGS, "s390-virt.xml", 0); + gdb_find_static_feature("s390-virt.xml"), 0); if (kvm_enabled()) { gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg, cpu_write_virt_kvm_reg, - S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xml", + gdb_find_static_feature("s390-virt-kvm.xml"), 0); } #endif From patchwork Fri Nov 3 19:59:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740728 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11830wrr; Fri, 3 Nov 2023 13:09:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgJQpk15C/oEU3MnSbq5JfCJvkAEZRAvvj7qp+jTWDU1do4BTt9jgUczA6oDa4dslY5/q1 X-Received: by 2002:ad4:5946:0:b0:672:2989:589c with SMTP id eo6-20020ad45946000000b006722989589cmr19187987qvb.27.1699042176422; Fri, 03 Nov 2023 13:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042176; cv=none; d=google.com; s=arc-20160816; b=HUT7jg8j0qtzYDBJW4FiDVUKjLVF1EQ9IPLoTBAelpXFoAQ8qeDVq/5OXoMF2boVSe fELv1FQWrBfX5Q5nWi9FCbEpdSLZVB5B5I8Zv2KBrhsM58bZGJUQUFrr5Gn5EYhkuQAN LJ+Rcvll7utc/opjDascyFj4BueAN2xEuwrJV+uzf44c6S9+pDJUVUq8ZmWp8698CRo7 xcz7naE43M5YanY5vJ7EXXyifoIe3opOu0PzeDUw1oWCXApjagfnXQa5SycxzJECJCsu ctBurMNK/Qg7rKTJobck1ocEPtY5IDtObGIFyzbhj+B/VD1NeMRHTiKhn3gt3zUgwhdK vqiw== 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=RQ/c0JSyQ2fa48neA+HZ186nKBtrMW/CG7eL+GndA8tcGDvp0kXVi7q4rapExlhjA0 K0Uoc06Zo+iVReqiLs3Ralbq2nYdHE9TxP3pkaBsw0tcZMGepo4RGkQwk6m3rGcPdFkK 1Qt4YMTh1V22b4sd6ixqYqPGqxhFUOorfy+SH+qbqX3whC0gQP7iBx4KssdUnyyTZ1Pr j0LNSdy75UqQfc2ycTnNJHZ9vKAOxvqgwJTo/5yC5L+PbcNoEwXCnEbus6GYK4NOt+my OQD3I9/giXphXNpHtqfWNrIQiHAUD6BYQ0O+kHRmHEXQp3H+GnM6/w13o+bNb76+jS45 GFlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c2RRyGuk; 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 ev18-20020a0562140a9200b0066cf12ca208si1986440qvb.309.2023.11.03.13.09.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:36 -0700 (PDT) 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=c2RRyGuk; 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 1qz0Qp-0003WX-36; Fri, 03 Nov 2023 16:06:15 -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 1qz0Qm-0003Mw-Nw for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:12 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qh-0006vc-GF for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:12 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32f7c44f6a7so1429268f8f.1 for ; Fri, 03 Nov 2023 13:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041965; x=1699646765; 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; b=c2RRyGuksi3vjxs6sO6a2MSZjoRkbwG66rbPUWTutEYqQH0IQRTJ3y5orvgU/Eb9K+ TYqzB/+mUZCGunTWpIdqX2XNX8gFtEqr5TFslLMFCwI5u3xLqXE1NxJnEPrtwERsyruX 6nPPq2ECa+lLJ2Ve4pGSG6a8WT2eira5mFGhPmKo6gx1tDAIXvQxZu2EbPp8xbaXsnOp +pGylLlQqy6g+jBC4YV5LDBRIDQpmr9h7oqmGPvIBZcXyD8WQ9i30Wl684n71uC1SIsr bQNKSnF/CVvoXHpedcIlg8oiWmYjuWViiE7jRAllL6USm4ssUjUyqeocz9kqIzGsHhff D0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041965; x=1699646765; 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; b=XuQi6a+qNMMyg35cI9PJEgK7KhCNGMcvG11zMGfX9Lr+MIG2J443uq9rsfEb++sli3 CYVn0TL2zX9hqIHR89ORX0dtJSi7CDlreNVwNEj7qUFuhpZoXyHg/qqyHHCldtx2dUnq 1o8HngHcPocxP0NWHoPPoiMlgc2CcE+Kw+etUH1Xle8xgjjr736SoWMpz0AJul8jE9Ge oHJ+1wZiH2i5xDqaT7N2mXsvaf4lGDPNALxVE9BzYADpdh2vDFineepz1bWM2kwAToCU LeMbMsKaBYwk/CuwT2irIXKONOBPZ+zHMPIbHFfBO1etqmjsRJWp//ZbpIWxJLB2yRKD og8A== X-Gm-Message-State: AOJu0YyjsVlvAbPRnQuHuJSnCYm6F3z/FmsMMuHFUx9YpuajMZsC1hC7 G03hYlQ9dVCipit44DANZ4RNFA== X-Received: by 2002:a05:6000:b8d:b0:32d:9395:dec6 with SMTP id dl13-20020a0560000b8d00b0032d9395dec6mr17341981wrb.67.1699041965381; Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h3-20020a5d5043000000b0032dba85ea1bsm2636714wrt.75.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 407AC6574B; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 15/29] gdbstub: Use GDBFeature for GDBRegisterState Date: Fri, 3 Nov 2023 19:59:42 +0000 Message-Id: <20231103195956.1998255-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-9-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 67c6fd2609..ebabbc00f6 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,10 +47,9 @@ typedef struct GDBRegisterState { int base_reg; - int num_regs; gdb_get_reg_cb get_reg; gdb_set_reg_cb set_reg; - const char *xml; + const GDBFeature *feature; } GDBRegisterState; GDBState gdbserver_state; @@ -391,7 +390,7 @@ static const char *get_feature_xml(const char *p, const char **newp, g_ptr_array_add( xml, g_markup_printf_escaped("", - r->xml)); + r->feature->xmlname)); } } g_ptr_array_add(xml, g_strdup("")); @@ -513,7 +512,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) if (cpu->gdb_regs) { for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -534,7 +533,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) if (cpu->gdb_regs) { for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -553,7 +552,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i = 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) == 0) { + if (s->feature == feature) { return; } } @@ -565,10 +564,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; - s->num_regs = feature->num_regs; s->get_reg = get_reg; s->set_reg = set_reg; - s->xml = feature->xml; + s->feature = feature; /* Add to end of list. */ cpu->gdb_num_regs += feature->num_regs; From patchwork Fri Nov 3 19:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740711 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8327wrr; Fri, 3 Nov 2023 13:02:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3ntv1aZi1k2eLMGoSn1TvGRVQUhWd9wR2HBoHF8yrJoF3H1HWHKDa4EkO6ZLer+rUbvgw X-Received: by 2002:a67:c20e:0:b0:45d:a69d:fe2e with SMTP id i14-20020a67c20e000000b0045da69dfe2emr2033721vsj.27.1699041763964; Fri, 03 Nov 2023 13:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041763; cv=none; d=google.com; s=arc-20160816; b=Z30t5MEQVTF1fgaQjhN5va4nWXmQ5mIF8RR8NcfeUtpvohoTyV03zF/7/CfF3Y8g6T iMXekXnUhP/qSiQwD2UgjblqM4eJNlY2vGutKOLnTk79DDnWsWqDZWHK+oK6hWAh6vUy L58O73XHKVtrEEBeQxw2pPhd2eo9HWmRFIbDvBpEYOvAo83o4rLPYuJFlljwRzWd5Gw8 34gIAcF9IdPwoQ3Fya1fuNc6+5oNkYRmerHE6k147Oh9mznuiNMnta8HGVqv27gvCPaS mqcjXLXLoEMmKsk/K8hZaWXV2c0fr8X0clI/8irVpEPkPZOgpv/8LaKZt8tZKPJt+W2f 48SA== 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=KytR1mFE1e0nUwetK/l0lWU6QvQjID1KZxqMLq7Q7JY=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=BqIp/8v75BwaDRvIGpkK7qoZdJhQAzk2o4wgEp0j+hqWZxnqvX5Hx7wwijR2hK6mfe WHLGi2lol5Se12YUVRg8vZd+RQlaeA9yxQ8UMUwpYfxzrkcrs4UeI+YUiD1VDsguHc0c JXoWeLQUtAIPj+6etG9HPrp2lZ/WSI8DFpb3OEyBqp6hNF+0bH67bgPWAs6UBsVizSre ZQ2ypBkP25X+RhZfweZEkDU8H/eu5FWhYhTYefI7ojD76sOGumkoUoh2EfKFJX87qs0D WlUpma6AuAMJf0aLNHDpzcZFSeX8JnpM2K0s/EuQHmUFo3v+Wfy2XO7kxYLMphRhEekz RC/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z5K+jfqY; 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 z14-20020a0cfece000000b0065b10fcfba6si2039323qvs.370.2023.11.03.13.02.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:02:43 -0700 (PDT) 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=Z5K+jfqY; 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 1qz0Mt-0002f0-G5; Fri, 03 Nov 2023 16:02:11 -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 1qz0LR-0008Su-Ua for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:45 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0L7-0005fJ-SG for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:41 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso1158753f8f.1 for ; Fri, 03 Nov 2023 13:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041615; x=1699646415; 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=KytR1mFE1e0nUwetK/l0lWU6QvQjID1KZxqMLq7Q7JY=; b=Z5K+jfqYhqO48It7NDFl3uC59ytvWkhEE48WNefny67xfZhkV9uFbfC6tDN+vz/SUK 3VmEllkZLasnXqB5QDvGYUFLTdvyLIn5EsWVcaXIzIfB3vHLKG1qaKiWzQUS7e6qjx+Z Ybe4FmYtE0F8JTxSZ65YDgzPCzJ/zoTia9fgctpLgpxpzBOBt9VcDWqY3Y68M3GdPfWy vekzHwchpUb/JrA2U6SquA1Z9hmYTqzF+em993FNk6MV7U8wXYXIAhc7zghDTsNEgERT b9NnCORhaZWe9HnoQD5cIECLJZkMloSrpKr9o8tCZdkdWTiO9+a5I8t43KeGkMrYJe40 oxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041615; x=1699646415; 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=KytR1mFE1e0nUwetK/l0lWU6QvQjID1KZxqMLq7Q7JY=; b=LC2VQEXEwE3C8Ub2RUfrleuZSa608tU7vtWmXrXFBUKrT77BKLszJOFyEWc4cmSEIc CJ3nI4oKhkalwJdORXcOQTjuFaqJd56fQRAMb5vuv7LJJ8+oXAURk61zkVtzmdv7aYWx j7BuzpucXo87uW7hraoOeC1RuUJSlVqemYcnHKkaa0DygPDM2YxVMZNvjeXP1U5mThox gbOYU/58xJCLnZWw4XXYDoeQJdlm+JZfZbH+cyPU0AI8yH5wvtdxTJsrkWCuLTpRvKh3 RvdWPwOBMki5CedqqbI6QxxI6Jb3FdSS7WinGCmp3ko8DpIzzspg9UDz9ISQVAw5KqvE ClEQ== X-Gm-Message-State: AOJu0YwSMFc1vNrnfhdmEUHYhqfRmrx+OPQZExr0JLb7hl/f27GrYsf+ z3OhY6fuDq0EmAuBwz1F8IYyDg== X-Received: by 2002:a05:6000:1868:b0:32f:a254:c8b2 with SMTP id d8-20020a056000186800b0032fa254c8b2mr5151575wri.20.1699041615331; Fri, 03 Nov 2023 13:00:15 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bd13-20020a05600c1f0d00b004078d71be9csm3539996wmb.13.2023.11.03.13.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6A6826574C; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 16/29] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb Date: Fri, 3 Nov 2023 19:59:43 +0000 Message-Id: <20231103195956.1998255-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Align the parameters of gdb_get_reg_cb and gdb_set_reg_cb with the gdb_read_register and gdb_write_register members of CPUClass to allow to unify the logic to access registers of the core and coprocessors in the future. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-10-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 4 +- target/arm/internals.h | 12 +++--- target/hexagon/internal.h | 4 +- target/microblaze/cpu.h | 4 +- gdbstub/gdbstub.c | 6 +-- target/arm/gdbstub.c | 51 ++++++++++++++++-------- target/arm/gdbstub64.c | 27 +++++++++---- target/hexagon/gdbstub.c | 10 ++++- target/loongarch/gdbstub.c | 11 ++++-- target/m68k/helper.c | 20 ++++++++-- target/microblaze/gdbstub.c | 9 ++++- target/ppc/gdbstub.c | 46 +++++++++++++++++----- target/riscv/gdbstub.c | 46 ++++++++++++++++------ target/s390x/gdbstub.c | 77 ++++++++++++++++++++++++++++--------- 14 files changed, 236 insertions(+), 91 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index ac6fce99a6..bcaab1bc75 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -24,8 +24,8 @@ typedef struct GDBFeatureBuilder { /* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); -typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg); +typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg); /** * gdb_register_coprocessor() - register a supplemental set of registers diff --git a/target/arm/internals.h b/target/arm/internals.h index 989416e613..4ef5137967 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1441,12 +1441,12 @@ static inline uint64_t pmu_counter_mask(CPUARMState *env) #ifdef TARGET_AARCH64 GDBFeature *arm_gen_dynamic_svereg_feature(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_sve_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_sve_reg(CPUState *cs, uint8_t *buf, int reg); +int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg); +int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg); +int aarch64_gdb_set_pauth_reg(CPUState *cs, 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/hexagon/internal.h b/target/hexagon/internal.h index d732b6bb3c..beb08cb7e3 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -33,8 +33,8 @@ int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -int hexagon_hvx_gdb_read_register(CPUHexagonState *env, GByteArray *mem_buf, int n); -int hexagon_hvx_gdb_write_register(CPUHexagonState *env, uint8_t *mem_buf, int n); +int hexagon_hvx_gdb_read_register(CPUState *env, GByteArray *mem_buf, int n); +int hexagon_hvx_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n); void hexagon_debug_vreg(CPUHexagonState *env, int regnum); void hexagon_debug_qreg(CPUHexagonState *env, int regnum); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index e43c49d4af..c14b3357b7 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -370,8 +370,8 @@ G_NORETURN void mb_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int reg); -int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int reg); +int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *buf, int reg); +int mb_cpu_gdb_write_stack_protect(CPUState *cs, uint8_t *buf, int reg); static inline uint32_t mb_cpu_read_msr(const CPUMBState *env) { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ebabbc00f6..4809c90c4a 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -502,7 +502,6 @@ const GDBFeature *gdb_find_static_feature(const char *xmlname) static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); - CPUArchState *env = cpu_env(cpu); GDBRegisterState *r; if (reg < cc->gdb_num_core_regs) { @@ -513,7 +512,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { - return r->get_reg(env, buf, reg - r->base_reg); + return r->get_reg(cpu, buf, reg - r->base_reg); } } } @@ -523,7 +522,6 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); - CPUArchState *env = cpu_env(cpu); GDBRegisterState *r; if (reg < cc->gdb_num_core_regs) { @@ -534,7 +532,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { - return r->set_reg(env, mem_buf, reg - r->base_reg); + return r->set_reg(cpu, mem_buf, reg - r->base_reg); } } } diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index f2b201d312..059d84f98e 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -106,9 +106,10 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) +static int vfp_gdb_get_reg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu = env_archcpu(env); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; int nregs = cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; /* VFP data registers are always little-endian. */ @@ -130,9 +131,10 @@ static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) return 0; } -static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_set_reg(CPUState *cs, uint8_t *buf, int reg) { - ARMCPU *cpu = env_archcpu(env); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; int nregs = cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; if (reg < nregs) { @@ -156,8 +158,11 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -static int vfp_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) +static int vfp_gdb_get_sysreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPSID]); @@ -167,8 +172,11 @@ static int vfp_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) return 0; } -static int vfp_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_set_sysreg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0: env->vfp.xregs[ARM_VFP_FPSID] = ldl_p(buf); @@ -180,8 +188,11 @@ static int vfp_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -static int mve_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) +static int mve_gdb_get_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0: return gdb_get_reg32(buf, env->v7m.vpr); @@ -190,8 +201,11 @@ static int mve_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) } } -static int mve_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) +static int mve_gdb_set_reg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0: env->v7m.vpr = ldl_p(buf); @@ -210,9 +224,10 @@ static int mve_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) * We return the number of bytes copied */ -static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) +static int arm_gdb_get_sysreg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu = env_archcpu(env); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; const ARMCPRegInfo *ri; uint32_t key; @@ -228,7 +243,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) return 0; } -static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_sysreg(CPUState *cs, uint8_t *buf, int reg) { return 0; } @@ -367,8 +382,11 @@ static int m_sysreg_get(CPUARMState *env, GByteArray *buf, return gdb_get_reg32(buf, *ptr); } -static int arm_gdb_get_m_systemreg(CPUARMState *env, GByteArray *buf, int reg) +static int arm_gdb_get_m_systemreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + /* * Here, we emulate MRS instruction, where CONTROL has a mix of * banked and non-banked bits. @@ -379,7 +397,7 @@ static int arm_gdb_get_m_systemreg(CPUARMState *env, GByteArray *buf, int reg) return m_sysreg_get(env, buf, reg, env->v7m.secure); } -static int arm_gdb_set_m_systemreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_m_systemreg(CPUState *cs, uint8_t *buf, int reg) { return 0; /* TODO */ } @@ -414,12 +432,15 @@ static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs, * 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) +static int arm_gdb_get_m_secextreg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + return m_sysreg_get(env, buf, reg >> 1, reg & 1); } -static int arm_gdb_set_m_secextreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_set_m_secextreg(CPUState *cs, uint8_t *buf, int reg) { return 0; /* TODO */ } diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 5286d5c604..caa31ff3fa 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -72,8 +72,11 @@ int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0 ... 31: { @@ -92,8 +95,11 @@ 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_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0 ... 31: /* 128 bit FP register */ @@ -116,9 +122,10 @@ int aarch64_gdb_set_fpu_reg(CPUARMState *env, uint8_t *buf, int reg) } } -int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray *buf, int reg) { - ARMCPU *cpu = env_archcpu(env); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; switch (reg) { /* The first 32 registers are the zregs */ @@ -164,9 +171,10 @@ int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg) return 0; } -int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) +int aarch64_gdb_set_sve_reg(CPUState *cs, uint8_t *buf, int reg) { - ARMCPU *cpu = env_archcpu(env); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; /* The first 32 registers are the zregs */ switch (reg) { @@ -210,8 +218,11 @@ int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg) +int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArray *buf, int reg) { + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + switch (reg) { case 0: /* pauth_dmask */ case 1: /* pauth_cmask */ @@ -241,7 +252,7 @@ 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_set_pauth_reg(CPUState *cs, uint8_t *buf, int reg) { /* All pseudo registers are read-only. */ return 0; diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index 54d37e006e..6007e6462b 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -81,8 +81,11 @@ static int gdb_get_qreg(CPUHexagonState *env, GByteArray *mem_buf, int n) return total; } -int hexagon_hvx_gdb_read_register(CPUHexagonState *env, GByteArray *mem_buf, int n) +int hexagon_hvx_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { + HexagonCPU *cpu = HEXAGON_CPU(cs); + CPUHexagonState *env = &cpu->env; + if (n < NUM_VREGS) { return gdb_get_vreg(env, mem_buf, n); } @@ -115,8 +118,11 @@ static int gdb_put_qreg(CPUHexagonState *env, uint8_t *mem_buf, int n) return MAX_VEC_SIZE_BYTES / 8; } -int hexagon_hvx_gdb_write_register(CPUHexagonState *env, uint8_t *mem_buf, int n) +int hexagon_hvx_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { + HexagonCPU *cpu = HEXAGON_CPU(cs); + CPUHexagonState *env = &cpu->env; + if (n < NUM_VREGS) { return gdb_put_vreg(env, mem_buf, n); } diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 843a869450..22c6889011 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -84,9 +84,11 @@ int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return length; } -static int loongarch_gdb_get_fpu(CPULoongArchState *env, - GByteArray *mem_buf, int n) +static int loongarch_gdb_get_fpu(CPUState *cs, GByteArray *mem_buf, int n) { + LoongArchCPU *cpu = LOONGARCH_CPU(cs); + CPULoongArchState *env = &cpu->env; + if (0 <= n && n < 32) { return gdb_get_reg64(mem_buf, env->fpr[n].vreg.D(0)); } else if (32 <= n && n < 40) { @@ -97,9 +99,10 @@ static int loongarch_gdb_get_fpu(CPULoongArchState *env, return 0; } -static int loongarch_gdb_set_fpu(CPULoongArchState *env, - uint8_t *mem_buf, int n) +static int loongarch_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n) { + LoongArchCPU *cpu = LOONGARCH_CPU(cs); + CPULoongArchState *env = &cpu->env; int length = 0; if (0 <= n && n < 32) { diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 675f2dcd5a..a5ee4d87e3 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -69,8 +69,11 @@ void m68k_cpu_list(void) g_slist_free(list); } -static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) +static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) { + M68kCPU *cpu = M68K_CPU(cs); + CPUM68KState *env = &cpu->env; + if (n < 8) { float_status s; return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); @@ -86,8 +89,11 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) return 0; } -static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) { + M68kCPU *cpu = M68K_CPU(cs); + CPUM68KState *env = &cpu->env; + if (n < 8) { float_status s; env->fregs[n].d = float64_to_floatx80(ldq_p(mem_buf), &s); @@ -106,8 +112,11 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) return 0; } -static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) +static int m68k_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) { + M68kCPU *cpu = M68K_CPU(cs); + CPUM68KState *env = &cpu->env; + if (n < 8) { int len = gdb_get_reg16(mem_buf, env->fregs[n].l.upper); len += gdb_get_reg16(mem_buf, 0); @@ -125,8 +134,11 @@ static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) return 0; } -static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int m68k_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) { + M68kCPU *cpu = M68K_CPU(cs); + CPUM68KState *env = &cpu->env; + if (n < 8) { env->fregs[n].l.upper = lduw_be_p(mem_buf); env->fregs[n].l.lower = ldq_be_p(mem_buf + 4); diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 29ac6e9c0f..6ffc5ad075 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -94,8 +94,10 @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) return gdb_get_reg32(mem_buf, val); } -int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, int n) +int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n) { + MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); + CPUMBState *env = &cpu->env; uint32_t val; switch (n) { @@ -153,8 +155,11 @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 4; } -int mb_cpu_gdb_write_stack_protect(CPUMBState *env, uint8_t *mem_buf, int n) +int mb_cpu_gdb_write_stack_protect(CPUState *cs, uint8_t *mem_buf, int n) { + MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); + CPUMBState *env = &cpu->env; + switch (n) { case GDB_SP_SHL: env->slr = ldl_p(mem_buf); diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 09b852464f..8ca37b6bf9 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -369,8 +369,10 @@ static int gdb_find_spr_idx(CPUPPCState *env, int n) return -1; } -static int gdb_get_spr_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_spr_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; int reg; int len; @@ -385,8 +387,10 @@ static int gdb_get_spr_reg(CPUPPCState *env, GByteArray *buf, int n) return len; } -static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_spr_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; int reg; int len; @@ -403,8 +407,10 @@ static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) } #endif -static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_float_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; uint8_t *mem_buf; if (n < 32) { gdb_get_reg64(buf, *cpu_fpr_ptr(env, n)); @@ -421,8 +427,11 @@ static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n) return 0; } -static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_float_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { ppc_maybe_bswap_register(env, mem_buf, 8); *cpu_fpr_ptr(env, n) = ldq_p(mem_buf); @@ -436,8 +445,10 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_avr_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; uint8_t *mem_buf; if (n < 32) { @@ -462,8 +473,11 @@ static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n) return 0; } -static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_avr_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { ppc_avr_t *avr = cpu_avr_ptr(env, n); ppc_maybe_bswap_register(env, mem_buf, 16); @@ -484,8 +498,11 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_spe_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_spe_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { #if defined(TARGET_PPC64) gdb_get_reg32(buf, env->gpr[n] >> 32); @@ -508,8 +525,11 @@ static int gdb_get_spe_reg(CPUPPCState *env, GByteArray *buf, int n) return 0; } -static int gdb_set_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_spe_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { #if defined(TARGET_PPC64) target_ulong lo = (uint32_t)env->gpr[n]; @@ -537,8 +557,11 @@ static int gdb_set_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_vsx_reg(CPUPPCState *env, GByteArray *buf, int n) +static int gdb_get_vsx_reg(CPUState *cs, GByteArray *buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { gdb_get_reg64(buf, *cpu_vsrl_ptr(env, n)); ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); @@ -547,8 +570,11 @@ static int gdb_get_vsx_reg(CPUPPCState *env, GByteArray *buf, int n) return 0; } -static int gdb_set_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_set_vsx_reg(CPUState *cs, uint8_t *mem_buf, int n) { + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + if (n < 32) { ppc_maybe_bswap_register(env, mem_buf, 8); *cpu_vsrl_ptr(env, n) = ldq_p(mem_buf); diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index df2e6335b5..9553ad62a3 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -106,8 +106,11 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return length; } -static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_fpu(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + if (n < 32) { if (env->misa_ext & RVD) { return gdb_get_reg64(buf, env->fpr[n]); @@ -119,8 +122,11 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) return 0; } -static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_set_fpu(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + if (n < 32) { env->fpr[n] = ldq_p(mem_buf); /* always 64-bit */ return sizeof(uint64_t); @@ -128,8 +134,10 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_vector(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; uint16_t vlenb = riscv_cpu_cfg(env)->vlen >> 3; if (n < 32) { int i; @@ -144,8 +152,10 @@ static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n) return 0; } -static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_set_vector(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; uint16_t vlenb = riscv_cpu_cfg(env)->vlen >> 3; if (n < 32) { int i; @@ -158,8 +168,11 @@ static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) +static int riscv_gdb_get_csr(CPUState *cs, GByteArray *buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + if (n < CSR_TABLE_SIZE) { target_ulong val = 0; int result; @@ -172,8 +185,11 @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) return 0; } -static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_set_csr(CPUState *cs, uint8_t *mem_buf, int n) { + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + if (n < CSR_TABLE_SIZE) { target_ulong val = ldtul_p(mem_buf); int result; @@ -186,25 +202,31 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n) +static int riscv_gdb_get_virtual(CPUState *cs, GByteArray *buf, int n) { if (n == 0) { #ifdef CONFIG_USER_ONLY return gdb_get_regl(buf, 0); #else - return gdb_get_regl(buf, cs->priv); + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + + return gdb_get_regl(buf, env->priv); #endif } return 0; } -static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n) +static int riscv_gdb_set_virtual(CPUState *cs, uint8_t *mem_buf, int n) { if (n == 0) { #ifndef CONFIG_USER_ONLY - cs->priv = ldtul_p(mem_buf) & 0x3; - if (cs->priv == PRV_RESERVED) { - cs->priv = PRV_S; + RISCVCPU *cpu = RISCV_CPU(cs); + CPURISCVState *env = &cpu->env; + + env->priv = ldtul_p(mem_buf) & 0x3; + if (env->priv == PRV_RESERVED) { + env->priv = PRV_S; } #endif return sizeof(target_ulong); diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 02c388dc32..c1e7c59b82 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -70,8 +70,11 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) #define S390_A0_REGNUM 0 #define S390_A15_REGNUM 15 -static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_ac_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: return gdb_get_reg32(buf, env->aregs[n]); @@ -80,8 +83,11 @@ static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) } } -static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_ac_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: env->aregs[n] = ldl_p(mem_buf); @@ -97,8 +103,11 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_F0_REGNUM 1 #define S390_F15_REGNUM 16 -static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_fp_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_FPC_REGNUM: return gdb_get_reg32(buf, env->fpc); @@ -109,8 +118,11 @@ static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) } } -static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_fp_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_FPC_REGNUM: env->fpc = ldl_p(mem_buf); @@ -129,8 +141,10 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_V16_REGNUM 16 #define S390_V31_REGNUM 31 -static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_vreg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; int ret; switch (n) { @@ -148,8 +162,11 @@ static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) return ret; } -static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_vreg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: env->vregs[n][1] = ldtul_p(mem_buf + 8); @@ -168,8 +185,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_C15_REGNUM 15 #ifndef CONFIG_USER_ONLY -static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_c_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: return gdb_get_regl(buf, env->cregs[n]); @@ -178,8 +198,11 @@ static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) } } -static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_c_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: env->cregs[n] = ldtul_p(mem_buf); @@ -199,8 +222,11 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 -static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n) +static int cpu_read_virt_reg(CPUState *cs, GByteArray *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_VIRT_CKC_REGNUM: return gdb_get_regl(mem_buf, env->ckc); @@ -215,24 +241,27 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n) } } -static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_virt_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_VIRT_CKC_REGNUM: env->ckc = ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_CPUTM_REGNUM: env->cputm = ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_BEA_REGNUM: env->gbea = ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; case S390_VIRT_PREFIX_REGNUM: env->psa = ldtul_p(mem_buf); - cpu_synchronize_post_init(env_cpu(env)); + cpu_synchronize_post_init(cs); return 8; default: return 0; @@ -245,8 +274,11 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_VIRT_KVM_PFS_REGNUM 2 #define S390_VIRT_KVM_PFC_REGNUM 3 -static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n) +static int cpu_read_virt_kvm_reg(CPUState *cs, GByteArray *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_VIRT_KVM_PP_REGNUM: return gdb_get_regl(mem_buf, env->pp); @@ -261,8 +293,11 @@ static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, int n) } } -static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_virt_kvm_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + switch (n) { case S390_VIRT_KVM_PP_REGNUM: env->pp = ldtul_p(mem_buf); @@ -292,13 +327,19 @@ static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_GS_GSSM_REGNUM 2 #define S390_GS_GSEPLA_REGNUM 3 -static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) +static int cpu_read_gs_reg(CPUState *cs, GByteArray *buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + return gdb_get_regl(buf, env->gscb[n]); } -static int cpu_write_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_write_gs_reg(CPUState *cs, uint8_t *mem_buf, int n) { + S390CPU *cpu = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + env->gscb[n] = ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; From patchwork Fri Nov 3 19:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740722 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp10554wrr; Fri, 3 Nov 2023 13:06:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3MAV/ZsNEWVAL6TQeIjjctRb3jCF7YLqnW9KQMHazjHS/QRnglG2YH7UtF08xgLHq4k5l X-Received: by 2002:a05:620a:880c:b0:775:ed1e:2741 with SMTP id qj12-20020a05620a880c00b00775ed1e2741mr23128946qkn.7.1699042010151; Fri, 03 Nov 2023 13:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042010; cv=none; d=google.com; s=arc-20160816; b=YUQfN4BxxJHXDGSFPEbqjVt++efrl8Km5YRyHAQ/PJlHAJiXIawWKQIUHhR2rNiuok Ye/q+n1FlsNHxt54tR39kH0aeZM5PRIO/vgXDq/RwPR3DLDkIC9FNZ9dbsykwF1pUf6c C/8eRC3n2cEqqZfMdXIkdXKVXsOyNrcPp3HmKMBmx8scnY+JIh1iLJnCzZQLaxoHFGNR kBU9EGHo2018rJQjgrpy8zmM7HbqWykUYHJzmSaC97NHn/sj6JC1dix/57OWTxao+Q+a y6uAQvLH3JbhlcJOyIBMHN5gvWA26babJYSMCsAyLUpQQnsTRKxCrByxmNDbye1xEm5C 2Irg== 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=0gobOZLUm4tucaoiLfVGUn6DQENUE7jBPnm4hmBlkNA=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=J4f9DnHbAVJC40cbo/OQtfokcINauSDkx8HywkzVOf15LEbhDEh3ncNQ/asLlEvKFK DLaOgIrhgbKgqxNQj+etsph29LO9mWJjgJM2dQLhs59M22z0EoRuINYNgJxHQjuGjuis cSYuW4D5uWY0TSOAa2RKAmUPdLsqncqH1COSE5thC4d9rwnX/YxB5o3qSPqeLXF9yhX1 JL65ocpBz+HBHmu5Sx5camRAvJoEmpgjmzaaCVQZw7NgR0+CZvnPgD1wuYfma9/DW/TN NkdTbaUddiPScFc1dXvibsIPbq+2VEbaCH8dkwezL5upVeZnCEfH2elAIerw/CG3XIO+ sTcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yi0dlQqp; 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 l22-20020a05620a28d600b007743391acf0si2026745qkp.324.2023.11.03.13.06.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:06:50 -0700 (PDT) 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=yi0dlQqp; 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 1qz0Qs-0003b6-32; Fri, 03 Nov 2023 16:06:18 -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 1qz0Qp-0003XK-T7 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:16 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qh-0006vj-Il for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:15 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c50d1b9f22so33604471fa.0 for ; Fri, 03 Nov 2023 13:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041966; x=1699646766; 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=0gobOZLUm4tucaoiLfVGUn6DQENUE7jBPnm4hmBlkNA=; b=yi0dlQqpJKxFeDRF79dgpSS7Vld4lhsOY6DCqsFdjwijkGO26pNJR5al7dylcN7he4 PFXzKsfz67ZshKpoEMU11dDBAS18LulXoLzWp11+YB7Gcc2cHh4zh5nnZGU2snyvOkIk pnDLlpct2YMcnFoOd3qe7i6VGyZ5s/C8rAWaZgrh8DcQuUpDr9RbFKTeg+VpvIOOejzQ h888zcfKLMvLob0NNiQUP49LTrqb0CRiAqYePOWYeJkO0szruRgGHNzwhF1yxUrpn53k G28YAHR/z6J2/gUOrtIagehpys0uVC6/TzeV+EKZg78Vq451azvH8RzYmv8egu0P6RQ0 VEJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041966; x=1699646766; 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=0gobOZLUm4tucaoiLfVGUn6DQENUE7jBPnm4hmBlkNA=; b=v1EEOAGeSLLp9Lmk0WFN+SpqmV972aFyFeZsvncBRBlt7/j5q4zH01GlcgREyNXW8O ZQpF9sz/FWfskK4CkZOpCI20Fom/0Al167Ia7DpDmX/YaJy/toQuXTTjo4J/tSViZX6K /Ijwy9yjgQagc5AT6myWAP0rtsaPOp9SJGR1SlSl1IKzodVV2wYa/Vry0l9nshUq2qUw zWzOKnvbb4BBRz/1OUTtUeOEha3/PQDeSyZbqSrWUwOHFlE3H4ORg/MCyb4k2amMGgcp WoxfPwtP+p+AgPA8dQ9NOOykQP7WAzCOIlM0xZERiqTjutTHddoUEXUKxaJCQYWpWW3i 2OBw== X-Gm-Message-State: AOJu0YxXfKN/Cp5d/4mkLxTJQ9wMY/LUMzGulXo6vrc8hoEwsUYLzUFC iDMw7utMjL/XMYIx1GLaxmk5Les8DvCLy5ewoM/6PQ== X-Received: by 2002:a2e:155c:0:b0:2c6:ed6a:780f with SMTP id 28-20020a2e155c000000b002c6ed6a780fmr5120801ljv.11.1699041965654; Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g23-20020a7bc4d7000000b004063cd8105csm3381219wmk.22.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 850D56574D; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 17/29] gdbstub: Simplify XML lookup Date: Fri, 3 Nov 2023 19:59:44 +0000 Message-Id: <20231103195956.1998255-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki Now we know all instances of GDBFeature that is used in CPU so we can traverse them to find XML. This removes the need for a CPU-specific lookup function for dynamic XMLs. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-11-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 6 +++ gdbstub/gdbstub.c | 118 +++++++++++++++++++++-------------------- hw/core/cpu-common.c | 5 +- 3 files changed, 69 insertions(+), 60 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index bcaab1bc75..82a8afa237 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -27,6 +27,12 @@ typedef struct GDBFeatureBuilder { typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg); +/** + * gdb_init_cpu(): Initialize the CPU for gdbstub. + * @cpu: The CPU to be initialized. + */ +void gdb_init_cpu(CPUState *cpu); + /** * gdb_register_coprocessor() - register a supplemental set of registers * @cpu - the CPU associated with registers diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 4809c90c4a..5ecd1f23e6 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -352,6 +352,7 @@ static const char *get_feature_xml(const char *p, const char **newp, { CPUState *cpu = gdb_get_first_cpu_in_process(process); CPUClass *cc = CPU_GET_CLASS(cpu); + GDBRegisterState *r; size_t len; /* @@ -365,7 +366,6 @@ static const char *get_feature_xml(const char *p, const char **newp, /* Is it the main target xml? */ if (strncmp(p, "target.xml", len) == 0) { if (!process->target_xml) { - GDBRegisterState *r; g_autoptr(GPtrArray) xml = g_ptr_array_new_with_free_func(g_free); g_ptr_array_add( @@ -380,18 +380,12 @@ static const char *get_feature_xml(const char *p, const char **newp, g_markup_printf_escaped("%s", cc->gdb_arch_name(cpu))); } - g_ptr_array_add( - xml, - g_markup_printf_escaped("", - cc->gdb_core_xml_file)); - if (cpu->gdb_regs) { - for (guint i = 0; i < cpu->gdb_regs->len; i++) { - r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - g_ptr_array_add( - xml, - g_markup_printf_escaped("", - r->feature->xmlname)); - } + for (guint i = 0; i < cpu->gdb_regs->len; i++) { + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + g_ptr_array_add( + xml, + g_markup_printf_escaped("", + r->feature->xmlname)); } g_ptr_array_add(xml, g_strdup("")); g_ptr_array_add(xml, NULL); @@ -400,20 +394,11 @@ static const char *get_feature_xml(const char *p, const char **newp, } return process->target_xml; } - /* Is it dynamically generated by the target? */ - if (cc->gdb_get_dynamic_xml) { - g_autofree char *xmlname = g_strndup(p, len); - const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); - if (xml) { - return xml; - } - } - /* Is it one of the encoded gdb-xml/ files? */ - for (int i = 0; gdb_static_features[i].xmlname; i++) { - const char *name = gdb_static_features[i].xmlname; - if ((strncmp(name, p, len) == 0) && - strlen(name) == len) { - return gdb_static_features[i].xml; + /* Is it one of the features? */ + for (guint i = 0; i < cpu->gdb_regs->len; i++) { + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (strncmp(p, r->feature->xmlname, len) == 0) { + return r->feature->xml; } } @@ -508,12 +493,10 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) return cc->gdb_read_register(cpu, buf, reg); } - if (cpu->gdb_regs) { - for (guint i = 0; i < cpu->gdb_regs->len; i++) { - r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { - return r->get_reg(cpu, buf, reg - r->base_reg); - } + for (guint i = 0; i < cpu->gdb_regs->len; i++) { + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { + return r->get_reg(cpu, buf, reg - r->base_reg); } } return 0; @@ -528,51 +511,70 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) return cc->gdb_write_register(cpu, mem_buf, reg); } - if (cpu->gdb_regs) { - for (guint i = 0; i < cpu->gdb_regs->len; i++) { - r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { - return r->set_reg(cpu, mem_buf, reg - r->base_reg); - } + for (guint i = 0; i < cpu->gdb_regs->len; i++) { + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { + return r->set_reg(cpu, mem_buf, reg - r->base_reg); } } return 0; } +static void gdb_register_feature(CPUState *cpu, int base_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, + const GDBFeature *feature) +{ + GDBRegisterState s = { + .base_reg = base_reg, + .get_reg = get_reg, + .set_reg = set_reg, + .feature = feature + }; + + g_array_append_val(cpu->gdb_regs, s); +} + +void gdb_init_cpu(CPUState *cpu) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + const GDBFeature *feature; + + cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState)); + + if (cc->gdb_core_xml_file) { + feature = gdb_find_static_feature(cc->gdb_core_xml_file); + gdb_register_feature(cpu, 0, + cc->gdb_read_register, cc->gdb_write_register, + feature); + } + + cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs; +} + void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature, int g_pos) { GDBRegisterState *s; guint i; + int base_reg = cpu->gdb_num_regs; - if (cpu->gdb_regs) { - for (i = 0; i < cpu->gdb_regs->len; i++) { - /* Check for duplicates. */ - s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (s->feature == feature) { - return; - } + for (i = 0; i < cpu->gdb_regs->len; i++) { + /* Check for duplicates. */ + s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (s->feature == feature) { + return; } - } else { - cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState)); - i = 0; } - g_array_set_size(cpu->gdb_regs, i + 1); - s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - s->base_reg = cpu->gdb_num_regs; - s->get_reg = get_reg; - s->set_reg = set_reg; - s->feature = feature; + gdb_register_feature(cpu, base_reg, get_reg, set_reg, feature); /* Add to end of list. */ cpu->gdb_num_regs += feature->num_regs; if (g_pos) { - if (g_pos != s->base_reg) { + if (g_pos != base_reg) { error_report("Error: Bad gdb register numbering for '%s', " - "expected %d got %d", feature->xml, - g_pos, s->base_reg); + "expected %d got %d", feature->xml, g_pos, base_reg); } else { cpu->gdb_num_g_regs = cpu->gdb_num_regs; } diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index bab8942c30..2a2a6eb3eb 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -27,6 +27,7 @@ #include "qemu/main-loop.h" #include "exec/log.h" #include "exec/cpu-common.h" +#include "exec/gdbstub.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "sysemu/tcg.h" @@ -223,11 +224,10 @@ static void cpu_common_unrealizefn(DeviceState *dev) static void cpu_common_initfn(Object *obj) { CPUState *cpu = CPU(obj); - CPUClass *cc = CPU_GET_CLASS(obj); + gdb_init_cpu(cpu); cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX; - cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs; /* user-mode doesn't have configurable SMP topology */ /* the default value is changed by qemu_init_vcpu() for system-mode */ cpu->nr_cores = 1; @@ -247,6 +247,7 @@ static void cpu_common_finalize(Object *obj) { CPUState *cpu = CPU(obj); + g_array_free(cpu->gdb_regs, TRUE); qemu_lockcnt_destroy(&cpu->in_ioctl_lock); qemu_mutex_destroy(&cpu->work_mutex); } From patchwork Fri Nov 3 19:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740731 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12290wrr; Fri, 3 Nov 2023 13:10:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT2cfS4u04dHXIK1gRrsCCj8v4wbO62g7dxNBYSNuPQI0YFWcxXVdNzwGWicoHz+RXRQjh X-Received: by 2002:adf:ea11:0:b0:329:6d09:61ff with SMTP id q17-20020adfea11000000b003296d0961ffmr16581419wrm.62.1699042238023; Fri, 03 Nov 2023 13:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042238; cv=none; d=google.com; s=arc-20160816; b=ZhD5JN5r7k5PcOpwb5VRpZSwOzNDYeZXeF7RMSyUhpBTCuqy2sBwtQx9HqSEtYZ4vZ 3stpzBUdNuvzXyX53zQhsec2re1AIdPWJ0K/3GQ0ck/ZZB0QbQL27Qovxa12YEK1pGDX MeT6vQ5Pph4L/HA+Zz0oJQhxw5ukgO/tgJSkKFtcDoh1n1LQOAg0a3GjK6IjEGKLBC3c e6q5D0jInavBDvXRAU3JL5yIFTiuwh8xCxwSXa2uiE7THUTOivf41ySflstsRRlCQFAp 9KBRnb+0d8ptCS3zO7Tw46ADYzUDSELB6OsEsOV2+6V4+AVc7/Kfwt6251hRDTZ1qxn+ /9AA== 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=BrBEs03oRfbEhBwEEFQpVZTQS4QW+vTfRnSTYqOOAZA=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=rETm72fd0SpUSaW+7hUbFwuH2bysn1LYPHa8Z+0NDcP0Xfrd7y/CEmbHB2lwZbziMz /QkqAbk2lKQNQEYMKu7E8ES9d42Xgd/bbu+YtpdtLeObX3QwP2jY0BjfqCiqG+M8L0aV vzLVucscPnOeO3O8xk+vUOeJAOvzVT9qx7gq8Xkkw37yjiq5YMzd+JyWMAON8/2zCuQG UPw+2VTawVaH4GGuPndsQ/WEUgDM3NtRQmEWFBh6YBYjgBaxa9sk7os5SeY1qqrrgt88 U0U+oWkjlb81ZWZ7DbI9WJ3snP3ifciM+Skb8npSp80J5Pc5POFRwyJ0Zq9qUVAVjj7u OVNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eWHXeoOO; 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 bj25-20020a0560001e1900b00324835356afsi1937248wrb.792.2023.11.03.13.10.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:10:38 -0700 (PDT) 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=eWHXeoOO; 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 1qz0RQ-0005XB-U9; Fri, 03 Nov 2023 16:06: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 1qz0RI-0005Rb-NI for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:44 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qn-0006zN-FY for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:44 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c50305c5c4so34823991fa.1 for ; Fri, 03 Nov 2023 13:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041971; x=1699646771; 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=BrBEs03oRfbEhBwEEFQpVZTQS4QW+vTfRnSTYqOOAZA=; b=eWHXeoOODOkxZHRbt2FbK5KKqdJ/lWFqSRMbc4SF+hn0KX794ujpEHK4muGDb+9ejr MFLBlKd2K9OUyq6ndABImmLKa3yb0VAOfyZyTbR6OnV/wlD8NHm3QSPhL5Ci68M7rTS7 dCC60m7OEeLU7Nb40qvwqLDaPd7qDzBYmYfWKQ273jmU7+p8i6yg0mKt43jOgL5t9gh2 pc65oFdcFzYmd4bZ7N7jrlTOfPjVFjcjSshlAMaBQIZduZP7QxZ1a9FasTlBBh57QrDw gHubv/fwDsah9Xpz/LzRawlLzqkd/SCQaM1qF8FunECNUt24MkCKzGrOyQchoVyWxS5M O7nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041971; x=1699646771; 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=BrBEs03oRfbEhBwEEFQpVZTQS4QW+vTfRnSTYqOOAZA=; b=Mrn+X5NMCDvsLGwhokwyOjiuALIvN4YIP8RJyUnyPDsOyMUaK0/Z5CZmS9AkNlhC+O kn9Q+z/IPgSt7QeUOVS15wLyKIx0k+94S20xsnjIZpy9yX+ZJvFkX3vG7/TTIXAUlC7c RAzXRUA1/BCq0PwWFR8y839CjI/FnY7T3sDaZwTEF9qsSUn7qwAokfUoFk/LgMOtLe+x NfcFgGUv4PmJkO6F9CsD5RLdg2kYgPJvFZ9Jb5EFHJAYoCl/3uSaL4caqDh5vc4vRcO2 9gSXMhDV+9yh4iFrN4THt6JarEQH8u6QMmXknggovEt8FKpqvys0ae8li3jR+gj3n+4a BZcw== X-Gm-Message-State: AOJu0YzkBGf2j9fND4FRu16qqYszSgmVN8Kgy3C13LnDwl6RwvTJqyOg XMfj9iXPuwc2supyX0tCbMZyuw== X-Received: by 2002:a19:501c:0:b0:509:4a02:49f6 with SMTP id e28-20020a19501c000000b005094a0249f6mr3959351lfb.34.1699041971617; Fri, 03 Nov 2023 13:06:11 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id m1-20020a056000180100b0031980783d78sm2624721wrh.54.2023.11.03.13.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id ABA6D6574E; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 18/29] gdbstub: Infer number of core registers from XML Date: Fri, 3 Nov 2023 19:59:45 +0000 Message-Id: <20231103195956.1998255-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x234.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki GDBFeature has the num_regs member so use it where applicable to remove magic numbers. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-12-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/hw/core/cpu.h | 3 ++- target/s390x/cpu.h | 2 -- gdbstub/gdbstub.c | 5 ++++- target/arm/cpu.c | 1 - target/arm/cpu64.c | 1 - target/avr/cpu.c | 1 - target/hexagon/cpu.c | 1 - target/i386/cpu.c | 2 -- target/loongarch/cpu.c | 2 -- target/m68k/cpu.c | 1 - target/microblaze/cpu.c | 1 - target/riscv/cpu.c | 1 - target/rx/cpu.c | 1 - target/s390x/cpu.c | 1 - 14 files changed, 6 insertions(+), 17 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 18593db5b2..9a771d682f 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -127,7 +127,8 @@ struct SysemuCPUOps; * @gdb_adjust_breakpoint: Callback for adjusting the address of a * breakpoint. Used by AVR to handle a gdb mis-feature with * its Harvard architecture split code and data. - * @gdb_num_core_regs: Number of core registers accessible to GDB. + * @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer + * from @gdb_core_xml_file. * @gdb_core_xml_file: File name for core registers GDB XML description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop * before the insn which triggers a watchpoint rather than after it. diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 40c5cedd0e..12939bc562 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -458,8 +458,6 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState *env, vaddr *pc, #define S390_R13_REGNUM 15 #define S390_R14_REGNUM 16 #define S390_R15_REGNUM 17 -/* Total Core Registers. */ -#define S390_NUM_CORE_REGS 18 static inline void setcc(S390CPU *cpu, uint64_t cc) { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 5ecd1f23e6..af63b5d159 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -546,9 +546,12 @@ void gdb_init_cpu(CPUState *cpu) gdb_register_feature(cpu, 0, cc->gdb_read_register, cc->gdb_write_register, feature); + cpu->gdb_num_regs = cpu->gdb_num_g_regs = feature->num_regs; } - cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs; + if (cc->gdb_num_core_regs) { + cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs; + } } void gdb_register_coprocessor(CPUState *cpu, diff --git a/target/arm/cpu.c b/target/arm/cpu.c index df6496b019..a18b832c9a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2489,7 +2489,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->sysemu_ops = &arm_sysemu_ops; #endif - cc->gdb_num_core_regs = 26; cc->gdb_arch_name = arm_gdb_arch_name; cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1e9c6c85ae..8a5bad54cf 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -793,7 +793,6 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = aarch64_cpu_gdb_read_register; cc->gdb_write_register = aarch64_cpu_gdb_write_register; - cc->gdb_num_core_regs = 34; cc->gdb_core_xml_file = "aarch64-core.xml"; cc->gdb_arch_name = aarch64_gdb_arch_name; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 14d8b9d1f0..01adfb5089 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -244,7 +244,6 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register; cc->gdb_adjust_breakpoint = avr_cpu_gdb_adjust_breakpoint; - cc->gdb_num_core_regs = 35; cc->gdb_core_xml_file = "avr-cpu.xml"; cc->tcg_ops = &avr_tcg_ops; } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 60d52e1e9d..7c1426f70c 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -385,7 +385,6 @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data) cc->get_pc = hexagon_cpu_get_pc; cc->gdb_read_register = hexagon_gdb_read_register; cc->gdb_write_register = hexagon_gdb_write_register; - cc->gdb_num_core_regs = TOTAL_PER_THREAD_REGS; cc->gdb_stop_before_watchpoint = true; cc->gdb_core_xml_file = "hexagon-core.xml"; cc->disas_set_info = hexagon_cpu_disas_set_info; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fc8484cb5e..6af6013d2d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7969,10 +7969,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->gdb_arch_name = x86_gdb_arch_name; #ifdef TARGET_X86_64 cc->gdb_core_xml_file = "i386-64bit.xml"; - cc->gdb_num_core_regs = 66; #else cc->gdb_core_xml_file = "i386-32bit.xml"; - cc->gdb_num_core_regs = 50; #endif cc->disas_set_info = x86_disas_set_info; diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index ef1bf89dac..1b25920895 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -775,7 +775,6 @@ static void loongarch32_cpu_class_init(ObjectClass *c, void *data) { CPUClass *cc = CPU_CLASS(c); - cc->gdb_num_core_regs = 35; cc->gdb_core_xml_file = "loongarch-base32.xml"; cc->gdb_arch_name = loongarch32_gdb_arch_name; } @@ -789,7 +788,6 @@ static void loongarch64_cpu_class_init(ObjectClass *c, void *data) { CPUClass *cc = CPU_CLASS(c); - cc->gdb_num_core_regs = 35; cc->gdb_core_xml_file = "loongarch-base64.xml"; cc->gdb_arch_name = loongarch64_gdb_arch_name; } diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 538d9473c2..5fdbe5602b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -565,7 +565,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) #endif cc->disas_set_info = m68k_cpu_disas_set_info; - cc->gdb_num_core_regs = 18; cc->tcg_ops = &m68k_tcg_ops; } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 1998f69828..9d3fbfe159 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -428,7 +428,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->sysemu_ops = &mb_sysemu_ops; #endif device_class_set_props(dc, mb_properties); - cc->gdb_num_core_regs = 32 + 25; cc->gdb_core_xml_file = "microblaze-core.xml"; cc->disas_set_info = mb_disas_set_info; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5200fba9b9..00518df497 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1575,7 +1575,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->get_pc = riscv_cpu_get_pc; cc->gdb_read_register = riscv_cpu_gdb_read_register; cc->gdb_write_register = riscv_cpu_gdb_write_register; - cc->gdb_num_core_regs = 33; cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 4d0d3a0c8c..7b9e46d1bc 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -235,7 +235,6 @@ static void rx_cpu_class_init(ObjectClass *klass, void *data) cc->gdb_write_register = rx_cpu_gdb_write_register; cc->disas_set_info = rx_cpu_disas_set_info; - cc->gdb_num_core_regs = 26; cc->gdb_core_xml_file = "rx-core.xml"; cc->tcg_ops = &rx_tcg_ops; } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 6acfa1c91b..6fba949729 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -362,7 +362,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) s390_cpu_class_init_sysemu(cc); #endif cc->disas_set_info = s390_cpu_disas_set_info; - cc->gdb_num_core_regs = S390_NUM_CORE_REGS; cc->gdb_core_xml_file = "s390x-core64.xml"; cc->gdb_arch_name = s390_gdb_arch_name; From patchwork Fri Nov 3 19:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740723 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11103wrr; Fri, 3 Nov 2023 13:07:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBvOC4w3GWKPWkY2b4NMMick7e9ICw4DhVuaQVU9E17zZWfpeTLfJLF91sKZt7egBoF2Kw X-Received: by 2002:a05:620a:126c:b0:775:bfe3:a91d with SMTP id b12-20020a05620a126c00b00775bfe3a91dmr19015008qkl.22.1699042077084; Fri, 03 Nov 2023 13:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042077; cv=none; d=google.com; s=arc-20160816; b=oMQg/Appmo6we/7w0bD9Cwu8a/sqmKFcQvyeK7SoScYbL3vEO/bvvzwUM+ibMjY41H OeKkCoys4FK9/VEoNHpGgQfdYBnWfhSyaqr1DAW9gGzkVbEHdfP1hzyM8W+x84I0V0ko a0FgsHdkin66rHzoQ7/RWg7miRVg7Nh18UT8Jc1fp96JKLz0pJLZArLOrhivFk9L+dR0 oXteSZ3R/9EMWTgyOf+8FA/uPoeOLNCN6pygICKWmaEpYWOBOoEp42T2+/9EGlsWIYrD /hDfIWB47qUsIaiWiuwzo0/LzQAienpkExkD6JXQw1/MRhANPHba7pbF8x79f5rfRAy4 I2pQ== 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=FtfsESgykLLvPeIAuq4QyDjZLcqaVjQHtpMnoZ4LFFQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=iI+u4ZOr5yE9lLJulbX6blFS6w11zIWZd+vTi6myimXFy04A7yIfAbWinAZBtCzLw6 dwfZYIhVaklJJkr9/+R4nF0CRyDR6YB6QBgYJdeDpEDVDvHszPGP6B1O2LhXYivWMOB8 NiATDPYb+eh74jqb2IHbgBvV/rxe4C0nqOepHPq8Od+SY+5Xqm381s0g3QZt6yZoL6iU hQRw6UQuzXQh2OwX/mUN6nhcLp2IwIymINlnVp3945/tbLEpcCedUuY0o7CD3TM0RKBt 8AVGtBhGyQyT3EhETeKQfeXXGvjdizVPwFj6GNzCKUFXE20S052owavCrB5iv452dbF9 uLRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fzVH0kOG; 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 sm6-20020a05620a944600b00778ae4e9288si1870156qkn.646.2023.11.03.13.07.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:07:57 -0700 (PDT) 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=fzVH0kOG; 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 1qz0R2-00048d-GZ; Fri, 03 Nov 2023 16:06:28 -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 1qz0Qy-0003oc-4N for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:24 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Ql-0006xL-8O for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:23 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32fb1d757f7so1025998f8f.0 for ; Fri, 03 Nov 2023 13:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041968; x=1699646768; 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=FtfsESgykLLvPeIAuq4QyDjZLcqaVjQHtpMnoZ4LFFQ=; b=fzVH0kOGMWEfQVriITpzIBdv8e+2graz3zXxUOWAQYkHuSTahDrfXo+ns2OwmOYJ4C H3AyFF6hD9gXuyCp1rMoKVkptk77NM/piogz2BmNQ5Zb80qy1HPba65cNlGwPqWiqQd9 a97pvE0cm97CGhFZpkq9gGk4GPUJMTWgwvHLC+c9rpPTFxW7BU2venkxVFBr42LUmaP7 vPQadArqOJRRczayabJoUjCz4H1xengJj1JCgL9U2YA5Wes1G7x1bInbZwK+/PkdUyBy k/P6eMM31JLv9qcqFu+hXUBeh83TcO46EaF7ET8i3AqQh4B+jZJcIQivE97v6Ht/BkOP nT/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041968; x=1699646768; 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=FtfsESgykLLvPeIAuq4QyDjZLcqaVjQHtpMnoZ4LFFQ=; b=sXOy1RKgrMMNEykvZY9F6iWqMCFZJlwWcuo2RRGFWEmGIDiCN1sQGjhL2S2Bxxdez0 +dw7A44bopFGro4yJzW0dpFrdfW2MZsRcv4fb+m6sCwgXHTpYcS4f6RX/jdZkJY2HBgT Qa5LBfLgQ0c3b+mp84CaVZXuizU49sxV7jsIqRktr4/mnzdSBDCIt5tlzOOzsh29l1xc 2hPTf3wmUN3vSzYEgUEOVp09cmIS0/oyuEnVcl05bu8cATxPstVg3DcOEWp4AmLGIlm/ yjSAaskHC0khfLglY6HYHdJlv9n3iY0del75OpdC6Xqxj8DEqSXtwHesW9Sgr8ady+PF DOzw== X-Gm-Message-State: AOJu0Yw/AbU9PQZk0UY+qlxiTHPdlpSNggEG8QYNYjdPmyuP08wKRcYK BGlKFJeloVSW3877RUbsjUKX2w== X-Received: by 2002:a5d:4f8c:0:b0:317:e542:80a8 with SMTP id d12-20020a5d4f8c000000b00317e54280a8mr15309457wru.15.1699041968551; Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h3-20020a5d5043000000b0032dba85ea1bsm2636745wrt.75.2023.11.03.13.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CC2FB6574F; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 19/29] hw/core/cpu: Remove gdb_get_dynamic_xml member Date: Fri, 3 Nov 2023 19:59:46 +0000 Message-Id: <20231103195956.1998255-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki This function is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-13-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/hw/core/cpu.h | 4 ---- target/arm/cpu.h | 6 ------ target/ppc/cpu.h | 1 - target/arm/cpu.c | 1 - target/arm/gdbstub.c | 18 ------------------ target/ppc/cpu_init.c | 3 --- target/ppc/gdbstub.c | 10 ---------- target/riscv/cpu.c | 14 -------------- 8 files changed, 57 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 9a771d682f..e4d28e09e8 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -134,9 +134,6 @@ struct SysemuCPUOps; * before the insn which triggers a watchpoint rather than after it. * @gdb_arch_name: Optional callback that returns the architecture name known * to GDB. The caller must free the returned string with g_free. - * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for the - * gdb stub. Returns a pointer to the XML contents for the specified XML file - * or NULL if the CPU doesn't have a dynamically generated content for it. * @disas_set_info: Setup architecture specific components of disassembly info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. @@ -167,7 +164,6 @@ struct CPUClass { const char *gdb_core_xml_file; const gchar * (*gdb_arch_name)(CPUState *cpu); - const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname); void (*disas_set_info)(CPUState *cpu, disassemble_info *info); diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2549681367..ad0940dc57 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1137,12 +1137,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, 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); -/* 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. - */ -const char *arm_gdb_get_dynamic_xml(CPUState *cpu, const char *xmlname); - int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 848062bc9f..650e6ece70 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1384,7 +1384,6 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a18b832c9a..9de8dd7599 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2490,7 +2490,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->sysemu_ops = &arm_sysemu_ops; #endif cc->gdb_arch_name = arm_gdb_arch_name; - cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = arm_disas_set_info; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 059d84f98e..a3bb73cfa7 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -474,24 +474,6 @@ static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs, #endif #endif /* CONFIG_TCG */ -const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) -{ - ARMCPU *cpu = ARM_CPU(cs); - - if (strcmp(xmlname, "system-registers.xml") == 0) { - return cpu->dyn_sysreg_feature.desc.xml; - } else if (strcmp(xmlname, "sve-registers.xml") == 0) { - return cpu->dyn_svereg_feature.desc.xml; - } else if (strcmp(xmlname, "arm-m-system.xml") == 0) { - return cpu->dyn_m_systemreg_feature.desc.xml; -#ifndef CONFIG_USER_ONLY - } else if (strcmp(xmlname, "arm-m-secext.xml") == 0) { - return cpu->dyn_m_secextreg_feature.desc.xml; -#endif - } - return NULL; -} - void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) { CPUState *cs = CPU(cpu); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index a0178c3ce8..909d753b02 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7380,9 +7380,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #endif cc->gdb_num_core_regs = 71; -#ifndef CONFIG_USER_ONLY - cc->gdb_get_dynamic_xml = ppc_gdb_get_dynamic_xml; -#endif #ifdef USE_APPLE_GDB cc->gdb_read_register = ppc_cpu_gdb_read_register_apple; cc->gdb_write_register = ppc_cpu_gdb_write_register_apple; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 8ca37b6bf9..f47878a67b 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -342,16 +342,6 @@ static void gdb_gen_spr_feature(CPUState *cs) gdb_feature_builder_end(&builder); } - -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) -{ - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); - - if (strcmp(xml_name, "power-spr.xml") == 0) { - return pcc->gdb_spr.xml; - } - return NULL; -} #endif #if !defined(CONFIG_USER_ONLY) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 00518df497..aee422c497 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1416,19 +1416,6 @@ static const gchar *riscv_gdb_arch_name(CPUState *cs) } } -static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) -{ - RISCVCPU *cpu = RISCV_CPU(cs); - - if (strcmp(xmlname, "riscv-csr.xml") == 0) { - return cpu->dyn_csr_feature.xml; - } else if (strcmp(xmlname, "riscv-vector.xml") == 0) { - return cpu->dyn_vreg_feature.xml; - } - - return NULL; -} - #ifndef CONFIG_USER_ONLY static int64_t riscv_get_arch_id(CPUState *cs) { @@ -1582,7 +1569,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) cc->get_arch_id = riscv_get_arch_id; #endif cc->gdb_arch_name = riscv_gdb_arch_name; - cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml; object_class_property_add(c, "mvendorid", "uint32", cpu_get_mvendorid, cpu_set_mvendorid, NULL, NULL); From patchwork Fri Nov 3 19:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740732 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12496wrr; Fri, 3 Nov 2023 13:11:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHArpu3igULeAeLGwJ4FgHdb6IRV4MIZ3xqwxR/emcPomMmdXjkPt34M4nXH8LqhbTj6duJ X-Received: by 2002:a5d:6d8a:0:b0:32f:76f4:b2b with SMTP id l10-20020a5d6d8a000000b0032f76f40b2bmr4675600wrs.11.1699042265421; Fri, 03 Nov 2023 13:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042265; cv=none; d=google.com; s=arc-20160816; b=cds9TeItp4+i2BPhrDUFnk8xMBpNa0XHD+6hA2d3zq8/Kplb2NIf4mUbh/rHPxCWx+ bncStZbMLd8KYINmG2e7k3pvurHuwTTsiLNEPLhkG07TN7G0D3XmllkdiYLBsy0tZoWB 4tbWJePqLxSjBuvId9DhDZgc2K9o2K9z52X98Wfohb5hMRNPZL4WTtuUJy3d2vcddksZ unPLdX86vdqwZ+sGv7MslbOPqnP2Ff7ZaDjxB0ceBcYD0RyQZ45FKqpr9vfC6XPoF9w5 8lJ7cGZg1ECPgm8y87P24GbUMMJOqLCzSmCGzgMWj9nzDtS6r9WttfWoTaO0hjZLU6Vy HyfQ== 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=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=m5CxfFwj6p7vPKxuqBCPeEJgRCCHILcs6Rrk/+gCQJnJUqsdVWxyvHEMuwG61ilDg3 1LlsLgxs7EwRuDVlfxZ7RuNhjhS7M0Wo6rc9TisgWjgKhI232lnXL63KUa53zBwtZC2u 2KwIKYShu94o4HNLAtXQXuSmGxPEPS5yWBeZyvT8VPyPmB7qEa333Pp3uOKxqUHiUIfn +dM7vIgYs91GRvabRVW0Z4HSxeUZXd/ebhVSM55IyXtDRE8Wu3ggUz11gW6GCbTppvMO vnM/qWeXp5oQcimuqfOrNqiriE2goifHyCSLZtoYW+DptwgylR58VDCjWV4lytGyxUmd 5QdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZKC5Q/On"; 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 f12-20020a0560001a8c00b0032cc2f12a3csi1906863wry.133.2023.11.03.13.11.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:11:05 -0700 (PDT) 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="ZKC5Q/On"; 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 1qz0R9-0004c5-IO; Fri, 03 Nov 2023 16:06:35 -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 1qz0R1-000431-7m for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:27 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qm-0006ya-0m for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:26 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32f78dcf036so2168357f8f.0 for ; Fri, 03 Nov 2023 13:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041970; x=1699646770; 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=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; b=ZKC5Q/On2c9NL162wKSjoC+GM6EDyD//JHWP5WNf2SI5ydiinby8FMHBDm6YRfIItK 5e1UzrU7hTDnloEpv0Dw2gYQhNyND877YAd/VHS9xIZcQgr6gXvsdQeABgot9qKWQen7 xhjX6s7r2S5R2akjNNEADJz4a97HWDu9PCYwwTxIxRP1zcVGIX8blQnJ5HnMPkMtCmPo Xz3qUBx3WXi4nxgV3Gm2rWNhNNgwCBciHFCXVuJ3wXIaxgQH9PnyTAsVFcH+Vz9ikZOe DNLaRSHNIzX0S72CFLDX6XHB+GHqx3adCNGhrUlIafTBinRmYrb7JN6vxNSip2cwF2t8 oNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041970; x=1699646770; 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=WvNpdCx7aCfQzdBz6Tk/5RuJuiLgzcCIAvSItOrN2Ac=; b=YmVpUy4deb6bGlhp/UNpkqNp2kyaoTLOF79UFNotPUta6LGbgC0q2sRgjsALSbAra/ WkUP5uEyw76hxTzC6z80mnMCl/3swj+p3WbOcaZX4AYrkhC2iinFO0PutVzmbUDSlVEP 9Jfjc6FqBXTOJqc8PuGt7CZOh3AO5Zk1WobJNYzRhfvcimwFuUASfrAb70AJaRpfdsuz mI7iD+n0VTrTLs3CEx2ieQBJ4YieJCy5zmB7Yi51qyNj4tFvmyJYP0Lb76PpKkPA35ev Hc2EO3mnOYVMMiWMDLNmVWM735iBtYXFduySiW57nN7GcuD6fWypGG58kro6h7pWXLH3 55tw== X-Gm-Message-State: AOJu0YwkvnbNKN52IKqPkgpAJyzpzrwxqhoUZDAjGaZvojLxnn479kLY pofFbctlzjaR6UW/MRLwsqNrhw== X-Received: by 2002:a05:6000:1acf:b0:32f:81f6:9a1e with SMTP id i15-20020a0560001acf00b0032f81f69a1emr4137029wry.28.1699041970527; Fri, 03 Nov 2023 13:06:10 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e11-20020adfe7cb000000b00317a04131c5sm2635033wrn.57.2023.11.03.13.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E6EBA65750; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 20/29] gdbstub: Add members to identify registers to GDBFeature Date: Fri, 3 Nov 2023 19:59:47 +0000 Message-Id: <20231103195956.1998255-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki These members will be used to help plugins to identify registers. The added members in instances of GDBFeature dynamically generated by CPUs will be filled in later changes. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-14-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 3 +++ gdbstub/gdbstub.c | 12 +++++++++--- target/riscv/gdbstub.c | 4 +--- scripts/feature_to_c.py | 14 +++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 82a8afa237..da9ddfe54c 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,12 +13,15 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + const char *name; + const char * const *regs; int num_regs; } GDBFeature; typedef struct GDBFeatureBuilder { GDBFeature *feature; GPtrArray *xml; + GPtrArray *regs; int base_reg; } GDBFeatureBuilder; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index af63b5d159..7d7d887817 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -419,9 +419,10 @@ void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, builder->feature = feature; builder->xml = g_ptr_array_new(); g_ptr_array_add(builder->xml, header); + builder->regs = g_ptr_array_new(); builder->base_reg = base_reg; feature->xmlname = xmlname; - feature->num_regs = 0; + feature->name = name; } void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, @@ -440,10 +441,12 @@ void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, const char *type, const char *group) { - if (builder->feature->num_regs < regnum) { - builder->feature->num_regs = regnum; + if (builder->regs->len <= regnum) { + g_ptr_array_set_size(builder->regs, regnum + 1); } + builder->regs->pdata[regnum] = (gpointer *)name; + if (group) { gdb_feature_builder_append_tag( builder, @@ -469,6 +472,9 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *builder) } g_ptr_array_free(builder->xml, TRUE); + + builder->feature->num_regs = builder->regs->len; + builder->feature->regs = (void *)g_ptr_array_free(builder->regs, FALSE); } const GDBFeature *gdb_find_static_feature(const char *xmlname) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 9553ad62a3..fce87a16c2 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -263,11 +263,9 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) } predicate = csr_ops[i].predicate; if (predicate && (predicate(env, i) == RISCV_EXCP_NONE)) { - g_autofree char *dynamic_name = NULL; name = csr_ops[i].name; if (!name) { - dynamic_name = g_strdup_printf("csr%03x", i); - name = dynamic_name; + name = g_strdup_printf("csr%03x", i); } gdb_feature_builder_append_reg(&builder, name, bitsize, i, diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index e04d6b2df7..807af0e685 100644 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -50,7 +50,9 @@ def writeliteral(indent, bytes): sys.stderr.write(f'unexpected start tag: {element.tag}\n') exit(1) + feature_name = element.attrib['name'] regnum = 0 + regnames = [] regnums = [] tags = ['feature'] for event, element in events: @@ -67,6 +69,7 @@ def writeliteral(indent, bytes): if 'regnum' in element.attrib: regnum = int(element.attrib['regnum']) + regnames.append(element.attrib['name']) regnums.append(regnum) regnum += 1 @@ -85,6 +88,15 @@ def writeliteral(indent, bytes): writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write(f',\n {num_regs},\n }},\n') + sys.stdout.write(',\n') + writeliteral(8, bytes(feature_name, 'utf-8')) + sys.stdout.write(',\n (const char * const []) {\n') + + for index, regname in enumerate(regnames): + sys.stdout.write(f' [{regnums[index] - base_reg}] =\n') + writeliteral(16, bytes(regname, 'utf-8')) + sys.stdout.write(',\n') + + sys.stdout.write(f' }},\n {num_regs},\n }},\n') sys.stdout.write(' { NULL }\n};\n') From patchwork Fri Nov 3 19:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740730 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12036wrr; Fri, 3 Nov 2023 13:10:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM9UyVOgl7aCndO1ISU8KxIKuzqludZvTK8zPUzhEXNJB+g9N46u4Xsh+hGwFCLYbkWAA2 X-Received: by 2002:a05:6902:1366:b0:d9a:6b48:db71 with SMTP id bt6-20020a056902136600b00d9a6b48db71mr21560676ybb.62.1699042205825; Fri, 03 Nov 2023 13:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042205; cv=none; d=google.com; s=arc-20160816; b=yBagW9Hul2u6/2EPqLqUi9Pd3HOA5/tr5UXFpDvyK9ihZinuh+S0EGw10TAwGoC+fr 5CNePWMCOMwO101bA+X8ymvyRrkdRjMkYmZ2BmNu07NMOgVucF0x7aklCgtxKP8sOMyJ 4Pxj7qBWwr5lpLEdSZw/RLFuC+pN+A/h3t6U5LoBcdflDjFqIxWiWfflVQjfLH8bxiar 9yXooFj8eLRISZygN4IJ3GyARsjg+RCZZvOHRQswi4gwEKkbMEgr3M2lQscgm/wYHD73 LHT2E216ExeuYG548jFDV229zY6j7mNzaXyEKv5mBlT0y/QU5iEkO5kg0om2I+ySENEP OjQw== 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=7sLTMALisCLY6Bva5cUZONqTNhvGsWtyZ83Zemwfzds=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=DiGvc9s15VoGSAinCylOjfoMKPGZHROdR6CzH87Gim5GbZhnk76sNowdKWcvrohWNb zoIh2PBjJLc8ZianTYFhypLH79D+ZXR771g97P3dT0pudrfMx/uRWgph+b77YRT9vziO kPIpaOKCgtGk1L7GOG9G3sd+aGxq4bLzezAEJ53a8Ugj9pnf6unRMG09U2vcD1yvgwfN pLPMpXou1QVIeJz0shqpTZY8yWiRoEDNz+NwhNJLR9GMdgbxH7E63kaWoGKeym2oCm45 7vTMRPon6IDVr8grUujeOV3s4K2n6pQNX4hSs7RlG8HWkQTFhmzk2r7rPVE7GynQPnE+ bMcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYiZnNVa; 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 cz13-20020a056214088d00b0066d1a15d84csi2000896qvb.414.2023.11.03.13.10.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:10:05 -0700 (PDT) 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=LYiZnNVa; 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 1qz0Qz-0003tV-1S; Fri, 03 Nov 2023 16:06:25 -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 1qz0Qv-0003jg-SH for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:22 -0400 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 1qz0Qk-0006x7-Fk for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:20 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32da4ffd7e5so1535317f8f.0 for ; Fri, 03 Nov 2023 13:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041968; x=1699646768; 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=7sLTMALisCLY6Bva5cUZONqTNhvGsWtyZ83Zemwfzds=; b=LYiZnNVaNCk51B4cDg7R2AfUmz9FfH5JRpilM8B86SbwVLuttC+VQvdvoxjhRy21xG AEZqgs0tW1qmJMBpQyWH57tV5j/lwwsZLe8Pd1+R4ksAGblXsBrCOHvRMgsPyoPCjuW7 rs+cqPnlBY6Oy+RQdH1aw9yncyXAAomop/7RKE3qOlsyLJelm07KiLCpmOCZrDyvRNSK sgFlA45emwqlzetY0G3R8vNCbWRoauxuMPKsZn/kCEZtgunNgquVKoOpaptWO60QSuC0 C4du8Wl47/Dcdtbkkoig8hpjlrCB+ESWziERPl9LBuXXEbyVpk04xUQJapYHR6jXrJ2n 9qWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041968; x=1699646768; 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=7sLTMALisCLY6Bva5cUZONqTNhvGsWtyZ83Zemwfzds=; b=kDtckI8rLj6rFKUBR7dAIcja3uTuOF7HR5TUEZw6GbGL2Od9/fiL66+cBCbRNZ7YUB s3/kVmO80kNJJROlOqU0IBcOLcUaXyHcl1pyQZVUPXUgyvGjeSio3CfO3fBvi9d3Lfbj 9X++yUmGZDA80h/Q7qFKhHpKEJ8AM3gYVChz0MY58lYbTPVIqcGGnHWNjLZEPHKe7pTk jdeSAIvxquzvEAMcm5qe8/sseNRMUPw6r/0N/HpdbcTIa4VrKBuTIjNZWf9jbR7dVF4g 4gsokt3YTFS94zSpaXAaIH6pJq9R6io4tuLnr5t1Mvmjd6vmnYNQXpjf/WCUJWHOTGUw g7lg== X-Gm-Message-State: AOJu0YxkpelD5LaZHlKrrmCNtxJHWQWZnW5NkNcwk+uVaY++FVzZJk4F G/D4v6DeWDsnRMBydOhhKvVwpg== X-Received: by 2002:a05:6000:2a9:b0:32f:7260:1220 with SMTP id l9-20020a05600002a900b0032f72601220mr4254287wry.17.1699041968323; Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id j20-20020a5d4534000000b0032dc74c093dsm1333423wra.103.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 09F0065751; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 21/29] gdbstub: expose api to find registers Date: Fri, 3 Nov 2023 19:59:48 +0000 Message-Id: <20231103195956.1998255-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Expose an internal API to QEMU to find groups of registers. It returns a list containing the details required to called gdb_read_register(). Based-on: <20231025093128.33116-15-akihiko.odaki@daynix.com> Cc: Akihiko Odaki Signed-off-by: Alex Bennée --- vAJB: This principle difference is the find registers is a single call which can return a) multiple registers and b) is agnostic to the gdb feature. This is because I haven't so far found any duplicate registers in the system so I thing the regname by itself should be enough. However I do expose the gdb feature name in case the caller wants to do some additional filtering. --- include/exec/gdbstub.h | 47 +++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 59 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 105 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index da9ddfe54c..b201eb4b84 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -111,6 +111,53 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *builder); */ const GDBFeature *gdb_find_static_feature(const char *xmlname); +/** + * gdb_find_feature() - Find a feature associated with a CPU. + * @cpu: The CPU associated with the feature. + * @name: The feature's name. + * + * Return: The feature's number. + */ +int gdb_find_feature(CPUState *cpu, const char *name); + +/** + * gdb_find_feature_register() - Find a register associated with a CPU. + * @cpu: The CPU associated with the register. + * @feature: The feature's number returned by gdb_find_feature(). + * @name: The register's name. + * + * Return: The register's number. + */ +int gdb_find_feature_register(CPUState *cpu, int feature, const char *name); + +/** + * gdb_read_register() - Read a register associated with a CPU. + * @cpu: The CPU associated with the register. + * @buf: The buffer that the read register will be appended to. + * @reg: The register's number returned by gdb_find_feature_register(). + * + * Return: The number of read bytes. + */ +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); + +/** + * typedef GDBRegDesc - a register description from gdbstub + */ +typedef struct { + int gdb_reg; + const char *name; + const char *feature_name; +} GDBRegDesc; + +/** + * gdb_find_registers() - Return list of registers matching pattern + * @cpu: The CPU being searched + * @reg_pattern: the pattern being searched for + * + * Returns a GArray of GDBRegDesc, caller frees + */ +GArray *gdb_find_registers(CPUState *cpu, const char *reg_pattern); + void gdb_set_stop_cpu(CPUState *cpu); /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7d7d887817..45882d1a6f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -490,7 +490,64 @@ const GDBFeature *gdb_find_static_feature(const char *xmlname) g_assert_not_reached(); } -static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) +int gdb_find_feature(CPUState *cpu, const char *name) +{ + GDBRegisterState *r; + + for (guint i = 0; i < cpu->gdb_regs->len; i++) { + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (!strcmp(name, r->feature->name)) { + return i; + } + } + + return -1; +} + +int gdb_find_feature_register(CPUState *cpu, int feature, const char *name) +{ + GDBRegisterState *r; + + r = &g_array_index(cpu->gdb_regs, GDBRegisterState, feature); + + for (int i = 0; i < r->feature->num_regs; i++) { + if (r->feature->regs[i] && !strcmp(name, r->feature->regs[i])) { + return r->base_reg + i; + } + } + + return -1; +} + +GArray *gdb_find_registers(CPUState *cpu, const char *reg_pattern) +{ + g_autoptr(GPatternSpec) pat = g_pattern_spec_new(reg_pattern); + GArray *results = g_array_new(true, true, sizeof(GDBRegDesc)); + + /* registers are only available once the CPU is initialised */ + if (!cpu->gdb_regs) { + return results; + } + + for (int f = 0; f < cpu->gdb_regs->len; f++) { + GDBRegisterState *r = &g_array_index(cpu->gdb_regs, GDBRegisterState, f); + for (int i = 0; i < r->feature->num_regs; i++) { + const char *name = r->feature->regs[i]; + if (name && g_pattern_match_string(pat, name)) { + GDBRegDesc desc = { + r->base_reg + i, + name, + r->feature->name + }; + g_array_append_val(results, desc); + } + } + } + + return results; +} + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; From patchwork Fri Nov 3 19:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740712 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8499wrr; Fri, 3 Nov 2023 13:03:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNEa0psk6tP9axrewScUcpPg24JwV4P1UueEwxgOvpTqtna1MyJHHnMAnx0+WwjyAnn6lv X-Received: by 2002:a05:6214:29c9:b0:66d:245a:4b70 with SMTP id gh9-20020a05621429c900b0066d245a4b70mr25489305qvb.2.1699041782509; Fri, 03 Nov 2023 13:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041782; cv=none; d=google.com; s=arc-20160816; b=zfVo4QFsgtBEOduk4ocx3Vdom7cCAQWM3FBhOFwY2Q063VP1f4Pss3qcOldB4EgZsM ZCQJx5TWTovSd2wOtdbvYc7QYBBY5Rh6KOKZimwyVlOO+qrkfD/BmPMrIfejlDiRGDal AezJyv7LhIqaxM77gaxvlF3Ef6bie72xY3IY+UaL5og7TQMpT57WEd+7Mf4f3mbYryCS mF+H3mBJp0cIVBix1xH6kUUUN6gbOvW7euyI60mNQYUQjz+XmD1mfcRtBqqAraI6Vq9C C5GYf96A8GTZY3IYyGG2B2HJDZRgNtiaFcywaPRwdyrVGTmrvgAi0iissVioNlnA/0yc B3GA== 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=b88ySiChZ2erUB0s9VPiqeJUXsHB8fg3nHTqedran50=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=q4GYo3sSW9kOW4wGgmLs2HZn/XpQMNJ4f+8jYhTrZHAtoZlXnWSuSmsPBfSO30tLWL bzwsiebYAB3Gz9TBJxp69JaItS0DpnmYenehCXBYk4O1mrXEjTZ4Yi1LeksqQg7Z/Ygm Br3vNoZTQUrJpWApb/uXekyoSscpe5VARktLJwiUobBnJbl7jfY8Hzk4r3CJMO9ERvfI k/WvGtTGs+EycX+2BR9J1A/aKzJl0CnJuTqdQcJ/M/gviXVrFD3wbIjCurulLJnFr3L1 qCLt2IiJam6YvpaFLb71blW7MFNKA7w9X6+ucP+6vbDTYzUl1ZAJJeMBTHFXk3Y29ZkU u7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qxl4kBZi; 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 dj5-20020a056214090500b006564001ff0esi1959172qvb.413.2023.11.03.13.03.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:03:02 -0700 (PDT) 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=Qxl4kBZi; 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 1qz0Me-0001hU-2U; Fri, 03 Nov 2023 16:01:56 -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 1qz0LK-0008OY-6m for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:37 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0L4-0005f9-BP for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:33 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c523ac38fbso33394371fa.0 for ; Fri, 03 Nov 2023 13:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041615; x=1699646415; 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=b88ySiChZ2erUB0s9VPiqeJUXsHB8fg3nHTqedran50=; b=Qxl4kBZiobhLr4Vg8JGFNrOiOOHKUo94SSxOPlWEmaVbnZBl0yAzHv8cN3KhRs4/2x 63sukS6sHd/ispC89zPcgelTqPzH4HG7AT8opJL1ANvPj/G5K0ANPN2og6EiKJgCurgT Mn1rAq6h0U/AtZWHog76gbOeu9ALLkxL453T3nOOoCGa9zEKBpKFBs6tk65lw8jLfLrv /JwHwmbO4QvVIV8gBYD5krYNLBodPw5SxHk8htSuwl0YYnkJvvUR9bkGowiOr3LX9SYN MwQO0ZmYilCy/jwBsUqkvakweTy97l7wxvEex43lVR7EK0UrwZMyNa90T8Bs7iDDxBKF eNTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041615; x=1699646415; 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=b88ySiChZ2erUB0s9VPiqeJUXsHB8fg3nHTqedran50=; b=h+aw+tLn84uexq9l6gLd/U1KCMmxZBQwDBWhGI9+NGnTFAuQ5j+txYLueOydF2b7n6 9pr38J4YgQO1pbWdsUvjtqZ/KU0Hy4KW3+KNM1QPVbMvNh+PekpNuHyFi2ZRafPlFY01 lEUyRWxWeYKMexOtuYZzOswnRSbaxDl4dPJOO7DzoKACPnMB8moQ50jRcAeG2RwwVawk SppIQk5m91IuLCbVWjBUb+3XkZMGiMT9weeiXSvWZXDsWIRW7lg5Nh8t/ejA0L5ZKw9A R9iHIiDN/cEm4RjzxvRFs2hK1Azz7NoO1iShvV3SEXisSi9HYOJ9bRGQizZV7J9aPLWS 4SNg== X-Gm-Message-State: AOJu0YwLz07MT+vMRVNx0T8IqwrlVg6mW1cTOf7vUowyIPSnug50vB93 6rodweKpDxdFR46fGUSi/mmU2g== X-Received: by 2002:a05:651c:1310:b0:2c5:98b:8bdb with SMTP id u16-20020a05651c131000b002c5098b8bdbmr14643914lja.49.1699041615092; Fri, 03 Nov 2023 13:00:15 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g23-20020a7bc4d7000000b004063cd8105csm3366511wmk.22.2023.11.03.13.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 22FDA65752; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 22/29] cpu: Call plugin hooks only when ready Date: Fri, 3 Nov 2023 19:59:49 +0000 Message-Id: <20231103195956.1998255-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22f.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki The initialization and exit hooks will not affect the state of vCPU outside TCG context, but they may depend on the state of vCPU. Therefore, it's better to call plugin hooks after the vCPU state is fully initialized and before it gets uninitialized. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Message-Id: <20231025093128.33116-16-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- cpu-target.c | 11 ----------- hw/core/cpu-common.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpu-target.c b/cpu-target.c index 79363ae370..00cd7f4d69 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -42,7 +42,6 @@ #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" #include "qemu/accel.h" -#include "qemu/plugin.h" uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; @@ -143,11 +142,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) /* Wait until cpu initialization complete before exposing cpu. */ cpu_list_add(cpu); - /* Plugin initialization must wait until cpu_index assigned. */ - if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); - } - #ifdef CONFIG_USER_ONLY assert(qdev_get_vmsd(DEVICE(cpu)) == NULL || qdev_get_vmsd(DEVICE(cpu))->unmigratable); @@ -174,11 +168,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) } #endif - /* Call the plugin hook before clearing cpu->cpu_index in cpu_list_remove */ - if (tcg_enabled()) { - qemu_plugin_vcpu_exit_hook(cpu); - } - cpu_list_remove(cpu); /* * Now that the vCPU has been removed from the RCU list, we can call diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 2a2a6eb3eb..409397e2b5 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -210,6 +210,11 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) cpu_resume(cpu); } + /* Plugin initialization must wait until the cpu is fully realized. */ + if (tcg_enabled()) { + qemu_plugin_vcpu_init_hook(cpu); + } + /* NOTE: latest generic point where the cpu is fully realized */ } @@ -217,6 +222,11 @@ static void cpu_common_unrealizefn(DeviceState *dev) { CPUState *cpu = CPU(dev); + /* Call the plugin hook before clearing the cpu is fully unrealized */ + if (tcg_enabled()) { + qemu_plugin_vcpu_exit_hook(cpu); + } + /* NOTE: latest generic point before the cpu is fully unrealized */ cpu_exec_unrealizefn(cpu); } From patchwork Fri Nov 3 19:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740734 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12607wrr; Fri, 3 Nov 2023 13:11:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWovzEUta8RAXmfszSjYfrmCjMtDXUsaocqUZO99oyacDNOL+Z4mgKgnqr2P3FvH/XPEZo X-Received: by 2002:adf:d1c3:0:b0:32f:a8bb:31b5 with SMTP id b3-20020adfd1c3000000b0032fa8bb31b5mr4919511wrd.23.1699042280959; Fri, 03 Nov 2023 13:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042280; cv=none; d=google.com; s=arc-20160816; b=B0USWKREnrJoKWjU7Qm6JsMEVacPVeliSPPopxEKhZ331HCSMh5ojV2ijyc5iNsEs1 OTHstCXj24NCiO9peG6qPljcqJrS+wvJ4FQQJVLfCp7I3gFZ2QmsUQAMpS0keAHSE+XG qHJVv8Ix7eG6oxmc+ntZOO+3JBuvwpbDFTH1agXH6Ky51KIslnhDoyu73qMrcudmbPzH u/0Zabrna6jt8I8b6uu0JqInE0sRN53ZT/EHxFv8JNwN5z3adJ67ju4CE7Y6BdJXyL9v vHmDBrZgD6O1/S7EFDrwK9G7kZhuTzzBLufE70zrf3RYTS/fu3M2EOjjDPwrJuuXIIKT OxdA== 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=wdU11JatOnlkWDYslbuq+w59cKTc9MbSWVr+zLol9PcFClg8GwE9th+kvwQHZCemID 8SdhgbOBDmO4u88iPbewK3EYeVS8h9EQFqNHQCVYZsLhTgd66X5+XtAC8XCf3cDyeMUL V3JKhNp2u3tph4+5km6ErUFzoXzlVtaaJ89r93IhJj7x+dZfzj7DSFhKT9dmNQ6MaQ1m 0j75BG5DszbmLSj2H0q5Twrciw4WmKSXsG8hcO2SJWaKAF7hxUlRlOeDz151w+pViHAZ SWJit39j2060M3ffpsM3XQwhMsWZ77o6aTMJvb3dyI7aztalR6+NT//b10n2c41RA+c1 mY2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mMrjqKlN; 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 n8-20020a5d5888000000b003176f1027cesi1887182wrf.33.2023.11.03.13.11.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:11:20 -0700 (PDT) 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=mMrjqKlN; 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 1qz0Qo-0003Vz-Vs; Fri, 03 Nov 2023 16:06:15 -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 1qz0Qn-0003R6-Jo for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:13 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qh-0006vq-Ii for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:13 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso1161363f8f.1 for ; Fri, 03 Nov 2023 13:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041966; x=1699646766; 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; b=mMrjqKlN4HmfrYOg/hMugXWmdQSAvCcOveQxqaGd0mombWu90c84fVqdwKTyVfO1Le zobQGB2HYceuJh0jG1S7YJmyPHGDjUEPuUGw5lnn/GvBJcJ9xc3svC434uBWMaZ6JEST 5c/WrwIeEGOzXe9lnSchOW5BuZkHY2KLhlDF0bRfyyruwAXvKmpXcvm9cIdgVHCTg5Wt nlxr9tsX08Nji2ToNSaFBhBaPDnhvhbpYLZduvosnq/NZmuazgCy3JCOLwkMLxJ5Hs9H n1/bVcDwNrrJ39CpQGP54yAphzuhUcCGMEWeA6yxxqbKHlSKciTEtB0Y5coUYLiPhSXt VRNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041966; x=1699646766; 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; b=bbdmCO28Xz/UgHQtJ+SVsOnpM7Uk19vLBA6e3qGSFM47SxiItvUntVPZrvyKaDG1hD BPnoKoVOitVN19NSduVthlkni0qghR54iU2EMw4U8yBCFy+7VRaJ55zcIbOfHdPBQoHk waKtyS6ycMUsw9K4Sgl92syUccX1SE0cr4o0w4vv02J116qI4PJ/bPf6VTcfX8cTwRNy 639NBTAwTB8luPH8Ot/94hIDcj9qttEecMxxRhbCWW70cJTwMijb2DWPrRH7sNFW/9ga IQXOydDMaTQ3T8tjI+bNhqbkEOboUIl4kTshQuq1SEkBdp8WvxNgOgb8eGzYWgTPKVO9 Mf/Q== X-Gm-Message-State: AOJu0YyU8omrqaqE3KI6/xQCoeJ3sU5u7yCwC/zJIgDmQdAwKCZqhA2Y KQ+lftD30EnxrqiN581BpRpaYA== X-Received: by 2002:a5d:47a1:0:b0:32f:a6b0:d21a with SMTP id 1-20020a5d47a1000000b0032fa6b0d21amr4562007wrb.34.1699041965871; Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g10-20020a056000118a00b00326dd5486dcsm2610517wrx.107.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3F0E365753; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 23/29] plugins: Use different helpers when reading registers Date: Fri, 3 Nov 2023 19:59:50 +0000 Message-Id: <20231103195956.1998255-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki This avoids optimizations incompatible when reading registers. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-17-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/plugin-helpers.h | 3 ++- include/qemu/plugin.h | 1 + accel/tcg/plugin-gen.c | 43 ++++++++++++++++++++++++++++++++++---- plugins/api.c | 12 +++++++++-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h index 8e685e0654..11796436f3 100644 --- a/accel/tcg/plugin-helpers.h +++ b/accel/tcg/plugin-helpers.h @@ -1,4 +1,5 @@ #ifdef CONFIG_PLUGIN -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr) +DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_wg, TCG_CALL_NO_WG | TCG_CALL_PLUGIN, void, i32, ptr) +DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_rwg, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr) DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, i32, i64, ptr) #endif diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 7fdc3a4849..b0c5ac6829 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -73,6 +73,7 @@ enum plugin_dyn_cb_type { enum plugin_dyn_cb_subtype { PLUGIN_CB_REGULAR, + PLUGIN_CB_REGULAR_R, PLUGIN_CB_INLINE, PLUGIN_N_CB_SUBTYPES, }; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 78b331b251..b37ce7683e 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -79,6 +79,7 @@ enum plugin_gen_from { enum plugin_gen_cb { PLUGIN_GEN_CB_UDATA, + PLUGIN_GEN_CB_UDATA_R, PLUGIN_GEN_CB_INLINE, PLUGIN_GEN_CB_MEM, PLUGIN_GEN_ENABLE_MEM_HELPER, @@ -90,7 +91,10 @@ enum plugin_gen_cb { * These helpers are stubs that get dynamically switched out for calls * direct to the plugin if they are subscribed to. */ -void HELPER(plugin_vcpu_udata_cb)(uint32_t cpu_index, void *udata) +void HELPER(plugin_vcpu_udata_cb_no_wg)(uint32_t cpu_index, void *udata) +{ } + +void HELPER(plugin_vcpu_udata_cb_no_rwg)(uint32_t cpu_index, void *udata) { } void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, @@ -98,7 +102,7 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -static void gen_empty_udata_cb(void) +static void gen_empty_udata_cb(void (*gen_helper)(TCGv_i32, TCGv_ptr)) { TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); TCGv_ptr udata = tcg_temp_ebb_new_ptr(); @@ -106,12 +110,22 @@ static void gen_empty_udata_cb(void) tcg_gen_movi_ptr(udata, 0); tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - gen_helper_plugin_vcpu_udata_cb(cpu_index, udata); + gen_helper(cpu_index, udata); tcg_temp_free_ptr(udata); tcg_temp_free_i32(cpu_index); } +static void gen_empty_udata_cb_no_wg(void) +{ + gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_wg); +} + +static void gen_empty_udata_cb_no_rwg(void) +{ + gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_rwg); +} + /* * For now we only support addi_i64. * When we support more ops, we can generate one empty inline cb for each. @@ -192,7 +206,8 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) gen_empty_mem_helper); /* fall through */ case PLUGIN_GEN_FROM_TB: - gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb); + gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb_no_rwg); + gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); break; default: @@ -588,6 +603,12 @@ static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR], begin_op); } +static void plugin_gen_tb_udata_r(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op) +{ + inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR_R], begin_op); +} + static void plugin_gen_tb_inline(const struct qemu_plugin_tb *ptb, TCGOp *begin_op) { @@ -602,6 +623,14 @@ static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], begin_op); } +static void plugin_gen_insn_udata_r(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + + inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR_R], begin_op); +} + static void plugin_gen_insn_inline(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { @@ -721,6 +750,9 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) case PLUGIN_GEN_CB_UDATA: plugin_gen_tb_udata(plugin_tb, op); break; + case PLUGIN_GEN_CB_UDATA_R: + plugin_gen_tb_udata_r(plugin_tb, op); + break; case PLUGIN_GEN_CB_INLINE: plugin_gen_tb_inline(plugin_tb, op); break; @@ -737,6 +769,9 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) case PLUGIN_GEN_CB_UDATA: plugin_gen_insn_udata(plugin_tb, op, insn_idx); break; + case PLUGIN_GEN_CB_UDATA_R: + plugin_gen_insn_udata_r(plugin_tb, op, insn_idx); + break; case PLUGIN_GEN_CB_INLINE: plugin_gen_insn_inline(plugin_tb, op, insn_idx); break; diff --git a/plugins/api.c b/plugins/api.c index 5521b0ad36..ac39cdea0b 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -89,7 +89,11 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], + int index = flags == QEMU_PLUGIN_CB_R_REGS || + flags == QEMU_PLUGIN_CB_RW_REGS ? + PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; + + plugin_register_dyn_cb__udata(&tb->cbs[index], cb, flags, udata); } } @@ -109,7 +113,11 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void *udata) { if (!insn->mem_only) { - plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], + int index = flags == QEMU_PLUGIN_CB_R_REGS || + flags == QEMU_PLUGIN_CB_RW_REGS ? + PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; + + plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][index], cb, flags, udata); } } From patchwork Fri Nov 3 19:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740733 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12510wrr; Fri, 3 Nov 2023 13:11:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMtBZzocvQ4w19nmPNrruDAgjGkZmr3yuHP4URhNQMv8aL9bzXIemhUNTvIT8DCk9mXXFS X-Received: by 2002:a2e:bb92:0:b0:2c0:21b6:e82e with SMTP id y18-20020a2ebb92000000b002c021b6e82emr15917737lje.4.1699042266667; Fri, 03 Nov 2023 13:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042266; cv=none; d=google.com; s=arc-20160816; b=SLNcLWJHzzyxWBcG94FFNuETRbQFJtyLx+rPkw9wp1iYch22xSply2SAn1XxhehIoK HXWK1JXhmXdwp2CRjSw0dc55igHhJbs6HI5IujTpXBNEvM9/ZD1kZN04NEyDGFh7BNG8 CkbEKqphzg4H/QsR33fwW9TbNK8aKroeZt0B4NvVJFZNOaM8DSouq3m5PBXYP1lWfx2j y+XYQzrJgiNv34ZQLsYre4ruzUojYyuNtR+cQmj73kl+qBKh7mXpHxx8vC8/x9sLtPKp POpC0SesJOeQbJkX7wQETJTLy8sJeyUOW7BLhjPqsFJnfkD6c2zUjrJOOO9mEdUY2sRL ALcA== 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=3BIf7/hKITxMMftVrPZ9EbRbAEu+bIjc+oIaOv86blM=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=XkequKFR4N4lk3nKGmvrB1k/S2c3UQ0L3eMiM7/sj8PyAGWrLVOy2XSLg5LlG5iHH3 Pw/848GCVrQm9V96GPsZk3i6uh2ml9UGDVlL4j3vGTsz/bOzoSLNctW8wL3Y1UvWKaO4 Oc+zKSwX29PUq0Tan8uW1govDPVQwHvFeWsXkwZrLN0p/B58XVZ3+iAtKEfZqtCRdZSQ l0jC6zeiXtPJbEW1cfwJR/vfSSjcOXjnt+p/G1NYmYlgxwewrRFy8u11lcCowHqLLsWn 7kqcnEoZC03SBpbX4koMS3aUSEXdyuyvhEZgCPbYhqSbbsgEm2BUZCRjCygV8hW2ek8O 5dWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pPwPbWcn; 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 m25-20020a05600c3b1900b0040653ab52d0si3933078wms.26.2023.11.03.13.11.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:11:06 -0700 (PDT) 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=pPwPbWcn; 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 1qz0Qu-0003fK-28; Fri, 03 Nov 2023 16:06:20 -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 1qz0Qr-0003aq-OX for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:17 -0400 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 1qz0Qj-0006wu-Qa for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:17 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40842752c6eso18809945e9.1 for ; Fri, 03 Nov 2023 13:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041968; x=1699646768; 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=3BIf7/hKITxMMftVrPZ9EbRbAEu+bIjc+oIaOv86blM=; b=pPwPbWcnvw0533t1472Jdor7bm94M2Kp0cw5iL6ACcrl5qaI7i1lax5Tggg+w6gKyJ czkEg5wfgGX8y/J0gt8SJlxo0chnkWEFmRav+dfCJ3IhO0n+H9hMekon0pULa4ow66Zy /prhg2ueN2oYCQNjw9OlT9vr9iZxbagiYtlyqvJXah1UqWFHm6xx3UFvaHMdiOq/bEwz 7ITxUyDsm8D2DAKUSAFj6otx7ooeGryeSah4mS9i/ZOU4JTiKTfoFzG38ZemlH8Cc/dN 6i0KlmqkgxoSH2Fr4KKv9u721pGjsTI0qhyxXaTbb3axc+BOEm7oYVM3mpYrsOjNKFuB D9Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041968; x=1699646768; 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=3BIf7/hKITxMMftVrPZ9EbRbAEu+bIjc+oIaOv86blM=; b=eHFwj7ma0t506IYKqHgVhVYkOAHLx3H6w6m/nn43BOW6KHdd/QOvTNXXiOTB09j9Mg 2bS4d2mqBPUBj1y6K+fFV7D6GVEq9VlqeLmSJThAlV0f3VxzbYV3LSVU5VdlKtjFnWkt uxuNWPysGOgw/Eh4KaohhBo+qk5bl0pqQMWX13/p5z6THHzAhd5d8+1efRQt75byvmks O8uwE3IZ+7SbKVdASve22IJEcMpF7DAy3KzMeL06QnAMk2VDEcOv6BtN7pMpTqDLMeHd nmixfeagNWhRXcUTnJywGVSvg8UWhdLl0p167pOgoPwj8vmvF7psJDsmWxKKf9Ld0k56 L6RQ== X-Gm-Message-State: AOJu0Yx/tQyjgTLsvkkbd2qH+N0cSjJaWIfCgIGvFEUDCFwijqyzS5Dv EUXcMMcbo3JWB3OXzm0lVp5AFA== X-Received: by 2002:a05:600c:4449:b0:408:4120:bab7 with SMTP id v9-20020a05600c444900b004084120bab7mr19208320wmn.15.1699041968020; Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r18-20020a05600c35d200b00401e32b25adsm3573036wmq.4.2023.11.03.13.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5904F65754; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 24/29] plugins: add an API to read registers Date: Fri, 3 Nov 2023 19:59:51 +0000 Message-Id: <20231103195956.1998255-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We can only request a list of registers once the vCPU has been initialised so the user needs to use either call the find function on vCPU initialisation or during the translation phase. We don't expose the reg number to the plugin instead hiding it behind an opaque handle. This allows for a bit of future proofing should the internals need to be changed while also being hashed against the CPUClass so we can handle different register sets per-vCPU in hetrogenous situations. Having an internal state within the plugins also allows us to expand the interface in future (for example providing callbacks on register change if the translator can track changes). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1706 Cc: Akihiko Odaki Based-on: <20231025093128.33116-18-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- vAJB: The main difference to Akikio's version is hiding the gdb register detail from the plugin for the reasons described above. --- include/qemu/qemu-plugin.h | 52 +++++++++++++++++- plugins/api.c | 102 +++++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 + 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 50a9957279..e5c16df5ca 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -11,6 +11,7 @@ #ifndef QEMU_QEMU_PLUGIN_H #define QEMU_QEMU_PLUGIN_H +#include #include #include #include @@ -218,8 +219,8 @@ struct qemu_plugin_insn; * @QEMU_PLUGIN_CB_R_REGS: callback reads the CPU's regs * @QEMU_PLUGIN_CB_RW_REGS: callback reads and writes the CPU's regs * - * Note: currently unused, plugins cannot read or change system - * register state. + * Note: currently QEMU_PLUGIN_CB_RW_REGS is unused, plugins cannot change + * system register state. */ enum qemu_plugin_cb_flags { QEMU_PLUGIN_CB_NO_REGS, @@ -664,4 +665,51 @@ uint64_t qemu_plugin_end_code(void); */ uint64_t qemu_plugin_entry_code(void); +/** struct qemu_plugin_register - Opaque handle for a translated instruction */ +struct qemu_plugin_register; + +/** + * typedef qemu_plugin_reg_descriptor - register descriptions + * + * @name: register name + * @handle: opaque handle for retrieving value with qemu_plugin_read_register + * @feature: optional feature descriptor, can be NULL + */ +typedef struct { + char name[32]; + struct qemu_plugin_register *handle; + const char *feature; +} qemu_plugin_reg_descriptor; + +/** + * qemu_plugin_find_registers() - return register list + * @vcpu_index: vcpu to query + * @reg_pattern: register name pattern + * + * Returns a GArray of qemu_plugin_reg_descriptor or NULL. Caller + * frees. As the register set of a given vCPU is only available once + * the vCPU is initialised if you want to monitor registers from the + * start you should call this from a qemu_plugin_register_vcpu_init_cb() + * callback. + */ +GArray * qemu_plugin_find_registers(unsigned int vcpu_index, const char *reg_pattern); + +/** + * qemu_plugin_read_register() - read register + * + * @vcpu: vcpu index + * @handle: a @qemu_plugin_reg_handle handle + * @buf: A GByteArray for the data owned by the plugin + * + * This function is only available in a context that register read access is + * explicitly requested. + * + * Returns the size of the read register. The content of @buf is in target byte + * order. On failure returns -1 + */ +int qemu_plugin_read_register(unsigned int vcpu, + struct qemu_plugin_register *handle, + GByteArray *buf); + + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index ac39cdea0b..2644af5bb3 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -8,6 +8,7 @@ * * qemu_plugin_tb * qemu_plugin_insn + * qemu_plugin_register * * Which can then be passed back into the API to do additional things. * As such all the public functions in here are exported in @@ -35,10 +36,12 @@ */ #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "qemu/plugin.h" #include "qemu/log.h" #include "tcg/tcg.h" #include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "exec/ram_addr.h" #include "disas/disas.h" #include "plugin.h" @@ -435,3 +438,102 @@ uint64_t qemu_plugin_entry_code(void) #endif return entry; } + +/* + * Register handles + * + * The plugin infrastructure keeps hold of these internal data + * structures which are presented to plugins as opaque handles. They + * are global to the system and therefor additions to the hash table + * must be protected by the @reg_handle_lock. + * + * In order to future proof for up-coming heterogeneous work we want + * different entries for each CPU type while sharing them in the + * common case of multiple cores of the same type. + */ + +static QemuMutex reg_handle_lock; + +struct qemu_plugin_register { + const char *name; + int gdb_reg_num; +}; + +static GHashTable *reg_handles; /* hash table of PluginReg */ + +/* Generate a stable key - would xxhash be overkill? */ +static gpointer cpu_plus_reg_to_key(CPUState *cs, int gdb_regnum) +{ + uintptr_t key = (uintptr_t) cs->cc; + key ^= gdb_regnum; + return GUINT_TO_POINTER(key); +} + +/* + * Create register handles. + * + * We need to create a handle for each register so the plugin + * infrastructure can call gdbstub to read a register. We also + * construct a result array with those handles and some ancillary data + * the plugin might find useful. + */ + +static GArray * create_register_handles(CPUState *cs, GArray *gdbstub_regs) { + GArray *find_data = g_array_new(true, true, sizeof(qemu_plugin_reg_descriptor)); + + WITH_QEMU_LOCK_GUARD(®_handle_lock) { + + if (!reg_handles) { + reg_handles = g_hash_table_new(g_direct_hash, g_direct_equal); + } + + for (int i=0; i < gdbstub_regs->len; i++) { + GDBRegDesc *grd = &g_array_index(gdbstub_regs, GDBRegDesc, i); + gpointer key = cpu_plus_reg_to_key(cs, grd->gdb_reg); + struct qemu_plugin_register *val = g_hash_table_lookup(reg_handles, key); + + /* Doesn't exist, create one */ + if (!val) { + val = g_new0(struct qemu_plugin_register, 1); + val->gdb_reg_num = grd->gdb_reg; + val->name = grd->name; + + g_hash_table_insert(reg_handles, key, val); + } + + /* Create a record for the plugin */ + qemu_plugin_reg_descriptor desc = { + .handle = val, + .feature = g_intern_string(grd->feature_name) + }; + g_strlcpy(desc.name, val->name, sizeof(desc.name)); + g_array_append_val(find_data, desc); + } + } + + return find_data; +} + +GArray * qemu_plugin_find_registers(unsigned int vcpu, const char *reg_pattern) +{ + CPUState *cs = qemu_get_cpu(vcpu); + if (cs) { + g_autoptr(GArray) regs = gdb_find_registers(cs, reg_pattern); + return regs->len ? create_register_handles(cs, regs) : NULL; + } else { + return NULL; + } +} + +int qemu_plugin_read_register(unsigned int vcpu, struct qemu_plugin_register *reg, GByteArray *buf) +{ + CPUState *cs = qemu_get_cpu(vcpu); + /* assert with debugging on? */ + return gdb_read_register(cs, buf, reg->gdb_reg_num); +} + +static void __attribute__((__constructor__)) qemu_api_init(void) +{ + qemu_mutex_init(®_handle_lock); + +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 71f6c90549..86928f5f50 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -42,4 +42,6 @@ qemu_plugin_tb_vaddr; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; + qemu_plugin_find_registers; + qemu_plugin_read_register; }; From patchwork Fri Nov 3 19:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740716 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp9507wrr; Fri, 3 Nov 2023 13:04:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/rS4i/egzzNIIU6yyzlbtYJ6u+ThRfsxmeRn/+zOW9LHRRUvmXeavmbvsP0jtKOjzsTwB X-Received: by 2002:a05:620a:674a:b0:76e:601d:a724 with SMTP id rq10-20020a05620a674a00b0076e601da724mr18768463qkn.34.1699041887161; Fri, 03 Nov 2023 13:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041887; cv=none; d=google.com; s=arc-20160816; b=Yp6oYKFXv0IS9OkZN+AIfk3OCNw68h+fdh4AprqiHodxUgtoOGw6jndwu9ZrOPEuAu taoq1nYTFU2iJBeWxR2+nhCcF2Wg55fRk+ree/fYA4JXHd/VjvfavOgqRLTJZZb4us1U zxHAkWREMyscy1Y6+yxiZx2Jig8gvzlay0Mj3cp1xaXdAXhRjPrO9cFskhjpci+jQLaa r+QThhXCG6tvvSuzcUjdzsHqkzgeh2BfKx+zLnhzQMo5p0tsUrp5giggc/YOmURXbK7x mXcH91m+j3mV1W8yGhnDanlThH48Po9Uu5Xf2shs6zRKxtG+eBLw24bzf6RrsJygQEhj c09A== 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=PVEcbCgEIMwIBIpaItr8CFnS0M+G6ZN1ZJ9VQLzARs0=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=X1s2Qp2hAZmiOeIUPzzZmOwnKXF1LxPqJnAdwZP0h6i+wDRywpbEyypvuhAPITE6Ij H1AEAoz0WnFcpVsF3Rm07K57AkBs1n19thwbdXZtF9tZ4UPkQmVM06uRMVv9JgBcWo2w +0s7+l5Q3N+0qKI6xnfxWjQ3C16hl6CYIhMdDncC40hNGXlBlQc/0g1Iw8n05FJAjRvS 2yBwZ0h9FM9QcOOaIueTqhyXJ1Jk0gdI6UYMkubXsQs3+p7so401cPMeCxWf4+oDtoAP +VKmAiCuJ/HUjeaVlAlxwHf3v00pRqK9P1YSi4knqFs/JMHu+RjBT1n7Oo9jVvoj3sQh 5Hhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RWf946nO; 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 x11-20020a05620a258b00b00773fb21ee2bsi2178538qko.105.2023.11.03.13.04.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:04:47 -0700 (PDT) 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=RWf946nO; 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 1qz0Mc-0001QX-HI; Fri, 03 Nov 2023 16:01:54 -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 1qz0LI-0008L5-TO for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:33 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0L4-0005e7-AP for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:32 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c594196344so33120101fa.3 for ; Fri, 03 Nov 2023 13:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041613; x=1699646413; 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=PVEcbCgEIMwIBIpaItr8CFnS0M+G6ZN1ZJ9VQLzARs0=; b=RWf946nO+pIZP6hmsS/5ZFCG6pyeEZrtoDLc+/1Hd9swRLEB65pfh0619m6JX6eAPu AzrfbbQqlheYSMLtKHVpbNv50lCFZ9kjTTSrDNH8f9hCRezZ8xZg9QO2GFAtnIuJltBh B7p1MLhKzoqj9UgMV24Nw1ZHslA1I73uxPVI+NbGpPh2htVkReeoPXOdTbovQJUL5ynf Fy/lZwwrmrfp9+CPMgelMccCl4L1PLJdLhX/IVwM56nUnjwiOENEdrz2mMLJg8YLvTou 547im3nMbJaDR6JIQemPPUkaARhCD6aW99FVqU4kZqFUmIIKeV+MvUh8BrexDiW6/OWE VbhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041613; x=1699646413; 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=PVEcbCgEIMwIBIpaItr8CFnS0M+G6ZN1ZJ9VQLzARs0=; b=bCULf7Epjta8VWCAu6a9DvrUYWHUlN3PiojVca5dfDtN6WPZIhszEGtlMLBNLGuBpi wwUln78LxrPhYLrQgPK/28dbwNJS0pqUvsD/Ay6zihKqS4LqoD7zgiqdtPr2chMhyEUX TId74A+yrBWsqle1kaeGk4bAWuwQKLnSgOnFTPwXGZQ+dUTc5jkbNEsvjdEEQRmbEPOY mGfhdYXSlYV/OHsmdI4JkMiWQGPZgQRF66eV6TuzYvmxtuq3TVkGYtbtmBKc443F7XAj 0Q364pSCnN+Xg6UP5fzf34sXHZRXxywGy4ikso4v73Ylzi0Fzx3LAK1gq9vlhxeYwEZK GJaw== X-Gm-Message-State: AOJu0Yx9RtAiYUM2PDdr2fToTbfOY7tFPpTT/NQQr1HYeCuEU4cY1pbv MAM7bK8LE0V97SBGZ4BhZ+uc3w== X-Received: by 2002:a2e:b4ab:0:b0:2c5:128c:fae7 with SMTP id q11-20020a2eb4ab000000b002c5128cfae7mr17357618ljm.38.1699041612721; Fri, 03 Nov 2023 13:00:12 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id v6-20020a05600c444600b0040651505684sm3549344wmn.29.2023.11.03.13.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 722EA65755; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 25/29] contrib/plugins: extend execlog to track register changes Date: Fri, 3 Nov 2023 19:59:52 +0000 Message-Id: <20231103195956.1998255-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x233.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org With the new plugin register API we can now track changes to register values. Currently the implementation is fairly dumb which will slow down if a large number of register values are being tracked. This could be improved by only instrumenting instructions which mention registers we are interested in tracking. Example usage: ./qemu-aarch64 -D plugin.log -d plugin \ -cpu max,sve256=on \ -plugin contrib/plugins/libexeclog.so,reg=sp,reg=z\* \ ./tests/tcg/aarch64-linux-user/sha512-sve will display in the execlog any changes to the stack pointer (sp) and the SVE Z registers. Cc: Akihiko Odaki Based-On: <20231025093128.33116-19-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- vAJB: Changes for the new API with a simpler glob based "reg" specifier which can be specified multiple times. --- docs/devel/tcg-plugins.rst | 10 ++- contrib/plugins/execlog.c | 180 ++++++++++++++++++++++++++++--------- 2 files changed, 145 insertions(+), 45 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 81dcd43a61..c9f8b27590 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -497,6 +497,15 @@ arguments if required:: $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so,ifilter=st1w,afilter=0x40001808 -d plugin +This plugin can also dump a specified register. The specification of register +follows `GDB standard target features `__. + +Specify the name of the feature that contains the register and the name of the +register with ``rfile`` and ``reg`` options, respectively:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libexeclog.so,rfile=org.gnu.gdb.arm.core,reg=sp -d plugin + - contrib/plugins/cache.c Cache modelling plugin that measures the performance of a given L1 cache @@ -583,4 +592,3 @@ The following API is generated from the inline documentation in include the full kernel-doc annotations. .. kernel-doc:: include/qemu/qemu-plugin.h - diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 82dc2f584e..dcee04fc37 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2021, Alexandre Iooss * - * Log instruction execution with memory access. + * Log instruction execution with memory access and register changes * * License: GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -15,30 +15,29 @@ #include +typedef struct { + struct qemu_plugin_register *handle; + GByteArray *last; + GByteArray *new; + const char *name; +} Register; + +typedef struct CPU { + /* Store last executed instruction on each vCPU as a GString */ + GString *last_exec; + /* Ptr array of Register */ + GPtrArray *registers; +} CPU; + QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -/* Store last executed instruction on each vCPU as a GString */ -static GPtrArray *last_exec; +static CPU *cpus; +static int num_cpus; static GRWLock expand_array_lock; static GPtrArray *imatches; static GArray *amatches; - -/* - * Expand last_exec array. - * - * As we could have multiple threads trying to do this we need to - * serialise the expansion under a lock. - */ -static void expand_last_exec(int cpu_index) -{ - g_rw_lock_writer_lock(&expand_array_lock); - while (cpu_index >= last_exec->len) { - GString *s = g_string_new(NULL); - g_ptr_array_add(last_exec, s); - } - g_rw_lock_writer_unlock(&expand_array_lock); -} +static GPtrArray *rmatches; /** * Add memory read or write information to current instruction log @@ -50,8 +49,8 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info, /* Find vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - g_assert(cpu_index < last_exec->len); - s = g_ptr_array_index(last_exec, cpu_index); + g_assert(cpu_index < num_cpus); + s = cpus[cpu_index].last_exec; g_rw_lock_reader_unlock(&expand_array_lock); /* Indicate type of memory access */ @@ -77,28 +76,46 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info, */ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { - GString *s; + CPU *cpu; - /* Find or create vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - if (cpu_index >= last_exec->len) { - g_rw_lock_reader_unlock(&expand_array_lock); - expand_last_exec(cpu_index); - g_rw_lock_reader_lock(&expand_array_lock); - } - s = g_ptr_array_index(last_exec, cpu_index); + g_assert(cpu_index < num_cpus); + cpu = &cpus[cpu_index]; g_rw_lock_reader_unlock(&expand_array_lock); /* Print previous instruction in cache */ - if (s->len) { - qemu_plugin_outs(s->str); + if (cpus->last_exec->len) { + if (cpus->registers) { + for (int n = 0; n < cpu->registers->len; n++) { + Register *reg = cpu->registers->pdata[n]; + int sz; + + g_byte_array_set_size(reg->new, 0); + sz = qemu_plugin_read_register(cpu_index, reg->handle, reg->new); + g_assert(sz == reg->last->len); + + if (memcmp(reg->last->data, reg->new->data, sz)) { + GByteArray *temp = reg->last; + g_string_append_printf(cpu->last_exec, ", %s -> ", reg->name); + /* TODO: handle BE properly */ + for (int i = sz; i >= 0; i--) { + g_string_append_printf(cpu->last_exec, "%02x", + reg->new->data[i]); + } + reg->last = reg->new; + reg->new = temp; + } + } + } + + qemu_plugin_outs(cpus[cpu_index].last_exec->str); qemu_plugin_outs("\n"); } /* Store new instruction in cache */ /* vcpu_mem will add memory access information to last_exec */ - g_string_printf(s, "%u, ", cpu_index); - g_string_append(s, (char *)udata); + g_string_printf(cpus[cpu_index].last_exec, "%u, ", cpu_index); + g_string_append(cpus[cpu_index].last_exec, (char *)udata); } /** @@ -167,8 +184,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) QEMU_PLUGIN_MEM_RW, NULL); /* Register callback on instruction */ - qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, - QEMU_PLUGIN_CB_NO_REGS, output); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, + rmatches ? QEMU_PLUGIN_CB_R_REGS : QEMU_PLUGIN_CB_NO_REGS, + output); /* reset skip */ skip = (imatches || amatches); @@ -177,17 +196,77 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } +static Register *init_vcpu_register(int vcpu_index, + qemu_plugin_reg_descriptor *desc) +{ + Register *reg = g_new0(Register, 1); + int r; + + reg->handle = desc->handle; + reg->name = g_strdup(desc->name); + reg->last = g_byte_array_new(); + reg->new = g_byte_array_new(); + + /* read the initial value */ + r = qemu_plugin_read_register(vcpu_index, reg->handle, reg->last); + g_assert(r > 0); + return reg; +} + +/* + * Initialise a new vcpu/thread with: + * - last_exec tracking data + * - list of tracked registers + * - initial value of registers + * + * As we could have multiple threads trying to do this we need to + * serialise the expansion under a lock. + */ +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + g_rw_lock_writer_lock(&expand_array_lock); + + if (vcpu_index >= num_cpus) { + cpus = g_realloc_n(cpus, vcpu_index + 1, sizeof(*cpus)); + while (vcpu_index >= num_cpus) { + cpus[num_cpus].last_exec = g_string_new(NULL); + + /* Any registers to track? */ + if (rmatches && rmatches->len) { + GPtrArray *registers = g_ptr_array_new(); + + /* For each pattern add the register definitions */ + for (int p = 0; p < rmatches->len; p++) { + g_autoptr(GArray) reg_list = + qemu_plugin_find_registers(vcpu_index, rmatches->pdata[p]); + if (reg_list && reg_list->len) { + for (int r = 0; r < reg_list->len; r++) { + Register *reg = + init_vcpu_register(vcpu_index, + &g_array_index(reg_list, + qemu_plugin_reg_descriptor, r)); + g_ptr_array_add(registers, reg); + } + } + } + cpus[num_cpus].registers = registers; + } + num_cpus++; + } + } + + g_rw_lock_writer_unlock(&expand_array_lock); +} + /** * On plugin exit, print last instruction in cache */ static void plugin_exit(qemu_plugin_id_t id, void *p) { guint i; - GString *s; - for (i = 0; i < last_exec->len; i++) { - s = g_ptr_array_index(last_exec, i); - if (s->str) { - qemu_plugin_outs(s->str); + for (i = 0; i < num_cpus; i++) { + if (cpus[i].last_exec->str) { + qemu_plugin_outs(cpus[i].last_exec->str); qemu_plugin_outs("\n"); } } @@ -212,6 +291,18 @@ static void parse_vaddr_match(char *match) g_array_append_val(amatches, v); } +/* + * We have to wait until vCPUs are started before we can check the + * patterns find anything. + */ +static void add_regpat(char *regpat) +{ + if (!rmatches) { + rmatches = g_ptr_array_new(); + } + g_ptr_array_add(rmatches, g_strdup(regpat)); +} + /** * Install the plugin */ @@ -224,9 +315,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, * we don't know the size before emulation. */ if (info->system_emulation) { - last_exec = g_ptr_array_sized_new(info->system.max_vcpus); - } else { - last_exec = g_ptr_array_new(); + cpus = g_new(CPU, info->system.max_vcpus); } for (int i = 0; i < argc; i++) { @@ -236,13 +325,16 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, parse_insn_match(tokens[1]); } else if (g_strcmp0(tokens[0], "afilter") == 0) { parse_vaddr_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "reg") == 0) { + add_regpat(tokens[1]); } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; } } - /* Register translation block and exit callbacks */ + /* Register init, translation block and exit callbacks */ + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); From patchwork Fri Nov 3 19:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740721 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp10466wrr; Fri, 3 Nov 2023 13:06:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSm05rMasYMIL3cPN6WLD62xm5CNTd5lZrU3zpJTQytJS18lCu5Wzbd+Lkv5fKDKvSx5rF X-Received: by 2002:a05:6808:2981:b0:3ad:fc0f:e852 with SMTP id ex1-20020a056808298100b003adfc0fe852mr23092479oib.23.1699041998022; Fri, 03 Nov 2023 13:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041997; cv=none; d=google.com; s=arc-20160816; b=Y7T1D2XEt5aivMFFfNi2DmCgvJjLc19q/VIA2bLqB2eFHPJYzdePKbYnvOegbjwYIz aXNHbaPKNMQOqeIjdsLVdkooE1Y1TQ3nJntfOTT4UKmrtnBnXuCiFKjSSU36ImKE9LKb PGlxP/L4Yk2TEaLWT2Wn7rTfhXhuJ7DB71t5Jla5VyAWF9faMm2c8/oRdIp1QURgKepj ZV4pTmggqcQsfcFtguLleTyKlR2ScwVFFKZb1TR1mDHG+RTnmJeg7OOxlvg8KFbSzWcw +d1RiN5cAsJN/DUaDsX1LowoDcibbrnFG4Y070LVOGeJ3qxPDcN0ZIxd2I6r/KqXWEfX z6Ug== 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=M3324MOZMoTl1SA1uX2cxDUy5LOgCifBBJDCwAPB5tE=; fh=gFOgPAQjalZwnoCIeS1biZSYMEsJIg8psB+5knxslb0=; b=1CKBhpLTawuBAf8RhceU4cPb4+WIBZ6Gh39zU4+fhRv9j/4Oe8UPqfzR2LXVhXb2aK S6QpszGBklZznzogEu/LB0DusXkeOJoy3Ch7XHda5tLZWLvXt3EbovgejpjdGcafFV7q nq5q98npbcR6RW3RsSSjg1M0E6lYqlYcOSf8Z5x4KLGo9SJf+9/HhuQNkjmbzs4ZwzvL hndCblywnexBYhy7MX8PFEVeEbgivIJUQUy1ycIMwtKu0MvuTtyM7zINQPrmF3jpL9CJ u54X2p65YQI+x3P9FoZkinL52WC9apZjSx23dpyymSVY1Z+MSqrud2McMir8tDiHxYFP bUDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EgbqyInq; 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 bs35-20020a05620a472300b0077417e7fd27si2146003qkb.290.2023.11.03.13.06.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:06:37 -0700 (PDT) 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=EgbqyInq; 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 1qz0Mg-0001ui-6i; Fri, 03 Nov 2023 16:01:58 -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 1qz0LP-0008Ro-Lo for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:43 -0400 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 1qz0L6-0005eI-8o for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:37 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40907b82ab9so21022895e9.1 for ; Fri, 03 Nov 2023 13:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041613; x=1699646413; 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=M3324MOZMoTl1SA1uX2cxDUy5LOgCifBBJDCwAPB5tE=; b=EgbqyInq7zK/l9wBVKoLG8RU2uMntk449kiZ3LpEwgA8pDhtENZN3cCAfUfBDgieT+ 79VP+KUTjpDxuPeEOzVWVemYld95ujtviOKT0jUa138kcPHEdoBfg4ibLPu02Ti/Vyqy MK+2yPUqcIRjSejseUxolegRYb6f6GBVPPNS3YK8/cAGytg45N+ZR/yPtIt+EntoSG9s +aJgihT73UC+nAY6zSyRgvYbvf2hLWLj3FaGz06FdEdzfTop1fkA6jfgkQnBQv25YkI1 oh3Xar46OffFWZ30dM2lSTBKXUjnQlr/hUffqJ1BoMn1VXrkJuZb/gGyx8Gb0acgVtQ/ 9r3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041613; x=1699646413; 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=M3324MOZMoTl1SA1uX2cxDUy5LOgCifBBJDCwAPB5tE=; b=Hf9OzgjPn2qzWqmXFGqzuLh+Fs5xf+idjUS+AweWzfIuYeAbXFgEYg7wsX9uxSxjKl LrWbNBSj93rf7nHNvYav1iE8v6eNwZNqEOC+0djym98gDR+aFxChhsTTIK17dXvDwYNy /L8GVFTWSgb5JBjX9uRq5HwsYzLlylZh3rslBs/0SwhAKTdwJ4Z1xXVLo9YNzdDItK6J UtBuSpskZkFlgHOMvgxOSoLPK5XjkFAZCOFJiTplkhVwIoCOQ/0Tw/4dpW7ik9VuTcoO 3VgRepMfyiPmMT/PbTje5C8TphpEe0H/xFbxRsk/tI6Kk8iwAftowE1UdqC6iUtZGKHo AcDw== X-Gm-Message-State: AOJu0Yw51qEPi+Z/ixX3rdb6fqdwLnRCyfhHeaApZBiGZkFnUzrUVA1W dHxkU3QV7IzJv5+qZ7TI5YAj9g== X-Received: by 2002:a05:600c:5488:b0:408:3634:b81e with SMTP id iv8-20020a05600c548800b004083634b81emr4756968wmb.13.1699041612983; Fri, 03 Nov 2023 13:00:12 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l41-20020a05600c1d2900b004083a105f27sm3551821wms.26.2023.11.03.13.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8AEC765756; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Greg Manning Subject: [PATCH 26/29] plugins: add dllexport and dllimport to api funcs Date: Fri, 3 Nov 2023 19:59:53 +0000 Message-Id: <20231103195956.1998255-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Greg Manning In qemu-plugin.h, mark all API functions as __declspec(dllexport) when compiling the executables, and as __declspec(dllimport) when being used to compile plugins against. Signed-off-by: Greg Manning Reviewed-by: Alex Bennée Message-Id: <20231102172053.17692-2-gmanning@rapitasystems.com> Signed-off-by: Alex Bennée --- include/qemu/qemu-plugin.h | 52 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index e5c16df5ca..785315c06d 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -23,15 +23,18 @@ * https://gcc.gnu.org/wiki/Visibility */ #if defined _WIN32 || defined __CYGWIN__ - #ifdef BUILDING_DLL - #define QEMU_PLUGIN_EXPORT __declspec(dllexport) - #else + #ifdef CONFIG_PLUGIN #define QEMU_PLUGIN_EXPORT __declspec(dllimport) + #define QEMU_PLUGIN_API __declspec(dllexport) + #else + #define QEMU_PLUGIN_EXPORT __declspec(dllexport) + #define QEMU_PLUGIN_API __declspec(dllimport) #endif #define QEMU_PLUGIN_LOCAL #else #define QEMU_PLUGIN_EXPORT __attribute__((visibility("default"))) #define QEMU_PLUGIN_LOCAL __attribute__((visibility("hidden"))) + #define QEMU_PLUGIN_API #endif /** @@ -148,6 +151,7 @@ typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index, * * Note: Calling this function from qemu_plugin_install() is a bug. */ +QEMU_PLUGIN_API void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); /** @@ -161,6 +165,7 @@ void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); * Plugins are reset asynchronously, and therefore the given plugin receives * callbacks until @cb is called. */ +QEMU_PLUGIN_API void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); /** @@ -172,6 +177,7 @@ void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); * * See also: qemu_plugin_register_vcpu_exit_cb() */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); @@ -184,6 +190,7 @@ void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, * * See also: qemu_plugin_register_vcpu_init_cb() */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); @@ -194,6 +201,7 @@ void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, * * The @cb function is called every time a vCPU idles. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); @@ -204,6 +212,7 @@ void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, * * The @cb function is called every time a vCPU resumes execution. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); @@ -254,6 +263,7 @@ typedef void (*qemu_plugin_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, * callbacks to be triggered when the block or individual instruction * executes. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t cb); @@ -266,6 +276,7 @@ void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, * * The @cb function is called every time a translated unit executes. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -297,6 +308,7 @@ enum qemu_plugin_op { * Note: ops are not atomic so in multi-threaded/multi-smp situations * you will get inexact results. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); @@ -310,6 +322,7 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, * * The @cb function is called every time an instruction is executed */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -325,6 +338,7 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, * Insert an inline op to every time an instruction executes. Useful * if you just want to increment a single counter somewhere in memory. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); @@ -335,6 +349,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, * * Returns: number of instructions in this block */ +QEMU_PLUGIN_API size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb); /** @@ -343,6 +358,7 @@ size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb); * * Returns: virtual address of block start */ +QEMU_PLUGIN_API uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); /** @@ -356,6 +372,7 @@ uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); * * Returns: opaque handle to instruction */ +QEMU_PLUGIN_API struct qemu_plugin_insn * qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); @@ -369,6 +386,7 @@ qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); * Returns: pointer to a stream of bytes containing the value of this * instructions opcode. */ +QEMU_PLUGIN_API const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn); /** @@ -377,6 +395,7 @@ const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn); * * Returns: size of instruction in bytes */ +QEMU_PLUGIN_API size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn); /** @@ -385,6 +404,7 @@ size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn); * * Returns: virtual address of instruction */ +QEMU_PLUGIN_API uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn); /** @@ -393,6 +413,7 @@ uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn); * * Returns: hardware (physical) target address of instruction */ +QEMU_PLUGIN_API void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn); /** @@ -411,6 +432,7 @@ struct qemu_plugin_hwaddr; * * Returns: size of access in ^2 (0=byte, 1=16bit, 2=32bit etc...) */ +QEMU_PLUGIN_API unsigned int qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info); /** * qemu_plugin_mem_is_sign_extended() - was the access sign extended @@ -418,6 +440,7 @@ unsigned int qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info); * * Returns: true if it was, otherwise false */ +QEMU_PLUGIN_API bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info); /** * qemu_plugin_mem_is_big_endian() - was the access big endian @@ -425,6 +448,7 @@ bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info); * * Returns: true if it was, otherwise false */ +QEMU_PLUGIN_API bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); /** * qemu_plugin_mem_is_store() - was the access a store @@ -432,6 +456,7 @@ bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); * * Returns: true if it was, otherwise false */ +QEMU_PLUGIN_API bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); /** @@ -447,6 +472,7 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); * information about the handle should be recovered before the * callback returns. */ +QEMU_PLUGIN_API struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, uint64_t vaddr); @@ -463,6 +489,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, * Returns true if the handle's memory operation is to memory-mapped IO, or * false if it is to RAM */ +QEMU_PLUGIN_API bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr); /** @@ -474,12 +501,14 @@ bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr); * Note that the returned physical address may not be unique if you are dealing * with multiple address spaces. */ +QEMU_PLUGIN_API uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr); /* * Returns a string representing the device. The string is valid for * the lifetime of the plugin. */ +QEMU_PLUGIN_API const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h); /** @@ -514,6 +543,7 @@ typedef void (*qemu_plugin_vcpu_mem_cb_t) (unsigned int vcpu_index, * callback so the plugin is responsible for ensuring it doesn't get * confused by making appropriate use of locking if required. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_mem_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -532,6 +562,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, * instruction. This provides for a lightweight but not thread-safe * way of counting the number of operations done. */ +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, void *ptr, @@ -545,6 +576,7 @@ typedef void uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8); +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_cb_t cb); @@ -552,6 +584,7 @@ typedef void (*qemu_plugin_vcpu_syscall_ret_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_idx, int64_t num, int64_t ret); +QEMU_PLUGIN_API void qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_ret_cb_t cb); @@ -564,6 +597,7 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, * Returns an allocated string containing the disassembly */ +QEMU_PLUGIN_API char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn); /** @@ -573,6 +607,7 @@ char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn); * Return a static string referring to the symbol. This is dependent * on the binary QEMU is running having provided a symbol table. */ +QEMU_PLUGIN_API const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn); /** @@ -584,9 +619,11 @@ const char *qemu_plugin_insn_symbol(const struct qemu_plugin_insn *insn); * * See also: qemu_plugin_register_vcpu_init_cb() */ +QEMU_PLUGIN_API void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); +QEMU_PLUGIN_API void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); @@ -603,6 +640,7 @@ void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, * In user-mode it is possible a few un-instrumented instructions from * child threads may run before the host kernel reaps the threads. */ +QEMU_PLUGIN_API void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *userdata); @@ -616,6 +654,7 @@ int qemu_plugin_n_max_vcpus(void); * qemu_plugin_outs() - output string via QEMU's logging system * @string: a string */ +QEMU_PLUGIN_API void qemu_plugin_outs(const char *string); /** @@ -629,6 +668,7 @@ void qemu_plugin_outs(const char *string); * returns true if the combination @name=@val parses correctly to a boolean * argument, and false otherwise */ +QEMU_PLUGIN_API bool qemu_plugin_bool_parse(const char *name, const char *val, bool *ret); /** @@ -639,6 +679,7 @@ bool qemu_plugin_bool_parse(const char *name, const char *val, bool *ret); * return NULL. The user should g_free() the string once no longer * needed. */ +QEMU_PLUGIN_API const char *qemu_plugin_path_to_binary(void); /** @@ -647,6 +688,7 @@ const char *qemu_plugin_path_to_binary(void); * Returns the nominal start address of the main text segment in * user-mode. Currently returns 0 for system emulation. */ +QEMU_PLUGIN_API uint64_t qemu_plugin_start_code(void); /** @@ -655,6 +697,7 @@ uint64_t qemu_plugin_start_code(void); * Returns the nominal end address of the main text segment in * user-mode. Currently returns 0 for system emulation. */ +QEMU_PLUGIN_API uint64_t qemu_plugin_end_code(void); /** @@ -663,6 +706,7 @@ uint64_t qemu_plugin_end_code(void); * Returns the nominal entry address of the main text segment in * user-mode. Currently returns 0 for system emulation. */ +QEMU_PLUGIN_API uint64_t qemu_plugin_entry_code(void); /** struct qemu_plugin_register - Opaque handle for a translated instruction */ @@ -692,6 +736,7 @@ typedef struct { * start you should call this from a qemu_plugin_register_vcpu_init_cb() * callback. */ +QEMU_PLUGIN_API GArray * qemu_plugin_find_registers(unsigned int vcpu_index, const char *reg_pattern); /** @@ -707,6 +752,7 @@ GArray * qemu_plugin_find_registers(unsigned int vcpu_index, const char *reg_pat * Returns the size of the read register. The content of @buf is in target byte * order. On failure returns -1 */ +QEMU_PLUGIN_API int qemu_plugin_read_register(unsigned int vcpu, struct qemu_plugin_register *handle, GByteArray *buf); From patchwork Fri Nov 3 19:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740729 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11831wrr; Fri, 3 Nov 2023 13:09:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJEd8ncLRYoQi+r/0cdY/1DNS+gqZG5r8PYLsACO6D2DetOFMiYjbyV+/XAfa0ur99c792 X-Received: by 2002:ad4:5767:0:b0:671:188b:7367 with SMTP id r7-20020ad45767000000b00671188b7367mr19653179qvx.65.1699042176587; Fri, 03 Nov 2023 13:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042176; cv=none; d=google.com; s=arc-20160816; b=0IFW4FIyT8fr8m8NoDsCJNnqPtq7daK6ZtCGcSVsnuzJvBH/ZN5wl3YhyjTfKjqPme /FM614Z1f63IE8wdVoVge2RssA0J/K5gWVQXskp4Pqn+ai4sPHV8UnqUgDBaEuDvPMDt nyV0UJgrXfb4DZqJpZ3YExHZ8H9yLtI9LTvpuzELxUrJMCoMhkcMUkMdUy3PqXGxwMU0 05XRMeAQ+n0eK/qSNOK18/zjaPuFcl0pCAVCnobwATsrgnsRJVUIuWNN3hNImyp0KZCW 9ybyfVoWherkuCMm7wiNVMOI39Cz+KdjKTfI2EAMNeZUDRK8p8kD//3TjbSDCJz1Gk+z GEmQ== 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=irSpAQbacIjAn4tboyPxxEXP8GwQwy4xoP2FBlrokWA=; fh=gFOgPAQjalZwnoCIeS1biZSYMEsJIg8psB+5knxslb0=; b=T1GQF1kC77/OdDJdSjAOmnw32vBZh3TKhvlf2QMg4Y0evTfRuTOJd0lKxtD4osLjoL 9EuTRGx8olmlGK0haNue/TuUCM/vAvs7CcUFjTKVmK2nay8VxM/iNanEvg1pRTSEdmoV sND2KP9/Rkn8RegO5V4qirmrDCoSJZOhbFF1lrYl250cjOuj906s6IhlrNK0BkX8ykJl x0T4gtTCgYIcZrWxmgfw3oLF8HX4fqg5Dswadl1/9JFJGssx6m2HE5de46TbHxJVnHT0 G7/c5XsO6lNDuEeEkGQmefAvsWw15A4pXNQxAbet1x+MjB7Z6R1SW9V+M7YSfNEEFJy5 LZIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y2lEUSmE; 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 l8-20020ad44248000000b0066d03c88ec3si2014754qvq.236.2023.11.03.13.09.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:36 -0700 (PDT) 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=Y2lEUSmE; 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 1qz0RB-0004n3-5I; Fri, 03 Nov 2023 16:06:37 -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 1qz0R4-0004I2-MG for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:30 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qn-0006z7-2e for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:30 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32d9d8284abso1432474f8f.3 for ; Fri, 03 Nov 2023 13:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041971; x=1699646771; 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=irSpAQbacIjAn4tboyPxxEXP8GwQwy4xoP2FBlrokWA=; b=Y2lEUSmEM4Beux5P7itLTR+M5AAO9uzu5q8v81lTdPgIbxSdGgtxXThUdiwKXDDA8K 5Ca0K0VShdVPbZREfonRQxx4CQFQfKspMRf5VzByniKJYBvaoY/int8iJIw/pu1dv+N8 CMETUyzuWjRYQDXkA9U3rKNFyC5NEFrp3dNGEI78VGhUpXZUJ/iNUwzsjO5bi8kpH1Ix B9akoWN5kzSd3FLvOp2nRMqWOaLDg+i3WtILRQH37+RnwJew32oBJP0N4Kni5KVfask5 b18DgfA0pjBjpmKdXYsG47mpaItgktG0cPvGsJUc5Pr3reuijF/jHz/oGBULhj6/UrHw PPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041971; x=1699646771; 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=irSpAQbacIjAn4tboyPxxEXP8GwQwy4xoP2FBlrokWA=; b=lp7GKk8hucfUk1UbiYdPYsEdeDM4lkmp82q/uiNfRrUI4eNh5aXiAIpj9wtvW+VaEX khgf8UsCo6BbTsDmz2Z37QAF68fD3a4caqblqXv2JtOV1TyGfHWTkt/YsP9+2Kbocvv1 Nb6mYXjfZ4oFzetpcxSnImYeqA14q+w0D/8fdn0YGxH8KeHrskUZqV4XT3b4EfFJSCL2 JBtNAKKFJ/jI4/q00Ldb+ChG+bbwVZ0SoCJI4PvsRGJWag9lnl8e1DEt9he3YnBJ2xQ4 RkBRYP1UsfENJqndyX8itlx7eeFPXq152fsPgEGSoWnPYGJFvlIay/UdmY+1taZHIVd9 T8Gw== X-Gm-Message-State: AOJu0Yza/9dZKG3PH8nC2FB7jzBsM8SujwvimGXi7Q+PefELG6K1ygiA wrRF5QgPKmsCR8z0Tmi+/k92JQ== X-Received: by 2002:adf:e590:0:b0:31f:d2dc:df26 with SMTP id l16-20020adfe590000000b0031fd2dcdf26mr15669864wrm.28.1699041971325; Fri, 03 Nov 2023 13:06:11 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k12-20020adff28c000000b0032f99801273sm2613842wro.66.2023.11.03.13.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A709E65757; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Greg Manning Subject: [PATCH 27/29] plugins: make test/example plugins work on windows Date: Fri, 3 Nov 2023 19:59:54 +0000 Message-Id: <20231103195956.1998255-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Greg Manning Generate a qemu_plugin_api.lib delay import lib on windows, for windows qemu plugins to link against. Implement an example dll load fail hook to link up the API functions correctly when a plugin is loaded on windows. Update the build scripts for the test and example plugins to use these things. Signed-off-by: Greg Manning Acked-by: Alex Bennée Message-Id: <20231102172053.17692-3-gmanning@rapitasystems.com> Signed-off-by: Alex Bennée --- configure | 3 +++ contrib/plugins/win32_linker.c | 34 ++++++++++++++++++++++++++++++++++ contrib/plugins/Makefile | 20 ++++++++++++++++---- plugins/meson.build | 17 +++++++++++++++++ tests/plugin/meson.build | 14 +++++++++++--- 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 contrib/plugins/win32_linker.c diff --git a/configure b/configure index f1456f6123..04f2cdd166 100755 --- a/configure +++ b/configure @@ -1662,6 +1662,9 @@ echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config if test "$targetos" = darwin; then echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak fi +if test "$targetos" = windows; then + echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak +fi # tests/tcg configuration (config_host_mak=tests/tcg/config-host.mak diff --git a/contrib/plugins/win32_linker.c b/contrib/plugins/win32_linker.c new file mode 100644 index 0000000000..50797d616e --- /dev/null +++ b/contrib/plugins/win32_linker.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023, Greg Manning + * + * This hook, __pfnDliFailureHook2, is documented in the microsoft documentation here: + * https://learn.microsoft.com/en-us/cpp/build/reference/error-handling-and-notification + * It gets called when a delay-loaded DLL encounters various errors. + * We handle the specific case of a DLL looking for a "qemu.exe", + * and give it the running executable (regardless of what it is named). + * + * This work is licensed under the terms of the GNU LGPL, version 2 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#include +#include + +FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli); + + +PfnDliHook __pfnDliFailureHook2 = dll_failure_hook; + +FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli) { + if (dliNotify == dliFailLoadLib) { + /* If the failing request was for qemu.exe, ... */ + if (strcmp(pdli->szDll, "qemu.exe") == 0) { + /* Then pass back a pointer to the top level module. */ + HMODULE top = GetModuleHandle(NULL); + return (FARPROC) top; + } + } + /* Otherwise we can't do anything special. */ + return 0; +} + diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index 8ba78c7a32..751fa38619 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -22,7 +22,14 @@ NAMES += hwprofile NAMES += cache NAMES += drcov -SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) +ifeq ($(CONFIG_WIN32),y) +SO_SUFFIX := .dll +LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0) +else +SO_SUFFIX := .so +endif + +SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES))) # The main QEMU uses Glib extensively so it's perfectly fine to use it # in plugins (which many example do). @@ -35,15 +42,20 @@ all: $(SONAMES) %.o: %.c $(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $< -lib%.so: %.o -ifeq ($(CONFIG_DARWIN),y) +ifeq ($(CONFIG_WIN32),y) +lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/qemu_plugin_api.lib + $(CC) -shared -o $@ $^ $(LDLIBS) +else ifeq ($(CONFIG_DARWIN),y) +lib%$(SO_SUFFIX): %.o $(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS) else +lib%$(SO_SUFFIX): %.o $(CC) -shared -o $@ $^ $(LDLIBS) endif + clean: - rm -f *.o *.so *.d + rm -f *.o *$(SO_SUFFIX) *.d rm -Rf .libs .PHONY: all clean diff --git a/plugins/meson.build b/plugins/meson.build index 71ed996ed3..8ed9fa270c 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -14,6 +14,23 @@ if not enable_modules endif if get_option('plugins') + if targetos == 'windows' + # Generate a .lib file for plugins to link against. + # First, create a .def file listing all the symbols a plugin should expect to have + # available in qemu + win32_plugin_def = configure_file( + input: files('qemu-plugins.symbols'), + output: 'qemu_plugin_api.def', + capture: true, + command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + # then use dlltool to assemble a delaylib. + win32_qemu_plugin_api_lib = configure_file( + input: win32_plugin_def, + output: 'qemu_plugin_api.lib', + command: ['dlltool', '--input-def', '@INPUT@', + '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe'] + ) + endif specific_ss.add(files( 'loader.c', 'core.c', diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index 322cafcdf6..528bb9d86c 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,9 +1,17 @@ t = [] if get_option('plugins') foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] - t += shared_module(i, files(i + '.c'), - include_directories: '../../include/qemu', - dependencies: glib) + if targetos == 'windows' + t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', + include_directories: '../../include/qemu', + objects: [win32_qemu_plugin_api_lib], + dependencies: glib) + + else + t += shared_module(i, files(i + '.c'), + include_directories: '../../include/qemu', + dependencies: glib) + endif endforeach endif if t.length() > 0 From patchwork Fri Nov 3 19:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740724 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11650wrr; Fri, 3 Nov 2023 13:09:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjHq6JmP/GZjSruMeiAFzo0M560mUNShsakt+Yz5YyeC8G/o+/h07m+/6kb/kB5JMqK0iZ X-Received: by 2002:ac8:7d04:0:b0:412:2d6f:6149 with SMTP id g4-20020ac87d04000000b004122d6f6149mr5381997qtb.34.1699042149801; Fri, 03 Nov 2023 13:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042149; cv=none; d=google.com; s=arc-20160816; b=QqXShItx5jyegVatoZ888G1Gc/pHJzgaCaeKT5UzBlsIQoCGRjpek2YKulbChLZClN 6uyW0Yk/tX7lHSQAwHDw714SosuTxFnd5VMEkI6g9Q7ElmUNLMSaej+cUQ2xsocUdW6j IZSwlunZUM0aLtZDEctj2OeMVdBvkh2Ltcic6EnXLr9Xs9L65rbfAheIHM2MMgb/FeU7 NvvaPD56xWgts6EzQaWpK+W4TsLHkkmQruu2UozQvnjJ50gwEu/5TUnclp7/M/7k8r5c 3hByTZtQbQZiWxOtInED4sJyyza0I/rzPpkNI7um3xDjrnTzIeKBZ/zWSdJYi20qay9u Lb8A== 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=zPpQxgdh5VY8ZdTdWSvmFC1MKBcKGy7bnnvLXL/ucsM=; fh=gFOgPAQjalZwnoCIeS1biZSYMEsJIg8psB+5knxslb0=; b=QMza2aP4Cp0VFxR3P8Gy9gx4eWwBY4jwaVgE/+2h5MxFkFulNcfkzCgnemtpZ8d+1d DaTkUPXkZcrlAOzm8py//yPLk2Zg69bEh5O72tKUkS19a/WaBHsPdGAIMnuCjmh3xkqr rAfb76VBDmDO4bXnzixh/cktAPCR2qcaSFz/W8COj/CE+O4YvYqbVcXSx01cPuVy12wm aBhGpjoMYKSxTtD71Hz7WR0YRNEerP2r7a4Lx4MEcJGbxalaBx5yrxQe4674Lg9mALNZ xIYL9Z5kIwKbns5tRzuHkgYEbhP6mnCJI3BgDL3hFIqrKcFcbOVeKtTUAseL+sNMraWA lXgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KDnV+bJy; 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 s3-20020a05622a1a8300b00406c6e2e09csi2025452qtc.547.2023.11.03.13.09.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:09 -0700 (PDT) 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=KDnV+bJy; 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 1qz0Qv-0003gD-UL; Fri, 03 Nov 2023 16:06:22 -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 1qz0Qs-0003bs-CC for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:18 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qj-0006wt-VH for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:18 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40859c464daso18013395e9.1 for ; Fri, 03 Nov 2023 13:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041968; x=1699646768; 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=zPpQxgdh5VY8ZdTdWSvmFC1MKBcKGy7bnnvLXL/ucsM=; b=KDnV+bJy98NMeaD2/vPwIv6wBUiQnmbpfVQNDo9HSI3R0sjOADsZ8hNr7jhEA747RD UGiV/FnL58s0fDdq/Y2WMmxULLIbfL67nIjuGdu8ketbTNKiUPVBmMUo7PiNTw4pQ8m6 arMDW7jF4P1FMN16dTSYaqKB52saFNa4Gqz/9+cFDxT0pNRNTINhoDL5ScbsmrPbYJVg 90Y+YUbW6hM7WRB2vwJm93nLeLi55w38eN6pPbJh8DVx18DCkwITDEiu63nF/4Ktzufi 0X6JY0tmWOOdx9gFdcB5wc5H8h3OHEBnVFSJiI8z2dSCV0n7HCgmi1r+/bgaoE1wAlpH kIkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041968; x=1699646768; 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=zPpQxgdh5VY8ZdTdWSvmFC1MKBcKGy7bnnvLXL/ucsM=; b=GSSoDl+Stpdw3evNkz2YjxJ8cJn456Cx8u1CTAnjAOK3bmVvs/wZ+Z5P73FlJrwYJd cKHolHJJX5UY8URU/M8Tg/jv0CkNaxq41FifHD6qmw0gRT7Fr26ILheQ0jK/oxqzrVtY 8N4A+Arh6KstMYiOWn2GqpFgLXJrCtuw9OScJd8ADKdkPqTtUb9fzbSvfOBPU3W88QBY mISnsXQIMUj9FaDBrTh5GobLp20bmH0rt4KD67W5m2fzpTThCrC6l6SFAfkR3lbzZa3W 3pXcNQb5vDk69bBmz4ZReq6/zO6IZXZ5Tg3QuKvZGsDWHYvRjASilZMUAQKH/NV6jFv9 Kgpg== X-Gm-Message-State: AOJu0YxX0TR527AhVJtoTk1Ug+bwTI7T9YVCpI0C+UclUHQq08sLc5ZO rDCPWlpA6qg/zwUa8y8sDiRMVA== X-Received: by 2002:a05:600c:4445:b0:405:3251:47a1 with SMTP id v5-20020a05600c444500b00405325147a1mr17614556wmn.40.1699041968086; Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c19d100b00405c7591b09sm3572232wmq.35.2023.11.03.13.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BEB5965758; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Greg Manning Subject: [PATCH 28/29] plugins: disable lockstep plugin on windows Date: Fri, 3 Nov 2023 19:59:55 +0000 Message-Id: <20231103195956.1998255-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Greg Manning The lockstep plugin uses unix sockets and would require a different communication mechanism to work on Windows. Signed-off-by: Greg Manning Reviewed-by: Alex Bennée Message-Id: <20231102172053.17692-4-gmanning@rapitasystems.com> Signed-off-by: Alex Bennée --- contrib/plugins/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index 751fa38619..1783750cf6 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -17,7 +17,13 @@ NAMES += execlog NAMES += hotblocks NAMES += hotpages NAMES += howvec + +# The lockstep example communicates using unix sockets, +# and can't be easily made to work on windows. +ifneq ($(CONFIG_WIN32),y) NAMES += lockstep +endif + NAMES += hwprofile NAMES += cache NAMES += drcov From patchwork Fri Nov 3 19:59:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740727 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11811wrr; Fri, 3 Nov 2023 13:09:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFM4m8G/CCZ1+pqmPYjVLYfUCAOSZ8RlJFBdYHgX2mw70vQ7R3HMDqpH9D58SVe/marmFTJ X-Received: by 2002:a05:620a:269a:b0:77a:4462:1026 with SMTP id c26-20020a05620a269a00b0077a44621026mr11746901qkp.60.1699042174394; Fri, 03 Nov 2023 13:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042174; cv=none; d=google.com; s=arc-20160816; b=F4PHrlT6uN4WDcTumh9YfBe4zarA82dVX3KM7hneMUuOarRxzul2a+FhBwLR0L0aj0 H2qEmgByoQNrMMkHFbi9CYt28d1WCUo/0yuoZ1t5XqVK1GBKgIl4tL2Vbeth5ty0YoOb W90TRXxdkmqTB7VCyiCUlQlKpY+C2RVZ3rGY21URgSNjtzAiSsfJSt8Cgd0/CTL5Tn2g rja2n7edMkBRnSXbf+S/FMGYt6s968Uwxm0NAaCLB989+ivunygqagnJ/rsSxPvnO8t3 wWVe7MFpihQW8uonpT56EjiVDSrAl7jb7sMOOHVQOR/p9PSTDs/nnn91AhxqQatCT4BY Ksmg== 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=BM/WoalBWQwPuHSNHPl39Pw79pHu/OHGkHed2Wz/1M0=; fh=gFOgPAQjalZwnoCIeS1biZSYMEsJIg8psB+5knxslb0=; b=AIO+IQ25taujbKz37cXwsXom/m5Yn3bQZaR9vgFOM2dYaJv3g3FEJWULWFdWOF0V6v RxCuL5Deyf1wHbHdMocFKlHz/SXHPiip5FFgh1hpPGgyg0gHAynMX2eire2bMerRxvM0 4nDSiJeJ+Xr4g9oJ6x9PBR14y0gCOM7mBVC81XDxHiHTJr5UNzfOCPYp946WppzwfANK naXkzdHEBbDIEex/N+bKb+nhsHkmMwux79agByx3TlG3WbJc4/sk7K9jVAJY+LPkXz/l /6qx3yNqJUkwqCBHKBpSJQrEYtNRfOi9m/u0nPzlsAkfWwkVDlgW+LXVsHZtGRDIvkbD rZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EssZ6xim; 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 bs35-20020a05620a472300b00779d17610besi2124758qkb.349.2023.11.03.13.09.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:34 -0700 (PDT) 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=EssZ6xim; 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 1qz0R3-0004Br-91; Fri, 03 Nov 2023 16:06:29 -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 1qz0R1-000454-Jh for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:27 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Ql-0006yR-IT for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:27 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4094301d505so18922925e9.2 for ; Fri, 03 Nov 2023 13:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041970; x=1699646770; 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=BM/WoalBWQwPuHSNHPl39Pw79pHu/OHGkHed2Wz/1M0=; b=EssZ6ximDOKaQznSwK77KU4i1/W2FxhR7atYhepvmg6+mf/SPMb2pQ6L5ijTC70dyO 0cRMmaMEaSCwG9U2tZTUkX47dbJUNSQ9qb8JiR7rgb65IUwMZzpP5P+kpWf8meT941qm J+vIwa7Gxpgwhg7ueFYqOpswfGSLSacM9bQkaFtSZwUscX/qgXaIpkgLV8+9fGM6NPq+ HHTokn9nH1J/zkDwceUk+A+0zBmpztcjB7KxQaZ+P1ZOU97AoIQKjbh+XQWLNtdnUf5I Myuwi85nh5rb/X09qxEeavPN1yYRP4EpR3emLa2KseKEMqhRtVz2C3HRPdYOX+ZPyEYR fmng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041970; x=1699646770; 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=BM/WoalBWQwPuHSNHPl39Pw79pHu/OHGkHed2Wz/1M0=; b=OukvcbSYXaztc6CJnhlnaDpXSpxed+KAIbioZObaPaVJrPixTGjCKnmlllZTH5ns1O GaK6gyIodXVfNv9vz7/vijqTtlqgUgUWugTT7Yz+Pt4vDff7V/1SsODQH5ZDNqCLKLaB /ynJlkjvirKupugRGlnDWoNUy23EdH5krPLVsKR2P3JqfliooULiPyyStwqOOdVab0Di XU1NeutlXYtji75sLUFd03un0GN2PaJi8zPl254SGXKJrJu6M19ko5BiMGJhTMqc7oh5 ZSSr8rpfXeUWYUbeRmCOt9aTGelhYH2aIRbyo8dR/CQBWElB/SbRJi4VFZquLQUmZ31t S58A== X-Gm-Message-State: AOJu0YycXVNpBIc7ElnspfzuOXxFcx8pakInrs/FbT7a0B/H6CPHDFmT loEs4L8exuRFS5eBwVV4iFl1yg== X-Received: by 2002:a05:600c:4f92:b0:401:a0b1:aef6 with SMTP id n18-20020a05600c4f9200b00401a0b1aef6mr19860363wmq.2.1699041970242; Fri, 03 Nov 2023 13:06:10 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l7-20020a05600c1d0700b00405bbfd5d16sm3567011wms.7.2023.11.03.13.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D4D4D65759; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Greg Manning Subject: [PATCH 29/29] plugins: allow plugins to be enabled on windows Date: Fri, 3 Nov 2023 19:59:56 +0000 Message-Id: <20231103195956.1998255-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Greg Manning allow plugins to be enabled in the configure script on windows. Also, add the qemu_plugin_api.lib to the installer. Signed-off-by: Greg Manning Reviewed-by: Alex Bennée Message-Id: <20231102172053.17692-5-gmanning@rapitasystems.com> Signed-off-by: Alex Bennée --- configure | 6 ------ meson.build | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 04f2cdd166..1129e6dd94 100755 --- a/configure +++ b/configure @@ -1010,12 +1010,6 @@ if test "$targetos" = "bogus"; then fi # test for any invalid configuration combinations -if test "$targetos" = "windows"; then - if test "$plugins" = "yes"; then - error_exit "TCG plugins not currently supported on Windows platforms" - fi - plugins="no" -fi if test "$tcg" = "disabled" ; then if test "$plugins" = "yes"; then error_exit "Can't enable plugins on non-TCG builds" diff --git a/meson.build b/meson.build index dcef8b1e79..b855224acc 100644 --- a/meson.build +++ b/meson.build @@ -3904,6 +3904,11 @@ endforeach if get_option('plugins') install_headers('include/qemu/qemu-plugin.h') + if targetos == 'windows' + # On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer, + # so that plugin authors can compile against it. + install_data(win32_qemu_plugin_api_lib, install_dir: 'lib') + endif endif subdir('qga')