From patchwork Fri Mar 12 17:28:08 2021 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: 398689 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1424263jai; Fri, 12 Mar 2021 10:23:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6U/da4ClEMO8UoE8v6BIJTEqqJWRacfPTLXBqALYnbocCj3feYS9Xu0MA5JlRYVg8WrB5 X-Received: by 2002:a05:6602:1353:: with SMTP id i19mr412340iov.202.1615573433561; Fri, 12 Mar 2021 10:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615573433; cv=none; d=google.com; s=arc-20160816; b=OIGX5hY568mJ1o+R4FRfd1Ozvr/eHF2J1cQDZQZriEgSCMmG6xD1jXgGKI6CZCDRXz KYL5a0kxLFYlShPg8Fe78U/1Bke0LI2wLbbGJkBi3rU3jdBjaaoHQRHupgcWQ5dRhK0L THwr6s7WMDDhhoZprL02/K6JYtazQl3n2Iizcv1Ls5G+w75CnDlsJP4727XLSXxXZykT 3dqFDGDQ4nYfOYIFAx7kyNEDmS22Nj/kanmMhKOEcIJXxZaQuruJuYzuPDdP2XHMbJIw TBSFpR+BKJ+11Tylv1csUEzXVKu7yF9Xh2KP6Ipt4cv2ifzVR/Ur4TZ6ckZAPD5x7xHu Exkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=eRIYBL/UvBDgTYdklYBnpFFW+jkrI6mIBJA/5FnNiwo=; b=wCWMgYO+OkenBEkKq926Adzb5/I74DWDcabfPQ2+orHMPqSEgmmTJWIUxPbCQBg6zG LKMmzCYY+B9HfiZIbnnA8PFF6w1hdjXrY3BiOkj2oRtqh5ZcyQ+niLlSDUpADs/OBusq 1aeiimt7MN2y3a0Rq2CUIlHPBGgxK9pZ0Fo/Y5kogCZ+jwvtaJdaPOTqRtCR2ltn964h wgf+fN9ZYOizMyU94mt4LdeuCo3RdKKv4QRr0IotIYs1/3X8OJmEQG7RRMwQuVErAIsv Js/gGA51wgvTbLi3ez0AvEL9sOOW76nUmJ8+F2FJJU1CrTWsABKI70JC+A6wmNJnbgNZ rrjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YWbyXKQ6; 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=fail (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 z15si5314256iob.21.2021.03.12.10.23.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Mar 2021 10:23:53 -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=fail header.i=@linaro.org header.s=google header.b=YWbyXKQ6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKmS0-0005Df-U5 for patch@linaro.org; Fri, 12 Mar 2021 13:23:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKlac-0003z0-W9 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 12:28:43 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:41367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKlaL-0002Bk-05 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 12:28:42 -0500 Received: by mail-ej1-x632.google.com with SMTP id lr13so54869686ejb.8 for ; Fri, 12 Mar 2021 09:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eRIYBL/UvBDgTYdklYBnpFFW+jkrI6mIBJA/5FnNiwo=; b=YWbyXKQ6eh1gJcyKn99m5zZV50Vycpt4cCKLP88F4S48R4HCyo3MDzUgmwhWaqd01G emsa6zI4vpnWYV/bfur/ceSGJ8pg9dyoWECAxhs8Fzik9OJTEbxA7seQOZw1s51hhqVt Dq7ASdQSamBMEho82c3Zp+qNV8KIlb+lxjotnNlNVcZkU3BuY7e0fk1LVyno/b1JQQMV AB/RqTbJjA7OGfu058qvWy2Sdt40u1dLNRvmx414ib091xAkSgwdn2+5u5ag6rF0rgOi 8Oofaqdf3aCPotiKSTygVOkH0cKU+ypNkXFgEqrwQfHn3M5IzxuK325BaYA1SscPO/x+ ZFGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eRIYBL/UvBDgTYdklYBnpFFW+jkrI6mIBJA/5FnNiwo=; b=e7HdJgGIgLMg++XvcFjcabNwC3Wp6qjU0GBsH1irhhqq5ZfIjsH/DRPJjbv8e1jxzC zBZIO0ewiX17mZiS1FwwBqOiDVcFuXVKFYQIcRjAedUTrdOGm+4qyz1a58esLDO4x9ut o4YZOszM+xPsYwYwnSO4MKZ4zS2+l65dGBSL2f3xRmUKeNvj3l9PCtftYRglZ3dI8UAr rth80bVt95rpM7l1NQ5WRYEg79HnF4z8SNyxBPMlesK3p8OryyiFdEinxpmftNra0jHm eFVKn9HhF8bIq8WmZ0182a2S1G1y+vL7fkbU8/qaxnlPJwGV0LnoTA4/GfQHcW1KHVyn orTw== X-Gm-Message-State: AOAM530Ij1qy0b31Mz29H1TRV49sls/AKQdMWU72EQKFofEd/LATnksL O5TVBdtA7Ej4XEXliDluuLpa8Q== X-Received: by 2002:a17:906:1ecc:: with SMTP id m12mr9678705ejj.4.1615570103330; Fri, 12 Mar 2021 09:28:23 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id qo25sm3065199ejb.93.2021.03.12.09.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:28:22 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C1DD01FF87; Fri, 12 Mar 2021 17:28:21 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 01/14] plugins: new syscalls plugin Date: Fri, 12 Mar 2021 17:28:08 +0000 Message-Id: <20210312172821.31647-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210312172821.31647-1-alex.bennee@linaro.org> References: <20210312172821.31647-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Weckbecker , robhenry@microsoft.com, mahmoudabdalghany@outlook.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Matthias Weckbecker This commit adds a new syscalls plugin that displays the syscalls as they are executed and returned. This plugin outputs the number of the syscall as well as the syscall return value. Works in *-user only. Essentially, this commit restores: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00846.html by using the new QEMU plugin API. Signed-off-by: Matthias Weckbecker Signed-off-by: Alex Bennée Message-Id: <20200812115816.4454-1-matthias@weckbecker.name> --- tests/plugin/syscall.c | 49 ++++++++++++++++++++++++++++++++++++++++ tests/plugin/meson.build | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/plugin/syscall.c -- 2.20.1 diff --git a/tests/plugin/syscall.c b/tests/plugin/syscall.c new file mode 100644 index 0000000000..53ee2ab6c4 --- /dev/null +++ b/tests/plugin/syscall.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020, Matthias Weckbecker + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +static void vcpu_syscall(qemu_plugin_id_t id, unsigned int vcpu_index, + int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8) +{ + g_autofree gchar *out = g_strdup_printf("syscall #%" PRIi64 "\n", num); + qemu_plugin_outs(out); +} + +static void vcpu_syscall_ret(qemu_plugin_id_t id, unsigned int vcpu_idx, + int64_t num, int64_t ret) +{ + g_autofree gchar *out; + out = g_strdup_printf("syscall #%" PRIi64 " returned -> %" PRIi64 "\n", + num, ret); + qemu_plugin_outs(out); +} + +/* ************************************************************************* */ + +static void plugin_exit(qemu_plugin_id_t id, void *p) {} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall); + qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index 1eacfa6e35..2bbfc4b19e 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,5 +1,5 @@ t = [] -foreach i : ['bb', 'empty', 'insn', 'mem'] +foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] t += shared_module(i, files(i + '.c'), include_directories: '../../include/qemu', dependencies: glib)