From patchwork Tue Mar 5 17:12:18 2024 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: 778052 Delivered-To: patch@linaro.org Received: by 2002:a5d:48c8:0:b0:33e:474f:8c56 with SMTP id p8csp546411wrs; Tue, 5 Mar 2024 09:13:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUxJMX2gu1bkMAAXQJMZ9aBPajJs9/mAKMVVjfBB44DJn05NwIqCZxZ1kDc927OHrHZvqwhiBnXhO0U+7hlW1M4 X-Google-Smtp-Source: AGHT+IFp8FuhlwYddDQ4S2ZK9Jn4poJpjpKeUHi7N1Jb2UcjyZH3twpDyPMgQOsbZwiYNr1vNyKE X-Received: by 2002:a05:622a:164a:b0:42e:631d:c522 with SMTP id y10-20020a05622a164a00b0042e631dc522mr2733863qtj.34.1709658799636; Tue, 05 Mar 2024 09:13:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709658799; cv=none; d=google.com; s=arc-20160816; b=oxLriroICSkxItYJrYl1I646KLlXQ9RHVrOtm4paTwUx/pwHxhpHICakgv2saVfhI/ QbkY2YfZFwyAGr1SXFJlpGn3xvJwG8V3XZlW+wD+T0BnIHYRTz73NfxtsUaU4R9lSiqR pZp94jYp0fL0ic1oszI7JbEaPi9tH7RqcfIsNx2h0GIRBfxIFVXDfx3iYVV6polslwOO DDIKOLXoosPS27xf/phS8Le4BjnyFOJgRMw4jDLFRoP+yXF1e2UTzSY//dq9ij/908n1 bb4Xh0ebFKSG9vkXnStHuLqmJeESwpd9+Wfv6Y3UAIdrfPEMXR81oiETREu8kGnzzTgn HfhQ== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=0rjXKS6vGeWEZgAJZUHM1h05LKR0JFC5i6Cm52KHRQw=; fh=NW9wLbsgo8Em9Ei7q9D4cP2qUJOuAWLB8y1lU3MLFw4=; b=owJih5Y+rV3rjKRAgPCh4SkInVdzESxwn9uAY5JqcmC1ZPqsK2q/V7QI5oOVtjYFtW 38bJOYPKWNZG1MTz6NntWM7sXzgjCJ9yaZJ1KH0466F5nE33aXL285KZp0/S0iOkviJn 1I0kbdOYGH1Y7CtzHWeib8yQQg+eRWpEvMhq79anLB260XrB0B/GN9NYfD05E4F4T7FW goJIuE5lk3RnPhguY12NC577iPPZKaEs2gVZFOfe6zOoSdLUTDMZGrqYUc2pxr+i/cJ7 sGOHYhdYPB99IzhXrQn7E+UekLO1OJGXCdiVkeQ3t/8Wfu9KaVuwGRibB1rCCt9Gp3r8 GB1w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AdaHYCkq; 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 b3-20020ac87fc3000000b0042ee52a68aesi6774887qtk.84.2024.03.05.09.13.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2024 09:13:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AdaHYCkq; 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 1rhYL8-0002H4-5i; Tue, 05 Mar 2024 12:12:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhYL6-0002Gi-Df for qemu-devel@nongnu.org; Tue, 05 Mar 2024 12:12:28 -0500 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhYL4-0006sK-Lk for qemu-devel@nongnu.org; Tue, 05 Mar 2024 12:12:28 -0500 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-513382f40e9so4381707e87.2 for ; Tue, 05 Mar 2024 09:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709658744; x=1710263544; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0rjXKS6vGeWEZgAJZUHM1h05LKR0JFC5i6Cm52KHRQw=; b=AdaHYCkqMO/bQfS4lDu9huiPfr/8Bvj0sbJNRuCmHtYTIvw/bE+s44S8w1KH75A7oH pyGbcGeq3tmht1qTgnmEJ7COaTk6/Gi/ncHJV9CCHujztfP9ci+09SoyRGMC+BM6tUQ1 OtZGEws9lFkx/ZK/icixIypjNcZQmuMUQv8WU3BKQPsPkS1BviOOBUcn6evHhi1f3t1Z wMd7Y10MSNBE60pbhP2uSXVTQTshdOvJPxSchc5XJ9WXOKpkeMkfCNEavaxiFFG5/TW2 N63Xs9e0PVvRk/QBkCa/+9B5SGNTKul2UHEyj8jBsyXRdGikv2wWupVXPgkm3rxS6po6 6L5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709658744; x=1710263544; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0rjXKS6vGeWEZgAJZUHM1h05LKR0JFC5i6Cm52KHRQw=; b=IzcaF4UMoLAM7s2KoShd9+XsGKwgG5TVK5IGHH0lNBauBVFlQ+ccOcgVxIMyV5r/cI CRT0YqCkZxieix7V0w65po4Cj2rr6tjxdJXftnOlnILm8SAcjsQH8xOdbcObvbx8mPK5 qN4g3twgsvHf3wloAd8UKzrzSbtfLrptWWXGlCHOgta3A6WJk1tgHu9XCLuKKGq1ExM1 z1b5ilzR3WXzsSypLRE2FUB5X2CKLLxiFH5mjuISEN3EQGKVAPtJ6LZLdIP011YFGYDx t/HPftPgPK3O1ts1c4aHemlZWPBtOWKyMhdUyVRMR1q/Y5paSRQ8KNMeeAj1o8LSqRgL tsHA== X-Gm-Message-State: AOJu0YyEFoXIfGbsRj4vS9rp+6CHpo+xLHOEaFnQpOI3i72A9OrrbdIF vxogdknmklsUlTCNNE1KFKif3tt+GPUlslRFMgT+lVA/m10rWYyIKuDvXALaCJGG3HmKOnjBcik 5 X-Received: by 2002:a19:915d:0:b0:513:2b36:3195 with SMTP id y29-20020a19915d000000b005132b363195mr1529720lfj.51.1709658743636; Tue, 05 Mar 2024 09:12:23 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r12-20020a05600c35cc00b00412a0ce903dsm18465906wmq.46.2024.03.05.09.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 09:12:23 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D14345F753; Tue, 5 Mar 2024 17:12:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH] plugins: filter out the PC from the register list Date: Tue, 5 Mar 2024 17:12:18 +0000 Message-Id: <20240305171218.3621274-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x133.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 QEMU's handling of the program counter is special in so far as the translator avoids setting it whenever possible. As the PC is available at translation time lets avoid confusion by just filtering the program counter from the list of available registers. Update the documentation with some notes about the register access and calling out the behaviour of the PC. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2208 Signed-off-by: Alex Bennée --- docs/devel/tcg-plugins.rst | 15 +++++++++++++++ plugins/api.c | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 9cc09d8c3da..656df012e77 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -151,6 +151,21 @@ Unsuccessful operations (i.e. faults) will not be visible to memory instrumentation although the execution side effects can be observed (e.g. entering a exception handler). +Register Values ++++++++++++++++ + +Callbacks registered with the ``QEMU_PLUGIN_CB_R_REGS`` flags can read +the current register values of the system. The plugin need to request +the list of available registers after a vcpu has initialised by +calling ``qemu_plugin_get_registers`` and using the supplied handle to +query the values when executing the callback. + +.. Note:: the program counter (PC) is not available through this + interface but can be queried at translation time by using + the ``qemu_plugin_insn_vaddr`` and + ``qemu_plugin_insn_haddr`` on the instruction handle. + + System Idle and Resume States +++++++++++++++++++++++++++++ diff --git a/plugins/api.c b/plugins/api.c index 8fa5a600ac3..fc3477acf2d 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -448,6 +448,11 @@ static GArray *create_register_handles(GArray *gdbstub_regs) continue; } + /* skip the program counter */ + if (g_ascii_strncasecmp(grd->name, "pc", 2) == 0) { + continue; + } + /* Create a record for the plugin */ desc.handle = GINT_TO_POINTER(grd->gdb_reg); desc.name = g_intern_string(grd->name);