From patchwork Tue Sep 10 14:07:08 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: 827002 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325111wrc; Tue, 10 Sep 2024 07:08:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXWNkvJGFtofjmzFcB/uLszex4d4GejoTmEVWZczmwJND2/h8T3sJ/nw4RZ7r2xMXgQY+44UA==@linaro.org X-Google-Smtp-Source: AGHT+IHSlMGXcDGEmbIDzLjHCp7hJLnRNvCxPuTsVOL/TeOf6pl96ygESYj/dRIYaVOAwbjn4nPj X-Received: by 2002:a05:6902:c0d:b0:e17:bb87:fd06 with SMTP id 3f1490d57ef6-e1d34a0babamr15368900276.49.1725977291772; Tue, 10 Sep 2024 07:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977291; cv=none; d=google.com; s=arc-20240605; b=CPuHs1JC86C3jFp7TqVSp8+6WAIVvGmcm4QWa/iyvUHlQGGD5VoUrKabOYrEmnRDca 2aGHpjq2v1U6LmM2K5EswbAHv0Rxk2GT5dvJ2J6GNLptpP+9EkCA9WH0/JB9lBoukLb6 GXoAPCRvVYNuc8qMqfDYiagJR6FMvWwejUg60/GttCFrqipGOajFS4S8vVH7SevmYhov mj6+mBInKBCahTyX+rmbgyRQ9DVYzCu5UPU12O2KzWZYOgEyxGECQg71Yk8aFUcBPb0r 5QqmmGO69AXrOvAPDLMpcidS6M8U9aGRJuhvZx33FXWBoNQW86/46MaohjDL23ovXnkv QNFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=LndXJjyjZbmiVr1fSe4zs9iupkSXPp6CUIfGBaC22cA=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=gs1Y5M6quVuGjFyDN/5JgHGNygNxX+RpN4ZynKPBuQbgg8CfGudEjyegu8FXJ7xqkT l/EQxqqMPgDI6Ho1znzFFefXdn0iY9JtrncDRAg0x7GlBiTs2t9LJeIRTydGEAvAM3N9 l4rq+esMTvjA2NZmszS4DDCBj7+XtEgia1l6IVwQSk23+tW9MzMaofGSDqEGZ48OV0Fv wkYSU2S2Gn6PfTkTqC+KCHNXBxnSfz33/2CZLiwPhj+MD+k1s8X2v6vncQQdU1ejpYdU 1l0yK5eCiYu92/L6TySA73Dcyxwfrf597M+9kbc2W/KaYOXYlWmcaOToNrpdXfl2BJwX UQbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N56i99Iz; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bbc1a64si1009545276.366.2024.09.10.07.08.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:11 -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=N56i99Iz; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1Ww-0007RZ-Lj; Tue, 10 Sep 2024 10:07:42 -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 1so1Wu-0007LR-I9 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:40 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Ws-0006Tt-5j for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:40 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5c3c3b63135so6026087a12.3 for ; Tue, 10 Sep 2024 07:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977256; x=1726582056; 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=LndXJjyjZbmiVr1fSe4zs9iupkSXPp6CUIfGBaC22cA=; b=N56i99Iz3fwxtAICfunZEAjR7iYtuKSYXXjCefJq5ghuAjY9H7zYmCUR7RTrV+dpKm K0kVWTlmhGrTvBEwW/RwK5iKT1f6hNsji9K/eWslYtHf5yEamxE8HKFFenmJNd5lrVYr tJE9RHeuTZYJD5KTfo8L7Y01PyByL+/EfRP2qvjCeIZfu4qad8TDRYvq0VkGdHJBvxsK cENPqJM4xZ+90GwOCZ4iRulww4o1AypodEiJWGJIL+wQoeuoJfSYQM0HPFHU6LCYgyUi 3m29TWJm2TeVcrmxq0lgcJyn9Dq6oIO254VVmwwsocPQkzFWag46vXqLcrNRq48KdMP8 l/NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977256; x=1726582056; 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=LndXJjyjZbmiVr1fSe4zs9iupkSXPp6CUIfGBaC22cA=; b=kxxmk48QKxrOecVIFjMRRDFtEOma8mkAdSlDveK8Vl8RMTULY/ctj2Xw9NlBLny7Uo I8+4UTgqWF+LxK5183zY4uqclDoc6Q9B87lBn4B8aMIY58K7nevcecdqg+lL45g8JoJ/ b84v0gCleuOOjnqFozaaPFPZy6Lzgi0UyJlMPPdhM6x0nI0uHMeS9qRChtaplI1aH/Yc dXMESgtEqJsIN8yqv2mYgSU3I9tV3fdUVQojiVwzn4bLhA7o1d3U/5dKi4b0gOhxXbjZ gmBxHJAYNGjXsvFVz5isRqKK63KOwJ3LRlp+L0turd7pvaNMfzY2L+zzYhzQJya1ZoV6 pN3A== X-Gm-Message-State: AOJu0YyAXm+9vPr0VTryxeeYNukw2cK6ojM7zMZ4S0JAeKAt51jsYien /I4JuLdCqZeojvp8EdqA1ZPrM6zS7lhR+gBsjZCI5xAH5jpruhUItZKOH0V4w+s= X-Received: by 2002:a17:906:6a1b:b0:a77:b4e3:4fca with SMTP id a640c23a62f3a-a8ffaaa23bbmr101780366b.9.1725977255572; Tue, 10 Sep 2024 07:07:35 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d259f56f6sm478231866b.81.2024.09.10.07.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B879D5F78C; Tue, 10 Sep 2024 15:07:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 01/26] tests/docker: remove debian-armel-cross Date: Tue, 10 Sep 2024 15:07:08 +0100 Message-Id: <20240910140733.4007719-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org As debian-11 transitions to LTS we are starting to have problems building the image. While we could update to a later Debian building a 32 bit QEMU without modern floating point is niche host amongst the few remaining 32 bit hosts we regularly build for. For now we still have armhf-debian-cross-container which is currently built from the more recent debian-12. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- .gitlab-ci.d/container-cross.yml | 6 - .gitlab-ci.d/crossbuilds.yml | 7 - .../dockerfiles/debian-armel-cross.docker | 179 ------------------ tests/lcitool/refresh | 6 - 4 files changed, 198 deletions(-) delete mode 100644 tests/docker/dockerfiles/debian-armel-cross.docker diff --git a/.gitlab-ci.d/container-cross.yml b/.gitlab-ci.d/container-cross.yml index e3103940a0..9a3ebd885e 100644 --- a/.gitlab-ci.d/container-cross.yml +++ b/.gitlab-ci.d/container-cross.yml @@ -22,12 +22,6 @@ arm64-debian-cross-container: variables: NAME: debian-arm64-cross -armel-debian-cross-container: - extends: .container_job_template - stage: containers - variables: - NAME: debian-armel-cross - armhf-debian-cross-container: extends: .container_job_template stage: containers diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml index cb499e4ee0..459273f9da 100644 --- a/.gitlab-ci.d/crossbuilds.yml +++ b/.gitlab-ci.d/crossbuilds.yml @@ -1,13 +1,6 @@ include: - local: '/.gitlab-ci.d/crossbuild-template.yml' -cross-armel-user: - extends: .cross_user_build_job - needs: - job: armel-debian-cross-container - variables: - IMAGE: debian-armel-cross - cross-armhf-user: extends: .cross_user_build_job needs: diff --git a/tests/docker/dockerfiles/debian-armel-cross.docker b/tests/docker/dockerfiles/debian-armel-cross.docker deleted file mode 100644 index 8476fc8cce..0000000000 --- a/tests/docker/dockerfiles/debian-armel-cross.docker +++ /dev/null @@ -1,179 +0,0 @@ -# THIS FILE WAS AUTO-GENERATED -# -# $ lcitool dockerfile --layers all --cross-arch armv6l debian-11 qemu -# -# https://gitlab.com/libvirt/libvirt-ci - -FROM docker.io/library/debian:11-slim - -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && \ - apt-get install -y eatmydata && \ - eatmydata apt-get dist-upgrade -y && \ - eatmydata apt-get install --no-install-recommends -y \ - bash \ - bc \ - bison \ - bsdextrautils \ - bzip2 \ - ca-certificates \ - ccache \ - dbus \ - debianutils \ - diffutils \ - exuberant-ctags \ - findutils \ - flex \ - gcc \ - gcovr \ - gettext \ - git \ - hostname \ - libglib2.0-dev \ - libgtk-vnc-2.0-dev \ - libpcre2-dev \ - libsndio-dev \ - libspice-protocol-dev \ - llvm \ - locales \ - make \ - meson \ - mtools \ - ncat \ - ninja-build \ - openssh-client \ - pkgconf \ - python3 \ - python3-numpy \ - python3-opencv \ - python3-pillow \ - python3-pip \ - python3-setuptools \ - python3-sphinx \ - python3-sphinx-rtd-theme \ - python3-venv \ - python3-wheel \ - python3-yaml \ - rpm2cpio \ - sed \ - socat \ - sparse \ - tar \ - tesseract-ocr \ - tesseract-ocr-eng \ - xorriso \ - zstd && \ - eatmydata apt-get autoremove -y && \ - eatmydata apt-get autoclean -y && \ - sed -Ei 's,^# (en_US\.UTF-8 .*)$,\1,' /etc/locale.gen && \ - dpkg-reconfigure locales && \ - rm -f /usr/lib*/python3*/EXTERNALLY-MANAGED - -RUN /usr/bin/pip3 install tomli - -ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" -ENV LANG "en_US.UTF-8" -ENV MAKE "/usr/bin/make" -ENV NINJA "/usr/bin/ninja" -ENV PYTHON "/usr/bin/python3" - -RUN export DEBIAN_FRONTEND=noninteractive && \ - dpkg --add-architecture armel && \ - eatmydata apt-get update && \ - eatmydata apt-get dist-upgrade -y && \ - eatmydata apt-get install --no-install-recommends -y dpkg-dev && \ - eatmydata apt-get install --no-install-recommends -y \ - gcc-arm-linux-gnueabi \ - libaio-dev:armel \ - libasan6:armel \ - libasound2-dev:armel \ - libattr1-dev:armel \ - libbpf-dev:armel \ - libbrlapi-dev:armel \ - libbz2-dev:armel \ - libc6-dev:armel \ - libcacard-dev:armel \ - libcap-ng-dev:armel \ - libcapstone-dev:armel \ - libcmocka-dev:armel \ - libcurl4-gnutls-dev:armel \ - libdaxctl-dev:armel \ - libdrm-dev:armel \ - libepoxy-dev:armel \ - libfdt-dev:armel \ - libffi-dev:armel \ - libfuse3-dev:armel \ - libgbm-dev:armel \ - libgcrypt20-dev:armel \ - libglib2.0-dev:armel \ - libglusterfs-dev:armel \ - libgnutls28-dev:armel \ - libgtk-3-dev:armel \ - libibverbs-dev:armel \ - libiscsi-dev:armel \ - libjemalloc-dev:armel \ - libjpeg62-turbo-dev:armel \ - libjson-c-dev:armel \ - liblttng-ust-dev:armel \ - liblzo2-dev:armel \ - libncursesw5-dev:armel \ - libnfs-dev:armel \ - libnuma-dev:armel \ - libpam0g-dev:armel \ - libpipewire-0.3-dev:armel \ - libpixman-1-dev:armel \ - libpng-dev:armel \ - libpulse-dev:armel \ - librbd-dev:armel \ - librdmacm-dev:armel \ - libsasl2-dev:armel \ - libsdl2-dev:armel \ - libsdl2-image-dev:armel \ - libseccomp-dev:armel \ - libselinux1-dev:armel \ - libslirp-dev:armel \ - libsnappy-dev:armel \ - libspice-server-dev:armel \ - libssh-gcrypt-dev:armel \ - libsystemd-dev:armel \ - libtasn1-6-dev:armel \ - libubsan1:armel \ - libudev-dev:armel \ - liburing-dev:armel \ - libusb-1.0-0-dev:armel \ - libusbredirhost-dev:armel \ - libvdeplug-dev:armel \ - libvirglrenderer-dev:armel \ - libvte-2.91-dev:armel \ - libzstd-dev:armel \ - nettle-dev:armel \ - systemtap-sdt-dev:armel \ - zlib1g-dev:armel && \ - eatmydata apt-get autoremove -y && \ - eatmydata apt-get autoclean -y && \ - mkdir -p /usr/local/share/meson/cross && \ - printf "[binaries]\n\ -c = '/usr/bin/arm-linux-gnueabi-gcc'\n\ -ar = '/usr/bin/arm-linux-gnueabi-gcc-ar'\n\ -strip = '/usr/bin/arm-linux-gnueabi-strip'\n\ -pkgconfig = '/usr/bin/arm-linux-gnueabi-pkg-config'\n\ -\n\ -[host_machine]\n\ -system = 'linux'\n\ -cpu_family = 'arm'\n\ -cpu = 'arm'\n\ -endian = 'little'\n" > /usr/local/share/meson/cross/arm-linux-gnueabi && \ - dpkg-query --showformat '${Package}_${Version}_${Architecture}\n' --show > /packages.txt && \ - mkdir -p /usr/libexec/ccache-wrappers && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/arm-linux-gnueabi-cc && \ - ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/arm-linux-gnueabi-gcc - -ENV ABI "arm-linux-gnueabi" -ENV MESON_OPTS "--cross-file=arm-linux-gnueabi" -ENV QEMU_CONFIGURE_OPTS --cross-prefix=arm-linux-gnueabi- -ENV DEF_TARGET_LIST arm-softmmu,arm-linux-user,armeb-linux-user -# As a final step configure the user (if env is defined) -ARG USER -ARG UID -RUN if [ "${USER}" ]; then \ - id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index ac803e34f1..199d5fad87 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -154,12 +154,6 @@ try: trailer=cross_build("aarch64-linux-gnu-", "aarch64-softmmu,aarch64-linux-user")) - # migration to bookworm stalled: https://lists.debian.org/debian-arm/2023/09/msg00006.html - generate_dockerfile("debian-armel-cross", "debian-11", - cross="armv6l", - trailer=cross_build("arm-linux-gnueabi-", - "arm-softmmu,arm-linux-user,armeb-linux-user")) - generate_dockerfile("debian-armhf-cross", "debian-12", cross="armv7l", trailer=cross_build("arm-linux-gnueabihf-", From patchwork Tue Sep 10 14:07:09 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: 827012 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326604wrc; Tue, 10 Sep 2024 07:10:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXX5Klqdlm9xyYBVEas0QKunkZmY/qSt3qF3wMkHRixWXVxA6rocKO0JrhdoawTG5Yw7AZAZQ==@linaro.org X-Google-Smtp-Source: AGHT+IEMJx4lrH/0hbS0tpRulh6H/NyFMeRE4byK5xe681O5EJAiuiHb4A7AyHt+MCf7lZ1DKu6M X-Received: by 2002:a05:6902:2b0f:b0:e1d:13a3:87af with SMTP id 3f1490d57ef6-e1d3489b2admr12541132276.29.1725977430712; Tue, 10 Sep 2024 07:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977430; cv=none; d=google.com; s=arc-20240605; b=EHXXS1jg4kJaBnYzprIo/hp1GlRGQs6cdhwb9Xs7247JQZccsg0RzFf1ITphwhN3m4 OJ5QxJR6/Xr8PrIdXwv7xtPi4LhNVUcQGnGPv6BcRWMbBzlgyxckxj1CZlubLT1A1ouM CQG+I/L+at1LsMV3CulSkPzOWUPYTrX2nDdNJN6UFFEeDwy46+e/M9+QWQM5u/xqVdVQ AeIMKsnGdtnCvAuuLfaVKnHjvwx/ibeOVzF2bIS3YeS0l65A+ktMjntwkEQEPX4HdCef kwCPH5BBaa63HT07sx4rij6xUC1mIZ5IeUjlBk4ZSMzheSe5Irs8v+aSViptACHpayoa a6kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ExuMbIXOAQGfG1vwm+EE/TEBGthlbZ6vFrpI/DJuVTs=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=VqIoWThLb/IZ/YmvCisHRyVkhxab3MwuhzPE90B2+8VBI/499R83sNhQxl6kGwlRx1 GK6O3dYCUnMWeo9Db++3VDQeoCKrt6P+pItvAPXtbPQMTaUfbfnhGcNJ0VySJxoLESmi eD1tpDS8S5IZHP78TOp1FOd8tbkChaTZkfkqZqIePfVKpAQfnc+WM9v3LRDymd/f2XGy YwQ5iTwBlFTyuBgYB3G0N9U7fYbpZiNT7HmCTmSOLRdg1yaGx9kPQAxipR7Xu+y7G9H9 SHicaGuDHcljvTlj/rlmA4Gxot7fTQJB7SsNmq0TlnBHYpLQN2BSWvA2DYaIxPY1/6C+ h8qQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gWySgFGS; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bb7fe40si981963276.358.2024.09.10.07.10.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:10: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=gWySgFGS; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X1-0007ng-KW; Tue, 10 Sep 2024 10:07:47 -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 1so1Wx-0007WE-PE for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:43 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wt-0006Uf-RH for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:43 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5365a9574b6so6261784e87.1 for ; Tue, 10 Sep 2024 07:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977258; x=1726582058; 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=ExuMbIXOAQGfG1vwm+EE/TEBGthlbZ6vFrpI/DJuVTs=; b=gWySgFGSZJHBFSCZchbamVIoMYzoFyDoLUWaN56zotj/54fxcwDClfO1uHrgtzDCVo 87BoehHA4G9bJ+IbJE228SWpKXEEcskzz8cI6SNsfERZMPgJ5fgCXQVzjlU1H25iZqr8 zDbies236RfOiRL33o6lwGXDJDT57o58nnKc27eV+nNSpL9XW7IAGQVq/Wl0rY9R9Gcd BkM7dYoysdeBFcFum3YCkHJzVZvY3Q4X8XM3ZL7UONsvZ12OUQJAeN/OnZc+m/1nD271 gJxJM+KGNvxeDay6seaAvR+6hMzBOJtyKXaiNIK6+xnAMBCk/9Ut/VzsO5cCbgM44Dre fseQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977258; x=1726582058; 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=ExuMbIXOAQGfG1vwm+EE/TEBGthlbZ6vFrpI/DJuVTs=; b=gV+pVOYlaICYw40QLxhEI0VdnS4Howh90f3iED3faBDVHnOMJcYfAxIjvQZxCE+03L OaQMcBTsR7jQVi7BdKeC8qGa7bMg3RbcP9kbT10IxDcs84XO0p6kwzhuwS8rkDkBtY2+ OypBQlsvuF96C7bG6xQb9HtZ3YI327nLqvTc+W5LT58ipsBXVBpWyJnvUbVWoEh6jrrx BAe2dU4A4O0i/mxXdBhKw37ZP+cD4akGsJXClIUrLbTVa5as9Q0ZDhqMlX3U2i9rLZXO Onui1IHJ4ja/5+i57yWZjvDxseBVVKRn7H58ODdiAvJSt6irt6hMoFrUYm4H2DDnSDxU nMfg== X-Gm-Message-State: AOJu0YwpYnPcyAQwQBNenbVeALSQjlutbCLoV98wAA+/PaD8TkoU/z1p j1T7AehQ7oiNKSzHUWkBfPFdqJ16XWqixRDLluIOqMZLZJl7Pdb1GTJNaU9Yo1c= X-Received: by 2002:a05:6512:2395:b0:535:6925:7a82 with SMTP id 2adb3069b0e04-536587f845amr14728847e87.41.1725977255283; Tue, 10 Sep 2024 07:07:35 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cecc21sm484887666b.166.2024.09.10.07.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D33825F7B4; Tue, 10 Sep 2024 15:07:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 02/26] tests/docker: update debian i686 and mipsel images to bookworm Date: Tue, 10 Sep 2024 15:07:09 +0100 Message-Id: <20240910140733.4007719-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Whatever issues there were which stopped these being updates when the rest were have now been resolved. However mips64el continues to be broken so don't update it here. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- tests/docker/dockerfiles/debian-i686-cross.docker | 10 ++++------ tests/docker/dockerfiles/debian-mipsel-cross.docker | 10 ++++------ tests/lcitool/refresh | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/docker/dockerfiles/debian-i686-cross.docker b/tests/docker/dockerfiles/debian-i686-cross.docker index 3fe8ee623d..2328ee1732 100644 --- a/tests/docker/dockerfiles/debian-i686-cross.docker +++ b/tests/docker/dockerfiles/debian-i686-cross.docker @@ -1,10 +1,10 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross-arch i686 debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch i686 debian-12 qemu # # https://gitlab.com/libvirt/libvirt-ci -FROM docker.io/library/debian:11-slim +FROM docker.io/library/debian:12-slim RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ @@ -48,16 +48,15 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ - python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ - python3-wheel \ python3-yaml \ rpm2cpio \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \ @@ -69,8 +68,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ dpkg-reconfigure locales && \ rm -f /usr/lib*/python3*/EXTERNALLY-MANAGED -RUN /usr/bin/pip3 install tomli - ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make" @@ -145,6 +142,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ libvdeplug-dev:i386 \ libvirglrenderer-dev:i386 \ libvte-2.91-dev:i386 \ + libxdp-dev:i386 \ libzstd-dev:i386 \ nettle-dev:i386 \ systemtap-sdt-dev:i386 \ diff --git a/tests/docker/dockerfiles/debian-mipsel-cross.docker b/tests/docker/dockerfiles/debian-mipsel-cross.docker index 0d559ae4ba..4ac314e22e 100644 --- a/tests/docker/dockerfiles/debian-mipsel-cross.docker +++ b/tests/docker/dockerfiles/debian-mipsel-cross.docker @@ -1,10 +1,10 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool dockerfile --layers all --cross-arch mipsel debian-11 qemu +# $ lcitool dockerfile --layers all --cross-arch mipsel debian-12 qemu # # https://gitlab.com/libvirt/libvirt-ci -FROM docker.io/library/debian:11-slim +FROM docker.io/library/debian:12-slim RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ @@ -48,16 +48,15 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ python3-opencv \ python3-pillow \ python3-pip \ - python3-setuptools \ python3-sphinx \ python3-sphinx-rtd-theme \ python3-venv \ - python3-wheel \ python3-yaml \ rpm2cpio \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \ @@ -69,8 +68,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ dpkg-reconfigure locales && \ rm -f /usr/lib*/python3*/EXTERNALLY-MANAGED -RUN /usr/bin/pip3 install tomli - ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make" @@ -143,6 +140,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ libvdeplug-dev:mipsel \ libvirglrenderer-dev:mipsel \ libvte-2.91-dev:mipsel \ + libxdp-dev:mipsel \ libzstd-dev:mipsel \ nettle-dev:mipsel \ systemtap-sdt-dev:mipsel \ diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index 199d5fad87..c60490a7fa 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -159,7 +159,7 @@ try: trailer=cross_build("arm-linux-gnueabihf-", "arm-softmmu,arm-linux-user")) - generate_dockerfile("debian-i686-cross", "debian-11", + generate_dockerfile("debian-i686-cross", "debian-12", cross="i686", trailer=cross_build("i686-linux-gnu-", "x86_64-softmmu," @@ -171,7 +171,7 @@ try: trailer=cross_build("mips64el-linux-gnuabi64-", "mips64el-softmmu,mips64el-linux-user")) - generate_dockerfile("debian-mipsel-cross", "debian-11", + generate_dockerfile("debian-mipsel-cross", "debian-12", cross="mipsel", trailer=cross_build("mipsel-linux-gnu-", "mipsel-softmmu,mipsel-linux-user")) From patchwork Tue Sep 10 14:07:12 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: 827016 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp327095wrc; Tue, 10 Sep 2024 07:11:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXUGzistMaHOphe+CwEZXFRxpFQa5PlY80MirsC7U8rvNTVJCInEXMbd/jH2eCDv5Ne93qsg==@linaro.org X-Google-Smtp-Source: AGHT+IG+ZhaBQqBZBUd/AND4Nl4t0+/drU8kfuzzuPHMCoQHkE+p81+O/OG3S401XhmiREQXCeht X-Received: by 2002:a05:620a:2727:b0:7a9:b021:ee6 with SMTP id af79cd13be357-7a9b021147emr1566302285a.11.1725977480681; Tue, 10 Sep 2024 07:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977480; cv=none; d=google.com; s=arc-20240605; b=W60k0HKfnhTTY4RaBbqkssWv1jgTqd2rNaRt5xyKMt59zKd5jBGtd6nA3CeppKidRK TgJRJ1Xh4BB7lxfLQT7VmmzUwnGnmtER56jIRGxUu7zTwGkfRDqoYnkg3gP1U8aT2mg1 P3/cyevMoagn4YOTjyVPls7e95TbMIrYHOENTzuRM/cq7Ho+GQbC9bQZsw5Kw2wW2/S1 O6jBMebTAjbI+8zMSPrF23IKHhoD9zIqA+QFg2QfZ1wzj7EMEisphS3pVb3VdfaQpFSt BRUdVY6/gPQ57diOi4KISxHrj7/eMEodQ7cjkZ3yzP98dNSWXLZlZElpDjuzjskY802S fY+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=4x/2lUUGLpLRO+8rqUP/+rQmXa+2LMUSZP6UGcSNzgE=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=G9E5P04COUyyineWumNq9LL013IE8EbqI9rP4Y66X/gOrZ/Y9SQpGZ4eaJ2uDyq6yF oAhKVrHd7YDiHGiCDyLxtWpVUpRUAFvXj5x3ilT07OsnGe3s39k+X1w2CCmW4jcLKKVx M3xD3PgQabqmlRa47dd7ghrb8gmTE8MW/mv7jeIZslA4MV/dtjxNbhZ6u+Oq5vF+d6yu +6LPcBhyO3QAz3ydBWRsU5uwz9QA/ATfXTW6ROEb2PrBSekxDI6OA0NKn1BJl62IPY/f tOwpchruq/eNqIHrswA9AAEMxcIqgO8IQJUeJ2OYf5ShEdd7GPhIlcSQ8B8MZpUzRuaY 6v1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7E6uwHS; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a79c56easi808759585a.47.2024.09.10.07.11.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07: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=O7E6uwHS; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X2-0007qV-Ba; Tue, 10 Sep 2024 10:07:48 -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 1so1X0-0007hO-7T for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:46 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wv-0006VG-Ve for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:45 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a8d4093722bso449358366b.0 for ; Tue, 10 Sep 2024 07:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977260; x=1726582060; 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=4x/2lUUGLpLRO+8rqUP/+rQmXa+2LMUSZP6UGcSNzgE=; b=O7E6uwHSbHOuWwdIOCEcsg4vaGkmKongHQIe22PkTFdYOShs/iAWUf3JRvA9Yplfkv 2/+O9Q5OnuEQaO234QyRvxBkpU6pjYBrySXxduQ+X9PIigOXhxACQXvlyBr7TAHJdmEL gieD45sL3mPkLojRY9WQpaP88W74arVX7xg+LsciyzYylTLeV8AfatMWzOKhT/WgT+3E 5bXNhyuom5EIBrs+lWdl354f5SmMukps5MwWKv+JDRQqc/uJLWPaewXEEr4SnNaZ4D6S XnXVx8NWdKdEIsedP4FJQClWds70M4LzL/TRAghq8quUp1yIAMxHXd0eQBnRcQNkICzI W8VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977260; x=1726582060; 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=4x/2lUUGLpLRO+8rqUP/+rQmXa+2LMUSZP6UGcSNzgE=; b=G7OZ0wIfJUKrkbYx9UbVKiPFkCfAzAjntv7i0ape2uwNaOKXnUVTvZlme9sI98FRMn lyU4LGbOhIKoeZ2+9Inrh4m6nuqZ+sBYsAQ7yIZ/lewLWnPg5Du0AMEEQzVcApJ648pN VeDRkq6lTvOEyx1rSQOb65L/N+lv0JgPy0Lr4NLx2oFrMmFexYHtkpa767Rt4Nq1Cz+t 4j4Y9ZFYJew4aekeH+XPb6rLEbCU6cDAST/7hkolbX1++Siav5kc5zncwzOJ8e3bi2bz w+AAgOO2ypnNxzgKEvGTj2aaTUPoySRD/H0LjJP1Hu0VRpXuiLl5TWdsAbv82nxYcbaA i2oQ== X-Gm-Message-State: AOJu0Yw6HCRi/lcfCtIWKtzcWiFFmzkQEK22Dh7JZHYYicjAZKAQ8TXC U/tfeLZDJi6VJMDJYglOBCkiThsRSqZBryORJwDkILdX1e9HUG3yG7BQmXf7OA4= X-Received: by 2002:a17:906:dc92:b0:a7a:3928:3529 with SMTP id a640c23a62f3a-a8ffaaa54d0mr74864366b.13.1725977260214; Tue, 10 Sep 2024 07:07:40 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c7286esm481008866b.138.2024.09.10.07.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 22ADC5F9CE; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 05/26] gdbstub: Use specific MMU index when probing MTE addresses Date: Tue, 10 Sep 2024 15:07:12 +0100 Message-Id: <20240910140733.4007719-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x630.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=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: Gustavo Romero Use cpu_mmu_index() to determine the specific translation regime (MMU index) before probing addresses using allocation_tag_mem_probe(). Currently, the MMU index is hardcoded to 0 and only works for user mode. By obtaining the specific MMU index according to the translation regime, future use of the stubs relying on allocation_tag_mem_probe in other regimes will be possible, like in EL1. This commit also changes the ptr_size value passed to allocation_tag_mem_probe() from 8 to 1. The ptr_size parameter actually represents the number of bytes in the memory access (which can be as small as 1 byte), rather than the number of bits used in the address space pointed to by ptr. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson Message-Id: <20240906143316.657436-2-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée --- target/arm/gdbstub64.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 5221381cc8..85a19c14c7 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -435,6 +435,7 @@ static void handle_q_memtag(GArray *params, void *user_ctx) { ARMCPU *cpu = ARM_CPU(user_ctx); CPUARMState *env = &cpu->env; + uint32_t mmu_index; uint64_t addr = gdb_get_cmd_param(params, 0)->val_ull; uint64_t len = gdb_get_cmd_param(params, 1)->val_ul; @@ -458,8 +459,10 @@ static void handle_q_memtag(GArray *params, void *user_ctx) gdb_put_packet("E03"); } + /* Find out the current translation regime for probe. */ + mmu_index = cpu_mmu_index(env_cpu(env), false); /* Note that tags are packed here (2 tags packed in one byte). */ - tags = allocation_tag_mem_probe(env, 0, addr, MMU_DATA_LOAD, 8 /* 64-bit */, + tags = allocation_tag_mem_probe(env, mmu_index, addr, MMU_DATA_LOAD, 1, MMU_DATA_LOAD, true, 0); if (!tags) { /* Address is not in a tagged region. */ @@ -478,13 +481,16 @@ static void handle_q_isaddresstagged(GArray *params, void *user_ctx) { ARMCPU *cpu = ARM_CPU(user_ctx); CPUARMState *env = &cpu->env; + uint32_t mmu_index; uint64_t addr = gdb_get_cmd_param(params, 0)->val_ull; uint8_t *tags; const char *reply; - tags = allocation_tag_mem_probe(env, 0, addr, MMU_DATA_LOAD, 8 /* 64-bit */, + /* Find out the current translation regime for probe. */ + mmu_index = cpu_mmu_index(env_cpu(env), false); + tags = allocation_tag_mem_probe(env, mmu_index, addr, MMU_DATA_LOAD, 1, MMU_DATA_LOAD, true, 0); reply = tags ? "01" : "00"; @@ -495,6 +501,7 @@ static void handle_Q_memtag(GArray *params, void *user_ctx) { ARMCPU *cpu = ARM_CPU(user_ctx); CPUARMState *env = &cpu->env; + uint32_t mmu_index; uint64_t start_addr = gdb_get_cmd_param(params, 0)->val_ull; uint64_t len = gdb_get_cmd_param(params, 1)->val_ul; @@ -527,8 +534,10 @@ static void handle_Q_memtag(GArray *params, void *user_ctx) * Get all tags in the page starting from the tag of the start address. * Note that there are two tags packed into a single byte here. */ - tags = allocation_tag_mem_probe(env, 0, start_addr, MMU_DATA_STORE, - 8 /* 64-bit */, MMU_DATA_STORE, true, 0); + /* Find out the current translation regime for probe. */ + mmu_index = cpu_mmu_index(env_cpu(env), false); + tags = allocation_tag_mem_probe(env, mmu_index, start_addr, MMU_DATA_STORE, + 1, MMU_DATA_STORE, true, 0); if (!tags) { /* Address is not in a tagged region. */ gdb_put_packet("E04"); From patchwork Tue Sep 10 14:07:13 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: 827003 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325136wrc; Tue, 10 Sep 2024 07:08:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVl0w5aQ5Ix/BrHpz9C+DAOr4eqOy6sq/F96rCU/adqg2M109ItM1KTTX7dxy3v2ajuABXqpw==@linaro.org X-Google-Smtp-Source: AGHT+IGhrKy3yZU7+e8bFEiA0VovS1q/cA8o6XRcI4sURSY4/M3R3xYjGlLdqAmnXNgSpxDoeC6W X-Received: by 2002:a05:6902:1b8d:b0:e16:69b5:ef62 with SMTP id 3f1490d57ef6-e1d34875c13mr13652061276.5.1725977294530; Tue, 10 Sep 2024 07:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977294; cv=none; d=google.com; s=arc-20240605; b=I6P76HPtvV5YHm6B+ue85G/Jvboh/FZx6Qu9beQlM28VLuDTSoJUnucXmhYutbLkIV 4wVl+0uSBnN0xpJ1OQBoKwt0NGSEajlGa0z/KZ+6P9a6h9YTQq6dXr6qcGmIM4HWgCQe wIiYhduiuJwg0H/gwZpx6m7i6G2WpFYjd+utWjP000lfUcEN2CS573WJYdhPsQUtRBVd wRgaO46DyW1baLLRos3Be3xvqAAbL+je/PeJWd4obUXwVH2Amc5rC5lYGI+Stzn2R4+K P3IhfSSPXF/47J47IMkKVjXyZ4F8xW0YvNSwTe02mqJdiNUcfGYDechbnYrTg6JEzUKJ gVPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=fSOOKTU4/ntvh1NQhQ1KOTaJwtvBojTKzDVk3v/UKCo=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=c5Uv4U3rOV9Mlur7RtlV/kxNlV4TnZodBUbbOsg/u4SQQ+Y8NYtF0ptPEZ65n5sqRU Fao4LaZBvKEa+3gUdHLP8mxdXaAdKMpfq0lHsWdKwtbEF/xzjdQY6KZg/kMeYLTTlbsc LzxaGRw8KSRRd1Aak0JlHEy1a10VekgQ8TeQ8BCRuJxyaJXjsIgGTCFZeTGr4DDw0fYs +BYivb9h/GywCKDik9V+i2LvUF9d25m77AQqAvQAvHSiyNtdqxoh2Y8DQS8u/7cG9H8h cfmL856WYykZ8NLV3A7sFgyroeHpygEjCzJsYQkZtKMdC/y0WaOqjaKu87CPlr7M/Qi/ sjaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RoGl4P+d; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bbca60csi1058631276.480.2024.09.10.07.08.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:14 -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=RoGl4P+d; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X0-0007jX-Pg; Tue, 10 Sep 2024 10:07:46 -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 1so1Wx-0007UH-A8 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:43 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Ws-0006UB-OO for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:43 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a80eab3945eso535983166b.1 for ; Tue, 10 Sep 2024 07:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977257; x=1726582057; 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=fSOOKTU4/ntvh1NQhQ1KOTaJwtvBojTKzDVk3v/UKCo=; b=RoGl4P+dlREizikCWeXw5BgoFVw3qhiumZ+le+OHwkUS0J7XDufSPnLsiab8zriiCf f7+USNYn+4YQlCfq5LmHWOZGdj1fua60GpQqoOkEN8ysoORHd9MW+9IRj7bERoCLAn5W 7sJSBBCcrsO27O4+qalN2VxAdXNYDJOLbqT+ul38h/ZgM2PMcfO8ub+qaPwf1YNu9po0 j+ccBByHA3zL/OQi9eRoZbgEB/kaQaauE8LDsu9rCMAbobZEfBYrxHnoCuGG0sjVeeaC f0B3hOSAVVKahG7EMg53672A3xpeQwsG9RQCMHU4jbRCbN9WLwSWVJRdndXbiq6ufDdO lTJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977257; x=1726582057; 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=fSOOKTU4/ntvh1NQhQ1KOTaJwtvBojTKzDVk3v/UKCo=; b=iuRSHlYgi8TkpUhereM4lS7zjlaL6PQQZ8dO7RCW4u080G60L9cioBq9o9NPRkX3ZH gULrYJvfnuL8lQ3N7QkQGFVA9kacQpoyOLjZX9YE6J039SVpUH+V88zofae+q7XPzyLt /Dr6LDkTF9Xpv9GRQ6Qzuxn1x3n4vJPVIeZwS/2hwZ/CyEkRmJ8sU2tWnBETHASZ1tkz ddq8Pb3Xr5Uax2sWkaKUEZYAhkxgYWyYC8YqGqhRhKLb4osXSD4lnZ+dkKU8V7ubUhHZ icBjkFBSRmpT/AL4hDsVXvAcp/trN8LeS1w7I+F67YG93ZjVKQod8l48XstEUhc5BOQ7 qfFg== X-Gm-Message-State: AOJu0YxKIl+G1tVibZiYCN+wM/9HlNJqx8CCYvmMJmSbKoHwvsMgHk0N rmMybVinWLUgzDTnJHAJQCLbMBmURMRcfYLfS40V9J7aXwB2mP2L0Tknbn0uaYs= X-Received: by 2002:a17:907:3da4:b0:a8d:6073:2c13 with SMTP id a640c23a62f3a-a8ffab8f2d5mr80695566b.33.1725977257023; Tue, 10 Sep 2024 07:07:37 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25d547e5sm487267866b.201.2024.09.10.07.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 38F8B5FA08; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 06/26] gdbstub: Add support for MTE in system mode Date: Tue, 10 Sep 2024 15:07:13 +0100 Message-Id: <20240910140733.4007719-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero This commit makes handle_q_memtag, handle_q_isaddresstagged, and handle_Q_memtag stubs build for system mode, allowing all GDB 'memory-tag' subcommands to work with QEMU gdbstub on aarch64 system mode. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/620 Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson Message-Id: <20240906143316.657436-3-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée --- target/arm/gdbstub64.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 85a19c14c7..9462d3f560 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -430,6 +430,7 @@ int aarch64_gdb_set_tag_ctl_reg(CPUState *cs, uint8_t *buf, int reg) return 0; #endif } +#endif /* CONFIG_USER_ONLY */ static void handle_q_memtag(GArray *params, void *user_ctx) { @@ -600,12 +601,10 @@ static const GdbCmdParseEntry cmd_handler_table[NUM_CMDS] = { .need_cpu_context = true }, }; -#endif /* CONFIG_USER_ONLY */ void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *qsupported, GPtrArray *qtable, GPtrArray *stable) { -#ifdef CONFIG_USER_ONLY /* MTE */ if (cpu_isar_feature(aa64_mte, cpu)) { g_string_append(qsupported, ";memory-tagging+"); @@ -614,5 +613,4 @@ void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *qsupported, g_ptr_array_add(qtable, (gpointer) &cmd_handler_table[qIsAddressTagged]); g_ptr_array_add(stable, (gpointer) &cmd_handler_table[QMemTags]); } -#endif } From patchwork Tue Sep 10 14:07:14 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: 827017 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp327298wrc; Tue, 10 Sep 2024 07:11:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFycdz/Qs70uV6rXjMilizTTzV1MjGinLfZfDhaO7XAdageT6Ds4I5OgU7Ljsv0vrxcujiIQ==@linaro.org X-Google-Smtp-Source: AGHT+IFA48sqR5tgHwALEXFnrwAXIts4ec+zD03+APIN/1DUHPcvmjxln1Gge7CMPPSwIzk1f9bR X-Received: by 2002:a05:620a:2448:b0:7a3:49dc:e6e3 with SMTP id af79cd13be357-7a9a38ebfc8mr1579006985a.53.1725977499730; Tue, 10 Sep 2024 07:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977499; cv=none; d=google.com; s=arc-20240605; b=FItre/tVuC30l/gtgoRfPIomeKeytR/RdPLYL0rxlHoofotCvg9+zI8mmXB7+ppaP4 T7ieFeNHp46S7X89iKu2Qvk7z2Z7FzN2aIXuAM2YsvluzxyEoh/Pz1dKJGFjqWMgLbEl yEBObWimYz7VSKGJZEVL/5BsAymW7K3uFCtoB/GCI3nZYN7O/Yi65wffuhWNLHN1WSB7 +sINvESD0jOCTbRtG+HPT6Ml44La3JFfiv6s5wDlKJ4mWJ5T+8iyybvlw3Kw0/2z2Fz4 3mDb2RM8M7hco701o2aXWlp4QZErYWLxfmVy2Yil1XDociaa6Pg1Zbsb6MdJ9T5/Mk+b M+GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=0gsP/ANf70RJH0KlgA0KWCypst2Oh4Yb8PQcZ6VG+qU=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=QLbCwgWGVa0aK/aZc2s+RJQJDLm7kXCuJyY7ruTxTLeF3f1BSPvYfBgcENH3rRaltz 8NL5Xqk+dyNkC6nQk2YNfyc/hEo47FUXnkzPNZpCC4t4jm1VdcQrI7S0YltTUOPT+ATp F2E9rCP26MIBrci0b6phdvPYIiRtSDIhsqgNpiAXscStJdkBbNC0pqJOV8iaGJLH/AkI qeJ5w+x8ebjUKDWrjDMSomRh5iFcjsQjVvxlMsfzBXLd7bNx0ngKfBbrL/Q76DKM/zI4 tIg2m567OiGMdvp8c35WZbiITAi7dKoBqj+4lc9kkCSdjovqw7dFJ9aPHZH+DiRacPdf AXiw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vUealY35; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a7a47c4esi815911485a.408.2024.09.10.07.11.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:11:39 -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=vUealY35; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X2-0007qT-B0; Tue, 10 Sep 2024 10:07:48 -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 1so1Wz-0007cv-5u for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:45 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wv-0006VB-J6 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:44 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c25554ec1eso7302336a12.1 for ; Tue, 10 Sep 2024 07:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977260; x=1726582060; 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=0gsP/ANf70RJH0KlgA0KWCypst2Oh4Yb8PQcZ6VG+qU=; b=vUealY35jhI7MWFnRiYrGw4zqYgA5C5aH33YO/McliGEmZDQDG8nf+4m0apq9oQ/vK y3o5oJTYnCsc1t4cXKjnzBZxtz2hz9Bgs4hIL6I/ERuWLLuejMPzdOK4UUoHlcxxBWJh 0fwpKAp9tziIAtmGnc+JwCvcQ+DOo6VJ4HFjMsP/bZH8B2ITqKZgXy6aNo/92FhspAR6 2M1CMsanQa2zK94SvNoFnnJT7qawFZX1vmTSGsU6tmqtEqEyuyB/r0VNvwn+qPRR7H07 miiN5kNcjV0axG42VfnfzcofjR8EEKkcVTlR4aK4zQbIz/0aUd4akPoqjDB10wpjJBRt qneg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977260; x=1726582060; 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=0gsP/ANf70RJH0KlgA0KWCypst2Oh4Yb8PQcZ6VG+qU=; b=nDbonY+lrbFXR87gcfYRe456HYiQbgl3bdxeMbsAPFZwiKDU4QNWxSZNwkgHjOSXd6 vO22ceg5p0LoA1XfGgDmv1wKYXbCvC+gPzIP/FnSKxsbV0D58PNFdicze5hiUqrMFcl7 /KFW4CsJQVkBIEebweIspuB+DFvg8xIlVYN9hVk7XCvRr+CQZ6ZlSM6o2pZlK6rg+ksg DCwLo9B6SFL9Hc0cB9GeO7MeOEILXBRBVMKT+MXmAaovrYJegC4L4ceXa38wwHDtEeNS rEuaLNIWJZCtQNuVmsSAjsk5MUAFBmx5y1nbhLNsaiaYugWHe29EFZF5ZH/AVdA422Ns OXng== X-Gm-Message-State: AOJu0YwhYeMgUMjZv1+Zfcpb4tccGWyOG52WGUEECcIM/8UR5j+xZ/xF hqkumOIjQXQgC29sYVKxVWVwc3j+xgphbd2dMJWTjnc57cB9sLBd1f6HqvbucrY= X-Received: by 2002:a05:6402:40cd:b0:5be:f1a7:c2cd with SMTP id 4fb4d7f45d1cf-5c3e974b43fmr11967582a12.31.1725977259898; Tue, 10 Sep 2024 07:07:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424dasm4338661a12.9.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5342A5FA0E; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 07/26] tests/guest-debug: Support passing arguments to the GDB test script Date: Tue, 10 Sep 2024 15:07:14 +0100 Message-Id: <20240910140733.4007719-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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=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: Gustavo Romero This commit adds support for passing arguments to the GDB test scripts so it's possible to parse the args in an "argparse way" in the test scripts launched by the runner. The arguments should be preceded by -- when passed to the runner. For example, passing "--help" arg to the GDB_TEST_SCRIPT: run-test.py [...] --test -- --help The test script should not use the argparse module directly but import arg_parser from test_gdbstub module. arg_parser then can be used just like the argparse.ArgumentParser class: from test_gdbstub import arg_parser p = arg_parser(prog="test-mytest.py", description="My test.") p.add_argument("--vowel", help="Select vowel", required=True, choices=['a','e','i','o','u']) [...] The arg_parser allows a smooth and informative exit if, for instance, the caller of the runner script passes an invalid argument or misses a required argument by the test script. Signed-off-by: Gustavo Romero Reviewed-by: Alex Bennée Message-Id: <20240906143316.657436-4-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée --- tests/guest-debug/run-test.py | 6 ++++++ tests/guest-debug/test_gdbstub.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 368ff8a890..5a091db8be 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -27,6 +27,10 @@ def get_args(): parser.add_argument("--binary", help="Binary to debug", required=True) parser.add_argument("--test", help="GDB test script") + parser.add_argument('test_args', nargs='*', + help="Additional args for GDB test script. " + "The args should be preceded by -- to avoid confusion " + "with flags for runner script") parser.add_argument("--gdb", help="The gdb binary to use", default=None) parser.add_argument("--gdb-args", help="Additional gdb arguments") @@ -91,6 +95,8 @@ def log(output, msg): gdb_cmd += " -ex 'target remote %s'" % (socket_name) # finally the test script itself if args.test: + if args.test_args: + gdb_cmd += f" -ex \"py sys.argv={args.test_args}\"" gdb_cmd += " -x %s" % (args.test) diff --git a/tests/guest-debug/test_gdbstub.py b/tests/guest-debug/test_gdbstub.py index 46fbf98f0c..a715c0e3f5 100644 --- a/tests/guest-debug/test_gdbstub.py +++ b/tests/guest-debug/test_gdbstub.py @@ -2,6 +2,7 @@ """ from __future__ import print_function +import argparse import gdb import os import sys @@ -9,6 +10,10 @@ fail_count = 0 +class arg_parser(argparse.ArgumentParser): + def exit(self, status=None, message=""): + print("Wrong GDB script test argument! " + message) + gdb.execute("exit 1") def report(cond, msg): """Report success/fail of a test""" From patchwork Tue Sep 10 14:07:15 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: 827001 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325110wrc; Tue, 10 Sep 2024 07:08:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUeRde9GXYUCONawC1A+MWqkFN9ikAbyYq5AibX/6RjU5ncVK5jGuFn18HDcQu5ombMHoMxFg==@linaro.org X-Google-Smtp-Source: AGHT+IG20tMgT+MlMZZJnhziBmHSMHMIit7xwqDghJirCWDc5XRuNKZlTtBQ0fxL0sP/+J235APM X-Received: by 2002:a25:ae61:0:b0:e1d:3f80:2273 with SMTP id 3f1490d57ef6-e1d3f8024e0mr11087106276.56.1725977292065; Tue, 10 Sep 2024 07:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977292; cv=none; d=google.com; s=arc-20240605; b=QCoGeYXmaj2qNzKsmkivnT9qPa24mHM5Qccw6Jk5Ebg0fwlzkAPyWfTBOEx7hNks5D ppj8smTRvR0BmAOU12sww7c1px6TGEZ2kmpP7Yg0wkeVKBz/4aDW13UD67tAKmhLTgaR ZDt2V+0E1g6SVgfn9tlCjfboO8VYrpD0oWFt8M7ES8goPXC8RrAYFPipgjraGq6ENYly PbWqbkuq1ZaZBJpARQICw/gRoxVs/SJ/xSdY4VOGH1BEN8LNZ0O4umh2RwZJk5R9G7f+ ClwXc2EDUkOW/9dXRL7CBWUW6zKg0BUMu6kaVJMhMppZgG4HI68cF+hUEOxIkrWAUCaq wncg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Y9b0lTkZojj9hYO/C00YAyDV7juvCe44sJPqhBOockE=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=XoWgGV844ie+W5JDwky4P34h0lXMf6cFxdWWXIdt0ItxBdqOB5YghsSJGnJi9UOcAg TUvrGShsvLsl4Tdynb/CY/ojBGtSr2eUHSqKVar/9ijdX69OpnFJNqM0B7rmM8tPqq1u bUgoWUXlUb1eMDkrZX5qedXCWgCjbpoJt7D69FJ4DW9e8rZsfU7bpF92qIG2dZ1ONSl1 wIY4/woe3+VV4qitSg345OUH0X3WNvWDoSZzHcfXJqABPLLMso+kpBCgaJUjNGMgPAAl 4uZVPg5OcSMN/qG8C2bZX4h8Z8d1iJ6OpZurd5V5WZ/cwhJPZW/hjdz4FEl1jYURvvhi P6Bg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IP0zdsKX; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bc0ce64si1010691276.573.2024.09.10.07.08.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:12 -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=IP0zdsKX; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X0-0007g4-3J; Tue, 10 Sep 2024 10:07:46 -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 1so1Wy-0007Zo-Is for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:44 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wv-0006Uy-CD for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:44 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8a7596b7dfso23608466b.0 for ; Tue, 10 Sep 2024 07:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977260; x=1726582060; 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=Y9b0lTkZojj9hYO/C00YAyDV7juvCe44sJPqhBOockE=; b=IP0zdsKXM8qmWnxqNvsEX8q72HmDyZ5gd27QDb+PUxbsyf+Bgx2ZTVRAIlEgSq2Bl+ uFmicV5otAjQJYSjw8lBEUIx6DLLJ/OifYMI0p5nmOctXF/liE1tBBgvy4Ege4sAKCi+ TJSnIPROO3elzi8sJxqvsfYWQX1IXNUb0lnIHFPGYIuTiaIqxVMkQOr+AiZIfNeE0yN9 eY3jKEdjvmEbFs66DJ3ygfy6K7Uhb880B6LGE2QScb18xDJ4ggqrRcNCRP4aqXVQMFRg 1S8laBR9vItebm+BiTKlWQER1lY9IgHPXkZ9GumD52Y1ZIgOYNjULo/GWOdKqsN8ACGZ nXxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977260; x=1726582060; 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=Y9b0lTkZojj9hYO/C00YAyDV7juvCe44sJPqhBOockE=; b=E44kCbGBEfaudqVKQf4hCWKPMIMHbxSQOUr99kL10wR8uIBLFuSNcKyGfDfBRSlf3e OfGnkld7szuL2fh1M4zsid7qWQKfDJf+0lI76xY23xRL7tnM3RF6HTUS84DRY5iej9pE wowkqSR67ke+HY5ZS40oZMe1QwSCXI9yD2rgH73/eeI6yTfER088+ZI0YQt0tIIRhFab c2A7+U7B7quH4zKyG9U1/XippJ4Z9UYzrmss0xe0YrcfpqMkpfERzyrLGuL8i3ioll4I 1F79oWBgQzDLVx8330yGziPMWqAJLHvG47epG63Dtbc0slA4cUMxZSrD/A1voAO3mc4g TEkw== X-Gm-Message-State: AOJu0Yy9V5AtohGhmORDIl7SOtyvVDvDS/CQ06xvfBeAt2kcSV0auDKr JeuLsyl0+4tNYtkKEwm43/D1aNONwHmfKG5TfiNj35WVOyhorZ8Fp8Gb44jfCgM= X-Received: by 2002:a17:907:25c6:b0:a8a:8dd3:f135 with SMTP id a640c23a62f3a-a8ffab79894mr108768366b.14.1725977259513; Tue, 10 Sep 2024 07:07:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25835a76sm487586366b.39.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 69F825FA11; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 08/26] tests/tcg/aarch64: Improve linker script organization Date: Tue, 10 Sep 2024 15:07:15 +0100 Message-Id: <20240910140733.4007719-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero Improve kernel.ld linker script organization by using MEMORY command. Signed-off-by: Richard Henderson Signed-off-by: Gustavo Romero Message-Id: <20240906143316.657436-5-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée --- tests/tcg/aarch64/system/kernel.ld | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/tcg/aarch64/system/kernel.ld b/tests/tcg/aarch64/system/kernel.ld index 7b3a76dcbf..5f39258d32 100644 --- a/tests/tcg/aarch64/system/kernel.ld +++ b/tests/tcg/aarch64/system/kernel.ld @@ -1,23 +1,23 @@ ENTRY(__start) -SECTIONS -{ - /* virt machine, RAM starts at 1gb */ - . = (1 << 30); +MEMORY { + /* On virt machine RAM starts at 1 GiB. */ + + /* Align text and rodata to the 1st 2 MiB chunk. */ + TXT (rx) : ORIGIN = 1 << 30, LENGTH = 2M + /* Align r/w data to the 2nd 2 MiB chunk. */ + DAT (rw) : ORIGIN = (1 << 30) + 2M, LENGTH = 2M +} + +SECTIONS { .text : { *(.text) - } - .rodata : { *(.rodata) - } - /* align r/w section to next 2mb */ - . = ALIGN(1 << 21); + } >TXT .data : { *(.data) - } - .bss : { *(.bss) - } + } >DAT /DISCARD/ : { *(.ARM.attributes) } From patchwork Tue Sep 10 14:07:16 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: 827011 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326289wrc; Tue, 10 Sep 2024 07:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVA+4dPY0tpIYyEh7VSFy+pe8gY2785jm1NXlGoQrC+TPVmn6IMvJT2Imgj6n8yLHEgX7Z7pw==@linaro.org X-Google-Smtp-Source: AGHT+IGyakooJOpB6MQju/MyJ0MUeFWg+Il4vFR55SAT/bxHCMRWkXASHrRLShijB0G8stGbxRR6 X-Received: by 2002:a05:620a:c51:b0:7a2:c13:458d with SMTP id af79cd13be357-7a9a38a72fcmr1805303085a.42.1725977400354; Tue, 10 Sep 2024 07:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977400; cv=none; d=google.com; s=arc-20240605; b=DAcxSFT7ySqazMG2hTTjZ9tF09izSlmFRTGFzzm5+YerbBdxdvbDiKeKpnFNhnc8u1 3R7L+5I5ZiMFdUBdkyUr2wSnNwfoqIxAnkg+XS9N0g1BgqMkAIGBM1oMTvb32YhV4MGe 4o2DJXfOerMupRHTJdJ69ANtuDSrBX3MRWiCL8xLSbWwYQXQYErfERT+Qqq3VUZ3WRRY /wTI3K7iocE/2KdzW/jRngIBdVoo/bY8DrS0QCtHN4Zlp381tQMJn4iiN4TVGlPpNdoy CpScpL1gZ+o6Qk0KDfmNANMPWIW/PbxsezmY8YFHtTSFaqpxV6t0xc75CQ7V6ZT3WnTS cZ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=8lUubg39HWYdaIBsvXY2XTeRzXHTolhDbI/MSB6QBok=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=lTgsEV0hAosl8ROPe2nJ50MCybFtn1O/XUsb/g6ggtpBVAflES+6PD/Qhs7XxUJD7k lw3L5l/V3WWbd0ZFeX2cZjvoms5CqqpKTmgIN2clB3JplAh5nVMBsc2y60kss7rxkz3Z Ivg8JxAP3ryZe1jlt8K+q98f1MVlEqht8KNKcn8kGZ4U0gx7VfvTgoH2R2a7iq7/Mmb1 z3TQy7qgnCU6z2OgfuVIUBLL/Wh/xJdzvPC9nAlsb0hcv+m1G/gikSuMysMFpr8HNvUi 3DaLv6iZvDLXk3XcyDPKydM82x8LpOnHmOi4cGAPAgM7fYBade70wcmPRPr5tvS6cDfM 1GOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A/UWltSE"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45822fb02c6si81313021cf.600.2024.09.10.07.09.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:10: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="A/UWltSE"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X2-0007tO-Vh; Tue, 10 Sep 2024 10:07:49 -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 1so1X1-0007mn-ER for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:47 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wy-0006W6-0d for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:47 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a8a7b1c2f2bso133659766b.0 for ; Tue, 10 Sep 2024 07:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977262; x=1726582062; 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=8lUubg39HWYdaIBsvXY2XTeRzXHTolhDbI/MSB6QBok=; b=A/UWltSELuA4p82wdpPH1i4OTwbY+3mtI0vKjqge/gI1BlbGq5HV6NtqimZSEZ8jD5 FbbfIQThTBDrpk06gdUI3PW27VEzEYklrjEBTy+wwvFRX2lPaOB2y83bNeimGu8NoKH7 UroymOfh+CGRnAqIqRq9IIdwRGHHtA/ziLypWCfiKFadtRx+bMrWVqs1Nao1c+7Ilctn 0Sbaf6Arm27XPXFslDEH5eTHkrVKuxfpFqjuCmzn8mrLs7oyTseAEVmXHBWtttPFbG6r BVfa8Uf+U7SC8b8GiTOQWUqOPrpZHrhjpxAMmXLw5E/DXZEHCbH+cCR8WUL5r9qMnV9v 0p3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977262; x=1726582062; 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=8lUubg39HWYdaIBsvXY2XTeRzXHTolhDbI/MSB6QBok=; b=usEBvmHepIqnDDpQ3PkXRK+MeV1fWsVDi06w1I9O4vds7chCosQDb75LkfAS2NX8iP F9lE5dwqi1339jWV+OdXTOOaAQMr60gTnVud8JoaSnfbrSY6XaFdk82nVvKPhqMlgZXp cL/FlLrOGKgWtmEjngB83X58kUicbCBOtadc+cw5d3QFNCHX76n5IxpuH0lliltD6ylK HNBRylnyqKT6O/z0Z50Lol6gmSYnPg90LH4ePLQykKGjM8wOERJt5b+cfRdb6xMef2D+ mF4WSC6XTZTE93hDOLPhztb6mfBJ0aFL8DV9MdQl+ho3Lqjti8UUoh+WLXO8c0Rs7Tvv /TyQ== X-Gm-Message-State: AOJu0Yzz+hnT/cDN41tCOqbpgsEz3xDG2wjR1I0xmti+8S1aLKNTIL4o SeICiKnAysOmzoH0Xj88meRRkn505z/z6Y0ARZ2IiKTUBUYJyc+4vfEvV80Cfa0= X-Received: by 2002:a17:907:3d8b:b0:a8a:7501:de39 with SMTP id a640c23a62f3a-a8ffaab0216mr71778666b.9.1725977262218; Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c62485sm485443566b.104.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 876F25FA14; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 09/26] tests/tcg/aarch64: Extend MTE gdbstub tests to system mode Date: Tue, 10 Sep 2024 15:07:16 +0100 Message-Id: <20240910140733.4007719-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62e.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=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: Gustavo Romero Extend MTE gdbstub tests to also run in system mode (share tests between user mode and system mode). The tests will only run if a version of GDB that supports MTE on baremetal is available in the test environment and if available compiler supports the 'memtag' flag (-march=armv8.5-a+memtag). For the tests running in system mode, a page that supports MTE ops. is necessary. Therefore, an MTE-enabled page is made available (mapped) in the third 2 MB chunk of the second 1 GB space in the flat mapping set in boot.S. A new binary, mte.S, is also introduced for the tests. It links against boot.S and is executed by QEMU in system mode. Signed-off-by: Gustavo Romero Message-Id: <20240906143316.657436-6-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée --- configure | 5 + tests/tcg/aarch64/Makefile.softmmu-target | 49 +++++++++- tests/tcg/aarch64/Makefile.target | 3 +- tests/tcg/aarch64/gdbstub/test-mte.py | 71 +++++++++----- tests/tcg/aarch64/system/boot.S | 11 +++ tests/tcg/aarch64/system/kernel.ld | 9 ++ tests/tcg/aarch64/system/mte.S | 109 ++++++++++++++++++++++ 7 files changed, 229 insertions(+), 28 deletions(-) create mode 100644 tests/tcg/aarch64/system/mte.S diff --git a/configure b/configure index d08b71f14b..40186d865e 100755 --- a/configure +++ b/configure @@ -1679,6 +1679,11 @@ for target in $target_list; do echo "GDB_HAS_MTE=y" >> $config_target_mak fi + if test "${gdb_arches#*aarch64}" != "$gdb_arches" && version_ge $gdb_version 16.0; then + # GDB has to support MTE in baremetal to allow debugging MTE in QEMU system mode + echo "GDB_SUPPORTS_MTE_IN_BAREMETAL=y" >> $config_target_mak + fi + echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs tcg_tests_targets="$tcg_tests_targets $target" fi diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target index 139e04d15f..59ee662cda 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -2,14 +2,22 @@ # Aarch64 system tests # -AARCH64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/aarch64/system +AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 +AARCH64_SYSTEM_SRC=$(AARCH64_SRC)/system + VPATH+=$(AARCH64_SYSTEM_SRC) # These objects provide the basic boot code and helper functions for all tests CRT_OBJS=boot.o -AARCH64_TEST_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c) -AARCH64_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_SRCS)) +AARCH64_TEST_C_SRCS_=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c) +AARCH64_TEST_S_SRCS=$(AARCH64_SYSTEM_SRC)/mte.S + +AARCH64_C_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_C_SRCS)) +AARCH64_S_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.S, %, $(AARCH64_TEST_S_SRCS)) + +AARCH64_TESTS = $(AARCH64_C_TESTS) +AARCH64_TESTS += $(AARCH64_S_TESTS) CRT_PATH=$(AARCH64_SYSTEM_SRC) LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld @@ -21,7 +29,8 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc config-cc.mak: Makefile $(quiet-@)( \ - $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3)) 3> config-cc.mak + $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \ + $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak -include config-cc.mak # building head blobs @@ -88,3 +97,35 @@ pauth-3: run-pauth-3: $(call skip-test, "RUN of pauth-3", "not built") endif + +ifneq ($(CROSS_CC_HAS_ARMV8_MTE),) +QEMU_MTE_ENABLED_MACHINE=-M virt,mte=on -cpu max -display none +QEMU_OPTS_WITH_MTE_ON = $(QEMU_MTE_ENABLED_MACHINE) $(QEMU_BASE_ARGS) -kernel +mte: CFLAGS+=-march=armv8.5-a+memtag +mte: mte.S $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +run-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON) +run-mte: mte + +ifeq ($(GDB_SUPPORTS_MTE_IN_BAREMETAL),y) +run-gdbstub-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON) +run-gdbstub-mte: mte + $(call run-test, $@, $(GDB_SCRIPT) \ + --output run-gdbstub-mte.out \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "-chardev null$(COMMA)id=output $(QEMU_OPTS)" \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-mte.py -- --mode=system, \ + gdbstub MTE support) + +EXTRA_RUNS += run-gdbstub-mte +else # !GDB_SUPPORTS_MTE_IN_BAREMETAL +run-gdbstub-mte: + $(call skip-test "RUN of gdbstub-mte", "GDB does not support MTE in baremetal!") +endif +else # !CROSS_CC_HAS_ARMV8_MTE +mte: + $(call skip-test, "BUILD of $@", "missing compiler support") +run-mte: + $(call skip-test, "RUN of mte", "not build") +endif diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 8cc62eb456..9efe2f81ad 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -138,7 +138,8 @@ run-gdbstub-mte: mte-8 $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(GDB) \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ - --bin $< --test $(AARCH64_SRC)/gdbstub/test-mte.py, \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-mte.py \ + -- --mode=user, \ gdbstub MTE support) EXTRA_RUNS += run-gdbstub-mte diff --git a/tests/tcg/aarch64/gdbstub/test-mte.py b/tests/tcg/aarch64/gdbstub/test-mte.py index 66f9c25f8a..a4cae6caa0 100644 --- a/tests/tcg/aarch64/gdbstub/test-mte.py +++ b/tests/tcg/aarch64/gdbstub/test-mte.py @@ -1,21 +1,26 @@ from __future__ import print_function # # Test GDB memory-tag commands that exercise the stubs for the qIsAddressTagged, -# qMemTag, and QMemTag packets. Logical tag-only commands rely on local -# operations, hence don't exercise any stub. +# qMemTag, and QMemTag packets, which are used for manipulating allocation tags. +# Logical tags-related commands rely on local operations, hence don't exercise +# any stub and so are not used in this test. # -# The test consists in breaking just after a atag() call (which sets the -# allocation tag -- see mte-8.c for details) and setting/getting tags in -# different memory locations and ranges starting at the address of the array -# 'a'. +# The test consists in breaking just after a tag is set in a specific memory +# chunk, and then using the GDB 'memory-tagging' subcommands to set/get tags in +# different memory locations and ranges in the MTE-enabled memory chunk. # # This is launched via tests/guest-debug/run-test.py # -import gdb +try: + import gdb +except ModuleNotFoundError: + from sys import exit + exit("This script must be launched via tests/guest-debug/run-test.py!") import re -from test_gdbstub import main, report +from sys import argv +from test_gdbstub import arg_parser, main, report PATTERN_0 = "Memory tags for address 0x[0-9a-f]+ match \\(0x[0-9a-f]+\\)." @@ -23,12 +28,32 @@ def run_test(): - gdb.execute("break 95", False, True) + p = arg_parser(prog="test-mte.py", description="TCG MTE tests.") + p.add_argument("--mode", help="Run test for QEMU system or user mode.", + required=True, choices=['system','user']) + + args = p.parse_args(args=argv) + + if args.mode == "system": + # Break address: where to break before performing the tests + # See mte.S for details about this label. + ba = "main_end" + # Tagged address: the start of the MTE-enabled memory chunk to be tested + # 'tagged_addr' (x1) is a pointer to the MTE-enabled page. See mte.S. + ta = "$x1" + else: # mode="user" + # Line 95 in mte-8.c + ba = "95" + # 'a' array. See mte-8.c + ta = "a" + + gdb.execute(f"break {ba}", False, True) gdb.execute("continue", False, True) + try: - # Test if we can check correctly that the allocation tag for - # array 'a' matches the logical tag after atag() is called. - co = gdb.execute("memory-tag check a", False, True) + # Test if we can check correctly that the allocation tag for the address + # in {ta} matches the logical tag in {ta}. + co = gdb.execute(f"memory-tag check {ta}", False, True) tags_match = re.findall(PATTERN_0, co, re.MULTILINE) if tags_match: report(True, f"{tags_match[0]}") @@ -39,20 +64,20 @@ def run_test(): # tags rely on local operation and so don't exercise any stub. # Set the allocation tag for the first granule (16 bytes) of - # address starting at 'a' address to a known value, i.e. 0x04. - gdb.execute("memory-tag set-allocation-tag a 1 04", False, True) + # address starting at {ta} address to a known value, i.e. 0x04. + gdb.execute(f"memory-tag set-allocation-tag {ta} 1 04", False, True) # Then set the allocation tag for the second granule to a known # value, i.e. 0x06. This tests that contiguous tag granules are - # set correct and don't run over each other. - gdb.execute("memory-tag set-allocation-tag a+16 1 06", False, True) + # set correctly and don't run over each other. + gdb.execute(f"memory-tag set-allocation-tag {ta}+16 1 06", False, True) # Read the known values back and check if they remain the same. - co = gdb.execute("memory-tag print-allocation-tag a", False, True) + co = gdb.execute(f"memory-tag print-allocation-tag {ta}", False, True) first_tag = re.match(PATTERN_1, co)[1] - co = gdb.execute("memory-tag print-allocation-tag a+16", False, True) + co = gdb.execute(f"memory-tag print-allocation-tag {ta}+16", False, True) second_tag = re.match(PATTERN_1, co)[1] if first_tag == "0x4" and second_tag == "0x6": @@ -61,15 +86,15 @@ def run_test(): report(False, "Can't set/print allocation tags!") # Now test fill pattern by setting a whole page with a pattern. - gdb.execute("memory-tag set-allocation-tag a 4096 0a0b", False, True) + gdb.execute(f"memory-tag set-allocation-tag {ta} 4096 0a0b", False, True) # And read back the tags of the last two granules in page so # we also test if the pattern is set correctly up to the end of # the page. - co = gdb.execute("memory-tag print-allocation-tag a+4096-32", False, True) + co = gdb.execute(f"memory-tag print-allocation-tag {ta}+4096-32", False, True) tag = re.match(PATTERN_1, co)[1] - co = gdb.execute("memory-tag print-allocation-tag a+4096-16", False, True) + co = gdb.execute(f"memory-tag print-allocation-tag {ta}+4096-16", False, True) last_tag = re.match(PATTERN_1, co)[1] if tag == "0xa" and last_tag == "0xb": @@ -78,8 +103,8 @@ def run_test(): report(False, "Fill pattern failed!") except gdb.error: - # This usually happens because a GDB version that does not - # support memory tagging was used to run the test. + # This usually happens because a GDB version that does not support + # memory tagging was used to run the test. report(False, "'memory-tag' command failed!") diff --git a/tests/tcg/aarch64/system/boot.S b/tests/tcg/aarch64/system/boot.S index 501685d0ec..4eb1b35b88 100644 --- a/tests/tcg/aarch64/system/boot.S +++ b/tests/tcg/aarch64/system/boot.S @@ -135,6 +135,17 @@ __start: orr x1, x1, x3 str x1, [x2] /* 2nd 2mb (.data & .bss)*/ + /* Third block: at 'mte_page', set in kernel.ld */ + adrp x1, mte_page + add x1, x1, :lo12:mte_page + bic x1, x1, #(1 << 21) - 1 + and x4, x1, x5 + add x2, x0, x4, lsr #(21 - 3) + /* attr(AF, NX, block, AttrIndx=Attr1) */ + ldr x3, =(3 << 53) | 0x401 | (1 << 2) + orr x1, x1, x3 + str x1, [x2] + /* Setup/enable the MMU. */ /* diff --git a/tests/tcg/aarch64/system/kernel.ld b/tests/tcg/aarch64/system/kernel.ld index 5f39258d32..aef043e31d 100644 --- a/tests/tcg/aarch64/system/kernel.ld +++ b/tests/tcg/aarch64/system/kernel.ld @@ -7,6 +7,8 @@ MEMORY { TXT (rx) : ORIGIN = 1 << 30, LENGTH = 2M /* Align r/w data to the 2nd 2 MiB chunk. */ DAT (rw) : ORIGIN = (1 << 30) + 2M, LENGTH = 2M + /* Align the MTE-enabled page to the 3rd 2 MiB chunk. */ + TAG (rw) : ORIGIN = (1 << 30) + 4M, LENGTH = 2M } SECTIONS { @@ -18,6 +20,13 @@ SECTIONS { *(.data) *(.bss) } >DAT + .tag : { + /* + * Symbol 'mte_page' is used in boot.S to setup the PTE and in the mte.S + * test as the address that the MTE instructions operate on. + */ + mte_page = .; + } >TAG /DISCARD/ : { *(.ARM.attributes) } diff --git a/tests/tcg/aarch64/system/mte.S b/tests/tcg/aarch64/system/mte.S new file mode 100644 index 0000000000..b611240a95 --- /dev/null +++ b/tests/tcg/aarch64/system/mte.S @@ -0,0 +1,109 @@ +/* + * Code to help test the MTE gdbstubs in system mode. + * + * Copyright (c) 2024 Linaro Limited + * + * Author: Gustavo Romero + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#define addr x0 /* Ptr to the start of the MTE-enabled page. */ +#define tagged_addr x1 /* 'addr' ptr with a random-generated tag added. */ +#define tmp0 x2 /* Scratch register. */ +#define tmp1 x3 /* Scratch register. */ +#define tmp2 x4 /* Scratch register. */ +#define tmp3 x5 /* Sctatch register. */ + + .file "mte.S" + + .text + .align 4 + + .globl main + .type main, @function + +main: + /* + * Set MAIR_EL1 (Memory Attribute Index Register). In boot.S, the + * attribute index for .mte_page is set to point to MAILR_EL field Attr1 + * (AttrIndx=Attr1), so set Attr1 as Tagged Normal (MTE) to enable MTE + * on this page. + * + * Attr1 = 0xF0 => Tagged Normal (MTE) + */ + mrs tmp0, mair_el1 + orr tmp0, tmp0, (0xF0 << 8) + msr mair_el1, tmp0 + + /* + * Set TCR_EL1 (Translation Control Registers) to ignore the top byte + * in the translated addresses so it can be used to keep the tags. + * + * TBI0[37] = 0b1 => Top Byte ignored and used for tagged addresses + */ + mrs tmp1, tcr_el1 + orr tmp1, tmp1, (1 << 37) + msr tcr_el1, tmp1 + + /* + * Set SCTLR_EL1 (System Control Register) to enable the use of MTE + * insns., like stg & friends, and to enable synchronous exception in + * case of a tag mismatch, i.e., when the logical tag in 'tagged_addr' + * is different from the allocation tag related to 'addr' address. + * + * ATA[43] = 0b1 => Enable access to allocation tags at EL1 + * TCF[41:40] = 0b01 => Tag Check Faults cause a synchronous exception + * + */ + mrs tmp2, sctlr_el1 + mov tmp3, (1 << 43) | (1 << 40) + orr tmp2, tmp2, tmp3 + msr sctlr_el1, tmp2 + + isb + + /* + * MTE-enabled page resides at the 3rd 2MB chunk in the second 1GB + * block, i.e., at 0x40400000 address. See .mte_page section in boot.S + * and kernel.ld (where the address is effectively computed). + * + * Load .mte_page address into 'addr' register. + */ + adrp addr, mte_page + add addr, addr, :lo12:mte_page + + /* + * Set GCR for random tag generation. 0xA5 is just a random value to set + * GCR != 0 so the tag generated by 'irg' insn. is not zero, which is + * more interesting for the tests than when tag is zero. + */ + mov tmp0, 0xA5 + msr gcr_el1, tmp0 + + /* + * Generate a logical tag, add it to 'addr' address and put it into + * 'tagged_addr'. + */ + irg tagged_addr, addr + + /* + * Store the generated tag to memory region pointed to by 'addr', i.e. + * set the allocation tag for granule at 'addr'. The tag is extracted + * by stg from tagged_addr pointer. + */ + stg tagged_addr, [addr] + + /* + * Store a random value (0xdeadbeef) to tagged_addr address. This must + * not cause any Tag Check Fault since logical tag in tagged_addr and + * allocation tag associated with the memory pointed by tagged_addr are + * set the same, otherwise something is off and the test fails -- an + * exception is generated. + */ + ldr tmp1, =0xdeadbeef + str tmp1, [tagged_addr] + + /* This label is used by GDB Python script test-mte.py. */ +main_end: + ret From patchwork Tue Sep 10 14:07:17 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: 827014 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326861wrc; Tue, 10 Sep 2024 07:10:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJHBb1BLA83B/8/w/y422qORRK8nfNvCiWV8T9ffo2E+dSSsSzX8dYUvp/J4ZtobxruBi2aQ==@linaro.org X-Google-Smtp-Source: AGHT+IEJswZP7NvSUv4IBBm2ktqG7ia8l/oa4k6vrn1ljtbuoPCleRJGd7LGwehhr3zgWklWPumO X-Received: by 2002:a05:6902:168a:b0:e16:4dc7:aacb with SMTP id 3f1490d57ef6-e1d34884adcmr17572858276.23.1725977452633; Tue, 10 Sep 2024 07:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977452; cv=none; d=google.com; s=arc-20240605; b=f9eELAhgD0Q8nSQ7TYxEuJQeFaEN+id/rqa0faK4sPVpBEjCidqN8F1jrA7T9CgY1I mK/ULUlQU8QCoN8siorFVq/+Tqv320//+lqIoKXk709oW30mIbxytHwHJm0r33p2DF70 jFcITY9SjHTXoZxGgN+CK+PP/d9msdoADqGwuE5fhMRi3GVbDqKtJYTJAYtr6iIyUTXm QzghIaC53ZjJO1luVwadMg+ROCltuan0L8AKJQQ6bk/IhthsNfdzLJXFAqTv0GWf7yFz W//h0VbYC0KRi01++NSmKzyrK0hjmlL+octbyShFbtsm/axkFKbxmGCU9n43GiKPUUr4 KTZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=IsUfGT83ExXUAJJQLptvfbG4vLgQieFEBjde6vtierM=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=F4IEA2GcPLTZlrMpYQbUxfKWgPItnjkBx8awC86CnSX6wF3ouM5NYGKYFUANLj/q11 8SLGmk70qUoW5nw9uDwEW9coAyjKa96N88MPqjegMLXjEdkUdE0c2O+slVEfUm6n/X3X sSFjFW73mDA9voXHhFdFtkFb5p0G/Y8g3jv+b1QY5S4RALCiUjHtB/r+6UIYaEpYLqv4 yUmp04PKmQ622xlXo/BAhDmfZzIIuaL+8VKJBTk0VzgUp8WlIj63HzW49JeDBtzSLOpB VW6lhMXr8xXcS8sHGPgqihZ6GxcHsY7k7ZDUIy/u87JkPcG1rnhVBwGADfOz8cUdV+hV 13jA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cpOwIF5V; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7b9df9a5si1075222276.17.2024.09.10.07.10.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:10:52 -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=cpOwIF5V; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X3-0007ug-7a; Tue, 10 Sep 2024 10:07:49 -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 1so1X1-0007m2-9s for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:47 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1Wy-0006Wc-WB for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:47 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a83562f9be9so78615366b.0 for ; Tue, 10 Sep 2024 07:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977263; x=1726582063; 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=IsUfGT83ExXUAJJQLptvfbG4vLgQieFEBjde6vtierM=; b=cpOwIF5V2sARfRaaezi3XfCe2bohmIJkXVv8rh4pP1fHmdEXoVWWgT/LJSW61fcahV /jsIxQ2hvC2zmKF0zasnwuSz8fWE86Aku6wwRj5Yd2KqMzsXf7RhxaiXm/K5d18+Uk3I Dycc1hxLk8drz4zFshMH2VPvw2YrBzWgO58zqrnQt1wPnDBsDyv7z3gXTW7zoUuVDmQP SaRPwLklJ4yAp22R27odcak1/7/uJEs/2b+5G6/8SlVSWOc3qS8kjNvRGzAXiI/RdWCE St56dzfg+8RttEqjc43wQgiAIKZsBiwVg2LJmOF8RjC0NI1imG3HSuwZWk8TWJiSvnY3 89VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977263; x=1726582063; 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=IsUfGT83ExXUAJJQLptvfbG4vLgQieFEBjde6vtierM=; b=Re2/9xl5IMTsgNkefT7sjhHq3uE/3WoL9Il1QSoFNvUZDnevSeiI90a4inf4/z8Lly y3fUZpo9Srm1vRJoxDHE0uOeK8uu1GIQbtHG0g2xdFuqmPrL/jh3DGuaL8Qc7zLV7Bcb Y6z+Z/ltzRfKoF7r1xpz+IOorDZAdTAzeIZ3T/Bt04v4v7rCqGzxzD/zSXLLJtQDYiDj crf0qYhiCT5Azt0cxTpjHjIym8RTRzXrpgkPaIytnFLndmqOTGpzP3RW3dnR3UbwmuwA eQL/GZGu48gJVpeAsdcgDnQD4fQmqDCZoTi7WSr9zqrHj5MjBkIEgh4bsApmnL+J98zW La5w== X-Gm-Message-State: AOJu0YxW1osMYCreM8k7mGqpbPMgpnYp8LvjY4JyzlvRc7NcEDe/YSPJ K9Bb2c/x7TWGKzfnOsMkiJPZ8Zz+et6Ua+u/lhx1DLqaB4N0wddmOY0rwNirXuA= X-Received: by 2002:a17:906:7949:b0:a86:80ef:4fe5 with SMTP id a640c23a62f3a-a8ffadece87mr102318566b.47.1725977263302; Tue, 10 Sep 2024 07:07:43 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25a2c441sm487354166b.90.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:40 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A0FFB5FA18; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 10/26] contrib/plugins/Makefile: Add a 'distclean' target Date: Tue, 10 Sep 2024 15:07:17 +0100 Message-Id: <20240910140733.4007719-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Thomas Huth Running "make distclean" in the build tree currently fails since this tries to run the "distclean" target in the contrib/plugins/ folder, too, but the Makefile there is missing this target. Thus add 'distclean' there to fix this issue. And to avoid regressions with "make distclean", add this command to one of the build jobs, too. Signed-off-by: Thomas Huth Reviewed-by: Pierrick Bouvier Message-Id: <20240902154749.73876-1-thuth@redhat.com> Signed-off-by: Alex Bennée --- .gitlab-ci.d/buildtest.yml | 2 ++ contrib/plugins/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 1d2afae996..8bc67ef7e9 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -345,6 +345,8 @@ build-tcg-disabled: 124 132 139 142 144 145 151 152 155 157 165 194 196 200 202 208 209 216 218 227 234 246 247 248 250 254 255 257 258 260 261 262 263 264 270 272 273 277 279 image-fleecing + - cd ../.. + - make distclean build-user: extends: .native_build_job_template diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index edf256cd9d..05a2a45c5c 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -77,7 +77,7 @@ lib%$(SO_SUFFIX): %.o endif -clean: +clean distclean: rm -f *.o *$(SO_SUFFIX) *.d rm -Rf .libs From patchwork Tue Sep 10 14:07: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: 827015 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326913wrc; Tue, 10 Sep 2024 07:11:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWKSMIuYNmE73jyz1G6OqB1SjPEyhEa/hE8BzzOSw7kFG3A8S6eYia0MRBJPVtuJqDtBcnMOg==@linaro.org X-Google-Smtp-Source: AGHT+IGXMPBB5oCzcqTZbmYPjTPqfDFi4EkHBrY6wAW3kFs2DUAhbciohFNH3Seng5f6m+yk2f55 X-Received: by 2002:ac8:7dd1:0:b0:458:4772:44f6 with SMTP id d75a77b69052e-45847724726mr21503971cf.59.1725977460733; Tue, 10 Sep 2024 07:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977460; cv=none; d=google.com; s=arc-20240605; b=DCKB1PwzgXvwyvOvFA6yoxp6TqJuH3uLog/XosbR4NVp8Hx+t62cgPt6IU8hPT0s6c urLBSOaNz7U2QYJknjDRJ+Pa8ecqp+N1KZSKG66HIDQGJS4i4oMI4yUIYOH8O70wn7+I btSAUJDztm2Yk+ijK3g0Jvb1V0UKUH+T6oD5UOuuDlCNfEGCF+iaoMccSHYIabOxDIeW veqvGeZIvoH1UGX6R+1myLvV6WTTSt5GqnCRki+AwhzHs1TiOnUCXu1FAETIN7NBfo70 XqNrd4ogJr0gF8JskHzGWTShEQFFtKnRtDPA/NQC3p4ZmJ3/y36jp8M0spbeckgq27mB /XCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=b313DFQEs8B271qGHlfKxgFhU13Os4oo/NuzYy1RUc0=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=jR8PdSLDkDYGgPEsoQgyAgYu8xSl6uNbnN2NisWWkHDsB9IBmA7drrSuAvughoUAB3 XhsSuMMGEDIbkFY/IqHCg3WAo+UD7SvkMws3l6YRyUGDMBjZlprRj07zrirF6/OTvg2c R340blNL4nqM3kzcC8wzpw2mq9xqIUbq1aNBWdjJZajvwc9OggdAA5W6r0HbbS/G2RSZ eK5XsDdDKYisv02ImmEmY5WbYg0Yy+oq3FgxnYTv1H62jWWjXOp8tHN90uFxNjn0jACB Ox3EwxYltUaO6ssKGuS50c8dWCccXnhvzk3vTrhLAzLw2f7mC5s9dW0gWMBcUdNHf1T5 vgDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bMN4RQwD; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45822fa70efsi79181781cf.536.2024.09.10.07.11.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:11: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=bMN4RQwD; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X4-0007z4-BB; Tue, 10 Sep 2024 10:07:50 -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 1so1X2-0007sL-NH for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:48 -0400 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 1so1Wz-0006We-DB for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:48 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-53661a131b4so3723060e87.1 for ; Tue, 10 Sep 2024 07:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977263; x=1726582063; 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=b313DFQEs8B271qGHlfKxgFhU13Os4oo/NuzYy1RUc0=; b=bMN4RQwDrjOseBIGL0ppdfKoGAOQtpgLxsGZS/0Nv2mxme+/Qs8v0h1Qb4KecHwGxM oXMNW0gtDxk+Y386BX/r/cFfmkrv7wz9ilObAOTvZTuYt7KE/4SGt+fYWYdc5clPGKVi /h2gSoppokl5yqs8Tjb8PNuuGo6EG/RtftjU5hmSSrFp86x2PeEo0wTzyVNFc2a6mh7L bcJ6I9ZY4Zav8J/X8kokmRbCWD9XByNiHi8cXYTlvl5hJDwkQD2QwxYV+sCnrz4O/lqD QMUWQP3MYJDHy8fe4AtniC9p65f04jglA6s2wxiV9a1BPqvKCp9UrPOKrqqd1+aZjBBY l1+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977263; x=1726582063; 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=b313DFQEs8B271qGHlfKxgFhU13Os4oo/NuzYy1RUc0=; b=GIGNdFCGd5KNX7deNnkiDdXeYZlOUUAEtjFZs1wM1szJbqEzaOC1QXFA2gjebLP9SX JaRG8HCMlGys7cvB1yENiBUDECjbEx471h/9JuwxkldZvLKr+UTWPvCExoWtHt8X2mDz 83lPDb+AMFceG7wqmZRgflJeNgTpMPMFzmVbbLAuEmepSYtUSoqxA8D0o0zBF12pNkle Z97cesWWkJx+gxflstvLZylHMGEN1xni2MprywBg2FQ2dGY4bLjblJVjWE6f6whiIbyi mNeyGXN7Unw7SliUQpBL4jFBFa6xynWZ1moNsO3cbgpbpYfQ2/UWezrNsoF1NmmHKZzp 1eBw== X-Gm-Message-State: AOJu0YycnKPhvNLtyAUFd5EGhpTWjpIo0wND1sMka0nYkT+s885XQxcz lvn1QZS+ebNfQRiAT7WY35DIvmWedBjpAPfUQFQnI7OJlAEFpvn4NdMUjJ7EozM= X-Received: by 2002:a05:6512:398d:b0:533:4652:983a with SMTP id 2adb3069b0e04-536587cda61mr8522331e87.35.1725977262997; Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c72748sm485424066b.117.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B972C5FA1C; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 11/26] deprecation: don't enable TCG plugins by default on 32 bit hosts Date: Tue, 10 Sep 2024 15:07:18 +0100 Message-Id: <20240910140733.4007719-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> 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 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 The existing plugins already liberally use host pointer stuffing for passing user data which will fail when doing 64 bit guests on 32 bit hosts. We should discourage this by officially deprecating support and adding another nail to the 32 bit host coffin. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- v2 - don't manually set based on CPU type, use __SIZEOF_POINTER__ --- docs/about/deprecated.rst | 11 +++++++++++ configure | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 88f0f03786..f7c7c33d39 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -184,6 +184,17 @@ be an effective use of its limited resources, and thus intends to discontinue it. Since all recent x86 hardware from the past >10 years is capable of the 64-bit x86 extensions, a corresponding 64-bit OS should be used instead. +TCG Plugin support not enabled by default on 32-bit hosts (since 9.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +While it is still possible to enable TCG plugin support for 32-bit +hosts there are a number of potential pitfalls when instrumenting +64-bit guests. The plugin APIs typically pass most addresses as +uint64_t but practices like encoding that address in a host pointer +for passing as user-data will lose data. As most software analysis +benefits from having plenty of host memory it seems reasonable to +encourage users to use 64 bit builds of QEMU for analysis work +whatever targets they are instrumenting. System emulator CPUs -------------------- diff --git a/configure b/configure index 40186d865e..14581c1b9a 100755 --- a/configure +++ b/configure @@ -516,6 +516,25 @@ case "$cpu" in ;; esac +# Now we have our CPU_CFLAGS we can check if we are targeting a 32 or +# 64 bit host. + +check_64bit_host() { +cat > $TMPC < X-Patchwork-Id: 827006 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325576wrc; Tue, 10 Sep 2024 07:08:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkl5KNv9QXIwv6p3i3zk7hRdsVivQL5+wxcj0vCaQhzHdaN1/M1h9xdZl3beaZBSW1wT0Qcw==@linaro.org X-Google-Smtp-Source: AGHT+IHvFKEoDDgayTTFT52ELd80mrHCQ6y9UcsDmKbs2C0yAYbfSZvnIS6ytS46HyZVg/ZiXsk9 X-Received: by 2002:a05:620a:3951:b0:7a9:af05:79e2 with SMTP id af79cd13be357-7a9af057be3mr1578730985a.26.1725977336080; Tue, 10 Sep 2024 07:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977336; cv=none; d=google.com; s=arc-20240605; b=k0HWpD+S8vwdQ1BSQz9O/fba3GRXE+O60xthdN6J4ytw0gkACxsHcVqsOMQ8vVyXB5 aM3oLwF9HI26EEJxCWBMqbgA2tGr8UIp3YgvyL6UMuDN9hil/8ICX24YddzgB57dYvUR fZaY3OCv1zcQEK9px5YKpiQ7L8MCrXy8SWW8KKYi3sv39+sY6BdUCCRgjKEkS/tlm2s1 CusqjDMpw7GAQijR2mTJVAqDPMgAsmealcoLRhMfXpsGnWMIm3CXtGK5erabjzHVEvsN 2V1U3E0CLgF2igosp3AhkDtUeUCLkNigQCRfZIworUGGAqMQYYKXDcWNFCGzEY9jMZ2X GOjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=g4TlBd0JeT03UVw9sn8pYyZukJ9dto1YgZC+m8kda2c=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=IBRz40dmAp6eZR+ezloULlj+Bm5yynYh35RzLwEgifPHLi6pOci03SXBYqw260A2tU e0FXSwwVf7mGnaZForrqhN2R8EwvkGjYYQPE0etH28CHKsnaaoRJ6f+mV8JAzG6cSv6W hIWWNu5U8suIIrx2LDY6KDLN0iT0uB5NXbLp0g38MezO4mxEEYoNbXHbwSYDiHfFSfEV k8PHEuF/zPXc4/r3+2lE14Zf1a9QN/yagFXRSgf3WraYZcAI0EAosySwurBQDYefON+k txi7IBE0N938XsEkrGzRM3GK9E5OTPpME1yE9fBbQvwAUTi7HYZcftpWmqUqfpa3jT5k vsMg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tcNsxONH; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9ad39b24esi726844185a.655.2024.09.10.07.08.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:56 -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=tcNsxONH; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1XC-0000Cd-Qj; Tue, 10 Sep 2024 10:07: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 1so1X8-0008GK-1X for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:54 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X4-0006Yz-Nb for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:53 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8d2b4a5bf1so111545566b.2 for ; Tue, 10 Sep 2024 07:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977268; x=1726582068; 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=g4TlBd0JeT03UVw9sn8pYyZukJ9dto1YgZC+m8kda2c=; b=tcNsxONHHaJUkykjmJjolSw+9LCt8rt5KLYyP6+JoDLQZ9gPou3nN2oD87a2ot52ye BOwQuN2+tmrH4lPuZN0WdrDzypdOe3dNmm4M33rcP56w73hFATTAcwF7c/vOLzShBr5K /fl8UbiV7Nr+Bg6axe1gNFzDZjcXFXZ4J3GCjwzyE1fKPbuwyujscTJjNmSmNSl9uzs8 cRf4ypA23fo+5XVtQjU/TztuHopzGhT0zP6gahR2Ta8JUfQ8YJRIOhkuJnhuSNN+IN3x 5b4ErdgwGVQFug0DzhJNht0NM9GwENqBBT8SMon/JrZn+IcgAZWopNv5IPE7lMrnw8Zn wnVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977268; x=1726582068; 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=g4TlBd0JeT03UVw9sn8pYyZukJ9dto1YgZC+m8kda2c=; b=JL+tMtsFxP/G4BtpTM0+IQ1bUc8ZxhnhbRXxcKCimsroEat3erCA5QJIzfLrR0QVO9 rH9d2EzucZfjJEahbIzz+JQrwuhkNbC30vu8V/VfyOm+5ntCawFsFHY3cyJBJbuP5KZ4 FFmqCsxhfNKtO/L8DdlrRskRJkfyvEMH14HGPMEG9uSQsW/sMjeqpnIC3yC2YF88qIZR sJQ1DBE0UMR/QqTB+1czlhJvBqwaoSop0nh1M1AixYGns7rcKwgOLa7oiME94NE+ewfz rE1r6ktC+gVh6DBOrKsy3jdk9MRusBoMXSsZ7rMS1jDKcgwaygyCaWsW+6XprCtQcO1B uFdA== X-Gm-Message-State: AOJu0YzQVYShwpkzJZpw/aVgz5ApISphuGlAj3KLEYoR7HvCW72ZJyyQ qPGiUFBjX2KV3wFZ4lMrAVo1+0XAfUpZ7h+3GjWaAIb9NPT+j+LuVOUrQseFCK4= X-Received: by 2002:a17:907:7208:b0:a8d:2c3e:7ed3 with SMTP id a640c23a62f3a-a8ffab9752amr88481766b.35.1725977268040; Tue, 10 Sep 2024 07:07:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cf6a88sm483205466b.182.2024.09.10.07.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D55C862330; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 12/26] deprecation: don't enable TCG plugins by default with TCI Date: Tue, 10 Sep 2024 15:07:19 +0100 Message-Id: <20240910140733.4007719-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.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=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 The softmmu memory instrumentation test sees so many more accesses than a normal translated host and its really not worth fixing up. Lets deprecate this odd configuration and save on the CI cycles. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- docs/about/deprecated.rst | 8 ++++++++ configure | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index f7c7c33d39..5aa2e35314 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -196,6 +196,14 @@ benefits from having plenty of host memory it seems reasonable to encourage users to use 64 bit builds of QEMU for analysis work whatever targets they are instrumenting. +TCG Plugin support not enabled by default with TCI (since 9.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +While the TCG interpreter can interpret the TCG ops used by plugins it +is going to be so much slower it wouldn't make sense for any serious +instrumentation. Due to implementation differences there will also be +anomalies in things like memory instrumentation. + System emulator CPUs -------------------- diff --git a/configure b/configure index 14581c1b9a..1bda6b3a3b 100755 --- a/configure +++ b/configure @@ -629,6 +629,9 @@ meson_option_parse() { exit 1 fi } +has_meson_option() { + test "${meson_options#*"$1"}" != "$meson_options" +} meson_add_machine_file() { if test "$cross_compile" = "yes"; then @@ -1048,8 +1051,12 @@ if test "$static" = "yes" ; then plugins="no" fi if test "$plugins" != "no" && test $host_bits -eq 64; then - plugins=yes - subdirs="$subdirs contrib/plugins" + if has_meson_option "-Dtcg_interpreter=true"; then + plugins="no" + else + plugins=yes + subdirs="$subdirs contrib/plugins" + fi fi cat > $TMPC << EOF From patchwork Tue Sep 10 14:07:20 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: 827004 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325294wrc; Tue, 10 Sep 2024 07:08:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWK8p/5jWspAnTzqvCf+UXTJbWSQiM+NiORo6pgomBrdPxj4sw4/OVDE2EW2U6U53W9nsKc5w==@linaro.org X-Google-Smtp-Source: AGHT+IGVoDcty8Am8ON6ULnR88qTzRnCHbHzO+3RucJOQZnOEhUUpwx8fVAKDfn6FtR1U01gF50P X-Received: by 2002:a05:6902:2313:b0:e11:7d05:562b with SMTP id 3f1490d57ef6-e1d348a163amr15102950276.3.1725977311280; Tue, 10 Sep 2024 07:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977311; cv=none; d=google.com; s=arc-20240605; b=RemTvSIY122hHWhjrfyZqgFNMwMYsc1wteLnGs5+EnJPvTjjuXJ0nzfgsyNcmMeSKv O+Mmrp9Sr4KHfvpbP//wW9Uzns7Gms48qhdAzZlhWVjyet6rETWkIDAGOf5xXjtiUuLo kOEsWgu27uSOfUw5NCjOrmRyAEr+w5IdDVvbq20yZejIz0nb4aCNXAxlRoW9IoYZUxvn 1fpmkJDpmUWF0lvr5bg8Yyyvo/lgTceD2vtbGJTJTT/+YUmhQmi4GmYNL4osCDfH1j2r CNXGBNkjF9yFww/63EriTZWp0xgj7wuQJgUZQU+dK39g1QNmwgtkkyD00TKtQTaKAaF/ /sdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Jq+bIaq+Yu3DGt6tVQ6YepDYvCa3NgcrqP3wlvmzv9c=; fh=PhBQM8pmScIWHtkB7lnBtYO8zFHd76cVam1qPCuCqeM=; b=d79zH4varlwI/R6Y0fUUPoXAcoKLqoWglGuKhX6bDMfeK0JWkSuvyZQdOVXG4elWpT mmv+1GIjlJ7jDqQw7o+BfauXXxl9GIrmLGhllOehah4opz1N7rSAeCgCgVW+2w6M5Ku/ w49kuix6o9t4Avatvqll51CJGoKG42iaySvMm2pwQSCM8X+lhGWCcDDMLDOPxXBr9r/k xcPY5Nyu8rMby9mL5sLKHhum+5WgZhBvFdoSNxWkcPv8zyPyz95hjtjaZ/4Qs6PVUSRq 5BND595sOukqFeafnnbqQIcZqhkJLdF0KIhDvLoKNPpeV8pYe3XrPSUiYQoEfgJjlNox Oa9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hejLEhrA; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bb7fe35si1023550276.221.2024.09.10.07.08.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08: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=hejLEhrA; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X8-0008Kf-Vf; Tue, 10 Sep 2024 10:07:55 -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 1so1X4-00081d-UR for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:50 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X1-0006Xu-Rp for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:50 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a8d56155f51so94600166b.2 for ; Tue, 10 Sep 2024 07:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977266; x=1726582066; 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=Jq+bIaq+Yu3DGt6tVQ6YepDYvCa3NgcrqP3wlvmzv9c=; b=hejLEhrAHNHVxFwUI7ZjV4GN636PNxlaNVuVpPjwD+sT6pvWamR2VWuJViIeAQqlVh g9La4KPs5kfwSH/AokXyDbtUhkjFMeOqyXUuZH7yGgfR5eu7PUHrBGjmiZ+MY2yqQNE5 uym1WYPw3KlYd3KPGczfWzCuwy1nj270wzJPxoKY3lxjyu2TSKfuIEX+6vdscxbH7Xea gFLaHf02F1a0dFKaERCMgBd/eRWtNEzpj4P4SDTLSi2wJbTdgm/NePh+me8tIPdq/I1y BCAq/yHzJpcbDDIemt+gCfxmKH/AoItDHp/h3rxA96bg2cmtLDk9qcnMAVzjg/EzqGJI ygLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977266; x=1726582066; 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=Jq+bIaq+Yu3DGt6tVQ6YepDYvCa3NgcrqP3wlvmzv9c=; b=SL3Y2DkXJ/aISvhsKiW2W1wXF6vcopOWkVTV0kX9DASILTAQN5hUdegKuFRXLLBhJD Xnip0nN9OAstfvj0HmKLhbyYDbAuZTUdlixHfkQxjFx10WpOJsSjHajDSm2dLn5zcvgK pqd7RQK6u97KSLrVIuyX9t3vUZuXhCXSl1KzyPKrPSG02ysK248SmpABVX9Er+GGZ+2W AB0ASjZjPxjGnE8X7ALa/7P4HgU4aqvIn6PJE5o5pXuqyAuxZuFle3oCgAm/lChu+wUz j1SmHM+y9TklNmm/xIG4BqvG06SILUqVs2gHSI9rYnEDahL2hRukrZJbrchd1E4Gh3SI eb7g== X-Gm-Message-State: AOJu0YzOllfmINyUPLIelRdogeL2xjgc+Xs4pIKkuyZnGM9CuQfoQm5U b+krkCDHb9XClNfTJmdvCkQhW5pl79dK0hwage4b/14a0Z/4QrqT+a5vWTA/T3g= X-Received: by 2002:a17:907:961a:b0:a8a:4e39:a462 with SMTP id a640c23a62f3a-a8ffaaafcd9mr78363466b.7.1725977266086; Tue, 10 Sep 2024 07:07:46 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cf4aa7sm492483466b.176.2024.09.10.07.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F06316324D; Tue, 10 Sep 2024 15:07:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Gustavo Romero Subject: [PATCH 13/26] contrib/plugins: control flow plugin Date: Tue, 10 Sep 2024 15:07:20 +0100 Message-Id: <20240910140733.4007719-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is a simple control flow tracking plugin that uses the latest inline and conditional operations to detect and track control flow changes. It is currently an exercise at seeing how useful the changes are. Based-on: <20240312075428.244210-1-pierrick.bouvier@linaro.org> Cc: Gustavo Romero Cc: Pierrick Bouvier Signed-off-by: Alex Bennée Message-Id: <20240311153432.1395190-1-alex.bennee@linaro.org> Reviewed-by: Pierrick Bouvier --- v2 - only need a single call back - drop need for INSN_WIDTH - still don't understand the early exits v3 - move initial STORE ops to first instruction to avoid confusion with the conditional callback on the start - filter out non-branches before processing - fix off-by-one with accounting - display "sync fault" or "branch" instead of raw numbers v4 - rename hotdest to hottest (i.e. the hottest branch insn) - rename early to exception - WIP insn structure --- contrib/plugins/cflow.c | 413 +++++++++++++++++++++++++++++++++++++++ contrib/plugins/Makefile | 1 + 2 files changed, 414 insertions(+) create mode 100644 contrib/plugins/cflow.c diff --git a/contrib/plugins/cflow.c b/contrib/plugins/cflow.c new file mode 100644 index 0000000000..173daec60d --- /dev/null +++ b/contrib/plugins/cflow.c @@ -0,0 +1,413 @@ +/* + * Control Flow plugin + * + * This plugin will track changes to control flow and detect where + * instructions fault. + * + * Copyright (c) 2024 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +typedef enum { + SORT_HOTTEST, /* hottest branch insn */ + SORT_EXCEPTION, /* most early exits */ + SORT_POPDEST, /* most destinations (usually ret's) */ +} ReportType; + +ReportType report = SORT_HOTTEST; +int topn = 10; + +typedef struct { + uint64_t daddr; + uint64_t dcount; +} DestData; + +/* A node is an address where we can go to multiple places */ +typedef struct { + GMutex lock; + /* address of the branch point */ + uint64_t addr; + /* array of DestData */ + GArray *dests; + /* early exit/fault count */ + uint64_t early_exit; + /* jump destination count */ + uint64_t dest_count; + /* instruction data */ + char *insn_disas; + /* symbol? */ + const char *symbol; + /* times translated as last in block? */ + int last_count; + /* times translated in the middle of block? */ + int mid_count; +} NodeData; + +typedef enum { + /* last insn in block, expected flow control */ + LAST_INSN = (1 << 0), + /* mid-block insn, can only be an exception */ + EXCP_INSN = (1 << 1), + /* multiple disassembly, may have changed */ + MULT_INSN = (1 << 2), +} InsnTypes; + +typedef struct { + /* address of the branch point */ + uint64_t addr; + /* disassembly */ + char *insn_disas; + /* symbol? */ + const char *symbol; + /* types */ + InsnTypes type_flag; +} InsnData; + +/* We use this to track the current execution state */ +typedef struct { + /* address of end of block */ + uint64_t end_block; + /* next pc after end of block */ + uint64_t pc_after_block; + /* address of last executed PC */ + uint64_t last_pc; +} VCPUScoreBoard; + +/* descriptors for accessing the above scoreboard */ +static qemu_plugin_u64 end_block; +static qemu_plugin_u64 pc_after_block; +static qemu_plugin_u64 last_pc; + + +static GMutex node_lock; +static GHashTable *nodes; +struct qemu_plugin_scoreboard *state; + +static GMutex insn_lock; +static GHashTable *insn_hash; + +/* SORT_HOTTEST */ +static gint hottest(gconstpointer a, gconstpointer b) +{ + NodeData *na = (NodeData *) a; + NodeData *nb = (NodeData *) b; + + return na->dest_count > nb->dest_count ? -1 : + na->dest_count == nb->dest_count ? 0 : 1; +} + +static gint exception(gconstpointer a, gconstpointer b) +{ + NodeData *na = (NodeData *) a; + NodeData *nb = (NodeData *) b; + + return na->early_exit > nb->early_exit ? -1 : + na->early_exit == nb->early_exit ? 0 : 1; +} + +static gint popular(gconstpointer a, gconstpointer b) +{ + NodeData *na = (NodeData *) a; + NodeData *nb = (NodeData *) b; + + return na->dests->len > nb->dests->len ? -1 : + na->dests->len == nb->dests->len ? 0 : 1; +} + +/* Filter out non-branches - returns true to remove entry */ +static gboolean filter_non_branches(gpointer key, gpointer value, gpointer user_data) +{ + NodeData *node = (NodeData *) value; + + return node->dest_count == 0; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) result = g_string_new("collected "); + GList *data; + GCompareFunc sort = &hottest; + int n = 0; + + g_mutex_lock(&node_lock); + g_string_append_printf(result, "%d control flow nodes in the hash table\n", + g_hash_table_size(nodes)); + + /* remove all nodes that didn't branch */ + g_hash_table_foreach_remove(nodes, filter_non_branches, NULL); + + data = g_hash_table_get_values(nodes); + + switch (report) { + case SORT_HOTTEST: + sort = &hottest; + break; + case SORT_EXCEPTION: + sort = &exception; + break; + case SORT_POPDEST: + sort = &popular; + break; + } + + data = g_list_sort(data, sort); + + for (GList *l = data; + l != NULL && n < topn; + l = l->next, n++) { + NodeData *n = l->data; + const char *type = n->mid_count ? "sync fault" : "branch"; + g_string_append_printf(result, " addr: 0x%"PRIx64 " %s: %s (%s)\n", + n->addr, n->symbol, n->insn_disas, type); + if (n->early_exit) { + g_string_append_printf(result, " early exits %"PRId64"\n", + n->early_exit); + } + g_string_append_printf(result, " branches %"PRId64"\n", + n->dest_count); + for (int j = 0; j < n->dests->len; j++ ) { + DestData *dd = &g_array_index(n->dests, DestData, j); + g_string_append_printf(result, " to 0x%"PRIx64" (%"PRId64")\n", + dd->daddr, dd->dcount); + } + } + + qemu_plugin_outs(result->str); + + g_mutex_unlock(&node_lock); +} + +static void plugin_init(void) +{ + g_mutex_init(&node_lock); + nodes = g_hash_table_new(NULL, g_direct_equal); + state = qemu_plugin_scoreboard_new(sizeof(VCPUScoreBoard)); + + /* score board declarations */ + end_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, end_block); + pc_after_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, pc_after_block); + last_pc = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, last_pc); +} + +static NodeData *create_node(uint64_t addr) +{ + NodeData *node = g_new0(NodeData, 1); + g_mutex_init(&node->lock); + node->addr = addr; + node->dests = g_array_new(true, true, sizeof(DestData)); + return node; +} + +static NodeData *fetch_node(uint64_t addr, bool create_if_not_found) +{ + NodeData *node = NULL; + + g_mutex_lock(&node_lock); + node = (NodeData *) g_hash_table_lookup(nodes, (gconstpointer) addr); + if (!node && create_if_not_found) { + node = create_node(addr); + g_hash_table_insert(nodes, (gpointer) addr, (gpointer) node); + } + g_mutex_unlock(&node_lock); + return node; +} + +#if 0 +static InsnData *fetch_insn(uint64_t addr, struct qemu_plugin_insn *insn, InsnTypes flag) +{ + InsnData *d = NULL; + + g_mutex_lock(&insn_lock); + d = (InsnData *) g_hash_table_lookup(insn_hash, (gconstpointer) addr); + if (!d) { + d = g_new0(InsnData, 1); + d->addr = addr; + d->type_flag = flag; + d->insn_disas = qemu_plugin_insn_disas(insn); + d->symbol = qemu_plugin_insn_symbol(insn); + g_hash_table_insert(insn_hash, (gpointer) addr, (gpointer) d); + } else { + g_autofree char* cmp_disas = qemu_plugin_insn_disas(insn); + if (g_strcmp0(d->insn_disas, cmp_disas) != 0) { + d->type_flag |= MULT_INSN; + } + d->type_flag |= flag; + } + g_mutex_unlock(&insn_lock); + return d; +} +#endif + +/* + * Called when we detect a non-linear execution (pc != + * pc_after_block). This could be due to a fault causing some sort of + * exit exception (if last_pc != block_end) or just a taken branch. + */ +static void vcpu_tb_branched_exec(unsigned int cpu_index, void *udata) +{ + uint64_t lpc = qemu_plugin_u64_get(last_pc, cpu_index); + uint64_t ebpc = qemu_plugin_u64_get(end_block, cpu_index); + uint64_t npc = qemu_plugin_u64_get(pc_after_block, cpu_index); + uint64_t pc = GPOINTER_TO_UINT(udata); + + /* return early for address 0 */ + if (!lpc) { + return; + } + + NodeData *node = fetch_node(lpc, true); + DestData *data = NULL; + bool early_exit = (lpc != ebpc); + GArray *dests; + + /* the condition should never hit */ + g_assert(pc != npc); + + g_mutex_lock(&node->lock); + + if (early_exit) { + fprintf(stderr, "%s: pc=%"PRIx64", epbc=%"PRIx64 + " npc=%"PRIx64", lpc=%"PRIx64", \n", + __func__, pc, ebpc, npc, lpc); + node->early_exit++; + if (!node->mid_count) { + /* count now as we've only just allocated */ + node->mid_count++; + } + } + + dests = node->dests; + for (int i = 0; i < dests->len; i++) { + if (g_array_index(dests, DestData, i).daddr == pc) { + data = &g_array_index(dests, DestData, i); + } + } + + /* we've never seen this before, allocate a new entry */ + if (!data) { + DestData new_entry = { .daddr = pc }; + g_array_append_val(dests, new_entry); + data = &g_array_index(dests, DestData, dests->len - 1); + g_assert(data->daddr == pc); + } + + data->dcount++; + node->dest_count++; + + g_mutex_unlock(&node->lock); +} + +/* + * At the start of each block we need to resolve two things: + * + * - is last_pc == block_end, if not we had an early exit + * - is start of block last_pc + insn width, if not we jumped + * + * Once those are dealt with we can instrument the rest of the + * instructions for their execution. + * + */ +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + uint64_t pc = qemu_plugin_tb_vaddr(tb); + size_t insns = qemu_plugin_tb_n_insns(tb); + struct qemu_plugin_insn *first_insn = qemu_plugin_tb_get_insn(tb, 0); + struct qemu_plugin_insn *last_insn = qemu_plugin_tb_get_insn(tb, insns - 1); + + /* + * check if we are executing linearly after the last block. We can + * handle both early block exits and normal branches in the + * callback if we hit it. + */ + gpointer udata = GUINT_TO_POINTER(pc); + qemu_plugin_register_vcpu_tb_exec_cond_cb( + tb, vcpu_tb_branched_exec, QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_COND_NE, pc_after_block, pc, udata); + + /* + * Now we can set start/end for this block so the next block can + * check where we are at. Do this on the first instruction and not + * the TB so we don't get mixed up with above. + */ + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(first_insn, + QEMU_PLUGIN_INLINE_STORE_U64, + end_block, qemu_plugin_insn_vaddr(last_insn)); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(first_insn, + QEMU_PLUGIN_INLINE_STORE_U64, + pc_after_block, + qemu_plugin_insn_vaddr(last_insn) + + qemu_plugin_insn_size(last_insn)); + + for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + uint64_t ipc = qemu_plugin_insn_vaddr(insn); + /* + * If this is a potential branch point check if we could grab + * the disassembly for it. If it is the last instruction + * always create an entry. + */ + NodeData *node = fetch_node(ipc, last_insn); + if (node) { + g_mutex_lock(&node->lock); + if (!node->insn_disas) { + node->insn_disas = qemu_plugin_insn_disas(insn); + } + if (!node->symbol) { + node->symbol = qemu_plugin_insn_symbol(insn); + } + if (last_insn == insn) { + node->last_count++; + } else { + node->mid_count++; + } + g_mutex_unlock(&node->lock); + } + + /* Store the PC of what we are about to execute */ + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_U64, + last_pc, ipc); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); + if (g_strcmp0(tokens[0], "sort") == 0) { + if (g_strcmp0(tokens[1], "hottest") == 0) { + report = SORT_HOTTEST; + } else if (g_strcmp0(tokens[1], "early") == 0) { + report = SORT_EXCEPTION; + } else if (g_strcmp0(tokens[1], "exceptions") == 0) { + report = SORT_POPDEST; + } else { + fprintf(stderr, "failed to parse: %s\n", tokens[1]); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index 05a2a45c5c..d4ac599f93 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -29,6 +29,7 @@ NAMES += cache NAMES += drcov NAMES += ips NAMES += stoptrigger +NAMES += cflow ifeq ($(CONFIG_WIN32),y) SO_SUFFIX := .dll From patchwork Tue Sep 10 14:07:21 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: 827005 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325413wrc; Tue, 10 Sep 2024 07:08:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXRppzXpOxFsh6zE7fGYSmDqvQIQcOeN/BzIDgWp75reukhIl6lo1fGVv4mE604uF1Kc3q+sg==@linaro.org X-Google-Smtp-Source: AGHT+IGnsHEVxrESc8oywQUpv22PejHIChUQ0Ymy2tujTowZJ4BgTVcGq++uKyctx6TNiUKWJHRn X-Received: by 2002:a05:6902:18cf:b0:e11:453b:836f with SMTP id 3f1490d57ef6-e1d34864ca1mr17474152276.9.1725977320794; Tue, 10 Sep 2024 07:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977320; cv=none; d=google.com; s=arc-20240605; b=FyrKzSfw6D9clkUb1Kyzd55y4EA2ChqEODHSqGnhP/LerEerkQJ9oSu1EGzuxXnqDc CUpwczVIsVlOw6xU4PkWE+Zo+a0FkmHRNTRKXnMzgakHv6HfECxMwzNJgmBWuqbM57/r 92kn10FQwan7iB84Wpb++fFlgp4MEw1hCGEOnQqH1/jxbB3IRGPLNWY/zvq4XICN0khj 8eQSWBBk3LepX9sJvT1VOmAo0N/svzw+JfqJ2IfuG+YeFWgpHeKtCsFvnmlRWgtlM2jz XA3iMd8M48BOnTFqGR03Petzga6gH5dn5kzYSUuschy3KYyzSYKCSZSG0QpADmRxyK+W CFlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=QnElM81hCsi1ZuPnpFOx/34GLOM47VGqPSwGZVF4S40=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=gukVGHFsdNgPY46p3FF8Kn+PPDvZrRYla5v1FpV+0x4h0xxFIbfV9caJ3lSlAcq2fV x1dr4GPq8uWccbtcr4uf8JugEgYnYAHW8andh0AJV70Q/f7Ka62rMlSYbFK6Pfdm2IFj JM0Zo1pePsWCt9TyYB2/lUwW+SNavr0yKNwN5yhpX3BqQz3EB/YUMQeHLpz68ehi4JiN PVVmkWOt7UBmmfo6crB2IY9WwHSEIFoRKOQLU7NH/09fZXt5z7FovK3VxkPCddrLYNZb OgzHDLbqqUY4GFV+OOJkBkhL5JUiqKVezk6ekj4BliseVD0+hopSoaIhLCJkib+QbR+f +BqQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZpSNjzfq; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bb81848si1107189276.341.2024.09.10.07.08.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:40 -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=ZpSNjzfq; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X9-0008OJ-Mw; Tue, 10 Sep 2024 10:07:55 -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 1so1X6-00088f-Hf for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:52 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X2-0006Xq-2s for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:52 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5365cf5de24so4163559e87.1 for ; Tue, 10 Sep 2024 07:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977266; x=1726582066; 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=QnElM81hCsi1ZuPnpFOx/34GLOM47VGqPSwGZVF4S40=; b=ZpSNjzfqBSNa9AssxOMnRHj+tAvZjTWIlKtxINbUbr6dWespWi9Rx5TAZaMi0pqjSL NHgB/zZVCqK7/GyjzCB0l4DGs8/9nNDXjDppCn86SNuj9V2Dp1mqMN0+oig0cO0ZJAPC g2Y2UrCDPCJjPybZwJKky/NPQbTen0WZYw3LTbD/dB4ol6cNXKy+rxo8reUyq3xHEPwV YskuSfudvjdALIeVMOIWxhILNdMVpmLiQNZetx5OtLm/+F+IAa27yIjo+cZi1Cjex3qK chSasauIyYldVzvuiblS4175e+q4xCkfw4x1jGQw9qQiryTgz5jPorRVGH+RnLOdPewS jIOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977266; x=1726582066; 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=QnElM81hCsi1ZuPnpFOx/34GLOM47VGqPSwGZVF4S40=; b=CTC8XsycUcne73B6HSomWJv//kzMKbY4UsQRiscG0bTKjfPjrO/j2rMD+5RyVmPjcF u6vZBCC+cTgcLplwEGiL6h0oKrj64m0mIJ/VhVgiEaxOap/fQllVOuMP7c6BLwPVG6Uo FmdfRElm1iWoiVvyGTkpBU0peDu1Y3CUr1p7sC6+UWXIneHXo1YlEHzEriV9U1V7vFnz 5UIheBXMa/mM85BvYlnDjcoqwePjiRjpgMD0PEH1BJJq8Wd0+e0Soj1a6cEmGxuvosg/ Q+pONYfTwE+XiQPrFwfZo+ani/LHg1u8ZvVUkBwbOj2MCHjXPGLBZF9g6JGL3kIAxOlw pnRQ== X-Gm-Message-State: AOJu0Yw7gsaeVbZTR42Mj02PRpYZaajv4RHzP/Iy345D8p62FpnbZ4RK j+pT6n+lWw1QEeEgrVZFaChdh5zt6k9VbvfZPG/G8ARkCFCM6g4EqTDyvHTPlEo= X-Received: by 2002:a05:6512:3d1f:b0:52f:288:5664 with SMTP id 2adb3069b0e04-5365881008amr7435511e87.51.1725977265741; Tue, 10 Sep 2024 07:07:45 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c7277bsm480175966b.102.2024.09.10.07.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1845E633C9; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 14/26] plugins: save value during memory accesses Date: Tue, 10 Sep 2024 15:07:21 +0100 Message-Id: <20240910140733.4007719-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x131.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=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: Pierrick Bouvier Different code paths handle memory accesses: - tcg generated code - load/store helpers - atomic helpers This value is saved in cpu->neg.plugin_mem_value_{high,low}. Values are written only for accessed word size (upper bits are not set). Atomic operations are doing read/write at the same time, so we generate two memory callbacks instead of one, to allow plugins to access distinct values. For now, we can have access only up to 128 bits, thus split this in two 64 bits words. When QEMU will support wider operations, we'll be able to reconsider this. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Pierrick Bouvier Message-Id: <20240724194708.1843704-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- accel/tcg/atomic_template.h | 66 ++++++++++++++++++++++++++++++----- include/hw/core/cpu.h | 4 +++ include/qemu/plugin.h | 4 +++ plugins/core.c | 6 ++++ tcg/tcg-op-ldst.c | 66 +++++++++++++++++++++++++++++++---- accel/tcg/atomic_common.c.inc | 13 ++++++- accel/tcg/ldst_common.c.inc | 38 ++++++++++++-------- 7 files changed, 167 insertions(+), 30 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 1dc2151daf..89593b2502 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -53,6 +53,14 @@ # error unsupported data size #endif +#if DATA_SIZE == 16 +# define VALUE_LOW(val) int128_getlo(val) +# define VALUE_HIGH(val) int128_gethi(val) +#else +# define VALUE_LOW(val) val +# define VALUE_HIGH(val) 0 +#endif + #if DATA_SIZE >= 4 # define ABI_TYPE DATA_TYPE #else @@ -83,7 +91,12 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr, ret = qatomic_cmpxchg__nocheck(haddr, cmpv, newv); #endif ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(newv), + VALUE_HIGH(newv), + oi); return ret; } @@ -97,7 +110,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val, ret = qatomic_xchg__nocheck(haddr, val); ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); return ret; } @@ -109,7 +127,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \ ret = qatomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + VALUE_LOW(ret), \ + VALUE_HIGH(ret), \ + VALUE_LOW(val), \ + VALUE_HIGH(val), \ + oi); \ return ret; \ } @@ -145,7 +168,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ cmp = qatomic_cmpxchg__nocheck(haddr, old, new); \ } while (cmp != old); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + VALUE_LOW(old), \ + VALUE_HIGH(old), \ + VALUE_LOW(xval), \ + VALUE_HIGH(xval), \ + oi); \ return RET; \ } @@ -188,7 +216,12 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr, ret = qatomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); #endif ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(newv), + VALUE_HIGH(newv), + oi); return BSWAP(ret); } @@ -202,7 +235,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val, ret = qatomic_xchg__nocheck(haddr, BSWAP(val)); ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(val), + oi); return BSWAP(ret); } @@ -214,7 +252,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \ ret = qatomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + VALUE_LOW(ret), \ + VALUE_HIGH(ret), \ + VALUE_LOW(val), \ + VALUE_HIGH(val), \ + oi); \ return BSWAP(ret); \ } @@ -247,7 +290,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ ldn = qatomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ } while (ldo != ldn); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + VALUE_LOW(old), \ + VALUE_HIGH(old), \ + VALUE_LOW(xval), \ + VALUE_HIGH(xval), \ + oi); \ return RET; \ } @@ -281,3 +329,5 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef SUFFIX #undef DATA_SIZE #undef SHIFT +#undef VALUE_LOW +#undef VALUE_HIGH diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 1c9c775df6..04e9ad4996 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -350,6 +350,8 @@ typedef union IcountDecr { * from CPUArchState, via small negative offsets. * @can_do_io: True if memory-mapped IO is allowed. * @plugin_mem_cbs: active plugin memory callbacks + * @plugin_mem_value_low: 64 lower bits of latest accessed mem value. + * @plugin_mem_value_high: 64 higher bits of latest accessed mem value. */ typedef struct CPUNegativeOffsetState { CPUTLB tlb; @@ -358,6 +360,8 @@ typedef struct CPUNegativeOffsetState { * The callback pointer are accessed via TCG (see gen_empty_mem_helper). */ GArray *plugin_mem_cbs; + uint64_t plugin_mem_value_low; + uint64_t plugin_mem_value_high; #endif IcountDecr icount_decr; bool can_do_io; diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index af5f9db469..9726a9ebf3 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -167,6 +167,8 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret); void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_low, + uint64_t value_high, MemOpIdx oi, enum qemu_plugin_mem_rw rw); void qemu_plugin_flush_cb(void); @@ -251,6 +253,8 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) { } static inline void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_low, + uint64_t value_high, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { } diff --git a/plugins/core.c b/plugins/core.c index 2897453cac..bb105e8e68 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -602,6 +602,8 @@ void exec_inline_op(enum plugin_dyn_cb_type type, } void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_low, + uint64_t value_high, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { GArray *arr = cpu->neg.plugin_mem_cbs; @@ -610,6 +612,10 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, if (arr == NULL) { return; } + + cpu->neg.plugin_mem_value_low = value_low; + cpu->neg.plugin_mem_value_high = value_high; + for (i = 0; i < arr->len; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(arr, struct qemu_plugin_dyn_cb, i); diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index 8510160258..23dc807f11 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -148,11 +148,11 @@ static TCGv_i64 plugin_maybe_preserve_addr(TCGTemp *addr) return NULL; } +#ifdef CONFIG_PLUGIN static void plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { -#ifdef CONFIG_PLUGIN if (tcg_ctx->plugin_insn != NULL) { qemu_plugin_meminfo_t info = make_plugin_meminfo(oi, rw); @@ -172,6 +172,54 @@ plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, } } } +} +#endif + +static void +plugin_gen_mem_callbacks_i32(TCGv_i32 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + tcg_gen_st_i32(val, tcg_env, + offsetof(CPUState, neg.plugin_mem_value_low) - + sizeof(CPUState) + (HOST_BIG_ENDIAN * 4)); + plugin_gen_mem_callbacks(copy_addr, orig_addr, oi, rw); + } +#endif +} + +static void +plugin_gen_mem_callbacks_i64(TCGv_i64 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + tcg_gen_st_i64(val, tcg_env, + offsetof(CPUState, neg.plugin_mem_value_low) - + sizeof(CPUState)); + plugin_gen_mem_callbacks(copy_addr, orig_addr, oi, rw); + } +#endif +} + +static void +plugin_gen_mem_callbacks_i128(TCGv_i128 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + tcg_gen_st_i64(TCGV128_LOW(val), tcg_env, + offsetof(CPUState, neg.plugin_mem_value_low) - + sizeof(CPUState)); + tcg_gen_st_i64(TCGV128_HIGH(val), tcg_env, + offsetof(CPUState, neg.plugin_mem_value_high) - + sizeof(CPUState)); + plugin_gen_mem_callbacks(copy_addr, orig_addr, oi, rw); + } #endif } @@ -203,7 +251,8 @@ static void tcg_gen_qemu_ld_i32_int(TCGv_i32 val, TCGTemp *addr, opc = INDEX_op_qemu_ld_a64_i32; } gen_ldst(opc, tcgv_i32_temp(val), NULL, addr, oi); - plugin_gen_mem_callbacks(copy_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i32(val, copy_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { @@ -271,7 +320,7 @@ static void tcg_gen_qemu_st_i32_int(TCGv_i32 val, TCGTemp *addr, } } gen_ldst(opc, tcgv_i32_temp(val), NULL, addr, oi); - plugin_gen_mem_callbacks(NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i32(val, NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); if (swap) { tcg_temp_free_i32(swap); @@ -324,7 +373,8 @@ static void tcg_gen_qemu_ld_i64_int(TCGv_i64 val, TCGTemp *addr, opc = INDEX_op_qemu_ld_a64_i64; } gen_ldst_i64(opc, val, addr, oi); - plugin_gen_mem_callbacks(copy_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i64(val, copy_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); if ((orig_memop ^ memop) & MO_BSWAP) { int flags = (orig_memop & MO_SIGN @@ -396,7 +446,7 @@ static void tcg_gen_qemu_st_i64_int(TCGv_i64 val, TCGTemp *addr, opc = INDEX_op_qemu_st_a64_i64; } gen_ldst_i64(opc, val, addr, oi); - plugin_gen_mem_callbacks(NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i64(val, NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); if (swap) { tcg_temp_free_i64(swap); @@ -606,7 +656,8 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp *addr, tcg_constant_i32(orig_oi)); } - plugin_gen_mem_callbacks(ext_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i128(val, ext_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); } void tcg_gen_qemu_ld_i128_chk(TCGv_i128 val, TCGTemp *addr, TCGArg idx, @@ -722,7 +773,8 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp *addr, tcg_constant_i32(orig_oi)); } - plugin_gen_mem_callbacks(ext_addr, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i128(val, ext_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_W); } void tcg_gen_qemu_st_i128_chk(TCGv_i128 val, TCGTemp *addr, TCGArg idx, diff --git a/accel/tcg/atomic_common.c.inc b/accel/tcg/atomic_common.c.inc index 95a5c5ff12..6056598c23 100644 --- a/accel/tcg/atomic_common.c.inc +++ b/accel/tcg/atomic_common.c.inc @@ -14,9 +14,20 @@ */ static void atomic_trace_rmw_post(CPUArchState *env, uint64_t addr, + uint64_t read_value_low, + uint64_t read_value_high, + uint64_t write_value_low, + uint64_t write_value_high, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_RW); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + read_value_low, read_value_high, + oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + write_value_low, write_value_high, + oi, QEMU_PLUGIN_MEM_W); + } } /* diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index 87ceb95487..ebbf380d76 100644 --- a/accel/tcg/ldst_common.c.inc +++ b/accel/tcg/ldst_common.c.inc @@ -123,10 +123,15 @@ void helper_st_i128(CPUArchState *env, uint64_t addr, Int128 val, MemOpIdx oi) * Load helpers for cpu_ldst.h */ -static void plugin_load_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) +static void plugin_load_cb(CPUArchState *env, abi_ptr addr, + uint64_t value_low, + uint64_t value_high, + MemOpIdx oi) { if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + value_low, value_high, + oi, QEMU_PLUGIN_MEM_R); } } @@ -136,7 +141,7 @@ uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra) tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_UB); ret = do_ld1_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, ret, 0, oi); return ret; } @@ -147,7 +152,7 @@ uint16_t cpu_ldw_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); ret = do_ld2_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, ret, 0, oi); return ret; } @@ -158,7 +163,7 @@ uint32_t cpu_ldl_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); ret = do_ld4_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, ret, 0, oi); return ret; } @@ -169,7 +174,7 @@ uint64_t cpu_ldq_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); ret = do_ld8_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, ret, 0, oi); return ret; } @@ -180,7 +185,7 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); ret = do_ld16_mmu(env_cpu(env), addr, oi, ra); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, int128_getlo(ret), int128_gethi(ret), oi); return ret; } @@ -188,10 +193,15 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, * Store helpers for cpu_ldst.h */ -static void plugin_store_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) +static void plugin_store_cb(CPUArchState *env, abi_ptr addr, + uint64_t value_low, + uint64_t value_high, + MemOpIdx oi) { if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + value_low, value_high, + oi, QEMU_PLUGIN_MEM_W); } } @@ -199,7 +209,7 @@ void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val, MemOpIdx oi, uintptr_t retaddr) { helper_stb_mmu(env, addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, val, 0, oi); } void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, @@ -207,7 +217,7 @@ void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); do_st2_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, val, 0, oi); } void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, @@ -215,7 +225,7 @@ void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); do_st4_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, val, 0, oi); } void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, @@ -223,7 +233,7 @@ void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); do_st8_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, val, 0, oi); } void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, @@ -231,7 +241,7 @@ void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); do_st16_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, int128_getlo(val), int128_gethi(val), oi); } /* From patchwork Tue Sep 10 14:07:22 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: 827009 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326228wrc; Tue, 10 Sep 2024 07:09:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9fhPICtWGkZ7/5na4g3BFwqXRnsP+auTYRakxc5U8rdQXI7LUi0orROSxsbStdPKDNXQlAg==@linaro.org X-Google-Smtp-Source: AGHT+IGz9DFCU0swTxqud5WYUbTepPoyZ8ZadGmh6PFl10zD+zcfvvbUNfJ18+IIyEzePhbZy7ot X-Received: by 2002:a05:6214:3910:b0:6c5:5b68:d790 with SMTP id 6a1803df08f44-6c55b68da1amr25805886d6.14.1725977394375; Tue, 10 Sep 2024 07:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977394; cv=none; d=google.com; s=arc-20240605; b=ZmeTz42JBWiAjvzCP9bPfaQt0rOe3P3pYS35rjMwovL1vPziTalHR8/KEoEdHq9Kmy pNO/Hf78RMyeh3oOIZKbW4DCMpaU6WQfqoIu4ntKIj0+biNvu9PKAADbT9v7Yp+dHXDy kazzWC7M08YCQnI3xjERUvcMf+uT15ZJOV0XIllCHdOIPMxvBlrGjaNCWFQuToFtIYm+ KuC514HoNqKukMyHTy3phOWjMsbRFBCBpjTJo5Sh73mt/TJxNS6dk1nTufsyjU3Ma3i8 EUQAai4+oOMQaFUBfu4f/K9OPR6eO1ycHDknzHm2z1OpxZiRMUmggcovHyVjQzGUMtV8 by4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=bg1S7MpqFLKynDQMTW/BgVqsjzz9T+4SZvu94a93bN0=; fh=oBBE9wOdhjgpcP0FcSrE584/AGvZ2BHpP3QT5nS0ooo=; b=low058X1+mMsQQp7Id63F/5WC0G8T1zwlWDwwZC/mT9QKJ2rcrTrjGbQRRxF/OGgMe OXkq5BYPYqQfv8suMCWuVonl8QoQCVKOSTxdnQuGDkLe85ZO/bZY/L8ZDFDxITwBvM0A Bd5d6md+sKMt4ff5zjWnKW+p7HzMCV7ESvkCTTsNCVkK9q+0oxMdF7wFoWSzAfwb3c6p oLTOKqv/Lh2+tw34Zd8x8er3z7c805h/RlqwXUu0XDITgPYQelM0o2JsFKXxNHLGxEPY M67UCqnxCVIZoWx0P2q60AHKMxCHas2Yead4+S4ckLJ4pNHTJNGBK/m3J1vT5TcgCw6M UKtA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSGH31h3; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c53433dd7asi79965976d6.169.2024.09.10.07.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:09:54 -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=OSGH31h3; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X5-00084S-HA; Tue, 10 Sep 2024 10:07: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 1so1X4-0007y5-1U for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:50 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X0-0006XY-Vd for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:49 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5c26852af8fso7329944a12.2 for ; Tue, 10 Sep 2024 07:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977265; x=1726582065; 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=bg1S7MpqFLKynDQMTW/BgVqsjzz9T+4SZvu94a93bN0=; b=OSGH31h3qkkw7RvVqoDEAkbUyqhE03bXYGqVfczno4PyMCbnuxxQ1lki3CBdB1VNHE ibErBbDaongY04CUvmp/GiJIwQHI/8eaxUOEBnRhszK9r+f8ekIe8Eg9xMbBiOyYvsHm Y7GQsWr02kKAtPHDjR54PqRC2AfwMX/fwhDgimXGeNdiBM1YwaVK1ZEcDXkyESWa+NiO 6pstBrUWTPfTARW3BPhjy9sSDBCe94qsWZbObnyA5ofodaiCIiV4ED1aS6whezrQIvuV 2hDbIbY4sjvpR1MFQe/ssMwa6MFZAzC7GcwKpr/3b8ifVSwjY9NgiTTZPyA1w4YHF4w0 kEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977265; x=1726582065; 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=bg1S7MpqFLKynDQMTW/BgVqsjzz9T+4SZvu94a93bN0=; b=l8q/9C1YEFAHIBT0V7KSkyNT4OUvGDwrEW6DJ/vqK6At0aWsSB89bHTxnj78GyBTqM c9C9pEIKPWFDvruqz5oudbY28zhdfaX0jHo6XZhOpRK73dF9yb2J72otNla7AR1yk+u6 0E7ABRSkI1o+QfhERNP1pkKPuPWHUcyakFllICqtR9Ixb23l62DtrHzXw1VeWUsyhceK 5/WsavFI+DI+l4TXvoMt+4QEyh3wGGYNKZarhsaW/CvePj3jcudEm4wDAN0tDPWCUDpA HugyQKa0dBsigygxep4mB0/355B6qKZdq7rWS8hQqyTA9jVaP4Ga2jrL1TMwwIohPTN0 p00g== X-Gm-Message-State: AOJu0YxcFSglYMuJLEHyZ/JPJnBhEO5h8abt2iXBpy9xBk7JzppGxxXX mV94MFukR4AvTeiDHteKXKuzj8ZW5DumR1OiTIgKON1LAw6VI+SLh7uElKy0CIY= X-Received: by 2002:a05:6402:5109:b0:5c2:4d9f:61c with SMTP id 4fb4d7f45d1cf-5c3e9533614mr10178504a12.8.1725977265376; Tue, 10 Sep 2024 07:07:45 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd4696asm4311411a12.30.2024.09.10.07.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 31AEF633E6; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Xingtao Yao Subject: [PATCH 15/26] plugins: extend API to get latest memory value accessed Date: Tue, 10 Sep 2024 15:07:22 +0100 Message-Id: <20240910140733.4007719-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier This value can be accessed only during a memory callback, using new qemu_plugin_mem_get_value function. Returned value can be extended when QEMU will support accesses wider than 128 bits. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1719 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2152 Reviewed-by: Richard Henderson Reviewed-by: Xingtao Yao Reviewed-by: Alex Bennée Signed-off-by: Pierrick Bouvier Message-Id: <20240724194708.1843704-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- include/qemu/qemu-plugin.h | 32 ++++++++++++++++++++++++++++++++ plugins/api.c | 33 +++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 1 + 3 files changed, 66 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c71c705b69..649ce89815 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -262,6 +262,29 @@ enum qemu_plugin_mem_rw { QEMU_PLUGIN_MEM_RW, }; +enum qemu_plugin_mem_value_type { + QEMU_PLUGIN_MEM_VALUE_U8, + QEMU_PLUGIN_MEM_VALUE_U16, + QEMU_PLUGIN_MEM_VALUE_U32, + QEMU_PLUGIN_MEM_VALUE_U64, + QEMU_PLUGIN_MEM_VALUE_U128, +}; + +/* typedef qemu_plugin_mem_value - value accessed during a load/store */ +typedef struct { + enum qemu_plugin_mem_value_type type; + union { + uint8_t u8; + uint16_t u16; + uint32_t u32; + uint64_t u64; + struct { + uint64_t low; + uint64_t high; + } u128; + } data; +} qemu_plugin_mem_value; + /** * enum qemu_plugin_cond - condition to enable callback * @@ -551,6 +574,15 @@ bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); QEMU_PLUGIN_API bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); +/** + * qemu_plugin_mem_get_mem_value() - return last value loaded/stored + * @info: opaque memory transaction handle + * + * Returns: memory value + */ +QEMU_PLUGIN_API +qemu_plugin_mem_value qemu_plugin_mem_get_value(qemu_plugin_meminfo_t info); + /** * qemu_plugin_get_hwaddr() - return handle for memory operation * @info: opaque memory info structure diff --git a/plugins/api.c b/plugins/api.c index 2ff13d09de..3316d4a04d 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -351,6 +351,39 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } +qemu_plugin_mem_value qemu_plugin_mem_get_value(qemu_plugin_meminfo_t info) +{ + uint64_t low = current_cpu->neg.plugin_mem_value_low; + qemu_plugin_mem_value value; + + switch (qemu_plugin_mem_size_shift(info)) { + case 0: + value.type = QEMU_PLUGIN_MEM_VALUE_U8; + value.data.u8 = (uint8_t)low; + break; + case 1: + value.type = QEMU_PLUGIN_MEM_VALUE_U16; + value.data.u16 = (uint16_t)low; + break; + case 2: + value.type = QEMU_PLUGIN_MEM_VALUE_U32; + value.data.u32 = (uint32_t)low; + break; + case 3: + value.type = QEMU_PLUGIN_MEM_VALUE_U64; + value.data.u64 = low; + break; + case 4: + value.type = QEMU_PLUGIN_MEM_VALUE_U128; + value.data.u128.low = low; + value.data.u128.high = current_cpu->neg.plugin_mem_value_high; + break; + default: + g_assert_not_reached(); + } + return value; +} + /* * Virtual Memory queries */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index ca773d8d9f..eed9d8abd9 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -13,6 +13,7 @@ qemu_plugin_insn_size; qemu_plugin_insn_symbol; qemu_plugin_insn_vaddr; + qemu_plugin_mem_get_value; qemu_plugin_mem_is_big_endian; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; From patchwork Tue Sep 10 14:07:23 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: 827013 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp326723wrc; Tue, 10 Sep 2024 07:10:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUXak8CvPDHb5WZfsWMbKeptg45JlNArA1EucVIYELn4Ff9Z9DGlhmi7+dtmMljAMEWHTFt0w==@linaro.org X-Google-Smtp-Source: AGHT+IHu1AwignQvnKAEm439G5qPnvZYRu+QVSDpgQ0QlLueuWjMXaVas3n0BFOGlPZQL1VPtUez X-Received: by 2002:a05:690c:d95:b0:6d7:3c0d:3ab2 with SMTP id 00721157ae682-6db44df53edmr151482747b3.6.1725977439632; Tue, 10 Sep 2024 07:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977439; cv=none; d=google.com; s=arc-20240605; b=egBlp5+9zKNPyXJWIm58gID7EIs5rOURjOMz8eS6GEKJMz/W6ohuFaOgiHEEtUpWfn yC7H9jpYj6fq6e5G/UVbhoss/z3soNviFpL0QuiIOp1arqE1fqx0fNglB9f3VWKpkjBF M8UU4IHCHhYuxAnSRXtV7x9WrQYdKthqqD3y7dlIOtYZ05sh7JeDTnstvIOULwG5LDEP Q+D1t+SuZIJjzFW9n5SajDaloS08+rdEGF2+DiDXrpcBas5TcmOwm0Rx6ldOPaNdR+T3 qSng830KZ10T6ALJqfNAzZ+F9FIW2PX2Go6AJJz1C4/sQcW6ZIPFw2IPgpu7AQAdSlI8 TQHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ULpurcGomJFFFXGFveTbWvPTjZlX1tphSs0Gpvsy70s=; fh=oBBE9wOdhjgpcP0FcSrE584/AGvZ2BHpP3QT5nS0ooo=; b=BYN2e/SHf7s4SEisz7xOD/MnGoc/zCZVZJ9tDtHVrsEWR5j6C/02/zVvCrXy6Iqn3s Jp4nUwhX0oD2a3uH1tItelra4KLZJaTiHSEvOxCZo4l/nncfkykEy5ueLKpiKaYB7r/W TzwwL4K3YHLHBTGCQz9GxgrtwqBlrARHXVdimTfisDzonPxAqwQ50lpTrTfVtW77IVWv 3UCc7wNumUCK0MLk+k2jzhXfWgBb859G+WX2dXeyPxNw/A6yBUMpyBagH47zhIW96svy qnoFlnVBxxb1kvt7oHEy/WVQwgqjc/lADIc5K5JjWiPVz2kUoArVlJ8bRcbFXjZ1VKNy CgQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRCXR3IH; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 00721157ae682-6db96427fd4si9340367b3.32.2024.09.10.07.10.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:10:39 -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=SRCXR3IH; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1X4-00080O-Mg; Tue, 10 Sep 2024 10:07:50 -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 1so1X2-0007sc-PN for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:48 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X0-0006XO-Ti for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:48 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c3ca32974fso6333829a12.3 for ; Tue, 10 Sep 2024 07:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977265; x=1726582065; 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=ULpurcGomJFFFXGFveTbWvPTjZlX1tphSs0Gpvsy70s=; b=SRCXR3IHhnl+JZXbMBu9HjrxeOHFy2c6aenKD6QcZQX7gPeXouj5mXGVfFKg2FAvGS ptXT5+Rjy825IlO+5ewHUL0cesCe4CACCbvhA6jR6sfVza16n0MD8C6INmH8AjrwUT3+ nTyz15y29PKJZb7NlLL9MgRfREui+WI7ylv/PbA5B2b3gItblzM9KPMG633UQl0HvO4A or1pDSCMHO7pen5lfdIe7WEwsBVJXvh0wgSD9sEnAm+mJrCoxAlQfb7qrq8Ym2cxDbMy XoXLW6+/N6Wh6Bw0Tk2z8EbGqeMulFXvfBbl6Lzs1ozdEwUYxsQrzGAzRNXmoQEdAtFJ 8M/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977265; x=1726582065; 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=ULpurcGomJFFFXGFveTbWvPTjZlX1tphSs0Gpvsy70s=; b=XsBpoKrsA4r4UpaVtCiJR3LzVZ8Pu3zNfNLY43+V7SwXvUXbDqWXjqp6oy0H7IouU5 n4q9YnEdqN78+7J6w3ty7BXMJxoeFBqW7MXlnHI7A7Tzhg6GyC4aueWbpyaWpMEV525J A1GpzK+MOrcOebB1j6Vy3vpxnA86ahiuIlKcziQarumZ5ScHu8UzVn5FKCisVSKwctzM TpG7MymXttIr52c7MyMOMXEFPgKCeOJt0U2PV4o+gegSop3o7M4OQhErf3ih4a0ONZ5+ v4r27I7A+Sy5ozw0kx4nVEEsYW4Ow0ek0Z0eekuH/BRYELQ0Pm8SrtjzlwI53NnhdlqF +Nrg== X-Gm-Message-State: AOJu0Yy5fl4tbXZXco6bO61/RDWaS1PCgglFegjGRkrEz/Czc7UXMhp4 XCRRO9tqCxPensHQhIFkuR2K+GvnnSX2a1PddViURvkrs/S4B5Bbsc1VnmKaXsc= X-Received: by 2002:a05:6402:40c7:b0:5c3:da92:495d with SMTP id 4fb4d7f45d1cf-5c3dc78008cmr8846555a12.3.1725977265063; Tue, 10 Sep 2024 07:07:45 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd466dcsm4317560a12.24.2024.09.10.07.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 49394633F8; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Xingtao Yao Subject: [PATCH 16/26] tests/tcg: add mechanism to run specific tests with plugins Date: Tue, 10 Sep 2024 15:07:23 +0100 Message-Id: <20240910140733.4007719-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier Only multiarch tests are run with plugins, and we want to be able to run per-arch test with plugins too. Tested-by: Xingtao Yao Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240724194708.1843704-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- tests/tcg/Makefile.target | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 452a2cde65..c5b1c7a786 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -152,10 +152,11 @@ PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) # only expand MULTIARCH_TESTS which are common on most of our targets # to avoid an exponential explosion as new tests are added. We also # add some special helpers the run-plugin- rules can use below. +# In more, extra tests can be added using ADDITIONAL_PLUGINS_TESTS variable. ifneq ($(MULTIARCH_TESTS),) $(foreach p,$(PLUGINS), \ - $(foreach t,$(MULTIARCH_TESTS),\ + $(foreach t,$(MULTIARCH_TESTS) $(ADDITIONAL_PLUGINS_TESTS),\ $(eval run-plugin-$(t)-with-$(p): $t $p) \ $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p)))) endif # MULTIARCH_TESTS From patchwork Tue Sep 10 14:07:24 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: 827018 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp327619wrc; Tue, 10 Sep 2024 07:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgmeVWvyThFk/XPtHPnOcO94pTMrxT1h8OrDSDQaJLvR0aWGzDKdGE6T5gmZEK8BUvg9Ascg==@linaro.org X-Google-Smtp-Source: AGHT+IGev4OSz0+jD1OzvCTd5Df3SRlg1+vwsTECJ4oCknmg0b3ApIlzSLAjwYqNK1NZ9MHDrGsR X-Received: by 2002:a05:6122:7c6:b0:501:1c74:bfc5 with SMTP id 71dfb90a1353d-50207af4160mr16656634e0c.1.1725977533603; Tue, 10 Sep 2024 07:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977533; cv=none; d=google.com; s=arc-20240605; b=U7Zk67JJUyRRAXq/L5pT67eX0QBZ4/pYn8fGI5GFCHAYejZFxDh1sPRDNFmv4F+Ipp j4qHTaSOZjGdvPwEIWMq2ceSIWS0uS3dXRPwroZA3QYtu0xfLOOY8f3KenwtUuCbiSn2 /CXBKCIpS77TnHR64sbXd5WMQ9MKFz0k5Lyaz0Jqnu+eh6BzjjszrsiSii8lMJzTlbrA KoXlUPlzkBGxoUxuO7b5aov4X6msh5JGlWElAMJyHdvKVRQWaqfkTTmcMUIkG5527Rzc MMsIlaVnKrXnk2xyTsrIbXoORstbJ1f2O6jvQrgqfXOYheuC1NTP6/a5yB+hMRyeHYp7 npAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=XLtSiC/Qmy/Q/dtQX8Zk8sWvmopgnkSy4LkF7QeFpv4=; fh=oBBE9wOdhjgpcP0FcSrE584/AGvZ2BHpP3QT5nS0ooo=; b=H6L6HifZTfmZUXsl/5x5OKc+x7puu2EJJUirorauMZhyxuTJTLG/l4WVNb1T9ymy6o LEqaidt6prHgXGIAQtM5QlhD5pIuadp1KIaF7GEgUF1DtxaC3Maz5C5dptUGVLi+GYDS doUTop4Cl+/35ZfNRS9W544/Nm/0uVd7VrgeIgS3K1jJqV49W+SPsYxsZd4ugcAZf+q6 G2fysvJueZdDDa2RhY3DKvOwGurj97C3b42XfQU6jaGIUBJ+ErRPs+9L7sKg+dztOyOt Zurc4+8UYEXISv3zqs+wh0KwVYTvpTjBORnCG0E3lirUYtICXjkqCv/juP9FI2qjgeMe IkMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Eo+Yfplg; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-502f9b45f51si391560e0c.226.2024.09.10.07.12.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:12: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=Eo+Yfplg; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1XA-0008Ri-BE; Tue, 10 Sep 2024 10:07: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 1so1X6-00088h-I5 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:52 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X4-0006ZB-1Z for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:52 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a7a81bd549eso88146066b.3 for ; Tue, 10 Sep 2024 07:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977268; x=1726582068; 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=XLtSiC/Qmy/Q/dtQX8Zk8sWvmopgnkSy4LkF7QeFpv4=; b=Eo+YfplgzxTRJ6aaBfMkkRCHAW12mQEt5OuqKJoLpuxCBPqsyq7RaJSfVFg0oYbcei ZywLHNjIlbA8XtLrr1hj5l+1CSvvEqzS1muUO8kYHfIMTx4HdaIdOL6dIKfdAIYzNngh FwWzCZfphI4bTKGkksg0F+Szz89m/0+mn3ggYp83wa/zoCngdlxhruglKdiv/QrmO95P wfwm4H/hGXMLeZ762NAD5ot7rB5L38dyg+qd7cOUVapF3k9fyMu3vo3+J37lPB5hrRiB ahNAtGCRYClAl1If+rTM6Dj9lz1JxtA4Ld9eZIwTzezmsuKZ/8Zvmr6KctEG+ZbRJira hnfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977268; x=1726582068; 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=XLtSiC/Qmy/Q/dtQX8Zk8sWvmopgnkSy4LkF7QeFpv4=; b=N/DvBj9/zQidrHDf4XfhE37dU7auT0v8CZxZ1zGWQjv8ejmey1sTL3QIEyIFo1VJVm aPUVKkhF4ZqJX8vDPL+WAfiAsO/Dr6AG6vmIiV/p7w7QcILpSo7OjwblyiSS+joRfXIj Yp8+v038TGOgbb2/+UEJdihLDqzVLtEEAAxgwRPM/ZhdUkKMSHTpTNdAw7LOD6VqxjKt DmdotY2r7lqUo0orWEKb3zO6OYEacVYjenQGL+weC2pUXLiI4oarnAORqO8Mw/Exlkyf 1E2ZgrX79QvHZgljOaRwcWcceGJM0kBQM/A0OPd0pgcrFRWTRWB1JhjSiCJRreESNpEB GW8w== X-Gm-Message-State: AOJu0YxghCHC3k5UgLuFR4cUd8rd9HfQmNXrqeLfkc3Vr5k7d2zhGpNH +BphG7CDLtwV8jwsdjQyKn6SCt6xfamyer6LDHAo5SJCKqydRsAHVumsfOQigMk= X-Received: by 2002:a17:907:72d1:b0:a8a:8d81:97b1 with SMTP id a640c23a62f3a-a8ffab92bf0mr96711966b.27.1725977268411; Tue, 10 Sep 2024 07:07:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d259267a6sm493257866b.51.2024.09.10.07.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5F19763404; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Xingtao Yao Subject: [PATCH 17/26] tests/tcg: allow to check output of plugins Date: Tue, 10 Sep 2024 15:07:24 +0100 Message-Id: <20240910140733.4007719-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier A specific plugin test can now read and check a plugin output, to ensure it contains expected values. Tested-by: Xingtao Yao Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240724194708.1843704-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- tests/tcg/Makefile.target | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index c5b1c7a786..2da70b2fcf 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -90,6 +90,7 @@ CFLAGS= LDFLAGS= QEMU_OPTS= +CHECK_PLUGIN_OUTPUT_COMMAND= # If TCG debugging, or TCI is enabled things are a lot slower @@ -180,6 +181,10 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(call strip-plugin,$<)) + $(if $(CHECK_PLUGIN_OUTPUT_COMMAND), \ + $(call quiet-command, $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout, \ + TEST, check plugin $(call extract-plugin,$@) output \ + with $(call strip-plugin,$<))) else run-%: % $(call run-test, $<, \ @@ -194,6 +199,10 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(QEMU_OPTS) $(call strip-plugin,$<)) + $(if $(CHECK_PLUGIN_OUTPUT_COMMAND), \ + $(call quiet-command, $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout, \ + TEST, check plugin $(call extract-plugin,$@) output \ + with $(call strip-plugin,$<))) endif gdb-%: % From patchwork Tue Sep 10 14:07:25 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: 827008 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325695wrc; Tue, 10 Sep 2024 07:09:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/b025Kchr5EKX9tLSfmZCdkazCwlwLnT5E5IuACt3GxF0jiloq2W3jmAH3tVbiXaIpHEUNQ==@linaro.org X-Google-Smtp-Source: AGHT+IGaE8Ig+3z4S6kUVAYEoHVuEC8aCE8SUQJoem1k/zFg2vBdGGi07zcjV37YdVWKVXNy2+ap X-Received: by 2002:a05:6902:1b13:b0:e13:c6ec:2a7d with SMTP id 3f1490d57ef6-e1d34a56220mr16901829276.37.1725977346328; Tue, 10 Sep 2024 07:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977346; cv=none; d=google.com; s=arc-20240605; b=KwAaKJzQRx/NwzVDsqw0J/n1CxdDuvRYVBqRBooUwotzfak3zv4j2yuYS/xLtIrqR1 gXn9iSorNX1dqUXFYOIGVpBqmLPm8x+/Qx0YJ3qoNOZSVTTs5Bn1+gzDwrXsRdwMzrKs 83plz7uDl3zXnZIeQgZ5N5jcI0fh6mtsd5ARhBtNez86WQemT2v3D5OPh5HVdjMR6hjI VqWEw28ov1EYF/NNtNGg/ywRWRbSNnKHUl2djlUNT6n4Nis82UQ14/fWugsL+EdUdoNb pL/mEJChPCENUTIMFDEtP/HSIa/lpL8xzYXtXDgrJnXLL8KArPt3zx4KmZ614n+yLeri TYIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=tNcKpK3gqW5pd0AiX4NmCCbDvgLi1QOfUkQVya3+J3c=; fh=oBBE9wOdhjgpcP0FcSrE584/AGvZ2BHpP3QT5nS0ooo=; b=SumsmXy+GjBxU/+u+4Btc/qGenzlZWSv0MsTNAMFvbI0E8O7Rc8N0LAxp3zsfuFfLw QEJUgiAxiWwxZsiaa4C9ndeKGUf/VCiObNt8/AYuVPkiroIuN+dxKheLV6zFMa48doaJ Jz/2Yov82ZFUsqZhMdlpxfmjRSp4ygpiIbQI695saWxivw+0110EVQUaItJJ5Wv9dBgn IDASdpyaoV5EdGuaX0vCUT/Xoh7e6U1dCMZRLiodHQCSHO9z/bauZLfyT7K0CmLCTxK+ e1OzgE3fn7eJLuGMXrXtLBm33aOEPKV4bwKOi4/nGgLlzyjNGdJUcsEIvbUOmq15GL5r Z5pA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bwZPAxUO; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bb817f9si1003615276.281.2024.09.10.07.09.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:09: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=bwZPAxUO; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1XB-00005C-85; Tue, 10 Sep 2024 10:07:57 -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 1so1X8-0008GV-3C for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:54 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X4-0006ZO-O9 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:53 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a8a897bd4f1so581114566b.3 for ; Tue, 10 Sep 2024 07:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977269; x=1726582069; 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=tNcKpK3gqW5pd0AiX4NmCCbDvgLi1QOfUkQVya3+J3c=; b=bwZPAxUOz8fDk0nuJ8Nw6Ziy6JJ2cUV5PLew3t4woDjflcUzSlB+GA+CJopn2JcNQV kdHmbdGq/YmfXPH08F3Iyymi6NOWvGPH6630p1F6a1I8DGy5XjeTp4KxkEBiJayWGMYj S4pfHwb+iZGokZEvTLBYJN6ALTaZP95Qp0F/7aTt+q7Jb4ng++IoixfDDFzGUZneHz9Z QCUNJjLGuIGGK3PoJvcar5nBc9vnT3mD0L7WX8bebBOVDf79DUndlYTYRpR6Ip+wU64l eenF5XtsuKC8MjjKiHSNtdN/fD97Kho9MGhj2bdIkact0X6JFS2Sn0gJrcVaXm62sM/Z 7jcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977269; x=1726582069; 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=tNcKpK3gqW5pd0AiX4NmCCbDvgLi1QOfUkQVya3+J3c=; b=n+20q5rLKkGkm+yuGi0RX9wpd7WY+SA+eKfyvkKngzJAzJEzv+ASFN51aoNqfdGLZU zH2BaUMPIJjeSG+5AzdHukIdhHqRdY6oxE3/qBp1vmd/Tw0cgopwqCBWaMsocJNwoaLs aBTT+j1cCqsvfG0ljy0zU3YNp5JDKrXezKXDGM0B4VAIXQkHUKXnWaVPG0WppASfq+yA FZrJ/P2mm9WksR+7hVMRFQhUvHN+lfkeinat4hBs0TrY+jjJNiVa4gaGqA2GFnr1GagO MZwxC5C4i9NFa2gqh8XI18vZ3Zs+2getsAH3Ay8L/AC4pcuoxHnMABYfwKyY+SlzWH+B O+xw== X-Gm-Message-State: AOJu0YzIXrhnO03xMvIwugfQWR7IuKqtZQ202aEwtSIn50rVnNdrqpnX Dcj/iIfkiZpyu3R9Tbh/QOUfvMi+QUt3KQColH64W3Q5cik4TiWntwr02VqBNLM= X-Received: by 2002:a17:907:2684:b0:a72:9d25:8ad3 with SMTP id a640c23a62f3a-a8ffaa93bc5mr95735566b.9.1725977268733; Tue, 10 Sep 2024 07:07:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cea3e1sm482516466b.167.2024.09.10.07.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 74CEF5F7B4; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Xingtao Yao Subject: [PATCH 18/26] tests/plugin/mem: add option to print memory accesses Date: Tue, 10 Sep 2024 15:07:25 +0100 Message-Id: <20240910140733.4007719-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x630.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=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: Pierrick Bouvier By using "print-accesses=true" option, mem plugin will now print every value accessed, with associated size, type (store vs load), symbol, instruction address and phys/virt address accessed. Reviewed-by: Richard Henderson Reviewed-by: Xingtao Yao Signed-off-by: Pierrick Bouvier Message-Id: <20240724194708.1843704-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- tests/tcg/plugins/mem.c | 69 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c index b650dddcce..086e6f5bdf 100644 --- a/tests/tcg/plugins/mem.c +++ b/tests/tcg/plugins/mem.c @@ -21,10 +21,15 @@ typedef struct { uint64_t io_count; } CPUCount; +typedef struct { + uint64_t vaddr; + const char *sym; +} InsnInfo; + static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 mem_count; static qemu_plugin_u64 io_count; -static bool do_inline, do_callback; +static bool do_inline, do_callback, do_print_accesses; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; @@ -60,6 +65,44 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, } } +static void print_access(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + InsnInfo *insn_info = udata; + unsigned size = 8 << qemu_plugin_mem_size_shift(meminfo); + const char *type = qemu_plugin_mem_is_store(meminfo) ? "store" : "load"; + qemu_plugin_mem_value value = qemu_plugin_mem_get_value(meminfo); + uint64_t hwaddr = + qemu_plugin_hwaddr_phys_addr(qemu_plugin_get_hwaddr(meminfo, vaddr)); + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, + "0x%"PRIx64",%s,0x%"PRIx64",0x%"PRIx64",%d,%s,", + insn_info->vaddr, insn_info->sym, + vaddr, hwaddr, size, type); + switch (value.type) { + case QEMU_PLUGIN_MEM_VALUE_U8: + g_string_append_printf(out, "0x%02"PRIx8, value.data.u8); + break; + case QEMU_PLUGIN_MEM_VALUE_U16: + g_string_append_printf(out, "0x%04"PRIx16, value.data.u16); + break; + case QEMU_PLUGIN_MEM_VALUE_U32: + g_string_append_printf(out, "0x%08"PRIx32, value.data.u32); + break; + case QEMU_PLUGIN_MEM_VALUE_U64: + g_string_append_printf(out, "0x%016"PRIx64, value.data.u64); + break; + case QEMU_PLUGIN_MEM_VALUE_U128: + g_string_append_printf(out, "0x%016"PRIx64"%016"PRIx64, + value.data.u128.high, value.data.u128.low); + break; + default: + g_assert_not_reached(); + } + g_string_append_printf(out, "\n"); + qemu_plugin_outs(out->str); +} + static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { size_t n = qemu_plugin_tb_n_insns(tb); @@ -79,6 +122,16 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) QEMU_PLUGIN_CB_NO_REGS, rw, NULL); } + if (do_print_accesses) { + /* we leak this pointer, to avoid locking to keep track of it */ + InsnInfo *insn_info = g_malloc(sizeof(InsnInfo)); + const char *sym = qemu_plugin_insn_symbol(insn); + insn_info->sym = sym ? sym : ""; + insn_info->vaddr = qemu_plugin_insn_vaddr(insn); + qemu_plugin_register_vcpu_mem_cb(insn, print_access, + QEMU_PLUGIN_CB_NO_REGS, + rw, (void *) insn_info); + } } } @@ -117,6 +170,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + } else if (g_strcmp0(tokens[0], "print-accesses") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &do_print_accesses)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; @@ -129,6 +188,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, return -1; } + if (do_print_accesses) { + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, + "insn_vaddr,insn_symbol,mem_vaddr,mem_hwaddr," + "access_size,access_type,mem_value\n"); + qemu_plugin_outs(out->str); + } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); mem_count = qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, mem_count); From patchwork Tue Sep 10 14:07:26 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: 827020 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp328983wrc; Tue, 10 Sep 2024 07:14:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVyU8uTewYg2SGjQuaR4ZDNJ4g+dBpTT48Vit549vXFq/g7h1JPr+yfrxuSghdua5a556GrHw==@linaro.org X-Google-Smtp-Source: AGHT+IEfr3WdEKUWJVdc84G5ggTtIVe5FfqQem7q+X0lz+9fjJR2+4zype+4GBVrtxBRNjhqT8uJ X-Received: by 2002:a05:620a:25cd:b0:79d:21de:f80e with SMTP id af79cd13be357-7a99738c031mr1741295785a.56.1725977673061; Tue, 10 Sep 2024 07:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977673; cv=none; d=google.com; s=arc-20240605; b=ALGOpZZ8AY1pJitCZK7QuaXy4gU8vX/r/nei6FHc1XgqJZTRQET3KVnM1id37zRL6G klWSOQQ2PBBzA9Uxl9B2IgBuJD5qN6O8Ca84241O935pnnzB0EfSh1O2c1O0eZsCltK8 qRkqL3tomGhhjNhcBwTSQ0wK4pS8Jh8/8/eEjK1rPxr2x4F+Lv/2UoTBvz9NUImOF5WN nTvDGd0vE4EKO65hl+6RIILlrjXu2qwsvmylq5BawOl+ZYqAReMq3NJGId4uiG5WHM5G 50M8kgjpRwq5nIR8DIuE8unIotKJWksnftTZQCNkrnbP1Oty0Q3CzxMMfJ2DGN4WQbYr mmwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=uAf+CXUcolH9rKHrNsjwgZNqlQIpEkE3qYyXUtlw504=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=OtQVAIoO7eluyNFP58ipXFKjM0pRaXtLH9W6SEaqMDlCu2VZvTTPit7aELboezxP9B VJ07OU3zKA+PVkUQI4zGTrifD7j2QW5dCrb9/y6lPnLWm0hc71utyQ+mL2Yrh4xU/hD7 F3GowCvcAS4wbsxVNHNHmbuy1iVTmXESiDfjVzQbOfc+JvC2EiD3Ln7ypLH7j+cCBNwb MDqV1WAADCanXHbstCJlDP9Inhz3FNx3yeJlqM9AUZKutteksiuUDmJ+DbswRQmxNpli Iw5SO+Qsct3HwoDmeqkTgF0apHpPIqRN2x6W+VjdZvGhvQgL64Ey+D6qfGCXaQtQ+chN Y+3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N+7ZwCV1; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a7a34c6dsi827840085a.269.2024.09.10.07.14.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:14: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=N+7ZwCV1; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1cw-0002H1-Id; Tue, 10 Sep 2024 10:13: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 1so1cv-0002Bs-6S for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:53 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1ct-0007Sc-B1 for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:52 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-535be093a43so1123330e87.3 for ; Tue, 10 Sep 2024 07:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977629; x=1726582429; 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=uAf+CXUcolH9rKHrNsjwgZNqlQIpEkE3qYyXUtlw504=; b=N+7ZwCV1JFEhV8XpLvuinDGsFEYMkrw2eyWVxJek6Ds/pAGrUNddetSPeV8IBIDB0j BLSaG4SOBP0yJdiMqkAbH5TFPWC7DzOryVtgAx/vCGSRXyG+SfCzS+BCJsUSehA9oDHc o8usauivhOuYWaGdEFmqGIDa2Kq1Yjuoe6z2pbnWFb8oNJsVuk4SMgCxTdYDNblv2eIi HznJk6XXu0I3DeOq/jRN/t/5fHJZsfhpmfH5MVMvnBcvR13HCbHpztInx5nU2S+Js/k9 c+Q0xOnOseOZYkvtryvx+2dMmVY9arG7ns6lt/gHotXf4GfrFfpVrgSjhJgECjWzkbGX tHGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977629; x=1726582429; 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=uAf+CXUcolH9rKHrNsjwgZNqlQIpEkE3qYyXUtlw504=; b=Uv2iXTakex5qa0jlCAbDE4eEV127DxCihltGQHgVUn25m7t/t2rqzV4TGj7q3lcLVx ztEGmZfKkINAuVl27iLCUTA5iOwXRqmUf+kL+6WP4DguJBC54UTHWI9NS7+JOX4v71mz OnmEcicij0mv3cKF06azTlML146Q+BrUF+zyK9JKBICiBYPv50WvW291apO+2/Fxxj/1 /v3eGRtOevheKDV0Cu0lMJLiLk2u2pnPv1PrkkEtH6+sNlvBVAsE2/foPqOfVfhAKIar QeFu6fUCLiq+rtGT+kGrpDuTTpVWohQCrvdGBSLhiWbJPXzSH4ZNSRyoBiBxuf0vSPe/ c8Yw== X-Gm-Message-State: AOJu0Yy4NuYldCshN+eqEec9sOLtfqa57w/j28jsfyimRsXHAYY2+08J BPlFv6po19MGu2F4ehpruEUJWSGTmkamEzpMF+Nk8M2wivnVlcGDMWsgVjqUoSY= X-Received: by 2002:a05:6512:3b22:b0:536:545c:bbf6 with SMTP id 2adb3069b0e04-536587a3fb8mr9036141e87.1.1725977628420; Tue, 10 Sep 2024 07:13:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd41cd7sm4339984a12.3.2024.09.10.07.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:47 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8E34C6343F; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 19/26] tests/tcg: clean up output of memory system test Date: Tue, 10 Sep 2024 15:07:26 +0100 Message-Id: <20240910140733.4007719-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x131.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=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 useful information when debugging memory issues so lets improve by: - include the ptr address for u8 fills (like the others) - indicate the number of operations for reads and writes - explicitly note when we are flushing - move the fill printf to after the reset Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- tests/tcg/multiarch/system/memory.c | 47 ++++++++++++++++++----------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index 6eb2eb16f7..8f2371975d 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -63,12 +63,14 @@ static void init_test_data_u8(int unused_offset) int i; (void)(unused_offset); - ml_printf("Filling test area with u8:"); + ml_printf("Filling test area with u8 (%p):", ptr); + for (i = 0; i < TEST_SIZE; i++) { *ptr++ = BYTE_NEXT(count); pdot(i); } - ml_printf("done\n"); + + ml_printf("done %d @ %p\n", i, ptr); } /* @@ -94,7 +96,7 @@ static void init_test_data_s8(bool neg_first) *ptr++ = get_byte(i, !neg_first); pdot(i); } - ml_printf("done\n"); + ml_printf("done %d @ %p\n", i * 2, ptr); } /* @@ -105,9 +107,18 @@ static void reset_start_data(int offset) { uint32_t *ptr = (uint32_t *) &test_data[0]; int i; + + if (!offset) { + return; + } + + ml_printf("Flushing %d bytes from %p: ", offset, ptr); + for (i = 0; i < offset; i++) { *ptr++ = 0; } + + ml_printf("done %d @ %p\n", i, ptr); } static void init_test_data_u16(int offset) @@ -117,17 +128,17 @@ static void init_test_data_u16(int offset) const int max = (TEST_SIZE - offset) / sizeof(word); int i; - ml_printf("Filling test area with u16 (offset %d, %p):", offset, ptr); - reset_start_data(offset); + ml_printf("Filling test area with u16 (offset %d, %p):", offset, ptr); + for (i = 0; i < max; i++) { uint16_t low = BYTE_NEXT(count), high = BYTE_NEXT(count); word = BYTE_SHIFT(high, 1) | BYTE_SHIFT(low, 0); *ptr++ = word; pdot(i); } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); } static void init_test_data_u32(int offset) @@ -137,10 +148,10 @@ static void init_test_data_u32(int offset) const int max = (TEST_SIZE - offset) / sizeof(word); int i; - ml_printf("Filling test area with u32 (offset %d, %p):", offset, ptr); - reset_start_data(offset); + ml_printf("Filling test area with u32 (offset %d, %p):", offset, ptr); + for (i = 0; i < max; i++) { uint32_t b4 = BYTE_NEXT(count), b3 = BYTE_NEXT(count); uint32_t b2 = BYTE_NEXT(count), b1 = BYTE_NEXT(count); @@ -149,7 +160,7 @@ static void init_test_data_u32(int offset) *ptr++ = word; pdot(i); } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); } static void init_test_data_u64(int offset) @@ -159,10 +170,10 @@ static void init_test_data_u64(int offset) const int max = (TEST_SIZE - offset) / sizeof(word); int i; - ml_printf("Filling test area with u64 (offset %d, %p):", offset, ptr); - reset_start_data(offset); + ml_printf("Filling test area with u64 (offset %d, %p):", offset, ptr); + for (i = 0; i < max; i++) { uint64_t b8 = BYTE_NEXT(count), b7 = BYTE_NEXT(count); uint64_t b6 = BYTE_NEXT(count), b5 = BYTE_NEXT(count); @@ -174,7 +185,7 @@ static void init_test_data_u64(int offset) *ptr++ = word; pdot(i); } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); } static bool read_test_data_u16(int offset) @@ -198,7 +209,7 @@ static bool read_test_data_u16(int offset) } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); return true; } @@ -239,7 +250,7 @@ static bool read_test_data_u32(int offset) pdot(i); } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); return true; } @@ -293,7 +304,7 @@ static bool read_test_data_u64(int offset) pdot(i); } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); return true; } @@ -365,7 +376,7 @@ static bool read_test_data_s8(int offset, bool neg_first) return false; } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i * 2, ptr); return true; } @@ -398,7 +409,7 @@ static bool read_test_data_s16(int offset, bool neg_first) return false; } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); return true; } @@ -431,7 +442,7 @@ static bool read_test_data_s32(int offset, bool neg_first) return false; } } - ml_printf("done @ %p\n", ptr); + ml_printf("done %d @ %p\n", i, ptr); return true; } From patchwork Tue Sep 10 14:07:27 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: 827025 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp329338wrc; Tue, 10 Sep 2024 07:15:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXt+VvNrG0jxgVYpSTdcjACbnouBj6mDvNlv8jdPQ2iZu9cNHjE73GE9S9+NXUS/alVGcAlXg==@linaro.org X-Google-Smtp-Source: AGHT+IFbZtuTRjpYChLgzCvFxrv5BKm480viRQMuQZexPF73f7TbmEXCB1VCpDYifRPdUw52muFC X-Received: by 2002:a05:6214:1241:b0:6ad:84aa:2956 with SMTP id 6a1803df08f44-6c554d4e4famr56166276d6.13.1725977706098; Tue, 10 Sep 2024 07:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977706; cv=none; d=google.com; s=arc-20240605; b=M0M6k90NICpmAC7QJD6UAsTKiHKF0HTw6LRqC8csbP07Qznj6itvz+mQBp68K+NAS6 Iz4aqLEU8lhHPCgMINkN9IXwQmihUmReifN/08QQkME5fNIMfHYtk9tCl1Sosrxdlb9Q 2qrDi8XmZMNSZu2yTc9AaalSPf3fIxmfhTyq/LJu/ohN4ktwfh/V6UNdvtCIcE7eb+Pf 19Q8W/KRLQOgb+mgsTGqaEdsyYcYavJhPLMCpF3wsBAJ0Qqb3a/LwR03H9D8wAOOLWK2 rMOqr8HQNlh6nDPI10NDEntPb7+b0profd2Ewtq01QcU/bDe1Vz5cALaopROPBp3dk2u f/9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=VkzJlS4txjflyKkh4CCHIuVaip6qn2yADs/S0X5KKR8=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=QRSUF6tk8CZAMJzgAARJkIjo+B1Na+/jjteShTeU6grFNBSMcav+AaLtcc5dsFICqW zQ9SdDJg/ourOrwwHeJj+IUiuYDA5qwUeX2MVIHzQXcAVYqBg5vFJuFvob+7rS3oOzOo LpCq8khi4I5wk2JrI63ywhvax07ucOwvNoo3b2WvnmSPxl9gTFEChekfZ/MC0mpVF5Iy 8fn2YAw/Ln2ZJ7bKrWJIx2X1JRs14MOSK/hAqY77s4ief/HAUo1HqR+LQ8QHY1zdIcdl /+pFUaGUOCAxaBvywjBMKXpE+aiMcrQpYoEVSekI2DUjn7wTTYNsqa2ixr3r2sw3RKV/ elfw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="RNKA/M8m"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-49c16dd1751si341485137.428.2024.09.10.07.15.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:15: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="RNKA/M8m"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1d4-0003Cd-Pl; Tue, 10 Sep 2024 10:14:02 -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 1so1d2-0002xU-Ul for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:14:00 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1d1-0007Vq-4r for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:14:00 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso27825066b.1 for ; Tue, 10 Sep 2024 07:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977636; x=1726582436; 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=VkzJlS4txjflyKkh4CCHIuVaip6qn2yADs/S0X5KKR8=; b=RNKA/M8m4PM+OZSubSJ6YOY/OyokkKEotNLgR1Xs3kpZZyL/vpSvQ5oJkNp0/GaazA mLxjAj/cZr9t0q10f16VreTvNMc38j5lWUq78MfLjT0znKyde6zDqLFDHojtZeL40YU4 E5UJy+tfruWKVfxNV8EoAB/ivT7mi4SLk3N3YIVHYDAMXihD4Zx3Q3zkg52slLuHOGkA nUxlwRRLUVqOYAlyjvT9HeDtJGsliOO32wrTTHLSzDbzApYDptT1h2BbhNXKF+z5axQ1 QGmDZGSAapdyEaHTHunAe5cpj4hcsjPo8GUHDwDGTd0rUWflg1/WSB6388sH5hhbhzYF HbHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977636; x=1726582436; 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=VkzJlS4txjflyKkh4CCHIuVaip6qn2yADs/S0X5KKR8=; b=fcMq2MdVy9+Vd6O8ySERtBUKwg4xXfKVTlJV+aD+YqXwdYSulwCOGhD9E6r7lUcqJy H/YSzxGE5gNe9ZWpeWCg5HbJ9B38A7PkrMQIRXjM+TQ479NCO8HMXmNkKbIdRVkMxrMG 412jHFhVJcdFaqRm9PzLpiHSHDnlHlDNHMWpQXbSUxLYEWLwf0tTDyLhqMVR1FLP7AWH Wlw3an6FDo2xLkEZN73eJ4KZ+bguWeJLtENlOJ5uLSZmyeorj137TPXzvC6REHwwJN5b nhvYklFjyhtmCIm5tN6KMz2+40p3M8FuUXHH1vSB4R9jr7gBIQSlOseL8Km5emjEQMWT 9iJQ== X-Gm-Message-State: AOJu0Yz6hG5igd1c2Ad/SJt026ADH/76jXBMfbtMseQK/I2F9VdhXxWR OxuhTXe0eSOyTV2kDgsCmChSuvAZJGBYgE6nCtF4hNmFcVBInYijp0UptKq/RNA= X-Received: by 2002:a17:907:e291:b0:a8d:505a:5458 with SMTP id a640c23a62f3a-a8ffb20f42amr123827766b.10.1725977636389; Tue, 10 Sep 2024 07:13:56 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d259c1fa3sm487925166b.80.2024.09.10.07.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:53 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A628E63460; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 20/26] tests/tcg: only read/write 64 bit words on 64 bit systems Date: Tue, 10 Sep 2024 15:07:27 +0100 Message-Id: <20240910140733.4007719-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org While the compilers will generally happily synthesise a 64 bit value for you on 32 bit systems it doesn't exercise anything on QEMU. It also makes it hard to accurately compare the accesses to test_data when instrumenting. Signed-off-by: Alex Bennée Reviewed-by: Pierrick Bouvier --- tests/tcg/multiarch/system/memory.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index 8f2371975d..680dd4800b 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -163,6 +163,7 @@ static void init_test_data_u32(int offset) ml_printf("done %d @ %p\n", i, ptr); } +#if __SIZEOF_POINTER__ == 8 static void init_test_data_u64(int offset) { uint8_t count = 0; @@ -187,6 +188,7 @@ static void init_test_data_u64(int offset) } ml_printf("done %d @ %p\n", i, ptr); } +#endif static bool read_test_data_u16(int offset) { @@ -254,6 +256,7 @@ static bool read_test_data_u32(int offset) return true; } +#if __SIZEOF_POINTER__ == 8 static bool read_test_data_u64(int offset) { uint64_t word, *ptr = (uint64_t *)&test_data[offset]; @@ -307,11 +310,16 @@ static bool read_test_data_u64(int offset) ml_printf("done %d @ %p\n", i, ptr); return true; } +#endif /* Read the test data and verify at various offsets */ -read_ufn read_ufns[] = { read_test_data_u16, - read_test_data_u32, - read_test_data_u64 }; +read_ufn read_ufns[] = { + read_test_data_u16, + read_test_data_u32, +#if __SIZEOF_POINTER__ == 8 + read_test_data_u64 +#endif +}; bool do_unsigned_reads(int start_off) { @@ -476,10 +484,14 @@ bool do_signed_reads(bool neg_first) return ok; } -init_ufn init_ufns[] = { init_test_data_u8, - init_test_data_u16, - init_test_data_u32, - init_test_data_u64 }; +init_ufn init_ufns[] = { + init_test_data_u8, + init_test_data_u16, + init_test_data_u32, +#if __SIZEOF_POINTER__ == 8 + init_test_data_u64 +#endif +}; int main(void) { From patchwork Tue Sep 10 14:07:28 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: 827023 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp329156wrc; Tue, 10 Sep 2024 07:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV61nsg57RI5c2ZvDEuBz4QYsrBpXIXJCdhlg8Omlzmjoh3/yJ8xbFI68yJAXblhAXczN/FiA==@linaro.org X-Google-Smtp-Source: AGHT+IFzaKlQFjX0tsXtsvCnW2A+qqDBbeRsiKu4pVROufRRBD+rTy96hOEQuzLioNreD7gsF66v X-Received: by 2002:a05:6214:590f:b0:6c4:79df:a2e1 with SMTP id 6a1803df08f44-6c5285067f8mr199392586d6.23.1725977690261; Tue, 10 Sep 2024 07:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977690; cv=none; d=google.com; s=arc-20240605; b=PlJXmKf3HYdBzZTvvKlZFQHWWFmdcvhO0o6JZBRUX+Y7l9n30obhutYj1akurVd1nh Sc/Hx0SfW1Cz2spCaNUkL8abnZJD7HRRQQyGSlipJSkoGQhWYxT/okzJHMQN5/Uhb/v8 yQIlCj+PnVhKAtVGn6XLeHb7gopuXYiSruQ8WfQ/oIV8EpFKI28qusFL5Vdtxc7bJAqI dIDZcoiBrOi37zq+I0hy8tgsZ0abWkkIjNvTBt6Cu1b4XAU8gCxYRkxHBr0M+LHJXvWY n1y+u1wwbmUvsjGlT1GMUvV2hcj3MGn12KFM5lnMCdsGMpX7v2AD2hpkzdPREb8OAczx 2teg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Zroaak8xFFAJBnGJiz25P6JCeHv1e5w1wtwssc9iSGg=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=etuOkghdAHBhGC864j1QrvrNM/cy/jLX2kECgDvvomERPJbWVc3WnzBLqMl1D9DmWb SxOncgJ0pQS7C/YA/6564SmkhPuF2maTwOZBQeEGTxZCFV7C2LUoUqfKDyjl35ZpUBzP 4Ejtah5f2cKovdXiqzw1VgUU9avDzYxWXIhLUnrzd+eTEz7tST5YENxROcnAe2tsRL3z 5RWjkKiBagxE6Eh/pBFep5QDLytMaZnLSklzz69mXAZnQ8bA3l7bQwL+pIfZrWNmTHnA 5eVwL7c/InFN9Z0YPEh4F3uCzV8S6LZUSEcqBw0QpPPfwOOIA/vDPmS8cS9krTuyvV0b 2rUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HhONXx0x; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c534782e09si78246246d6.393.2024.09.10.07.14.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:14: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=HhONXx0x; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1d3-00030i-I2; Tue, 10 Sep 2024 10:14:01 -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 1so1d1-0002jy-6J for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:59 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1cx-0007Ub-Qh for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:58 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2f029e9c9cfso1351701fa.2 for ; Tue, 10 Sep 2024 07:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977634; x=1726582434; 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=Zroaak8xFFAJBnGJiz25P6JCeHv1e5w1wtwssc9iSGg=; b=HhONXx0xTryf6DjGZNASbMK047t84N9O8UJKqZCuUYU19vA8j0NS8xF/tVVu5+SI5P R1QOJeTk0J6IQL3IJfYQTFd4f+U8a1bB5ZUKL/H/MviOEpBhp7uFaGG5/boe+DEY8F6v Hp9SkSjpimURxO8iHN8lmd+HLS4RFmTOXuhDmTPMJCnHzrNUttDqQZStEt3hTeCr5krC tM6DKh2Q7l5/m5V3VwZrhxDfcGF92CrhWIAFttVOjHR8mKC960suk2AXVbykLe31hKPw YfCjghMQo799RitKPgSUqR77UQa9E7VFk3Y2C676pBKCxhD7dkSBapWGQmHjrVEa4RTG 4K0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977634; x=1726582434; 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=Zroaak8xFFAJBnGJiz25P6JCeHv1e5w1wtwssc9iSGg=; b=wOYan0oF/eMlZ86FAOVZLOP+kSZKuLl5wjBo3J41+uLv9YX7EcmW6hqzB+rXhYvnky INcOQL/uxsODGUEwJwyuVgW761S2BNmpHbZH9bIkraaKTrAIJxflW+V34kIXG5bCJR5V GjNch1RdfRGyVjRPb4ioq/nFj7Bi55zHxr+8kuXMYRFMb+0jNIRS67xkXkZRABBd2UhJ FYB2fZjWvvDEs0J4TM1e6vQWNdRZHd5P+ytl8MZI0szW5c3KUdNW9zRHJTlG2Vm69Foo 9y0GnBYQKbxaYEw7TSduVJfDsLXp2Bt8jFs/CdFkx+y1ZrTT4UWrX8OjfEisRwZur0gb dzfg== X-Gm-Message-State: AOJu0YxYlZKnLHuDm/vN5ZrNKvI7PlrNJ+kjyX0zZARybn3npkKgDJm9 bBuiWJizGWVeZk7AleJuKyiMnlzJUvWWg1atQFc83hfn09eiIPLq/guZZG4ziPo= X-Received: by 2002:a2e:b88a:0:b0:2ee:52f4:266 with SMTP id 38308e7fff4ca-2f75a96c43bmr108676401fa.3.1725977633258; Tue, 10 Sep 2024 07:13:53 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d2597a660sm485506266b.75.2024.09.10.07.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:47 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BF45F5F78C; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 21/26] tests/tcg: add a system test to check memory instrumentation Date: Tue, 10 Sep 2024 15:07:28 +0100 Message-Id: <20240910140733.4007719-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22c.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=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 At first I thought I could compile the user-mode test for system mode however we already have a fairly comprehensive test case for system mode in "memory" so lets use that. First we extend the test to report where the test_data region is. Then we expand the pdot() function to track the total number of reads and writes to the region. We have to add some addition pdot() calls to take into account multiple reads/writes in the test loops. As tracking every access will quickly build up with "print-access" we add a new mode to track groups of reads and writes to regions. Because the test_data is page aligned we can be sure all accesses to it are ones we can count. Finally we add a python script to integrate the data from the plugin and the output of the test and validate they both agree on the total counts. Signed-off-by: Alex Bennée --- v2 - aggressively align test_data on "region size" - sort the regions in the final report - ensure alpha-softmmu uses byte access when it can --- tests/tcg/multiarch/system/memory.c | 50 +++-- tests/tcg/plugins/mem.c | 178 +++++++++++++++++- tests/tcg/alpha/Makefile.softmmu-target | 2 +- .../multiarch/system/Makefile.softmmu-target | 6 + .../system/validate-memory-counts.py | 115 +++++++++++ 5 files changed, 332 insertions(+), 19 deletions(-) create mode 100755 tests/tcg/multiarch/system/validate-memory-counts.py diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index 680dd4800b..ccff699015 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -14,26 +14,35 @@ #include #include +#include #include #ifndef CHECK_UNALIGNED # error "Target does not specify CHECK_UNALIGNED" #endif +uint32_t test_read_count; +uint32_t test_write_count; + #define MEM_PAGE_SIZE 4096 /* nominal 4k "pages" */ #define TEST_SIZE (MEM_PAGE_SIZE * 4) /* 4 pages */ #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0]))) -__attribute__((aligned(MEM_PAGE_SIZE))) +__attribute__((aligned(TEST_SIZE))) static uint8_t test_data[TEST_SIZE]; typedef void (*init_ufn) (int offset); typedef bool (*read_ufn) (int offset); typedef bool (*read_sfn) (int offset, bool nf); -static void pdot(int count) +static void pdot(int count, bool write) { + if (write) { + test_write_count++; + } else { + test_read_count++; + } if (count % 128 == 0) { ml_printf("."); } @@ -67,7 +76,7 @@ static void init_test_data_u8(int unused_offset) for (i = 0; i < TEST_SIZE; i++) { *ptr++ = BYTE_NEXT(count); - pdot(i); + pdot(i, true); } ml_printf("done %d @ %p\n", i, ptr); @@ -93,8 +102,9 @@ static void init_test_data_s8(bool neg_first) neg_first ? "neg first" : "pos first"); for (i = 0; i < TEST_SIZE / 2; i++) { *ptr++ = get_byte(i, neg_first); + pdot(i, true); *ptr++ = get_byte(i, !neg_first); - pdot(i); + pdot(i, true); } ml_printf("done %d @ %p\n", i * 2, ptr); } @@ -116,6 +126,7 @@ static void reset_start_data(int offset) for (i = 0; i < offset; i++) { *ptr++ = 0; + pdot(i, true); } ml_printf("done %d @ %p\n", i, ptr); @@ -136,7 +147,7 @@ static void init_test_data_u16(int offset) uint16_t low = BYTE_NEXT(count), high = BYTE_NEXT(count); word = BYTE_SHIFT(high, 1) | BYTE_SHIFT(low, 0); *ptr++ = word; - pdot(i); + pdot(i, true); } ml_printf("done %d @ %p\n", i, ptr); } @@ -158,7 +169,7 @@ static void init_test_data_u32(int offset) word = BYTE_SHIFT(b1, 3) | BYTE_SHIFT(b2, 2) | BYTE_SHIFT(b3, 1) | BYTE_SHIFT(b4, 0); *ptr++ = word; - pdot(i); + pdot(i, true); } ml_printf("done %d @ %p\n", i, ptr); } @@ -184,7 +195,7 @@ static void init_test_data_u64(int offset) BYTE_SHIFT(b4, 4) | BYTE_SHIFT(b5, 3) | BYTE_SHIFT(b6, 2) | BYTE_SHIFT(b7, 1) | BYTE_SHIFT(b8, 0); *ptr++ = word; - pdot(i); + pdot(i, true); } ml_printf("done %d @ %p\n", i, ptr); } @@ -207,7 +218,7 @@ static bool read_test_data_u16(int offset) ml_printf("Error %d < %d\n", high, low); return false; } else { - pdot(i); + pdot(i, false); } } @@ -249,7 +260,7 @@ static bool read_test_data_u32(int offset) ml_printf("Error %d, %d, %d, %d", b1, b2, b3, b4); return false; } else { - pdot(i); + pdot(i, false); } } ml_printf("done %d @ %p\n", i, ptr); @@ -304,7 +315,7 @@ static bool read_test_data_u64(int offset) b1, b2, b3, b4, b5, b6, b7, b8); return false; } else { - pdot(i); + pdot(i, false); } } ml_printf("done %d @ %p\n", i, ptr); @@ -376,9 +387,11 @@ static bool read_test_data_s8(int offset, bool neg_first) second = *ptr++; if (neg_first && first < 0 && second > 0) { - pdot(i); + pdot(i, false); + pdot(i, false); } else if (!neg_first && first > 0 && second < 0) { - pdot(i); + pdot(i, false); + pdot(i, false); } else { ml_printf("Error %d %c %d\n", first, neg_first ? '<' : '>', second); return false; @@ -409,9 +422,9 @@ static bool read_test_data_s16(int offset, bool neg_first) int32_t data = *ptr++; if (neg_first && data < 0) { - pdot(i); + pdot(i, false); } else if (!neg_first && data > 0) { - pdot(i); + pdot(i, false); } else { ml_printf("Error %d %c 0\n", data, neg_first ? '<' : '>'); return false; @@ -442,9 +455,9 @@ static bool read_test_data_s32(int offset, bool neg_first) int64_t data = *ptr++; if (neg_first && data < 0) { - pdot(i); + pdot(i, false); } else if (!neg_first && data > 0) { - pdot(i); + pdot(i, false); } else { ml_printf("Error %d %c 0\n", data, neg_first ? '<' : '>'); return false; @@ -498,6 +511,9 @@ int main(void) int i; bool ok = true; + ml_printf("Test data start: 0x%"PRIxPTR"\n", &test_data[0]); + ml_printf("Test data end: 0x%"PRIxPTR"\n", &test_data[TEST_SIZE]); + /* Run through the unsigned tests first */ for (i = 0; i < ARRAY_SIZE(init_ufns) && ok; i++) { ok = do_unsigned_test(init_ufns[i]); @@ -513,6 +529,8 @@ int main(void) ok = do_signed_reads(true); } + ml_printf("Test data read: %"PRId32"\n", test_read_count); + ml_printf("Test data write: %"PRId32"\n", test_write_count); ml_printf("Test complete: %s\n", ok ? "PASSED" : "FAILED"); return ok ? 0 : -1; } diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c index 086e6f5bdf..42d735d5c8 100644 --- a/tests/tcg/plugins/mem.c +++ b/tests/tcg/plugins/mem.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -26,13 +27,46 @@ typedef struct { const char *sym; } InsnInfo; +/* + * For the "memory" system test we need to track accesses to + * individual regions. We mirror the data written to the region and + * then check when it is read that it matches up. + * + * We do this as regions rather than pages to save on complications + * with page crossing and the fact the test only cares about the + * test_data region. + */ +static uint64_t region_size = 4096 * 4; +static uint64_t region_mask; + +typedef struct { + uint64_t region_address; + uint64_t reads; + uint64_t writes; + uint8_t *data; + bool seen_all; /* Did we see every write and read with correct values? */ +} RegionInfo; + static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 mem_count; static qemu_plugin_u64 io_count; -static bool do_inline, do_callback, do_print_accesses; +static bool do_inline, do_callback, do_print_accesses, do_region_summary; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; + +static GMutex lock; +static GHashTable *regions; + +static gint addr_order(gconstpointer a, gconstpointer b) +{ + RegionInfo *na = (RegionInfo *) a; + RegionInfo *nb = (RegionInfo *) b; + + return na->region_address > nb->region_address ? 1 : -1; +} + + static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out = g_string_new(""); @@ -46,9 +80,129 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) qemu_plugin_u64_sum(io_count)); } qemu_plugin_outs(out->str); + + + if (do_region_summary) { + GList *counts = g_hash_table_get_values(regions); + + counts = g_list_sort(counts, addr_order); + + g_string_printf(out, "Region Base, Reads, Writes, Seen all\n"); + + if (counts && g_list_next(counts)) { + for (/* counts */; counts->next; counts = counts->next) { + RegionInfo *ri = (RegionInfo *) counts->data; + + g_string_append_printf(out, + "0x%016"PRIx64", " + "%"PRId64", %"PRId64", %s\n", + ri->region_address, + ri->reads, + ri->writes, + ri->seen_all ? "true" : "false"); + } + } + qemu_plugin_outs(out->str); + } + qemu_plugin_scoreboard_free(counts); } +/* + * Update the region tracking info for the access. We split up accesses + * that span regions even though the plugin infrastructure will deliver + * it as a single access. + */ +static void update_region_info(uint64_t region, uint64_t offset, + qemu_plugin_meminfo_t meminfo, + qemu_plugin_mem_value value, + unsigned size) +{ + bool be = qemu_plugin_mem_is_big_endian(meminfo); + bool is_store = qemu_plugin_mem_is_store(meminfo); + RegionInfo *ri; + bool unseen_data = false; + + g_assert(offset + size <= region_size); + + g_mutex_lock(&lock); + ri = (RegionInfo *) g_hash_table_lookup(regions, GUINT_TO_POINTER(region)); + + if (!ri) { + ri = g_new0(RegionInfo, 1); + ri->region_address = region; + ri->data = g_malloc0(region_size); + ri->seen_all = true; + g_hash_table_insert(regions, GUINT_TO_POINTER(region), (gpointer) ri); + } + + if (is_store) { + ri->writes++; + } else { + ri->reads++; + } + + switch (value.type) { + case QEMU_PLUGIN_MEM_VALUE_U8: + if (is_store) { + ri->data[offset] = value.data.u8; + } else if (ri->data[offset] != value.data.u8) { + unseen_data = true; + } + break; + case QEMU_PLUGIN_MEM_VALUE_U16: + { + uint16_t *p = (uint16_t *) &ri->data[offset]; + if (is_store) { + *p = be ? be16toh(value.data.u16) : value.data.u16; + } else if (*p != value.data.u16) { + unseen_data = true; + } + break; + } + case QEMU_PLUGIN_MEM_VALUE_U32: + { + uint32_t *p = (uint32_t *) &ri->data[offset]; + if (is_store) { + *p = be ? be32toh(value.data.u32) : value.data.u32; + } else if (*p != value.data.u32) { + unseen_data = true; + } + break; + } + case QEMU_PLUGIN_MEM_VALUE_U64: + { + uint64_t *p = (uint64_t *) &ri->data[offset]; + if (is_store) { + *p = be ? be64toh(value.data.u64) : value.data.u64; + } else if (*p != value.data.u64) { + unseen_data = true; + } + break; + } + case QEMU_PLUGIN_MEM_VALUE_U128: + /* skip */ + break; + default: + g_assert_not_reached(); + } + + /* + * This is expected for regions initialised by QEMU (.text etc) but we + * expect to see all data read and written to the test_data region + * of the memory test. + */ + if (unseen_data && ri->seen_all) { + g_autoptr(GString) error = g_string_new("Warning: "); + g_string_append_printf(error, "0x%016"PRIx64":%"PRId64" read an un-instrumented value\n", + region, offset); + qemu_plugin_outs(error->str); + ri->seen_all = false; + } + + g_mutex_unlock(&lock); +} + static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t vaddr, void *udata) { @@ -63,6 +217,15 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, } else { qemu_plugin_u64_add(mem_count, cpu_index, 1); } + + if (do_region_summary) { + uint64_t region = vaddr & ~region_mask; + uint64_t offset = vaddr & region_mask; + qemu_plugin_mem_value value = qemu_plugin_mem_get_value(meminfo); + unsigned size = 1 << qemu_plugin_mem_size_shift(meminfo); + + update_region_info(region, offset, meminfo, value, size); + } } static void print_access(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -117,7 +280,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) QEMU_PLUGIN_INLINE_ADD_U64, mem_count, 1); } - if (do_callback) { + if (do_callback || do_region_summary) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, QEMU_PLUGIN_CB_NO_REGS, rw, NULL); @@ -176,6 +339,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + } else if (g_strcmp0(tokens[0], "region-summary") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &do_region_summary)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; @@ -196,6 +365,11 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, qemu_plugin_outs(out->str); } + if (do_region_summary) { + region_mask = (region_size - 1); + regions = g_hash_table_new(NULL, g_direct_equal); + } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); mem_count = qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, mem_count); diff --git a/tests/tcg/alpha/Makefile.softmmu-target b/tests/tcg/alpha/Makefile.softmmu-target index a0eca4d6ea..a944102a3c 100644 --- a/tests/tcg/alpha/Makefile.softmmu-target +++ b/tests/tcg/alpha/Makefile.softmmu-target @@ -28,7 +28,7 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) -memory: CFLAGS+=-DCHECK_UNALIGNED=0 +memory: CFLAGS+=-DCHECK_UNALIGNED=0 -mbwx # Running QEMU_OPTS+=-serial chardev:output -kernel diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg/multiarch/system/Makefile.softmmu-target index 32dc0f9830..07be001102 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -65,3 +65,9 @@ endif MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-interrupt \ run-gdbstub-untimely-packet run-gdbstub-registers + +# Test plugin memory access instrumentation +run-plugin-memory-with-libmem.so: \ + PLUGIN_ARGS=$(COMMA)region-summary=true +run-plugin-memory-with-libmem.so: \ + CHECK_PLUGIN_OUTPUT_COMMAND=$(MULTIARCH_SYSTEM_SRC)/validate-memory-counts.py $@.out diff --git a/tests/tcg/multiarch/system/validate-memory-counts.py b/tests/tcg/multiarch/system/validate-memory-counts.py new file mode 100755 index 0000000000..16c2788384 --- /dev/null +++ b/tests/tcg/multiarch/system/validate-memory-counts.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +# +# validate-memory-counts.py: check we instrumented memory properly +# +# This program takes two inputs: +# - the mem plugin output +# - the memory binary output +# +# Copyright (C) 2024 Linaro Ltd +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import sys + +def extract_counts(path): + """ + Load the output from path and extract the lines containing: + + Test data start: 0x40214000 + Test data end: 0x40218001 + Test data read: 2522280 + Test data write: 262111 + + From the stream of data. Extract the values for use in the + validation function. + """ + start_address = None + end_address = None + read_count = 0 + write_count = 0 + with open(path, 'r') as f: + for line in f: + if line.startswith("Test data start:"): + start_address = int(line.split(':')[1].strip(), 16) + elif line.startswith("Test data end:"): + end_address = int(line.split(':')[1].strip(), 16) + elif line.startswith("Test data read:"): + read_count = int(line.split(':')[1].strip()) + elif line.startswith("Test data write:"): + write_count = int(line.split(':')[1].strip()) + return start_address, end_address, read_count, write_count + + +def parse_plugin_output(path, start, end): + """ + Load the plugin output from path in the form of: + + Region Base, Reads, Writes, Seen all + 0x0000000040004000, 31093, 0, false + 0x0000000040214000, 2522280, 278579, true + 0x0000000040000000, 137398, 0, false + 0x0000000040210000, 54727397, 33721956, false + + And extract the ranges that match test data start and end and + return the results. + """ + total_reads = 0 + total_writes = 0 + seen_all = False + + with open(path, 'r') as f: + next(f) # Skip the header + for line in f: + + if line.startswith("Region Base"): + continue + + parts = line.strip().split(', ') + if len(parts) != 4: + continue + + region_base = int(parts[0], 16) + reads = int(parts[1]) + writes = int(parts[2]) + + if start <= region_base < end: # Checking if within range + total_reads += reads + total_writes += writes + seen_all = parts[3] == "true" + + return total_reads, total_writes, seen_all + +def main(): + if len(sys.argv) != 3: + print("Usage: .py ") + sys.exit(1) + + memory_binary_output_path = sys.argv[1] + mem_plugin_output_path = sys.argv[2] + + # Extract counts from memory binary + start, end, expected_reads, expected_writes = extract_counts(memory_binary_output_path) + + if start is None or end is None: + print("Failed to extract start or end address from memory binary output.") + sys.exit(1) + + # Parse plugin output + actual_reads, actual_writes, seen_all = parse_plugin_output(mem_plugin_output_path, start, end) + + if not seen_all: + print("Fail: didn't instrument all accesses to test_data.") + sys.exit(1) + + # Compare and report + if actual_reads == expected_reads and actual_writes == expected_writes: + sys.exit(0) + else: + print("Fail: The memory reads and writes count does not match.") + print(f"Expected Reads: {expected_reads}, Actual Reads: {actual_reads}") + print(f"Expected Writes: {expected_writes}, Actual Writes: {actual_writes}") + sys.exit(1) + +if __name__ == "__main__": + main() From patchwork Tue Sep 10 14:07:29 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: 827024 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp329279wrc; Tue, 10 Sep 2024 07:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUC+yiQNonF/DPLn6FVz8xBplj0MBa2qKGQbBArDhsv04MzY58KMmEmLRz2Ho2cwRczhqdUXQ==@linaro.org X-Google-Smtp-Source: AGHT+IHCV3uqu93HbW3844DK1vcILOGtM59YKnh1RUKYxtlA/AnUlZz09z/ceMR3da8yxVhASQAF X-Received: by 2002:a05:6102:32cd:b0:49b:cb03:ba38 with SMTP id ada2fe7eead31-49bde2e7684mr15858660137.26.1725977701475; Tue, 10 Sep 2024 07:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977701; cv=none; d=google.com; s=arc-20240605; b=VjqwCVdKj+gda3Rmkp3GOedWI9MN/GLaXEQ/isa+ecv5e8uULrShG+I5rgMo2vsvuM aPuQvid5kXPRKaOT1s5BsFrPegHOajFuBFqLyMw0PrXAlITuSxZVlgCyO/eyv5IhPbJP 9I7R+jR4odIfCIrVwUrO6NcYL9V7Jx2+Ow+56pexTy1dj0VIersRejifLosT7uJ5tslJ /vxBNzgnQN05ySLQf6B5GVtWG2zpuqyb6+HfybR2BUXYC7fYM+lnVTlDBuOq9T6816rL 1Mlb0UThfiVWBx4hpoVeUshlS9HA5f+WWQT/kxXYo55sOAoFgseEZd0JxQ/j3chyJ+XB b9jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=cRFhj2SyvQ/EIwHMRij/KsWIl6x9+a8v4XWFbD+c1P0=; fh=fy9yO/TL9XWptt+ue0hUAFqVLBMbBfgjQrjExCF8tXg=; b=WchTXiiW8M0EkjgDtoJyY6WvtOAnEE/5ZcT2V4zpJndHtDUyPUIfyBznXMJxvzvrtP vKYri5OxWaSKmWBpF7JHtwAHfPFesXItflwNOvh5LSeePjSwsYum1jIy+B1oALkm47mI VIWda3WubENIWh4lc8kziTmmMk7RGxjGLFngkHfAMyhCrg0JA3kEZHn4Uy/Goz4Basg3 bquyE3CJ85pbjb0HfuGuzOrjr4OcjgoV2H/IWlogBgRkURBbN7cg3G/TkfHaH53NWDe1 ivf/h8auxQfnRPBErUBrwl2ZOE+XHYoTEDvItWuxAp7rsoHJDX/167XKvxuNXdAkSuR4 qI9w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kgandccl; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-49c16db046esi396690137.288.2024.09.10.07.15.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:15:01 -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=Kgandccl; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1d2-0002t8-CI; Tue, 10 Sep 2024 10:14:00 -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 1so1d1-0002mZ-HG for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:59 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1cz-0007Vl-Qu for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:59 -0400 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5c40942358eso746300a12.1 for ; Tue, 10 Sep 2024 07:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977636; x=1726582436; 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=cRFhj2SyvQ/EIwHMRij/KsWIl6x9+a8v4XWFbD+c1P0=; b=KgandcclTTA7JUISr/s1Py/KBi6AnHZW5BEsTRWNbdoLy7oH9i6AlrQVkZ+7Yv/C5T Vx0pTHxifAvl1AGCleEuBvGCyqjN5GGLixvJGHii37LNTcsy4jJEN0ZGSHizTCJe2IHa P0SgdOOeXpVF5Z/bpDI2AnqTPNBWfFIkACq+YJ/rDpKZ5D89sV/sRRJ8uGemJozmBaAK 6U/HQmEbUmqSTpdfaz1ILRngrjkZAIih4K0CgP50MFvVDW8U1IVBiiryAK1fXi+W1QzW NXQaD2YNay0LWaIczfuB+gmqj5nKS6vZTurleTkhbvoQSvwd8e1Q0pmSUKVUv7TODPvX en+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977636; x=1726582436; 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=cRFhj2SyvQ/EIwHMRij/KsWIl6x9+a8v4XWFbD+c1P0=; b=m70t36B+ciFW0KkxBjVBKmZcJOFF3rvOc7qJzIWEjtH1ObFemWD/0xEIY/Sjb2b3BY KlBSeFsRRoGgVdry1hIjmvdzZTL4jqz2Qlq+vIo7Jzw7yZKV4C82DvB2chEFpeRcnnsM npAUvajMgb7foL0DMmLmNzJHcTxur45nSravBHGN5vofjoF10/olWV9Kir6m6nnuX3ke 1DOFgSKALWieS1HSofwRfvmauF7gxk1DWajicKRUq/rhLfYAm7MgvPXQRGxTxgjW8Cvf MBXC/j4xBzESpDayriZ0i+tYbuS89i8+LrCvvu/iZBQhL4xiJiOgpkUJ1GuxnrG4fSSB REzg== X-Gm-Message-State: AOJu0Yxx++ifEUspsYiWJw3W4qZfyRM+8Xy/VgyoZKIoOivdjPAYvqWJ RbRcMttR4Lr350aVUfEc3LtO9xoKD3jMIk19o0RxeozqvOqlee9U687Qxpcy52I= X-Received: by 2002:a05:6402:3596:b0:5c0:c559:ad6 with SMTP id 4fb4d7f45d1cf-5c4015df1d1mr3218510a12.6.1725977635809; Tue, 10 Sep 2024 07:13:55 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd46909sm4504892a12.25.2024.09.10.07.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:53 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D603D6349A; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Elisha Hollander Subject: [PATCH 22/26] util/timer: avoid deadlock when shutting down Date: Tue, 10 Sep 2024 15:07:29 +0100 Message-Id: <20240910140733.4007719-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When we shut down a guest we disable the timers. However this can cause deadlock if the guest has queued some async work that is trying to advance system time and spins forever trying to wind time forward. Pay attention to the return code and bail early if we can't wind time forward. Signed-off-by: Alex Bennée Reported-by: Elisha Hollander --- util/qemu-timer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 213114be68..6b1533bc2a 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -685,10 +685,17 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest) { int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); AioContext *aio_context; + int64_t deadline; + aio_context = qemu_get_aio_context(); - while (clock < dest) { - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + + deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, QEMU_TIMER_ATTR_ALL); + /* + * A deadline of < 0 indicates this timer is not enabled, so we + * won't get far trying to run it forward. + */ + while (deadline >= 0 && clock < dest) { int64_t warp = qemu_soonest_timeout(dest - clock, deadline); qemu_virtual_clock_set_ns(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + warp); @@ -696,6 +703,9 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest) qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + + deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); } qemu_clock_notify(QEMU_CLOCK_VIRTUAL); From patchwork Tue Sep 10 14:07:30 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: 827021 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp329130wrc; Tue, 10 Sep 2024 07:14:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVfHcMOLLo+n1koSSs4PkfWahV6Dyy4GDiRqNlzgCcqYaSsV9gI6UTBwmgN/uZOesm0xFWfw==@linaro.org X-Google-Smtp-Source: AGHT+IHypihwCA+/XUmvMGypLS2b2ytca2kHbFyrNF/ZiEbn62oFEE1Y4dMJPuwCSaGJhREghS9O X-Received: by 2002:a05:622a:1803:b0:458:401e:c1f2 with SMTP id d75a77b69052e-458401ed111mr25469401cf.31.1725977687198; Tue, 10 Sep 2024 07:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977687; cv=none; d=google.com; s=arc-20240605; b=lLoe0BBc0XHt6KJNFY6J7pC14MYD9osrY1h6j0/onaCfaVCYGRMd92YsQTBS4AGN/8 ICEyuXca8OhUsluULc9f9c/Bc1H4iU4RDK1NUFo63IxvVUt9yAQcfQp0bPmHrIxlASzb iQXUansjjdMaXAMNFPEGt78MjffNY720s7KD0ALXtIXAnXCUbJmrQKFyBmkptpjJZo7y wmTOUW8rIWYj71DMWSvMKqimCKzzWxZQ+kitGSjJZnVXERk1T6+Jbry2QA3UO6XUNSv8 H+k2so4c5lsBdSGqzPp8jq/tFmJVuA45XcNlysa8m2718FQc208Mi4800qvJoFCIQaAe KW8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=S6DKrSbtb2UyOkFJWx3GO7dDs+1RREyLEnRKm6VRifM=; fh=yPECVxgso+RvX6M2cyxEg5Mp3ECkvTa/SX56SNNNjb0=; b=MVv0IK28Wt3YvmBDEzzk5gfI0bx+Y9ba9VSo4CYYRriWlsNzzchXLEpYKfGBGfvOmc XFAq4zWvyf4U7gZMVVekY38tSJS6sael43IS4FJUwe9tuGnSsBRistgGdZ29gXZNj9yg KaxJBI3lYxr0YlLPRIScE+st4XQDHDwEAh+SQMEP4ocClOgSP39PBFsc2YwHdtzAk7rK /bqEnKsb8Z/mc64zmF8gR9UezOzMDr9DBpWTxpUaCgUrGZcAP1FCpliMc/4/U7JKl1mG nVI4ddlPNIlCqJRj/ucoJ+xtN0TYFbr1jlYIe34ncIeVOpuRh98CojVVn765YA7OD7We 1OmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HJo7h8k0; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4582fa2d514si54174761cf.745.2024.09.10.07.14.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:14: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=HJo7h8k0; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1d1-0002o5-OI; Tue, 10 Sep 2024 10:13:59 -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 1so1cy-0002R2-MX for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:56 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1ct-0007Sx-Oc for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:56 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5c26852aff1so6524861a12.3 for ; Tue, 10 Sep 2024 07:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977630; x=1726582430; 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=S6DKrSbtb2UyOkFJWx3GO7dDs+1RREyLEnRKm6VRifM=; b=HJo7h8k0x5t/aNeCB1FTtjSocQHCZPj/t0EPjE+nzCfyc4Unvc6TIIJxGzfeHva++w aRcAow/vyzbuD60usyl8eyiR/Htp9iyFgVJNLiOIfwO6WIBoGfqzlHXlwFVRj3mc7cmg RCDeKO0uPm//yjn7+236/6g9FQzPTFlEp9k2Cf7WjKDUGdQXhH/G6y0+Ccty8wHP65sJ puGyho5ZspAEjiyWJfYrm57qAKRTU7Mzml+Sg8XNKhQEZK8t6ssJ8n2+wFAoe2/hpG7q HMKgoyDXcYK/516IZ11c+rISmvdNewjXugSxCShvPZhGnKvRcLAM2ZYc7xZ8lyI8LMW+ +p0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977630; x=1726582430; 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=S6DKrSbtb2UyOkFJWx3GO7dDs+1RREyLEnRKm6VRifM=; b=QbANkH72XSbr7akU3gz2VCIj5wCOfCV0Qf1EFqzjqq0qcKVv/4la3ROrfS8w+RX9R6 wFsf/zZAbz2oXgZa7LNpTVEwg0slXoaodokJTHucQ2eeDVKyJM9VlRu0uppTCQ9ZfKNV flYhywR/+JDG+ncvANxYfRdrYf3SdzZWzFuL97G0tELm1qvX+bNbIkBQh7v1ruRvhM2f byts6ItQnoOePhTU4YWZkT+BdYBm2fSpeFlRzkRUbO9jIdXkQEd7khA0Fc3DpgoDmJ2S mLpvwRcEnFLXMVUaC6/iFy2c7oPGgP/v3MprDX7xydbUS7omC6f4/oGU2YibLsx99r3a VtxQ== X-Gm-Message-State: AOJu0Yyhk4Jccuwfz3dHfygi3TkpVqo5Op2DeXMhRGDs5JkSoPN9eUoW 8OUoHYxe9La4tL12C+x/Bs41ThNSq2Acn85AsM48WyzP1YZeeiyj04pSCjRyHuE= X-Received: by 2002:a05:6402:4015:b0:5c3:cd88:a0a with SMTP id 4fb4d7f45d1cf-5c3e963621dmr9118972a12.18.1725977629785; Tue, 10 Sep 2024 07:13:49 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebce3448sm4368461a12.0.2024.09.10.07.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:47 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F2C9D634A2; Tue, 10 Sep 2024 15:07:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Akihiko Odaki , Yotaro Nada Subject: [PATCH 23/26] contrib/plugins: Add a plugin to generate basic block vectors Date: Tue, 10 Sep 2024 15:07:30 +0100 Message-Id: <20240910140733.4007719-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.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=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 SimPoint is a widely used tool to find the ideal microarchitecture simulation points so Valgrind[2] and Pin[3] support generating basic block vectors for use with them. Let's add a corresponding plugin to QEMU too. Note that this plugin has a different goal with tests/plugin/bb.c. This plugin creates a vector for each constant interval instead of counting the execution of basic blocks for the entire run and able to describe the change of execution behavior. Its output is also syntactically simple and better suited for parsing, while the output of tests/plugin/bb.c is more human-readable. [1] https://cseweb.ucsd.edu/~calder/simpoint/ [2] https://valgrind.org/docs/manual/bbv-manual.html [3] https://www.intel.com/content/www/us/en/developer/articles/tool/pin-a-dynamic-binary-instrumentation-tool.html Signed-off-by: Yotaro Nada Signed-off-by: Akihiko Odaki Reviewed-by: Pierrick Bouvier Message-Id: <20240816-bb-v3-1-b9aa4a5c75c5@daynix.com> Signed-off-by: Alex Bennée --- docs/about/emulation.rst | 30 ++++++++ contrib/plugins/bbv.c | 158 +++++++++++++++++++++++++++++++++++++++ contrib/plugins/Makefile | 1 + 3 files changed, 189 insertions(+) create mode 100644 contrib/plugins/bbv.c diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index eea1261baa..a4470127c9 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -272,6 +272,36 @@ Behaviour can be tweaked with the following arguments: * - idle=true|false - Dump the current execution stats whenever the guest vCPU idles +Basic Block Vectors +................... + +``contrib/plugins/bbv.c`` + +The bbv plugin allows you to generate basic block vectors for use with the +`SimPoint `__ analysis tool. + +.. list-table:: Basic block vectors arguments + :widths: 20 80 + :header-rows: 1 + + * - Option + - Description + * - interval=N + - The interval to generate a basic block vector specified by the number of + instructions (Default: N = 100000000) + * - outfile=PATH + - The path to output files. + It will be suffixed with ``.N.bb`` where ``N`` is a vCPU index. + +Example:: + + $ qemu-aarch64 \ + -plugin contrib/plugins/libbbv.so,interval=100,outfile=sha1 \ + tests/tcg/aarch64-linux-user/sha1 + SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6 + $ du sha1.0.bb + 23128 sha1.0.bb + Instruction ........... diff --git a/contrib/plugins/bbv.c b/contrib/plugins/bbv.c new file mode 100644 index 0000000000..a5256517dd --- /dev/null +++ b/contrib/plugins/bbv.c @@ -0,0 +1,158 @@ +/* + * Generate basic block vectors for use with the SimPoint analysis tool. + * SimPoint: https://cseweb.ucsd.edu/~calder/simpoint/ + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +#include + +typedef struct Bb { + uint64_t vaddr; + struct qemu_plugin_scoreboard *count; + unsigned int index; +} Bb; + +typedef struct Vcpu { + uint64_t count; + FILE *file; +} Vcpu; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; +static GHashTable *bbs; +static GRWLock bbs_lock; +static char *filename; +static struct qemu_plugin_scoreboard *vcpus; +static uint64_t interval = 100000000; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + for (int i = 0; i < qemu_plugin_num_vcpus(); i++) { + fclose(((Vcpu *)qemu_plugin_scoreboard_find(vcpus, i))->file); + } + + g_hash_table_unref(bbs); + g_free(filename); + qemu_plugin_scoreboard_free(vcpus); +} + +static void free_bb(void *data) +{ + qemu_plugin_scoreboard_free(((Bb *)data)->count); + g_free(data); +} + +static qemu_plugin_u64 count_u64(void) +{ + return qemu_plugin_scoreboard_u64_in_struct(vcpus, Vcpu, count); +} + +static qemu_plugin_u64 bb_count_u64(Bb *bb) +{ + return qemu_plugin_scoreboard_u64(bb->count); +} + +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + g_autofree gchar *vcpu_filename = NULL; + Vcpu *vcpu = qemu_plugin_scoreboard_find(vcpus, vcpu_index); + + vcpu_filename = g_strdup_printf("%s.%u.bb", filename, vcpu_index); + vcpu->file = fopen(vcpu_filename, "w"); +} + +static void vcpu_interval_exec(unsigned int vcpu_index, void *udata) +{ + Vcpu *vcpu = qemu_plugin_scoreboard_find(vcpus, vcpu_index); + GHashTableIter iter; + void *value; + + if (!vcpu->file) { + return; + } + + vcpu->count -= interval; + + fputc('T', vcpu->file); + + g_rw_lock_reader_lock(&bbs_lock); + g_hash_table_iter_init(&iter, bbs); + + while (g_hash_table_iter_next(&iter, NULL, &value)) { + Bb *bb = value; + uint64_t bb_count = qemu_plugin_u64_get(bb_count_u64(bb), vcpu_index); + + if (!bb_count) { + continue; + } + + fprintf(vcpu->file, ":%u:%" PRIu64 " ", bb->index, bb_count); + qemu_plugin_u64_set(bb_count_u64(bb), vcpu_index, 0); + } + + g_rw_lock_reader_unlock(&bbs_lock); + fputc('\n', vcpu->file); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + uint64_t n_insns = qemu_plugin_tb_n_insns(tb); + uint64_t vaddr = qemu_plugin_tb_vaddr(tb); + Bb *bb; + + g_rw_lock_writer_lock(&bbs_lock); + bb = g_hash_table_lookup(bbs, &vaddr); + if (!bb) { + bb = g_new(Bb, 1); + bb->vaddr = vaddr; + bb->count = qemu_plugin_scoreboard_new(sizeof(uint64_t)); + bb->index = g_hash_table_size(bbs); + g_hash_table_replace(bbs, &bb->vaddr, bb); + } + g_rw_lock_writer_unlock(&bbs_lock); + + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, count_u64(), n_insns); + + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, bb_count_u64(bb), n_insns); + + qemu_plugin_register_vcpu_tb_exec_cond_cb( + tb, vcpu_interval_exec, QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_COND_GE, count_u64(), interval, NULL); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); + if (g_strcmp0(tokens[0], "interval") == 0) { + interval = g_ascii_strtoull(tokens[1], NULL, 10); + } else if (g_strcmp0(tokens[0], "outfile") == 0) { + filename = tokens[1]; + tokens[1] = NULL; + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + if (!filename) { + fputs("outfile unspecified\n", stderr); + return -1; + } + + bbs = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, free_bb); + vcpus = qemu_plugin_scoreboard_new(sizeof(Vcpu)); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + + return 0; +} diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index d4ac599f93..bbddd4800f 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -13,6 +13,7 @@ TOP_SRC_PATH = $(SRC_PATH)/../.. VPATH += $(SRC_PATH) NAMES := +NAMES += bbv NAMES += execlog NAMES += hotblocks NAMES += hotpages From patchwork Tue Sep 10 14:07:31 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: 827022 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp329151wrc; Tue, 10 Sep 2024 07:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVnXvQCBzwB8XA5WKmuBbasS85qDWhnitztzQRNnlFI3GW2uQvDqkJLThjpjeHW4AgN8B7QA==@linaro.org X-Google-Smtp-Source: AGHT+IFZkg2B1P6Z8rjHPDJS19R+jeEuWfk6EnXddbF1gtG0JaMRQGVGuFmMkBXD0Fh2A2ps7eH/ X-Received: by 2002:a05:6122:3094:b0:4d3:3846:73bb with SMTP id 71dfb90a1353d-502c0021423mr9357550e0c.7.1725977690181; Tue, 10 Sep 2024 07:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977690; cv=none; d=google.com; s=arc-20240605; b=H9jfwj15A2uP+cRx6eOYfGUjIdWSf0ivg5t0MENZOUaDGWHlreswHYFALPLXdcJ0Y4 VmkIxi6ikaAcK7W5WU7m5WCL4Ka7W3oDC5BkS4oDrBHLTQ87waE71UiL8ZRCWHVqDfIP IRl9fi53Hz3yMMO06wK+/ffyqswMX2dd0ZFHt94Ce8X9uPieCGiGxCojlqWfCnHix7LO XGz8gYNshhVG9GPUC+NCx/bDNnF/SG9l49VussNLs8TnmspTcQ9+jIMoLgJhbpwUeUJn 0g/3VTgjJ2GTkqZhzFD/+LmmVgt6nuwvgq84Z87bOJNoWmtVkJxnaxZM0TIAOSsSEuo3 6Gkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Nn1a9HFZduZ/RNVuj0xIuaKX/DLxfqqaJjOeCmylyL8=; fh=ytn1i1StQInlrl1wNNUf7gJz/4slSQze+CRVS6YB8XM=; b=Akx4P9thsuDuFprUAElYcl+XULtQ752IpIuXeoaL+MklCKrlYUeC52hwU5swpejCz2 AnIztVwgqAlw7qwkzeGAGQfRj7EZk76BJXIA792Qt2R1kQCEOfNjF6SaB1/1sN5F1EWZ FF4fHrzYJoGeqC3WAdkbk4qbsAM83q49LO69inRSLWx5XVAyyRg73tJy+cLJLpiDh3h0 JFOyGQDV36YTzB7FJkpmwIldUnNQu+jBJHyrFruUO827Mi0L7WibjDBHENc+zXJ02CXY 9QK1sZ5/SUSwBtvkZ9RQrkkT2uWPyTjdMgZp/gRmFUhf19JZXnhBA6MFXlLJ2M7VTdOQ +Dcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPltl21W; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-502f9b42764si358181e0c.215.2024.09.10.07.14.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:14: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=WPltl21W; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1cy-0002Ol-58; Tue, 10 Sep 2024 10:13: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 1so1cw-0002I1-MK for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:54 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1ct-0007Si-Cg for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:54 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-5365c512b00so1000309e87.3 for ; Tue, 10 Sep 2024 07:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977629; x=1726582429; 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=Nn1a9HFZduZ/RNVuj0xIuaKX/DLxfqqaJjOeCmylyL8=; b=WPltl21WGO9N3hcGsvsCoSPlhh/76ABa/ckkY8KCrQTmIjQrrkq32heOQ9Lch5mp2L PnO4WHSk6I6szUrQybFbHHV76WZwYFcpS7bw1dRiWsgRLwoaeh9xhiXRZYF7jzRijER4 jjJaknY8Rf+LwTi51DlgZELOcRvszyK/6CxqNh+nPSpmGl3cdBDZK9qVzO9Dgm49CUZo 856YetQMLJeBCoHuhz2ulZaFNrmA3wFmK8U+3EQLJoZsl33/WacXm6SMjQUQACUtzmZl a/0/rREtqQZvQUpmJftx8fiujm0vaNuaZsxWYzSjIebXSYDhD+7cYgYOUzmJs8QlErS+ jIDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977629; x=1726582429; 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=Nn1a9HFZduZ/RNVuj0xIuaKX/DLxfqqaJjOeCmylyL8=; b=wlAyPjWGfK+mUlmfSUMRzATPTE47Xl7jUEgSZirxbQu/4Z9XInCCBpYnTPvFFMRxOP gh8+JMfRy2HKp6uzLinQYAKxi4MYSAdOe1hwFQcVAdEgE4/GJQGXKK1wRfqS6kkljXEN w/DXTDra9MFOqlxu3uaASm7d7EnlGFzdl7nwa6Q85oT8RBd825MsqN/ul9BISKSMgYTH xEtLaBW3Hgbs6rDg1ndECn33oVcHv3G2mTPyRVfHv9Uc22dJQirJ/HJUBQRzwWU9zzL4 zjo7dXGHrrf0EgYQLiR9IFNOGrHbyy1e4t65z8s1BpLBFJgp01tuUAx1LdDjrq0wCT3Q pfjQ== X-Gm-Message-State: AOJu0YymkTCmFHfNqtVbXSNnSBHEWwPUL32vsYvrDjlDkFi/eZbPL9Dr LMe0mZqaqiclcqzFkvbZQ9vvPlJN7vBDc+mI8tf2zMpfgihYK+yIFiwksunCB/Y= X-Received: by 2002:a05:6512:4025:b0:533:d3e:16e6 with SMTP id 2adb3069b0e04-536587b2adcmr10879582e87.25.1725977629182; Tue, 10 Sep 2024 07:13:49 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25835b0bsm494599366b.12.2024.09.10.07.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:47 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 194AE5F762; Tue, 10 Sep 2024 15:07:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Rowan Hart Subject: [PATCH 24/26] plugins: add plugin API to read guest memory Date: Tue, 10 Sep 2024 15:07:31 +0100 Message-Id: <20240910140733.4007719-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Rowan Hart Signed-off-by: Rowan Hart Reviewed-by: Pierrick Bouvier Message-Id: <20240827215329.248434-2-rowanbhart@gmail.com> [AJB: tweaked cpu_memory_rw_debug call] Signed-off-by: Alex Bennée --- vAJB: - explicit bool for cpu_memory_rw_debug --- include/qemu/qemu-plugin.h | 32 +++++++++++++++++++++++++++++++- plugins/api.c | 20 ++++++++++++++++++++ plugins/qemu-plugins.symbols | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 649ce89815..2015d6b409 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -57,11 +57,19 @@ typedef uint64_t qemu_plugin_id_t; * - Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. * Those functions are replaced by *_per_vcpu variants, which guarantee * thread-safety for operations. + * + * version 3: + * - modified arguments and return value of qemu_plugin_insn_data to copy + * the data into a user-provided buffer instead of returning a pointer + * to the data. + * + * version 4: + * - added qemu_plugin_read_memory_vaddr */ extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; -#define QEMU_PLUGIN_VERSION 3 +#define QEMU_PLUGIN_VERSION 4 /** * struct qemu_info_t - system information for plugins @@ -884,6 +892,28 @@ typedef struct { QEMU_PLUGIN_API GArray *qemu_plugin_get_registers(void); +/** + * qemu_plugin_read_memory_vaddr() - read from memory using a virtual address + * + * @addr: A virtual address to read from + * @data: A byte array to store data into + * @len: The number of bytes to read, starting from @addr + * + * @len bytes of data is read starting at @addr and stored into @data. If @data + * is not large enough to hold @len bytes, it will be expanded to the necessary + * size, reallocating if necessary. @len must be greater than 0. + * + * This function does not ensure writes are flushed prior to reading, so + * callers should take care when calling this function in plugin callbacks to + * avoid attempting to read data which may not yet be written and should use + * the memory callback API instead. + * + * Returns true on success and false on failure. + */ +QEMU_PLUGIN_API +bool qemu_plugin_read_memory_vaddr(uint64_t addr, + GByteArray *data, size_t len); + /** * qemu_plugin_read_register() - read register for current vCPU * diff --git a/plugins/api.c b/plugins/api.c index 3316d4a04d..24ea64e2de 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -560,6 +560,26 @@ GArray *qemu_plugin_get_registers(void) return create_register_handles(regs); } +bool qemu_plugin_read_memory_vaddr(vaddr addr, GByteArray *data, size_t len) +{ + g_assert(current_cpu); + + if (len == 0) { + return false; + } + + g_byte_array_set_size(data, len); + + int result = cpu_memory_rw_debug(current_cpu, addr, data->data, + data->len, false); + + if (result < 0) { + return false; + } + + return true; +} + int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf) { g_assert(current_cpu); diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index eed9d8abd9..032661f9ea 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -21,6 +21,7 @@ qemu_plugin_num_vcpus; qemu_plugin_outs; qemu_plugin_path_to_binary; + qemu_plugin_read_memory_vaddr; qemu_plugin_read_register; qemu_plugin_register_atexit_cb; qemu_plugin_register_flush_cb; From patchwork Tue Sep 10 14:07:32 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: 827019 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp328711wrc; Tue, 10 Sep 2024 07:14:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWhz1R3VxQGC2UP0DqYELNyZpJfv6NnFUveG84mZhEpLdY/HIBwpKo6Jf+U/iMsOZ0kFmLBXQ==@linaro.org X-Google-Smtp-Source: AGHT+IHd7R68unPZAnK6myhdR94Ozz8JgJHPTWy6qlDOP8m6gn5eMIKnH7OBehZMg8viCOE1Zalf X-Received: by 2002:a05:6122:2092:b0:4f5:1ea3:736f with SMTP id 71dfb90a1353d-5021439d454mr14858401e0c.13.1725977646350; Tue, 10 Sep 2024 07:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977646; cv=none; d=google.com; s=arc-20240605; b=A/J7udqN/YunGa35D1QT4LnL5lyl6KX7nZA5JA+yR7zY8Za59QCDe3/9mnrOIsf63w wljgqFiOaC7okIaHmt7h6Dgmjl3lAHUvH/jsPFdRu68Cs8g8NFRRoTWahbzZqHNTvxRP 87FLBRafnIHbGwu+lF4pI5V9XBEqG712E0KXSySCa/i4XO626TmmdOzg0jX2Duu8uk9m T4my6mYlALdeUcuwKJ7YBBTeS+QzOJ19fLzAHfJbfM+qHmqPBJ6EaYebwt2ZIOQuOv+M fKVBuoxH0eQNnKJGSNwJYWvvciRDXG1gTqYYDwPOqU1nZ9A9+UwBE1xGqklKgWnJjGgW lMgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=hEZbqliSm3idSAY5YqSflW1IHfDQd2AMSDogcHs/b2s=; fh=ytn1i1StQInlrl1wNNUf7gJz/4slSQze+CRVS6YB8XM=; b=kdB4JV6RLr+akxv4Rd0r9PJvzf+XM+Jjgy9VltvZeynpykzvBmUK6Ki3CFJrO/B4jT wk2InmXhTPY3zHw5QqvHeLBneByJvEkGUaCxTpVTG6p8lZRv089as41WSYf4dq3ccOnq s2nSEJ/J4VGM9kFRkANZ8LW3KR6HeqbNvK8iOCzHEoGHJoJZEbsiOi/+9Vuw+32rstYS ThHYTYCNBSU7H6MdX7xK0D8r3m0CjgzUOhtfe9F4MRCUA4uUfHw9d2xBFO0tqmwvrn2n RMyaKhClOZz1EIY4Tr+rq16gxS8TF1mjpHPdPR2z5s/+JXxI2l9VW148ppbTQOb0wnsi r7EA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rISTBAWt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-502f9d76656si354451e0c.256.2024.09.10.07.14.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:14: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=rISTBAWt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1cz-0002Vk-Rb; Tue, 10 Sep 2024 10:13:57 -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 1so1cy-0002Qy-MJ for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:56 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1cw-0007UF-Ho for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:13:56 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5365cf5de24so4174560e87.1 for ; Tue, 10 Sep 2024 07:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977633; x=1726582433; 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=hEZbqliSm3idSAY5YqSflW1IHfDQd2AMSDogcHs/b2s=; b=rISTBAWtpxzbOkOoj5vC4Kt9GZtVT4MqdZ1EbNK57wkLQurm0VRPqp+uoZDhImqfjG yOwiCdtMi2eZQxIkN5gXcxectwz8Fc5gZ3vs6D3uaIUjHJOJgLkxr/5HLLeqEafEgplQ a49kAIvabGhutoQqYm52cUNDrmqkJ447Lg/lYdWNgu/hoVk2ULil2psrAeoY+Rn/PHZB MZW8wO5t0wGGE7qYsFWNFpHFV0ZAcM7OI/Z6OnQlIQmta9Gz31oEDa1Y2cE7mRGPczrm vlpbpM/oiIU9GpIBxgRkZRGfzrP8hkPNZnva/GdSpF+uVIxRHD0p7Gpv4keOLcHlWhYr o09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977633; x=1726582433; 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=hEZbqliSm3idSAY5YqSflW1IHfDQd2AMSDogcHs/b2s=; b=a7R0zqYBcFVyme2FxUUWs6Ldlv35nv2uw5SZv9F+zutMt+OalmU8PcV4xNes54gD3R XM+qmYsy1TDH+vgdyAP7eBPKDxfTey5lvg5Jx8mnr0rk8J/mo9u0j+w1iadh+Mv1QdAp mBNLGJnmBj/tjNGGpU+52bl5LVwBETxT4MJHpiIuGUwwZnCXH7q+yM8oALJeplFsA2PP vaiIMLxQAG3hCGqYbTS6p3JFiZoJdBbuIBeAa4YvwEbaTnrAX6RxsUxEZJt7ga5lniIF /11f6liaF5FCTmEprgczz8xrDiM/PsmTpTZKLn9JwSKSPwdCWc6ia9TBkH1P6+0ULLK+ CqtA== X-Gm-Message-State: AOJu0Yxh13NRIYSsCv3kLorPkom4jPZY68H30JAHdwNRb/U394RVtxYm nR6rsQ85ZiaA9BHEqAMMX6kMmxcFY4Q/dyJ2kTyhXAX1y/270MkBKOjYoHPp9vI= X-Received: by 2002:a05:6512:2207:b0:536:541e:31c8 with SMTP id 2adb3069b0e04-536587fc18cmr7829864e87.37.1725977632611; Tue, 10 Sep 2024 07:13:52 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d258339a2sm494195966b.19.2024.09.10.07.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:13:47 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 315E7634BF; Tue, 10 Sep 2024 15:07:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta , Rowan Hart Subject: [PATCH 25/26] plugins: add option to dump write argument to syscall plugin Date: Tue, 10 Sep 2024 15:07:32 +0100 Message-Id: <20240910140733.4007719-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Rowan Hart Signed-off-by: Rowan Hart Reviewed-by: Pierrick Bouvier Tested-by: Pierrick Bouvier Message-Id: <20240827215329.248434-3-rowanbhart@gmail.com> [AJB: tweak fmt string for vaddr] Signed-off-by: Alex Bennée --- vAJB - tweak fmt string for PRIu64 --- docs/about/emulation.rst | 14 ++++- tests/tcg/plugins/syscall.c | 117 ++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index a4470127c9..23e4949049 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -418,6 +418,19 @@ run:: 160 1 0 135 1 0 +Behaviour can be tweaked with the following arguments: + +.. list-table:: Syscall plugin arguments + :widths: 20 80 + :header-rows: 1 + + * - Option + - Description + * - print=true|false + - Print the number of times each syscall is called + * - log_writes=true|false + - Log the buffer of each write syscall in hexdump format + Test inline operations ...................... @@ -807,4 +820,3 @@ Other emulation features When running system emulation you can also enable deterministic execution which allows for repeatable record/replay debugging. See :ref:`Record/Replay` for more details. - diff --git a/tests/tcg/plugins/syscall.c b/tests/tcg/plugins/syscall.c index 72e1a5bf90..647f478090 100644 --- a/tests/tcg/plugins/syscall.c +++ b/tests/tcg/plugins/syscall.c @@ -22,8 +22,57 @@ typedef struct { int64_t errors; } SyscallStats; +struct SyscallInfo { + const char *name; + int64_t write_sysno; +}; + +const struct SyscallInfo arch_syscall_info[] = { + { "aarch64", 64 }, + { "aarch64_be", 64 }, + { "alpha", 4 }, + { "arm", 4 }, + { "armeb", 4 }, + { "avr", -1 }, + { "cris", -1 }, + { "hexagon", 64 }, + { "hppa", -1 }, + { "i386", 4 }, + { "loongarch64", -1 }, + { "m68k", 4 }, + { "microblaze", 4 }, + { "microblazeel", 4 }, + { "mips", 1 }, + { "mips64", 1 }, + { "mips64el", 1 }, + { "mipsel", 1 }, + { "mipsn32", 1 }, + { "mipsn32el", 1 }, + { "or1k", -1 }, + { "ppc", 4 }, + { "ppc64", 4 }, + { "ppc64le", 4 }, + { "riscv32", 64 }, + { "riscv64", 64 }, + { "rx", -1 }, + { "s390x", -1 }, + { "sh4", -1 }, + { "sh4eb", -1 }, + { "sparc", 4 }, + { "sparc32plus", 4 }, + { "sparc64", 4 }, + { "tricore", -1 }, + { "x86_64", 1 }, + { "xtensa", 13 }, + { "xtensaeb", 13 }, + { NULL, -1 }, +}; + static GMutex lock; static GHashTable *statistics; +static GByteArray *memory_buffer; +static bool do_log_writes; +static int64_t write_sysno = -1; static SyscallStats *get_or_create_entry(int64_t num) { @@ -39,6 +88,44 @@ static SyscallStats *get_or_create_entry(int64_t num) return entry; } +/* + * Hex-dump a GByteArray to the QEMU plugin output in the format: + * 61 63 63 65 6c 09 09 20 20 20 66 70 75 09 09 09 | accel.....fpu... + * 20 6d 6f 64 75 6c 65 2d 63 6f 6d 6d 6f 6e 2e 63 | .module-common.c + */ +static void hexdump(const GByteArray *data) +{ + g_autoptr(GString) out = g_string_new(""); + + for (guint index = 0; index < data->len; index += 16) { + for (guint col = 0; col < 16; col++) { + if (index + col < data->len) { + g_string_append_printf(out, "%02x ", data->data[index + col]); + } else { + g_string_append(out, " "); + } + } + + g_string_append(out, " | "); + + for (guint col = 0; col < 16; col++) { + if (index + col >= data->len) { + break; + } + + if (g_ascii_isgraph(data->data[index + col])) { + g_string_append_printf(out, "%c", data->data[index + col]); + } else { + g_string_append(out, "."); + } + } + + g_string_append(out, "\n"); + } + + qemu_plugin_outs(out->str); +} + 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, @@ -54,6 +141,14 @@ static void vcpu_syscall(qemu_plugin_id_t id, unsigned int vcpu_index, g_autofree gchar *out = g_strdup_printf("syscall #%" PRIi64 "\n", num); qemu_plugin_outs(out); } + + if (do_log_writes && num == write_sysno) { + if (qemu_plugin_read_memory_vaddr(a2, memory_buffer, a3)) { + hexdump(memory_buffer); + } else { + fprintf(stderr, "Error reading memory from vaddr %"PRIu64"\n", a2); + } + } } static void vcpu_syscall_ret(qemu_plugin_id_t id, unsigned int vcpu_idx, @@ -127,6 +222,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_print)) { fprintf(stderr, "boolean argument parsing failed: %s\n", opt); } + } else if (g_strcmp0(tokens[0], "log_writes") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_log_writes)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + } } else { fprintf(stderr, "unsupported argument: %s\n", argv[i]); return -1; @@ -137,6 +236,24 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, statistics = g_hash_table_new_full(NULL, g_direct_equal, NULL, g_free); } + if (do_log_writes) { + for (const struct SyscallInfo *syscall_info = arch_syscall_info; + syscall_info->name != NULL; syscall_info++) { + + if (g_strcmp0(syscall_info->name, info->target_name) == 0) { + write_sysno = syscall_info->write_sysno; + break; + } + } + + if (write_sysno == -1) { + fprintf(stderr, "write syscall number not found\n"); + return -1; + } + + memory_buffer = g_byte_array_new(); + } + 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); From patchwork Tue Sep 10 14:07:33 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: 827007 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp325611wrc; Tue, 10 Sep 2024 07:08:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnstmLFCrGBeMj7HRlmca20Y3Iy289Yu+84UOZ/LXtV5QqrdCbd0lydnkahdjfPiX/Z1MwGg==@linaro.org X-Google-Smtp-Source: AGHT+IFi0cP/DsghIvl+nPYwGnH8s+Db7scExVPwyHm6eJWr/ediPf2+BxSECWX16dM4NwwBIBkF X-Received: by 2002:a05:6902:1547:b0:e1a:80fe:e660 with SMTP id 3f1490d57ef6-e1d3486bb10mr18240200276.4.1725977339273; Tue, 10 Sep 2024 07:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725977339; cv=none; d=google.com; s=arc-20240605; b=kDSAjtbWWvXsmyG0CsfkKty9Nq6MrXJe9oTYCjzqegEFZ8J/0yP2sUlybYZFT4WKNp pljAJ5Rllm6TCp+uHumQfYZjL4HKlxb83tHljXTF7/nq+gJ6O0uOQZ+630e2WXrS7LXT I9+RDBVkgZxJDvk+S5qLGRcootf9c/mj8IVF5j2mm9YDFoL7LxCUP+G1ea2ogihfOH2h npmhrJMt29vtNELlgXRMlKgzEAfxPbZq/k6TCv0SeOYYmhBxyhMG0giTCOdRX/xqU/RN cicPKE1OiNxeKkqQ97G5bV+JzeoWmqSA/OKhUOoatWLDaWmqW55ovCpQA8gcmybXWqZa RIYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=fi/Ma4iZQyq9UPktSL9wJjpSik/SOJE+/JzqHwnFA1g=; fh=BnBRB6Lw8W8NbEphFkypWwCCKF/td1C5yrG8L0vFoRU=; b=OhbnmYZT5jBHlzJMNxn7k2j0kVx+an43GtchFFac3phK8FnwDzf1eU0lBQKg206jAY US3R/rJ4q2eFo9LTSEFNxJMuugzr5jZf+tdXws0Os9xcPopI53wqDRdUwWuRQkgipfvo XF+ebg4DKJj9LDAyp56Y/zcJfyK8MJQlvoDTiXiEVdVKXnfJA1RHZ+75HLffHZi/0Ebe FVuV0pVolNBsKW6KxUtvSh/pLsyJigifBXHqXlXwzfT9hA8SejI7yTLCNI5TVtG+T4yV 5EUN6AnxU1+XOnDF4+wC/c9jKE1UiImuDnszE0fTrJpruk+zPe84FhF9fd2KmTth7DUU t5UA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tg5bZNSf; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 3f1490d57ef6-e1d7bc1c7f0si955028276.633.2024.09.10.07.08.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 07:08:59 -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=tg5bZNSf; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1so1XB-0008W3-47; Tue, 10 Sep 2024 10:07:57 -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 1so1X8-0008JR-Lg for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:54 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1so1X4-0006Za-Vz for qemu-devel@nongnu.org; Tue, 10 Sep 2024 10:07:54 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a8d4979b843so376646766b.3 for ; Tue, 10 Sep 2024 07:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725977269; x=1726582069; 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=fi/Ma4iZQyq9UPktSL9wJjpSik/SOJE+/JzqHwnFA1g=; b=tg5bZNSfbSotM8fdcSiSDEBIPwa9kIh/c4uK6+X6JAqcPspkcIeL8Z11gEI1B17hw1 TtRRqM68v/KImy87Ff+Aqy+xF5DScQTP9bqT+n/0RMUB7exTrCc7/Tg1oZl5E3vSBTzG j0xMqS9RQU0yarV1uBM+JpXbZMk6W8YY9vHwE06ABT/hRHg90WZ8EJEGa3IwoonPIIMs Mpbc2a+lTbRLAujNvgGsSPPs+kp4C2cejDvJgQKgv9um/4z4ecgjjGwFRvDD0EGoUyGD /fKipiK4LdyNp+DVc6e3UTyh9Kyno2WvyMT4Tkj9PxmuU7TgY5ONiVBWo+l3Ki3lWObQ kQCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725977269; x=1726582069; 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=fi/Ma4iZQyq9UPktSL9wJjpSik/SOJE+/JzqHwnFA1g=; b=ZKKErK+Gc02kO3xG/JLcY4pKJD+sO8yJQPMiWmcKu8jxtCLscxHfCNY4gJkFwjKh75 TwnrDd4sb8ZphQ5slRAncVzifWeIonuVuWyZ8V6RfwCHlDr037VkNtgqDSjprUlC9K3p Cdh4EaHtQR5O7cNw/n+2tCaCNZAQqMKOHdclGb+6SNZZ9c46mOM5k6OrjXIm29THXCI7 noUg8aDhD9yRVgVv/5keuRoJmspIsspW4fDUlLP+8Xd9cXp4fe3ukssbQtbp02s635Yu 0Vo+O3Fi/8KTToPpi1RRlX3X5DD4zDTIqZ7Bz3P5bj290MoVOeMjcmSryZIx8tnQgxml ihPw== X-Gm-Message-State: AOJu0Yxbzz0RquUSFEHtLRfOcHdwypKHP2YFmbRrCiB7JFbB6+Xm+UEw Mhsx7Mpv0LNIkCg6BienOEKWWXHxwhMRHARk0BYsRE9ZJwFtojIELbdY/by9shg= X-Received: by 2002:a17:906:4fc4:b0:a86:8e3d:86e2 with SMTP id a640c23a62f3a-a8ffaaa4ae0mr97954566b.11.1725977269050; Tue, 10 Sep 2024 07:07:49 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cea3e1sm482519066b.167.2024.09.10.07.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 07:07:42 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 515645F9CC; Tue, 10 Sep 2024 15:07:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Zhao Liu , Marcel Apfelbaum , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Yanan Wang , Peter Maydell , Mahmoud Mandour , Thomas Huth , qemu-arm@nongnu.org, devel@lists.libvirt.org, Jiaxun Yang , Paolo Bonzini , Richard Henderson , Wainer dos Santos Moschetta Subject: [PATCH 26/26] plugins: add ability to register a GDB triggered callback Date: Tue, 10 Sep 2024 15:07:33 +0100 Message-Id: <20240910140733.4007719-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240910140733.4007719-1-alex.bennee@linaro.org> References: <20240910140733.4007719-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x635.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=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 Now gdbstub has gained the ability to extend its command tables we can allow it to trigger plugin callbacks. This is probably most useful for QEMU developers debugging plugins themselves but might be useful for other stuff. Trigger the callback by sending: maintenance packet Qqemu.plugin_cb I've extended the memory plugin to report on the packet. Signed-off-by: Alex Bennée --- include/qemu/plugin-event.h | 1 + include/qemu/qemu-plugin.h | 16 ++++++++++++++++ plugins/plugin.h | 9 +++++++++ plugins/api.c | 18 ++++++++++++++++++ plugins/core.c | 37 ++++++++++++++++++++++++++++++++++++ tests/tcg/plugins/mem.c | 11 +++++++++-- plugins/qemu-plugins.symbols | 1 + 7 files changed, 91 insertions(+), 2 deletions(-) diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h index 7056d8427b..d9aa56cf4f 100644 --- a/include/qemu/plugin-event.h +++ b/include/qemu/plugin-event.h @@ -20,6 +20,7 @@ enum qemu_plugin_event { QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, QEMU_PLUGIN_EV_FLUSH, QEMU_PLUGIN_EV_ATEXIT, + QEMU_PLUGIN_EV_GDBSTUB, QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */ }; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 2015d6b409..3592e142f8 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -802,6 +802,22 @@ QEMU_PLUGIN_API void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, qemu_plugin_udata_cb_t cb, void *userdata); + +/** + * qemu_plugin_register_gdb_cb() - register a gdb callback + * @id: plugin ID + * @cb: callback + * @userdata: user data for callback + * + * When using the gdbstub to debug a guest you can send a command that + * will trigger the callback. This is useful if you want the plugin to + * print out collected state at particular points when debugging a + * program. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_gdb_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, void *userdata); + /* returns how many vcpus were started at this point */ int qemu_plugin_num_vcpus(void); diff --git a/plugins/plugin.h b/plugins/plugin.h index 30e2299a54..f37667c9fb 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -118,4 +118,13 @@ struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size); void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); +/** + * plugin_register_gdbstub_commands - register gdbstub commands + * + * This should only be called once to register gdbstub commands so we + * can trigger callbacks if needed. + */ +void plugin_register_gdbstub_commands(void); + + #endif /* PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 24ea64e2de..62141616f4 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -681,3 +681,21 @@ void qemu_plugin_update_ns(const void *handle, int64_t new_time) } #endif } + +/* + * gdbstub hooks + */ + +static bool gdbstub_callbacks; + +void qemu_plugin_register_gdb_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, + void *udata) +{ + plugin_register_cb_udata(id, QEMU_PLUGIN_EV_GDBSTUB, cb, udata); + + if (!gdbstub_callbacks) { + plugin_register_gdbstub_commands(); + gdbstub_callbacks = true; + } +} diff --git a/plugins/core.c b/plugins/core.c index bb105e8e68..e7fce08799 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -23,6 +23,7 @@ #include "qemu/xxhash.h" #include "qemu/rcu.h" #include "hw/core/cpu.h" +#include "gdbstub/commands.h" #include "exec/exec-all.h" #include "exec/tb-flush.h" @@ -147,6 +148,7 @@ static void plugin_cb__udata(enum qemu_plugin_event ev) switch (ev) { case QEMU_PLUGIN_EV_ATEXIT: + case QEMU_PLUGIN_EV_GDBSTUB: QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { qemu_plugin_udata_cb_t func = cb->f.udata; @@ -768,3 +770,38 @@ void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) g_array_free(score->data, TRUE); g_free(score); } + +/* + * gdbstub integration + */ + +static void handle_plugin_cb(GArray *params, void *user_ctx) +{ + plugin_cb__udata(QEMU_PLUGIN_EV_GDBSTUB); + gdb_put_packet("OK"); +} + +enum Command { + PluginCallback, + NUM_GDB_CMDS +}; + +static const GdbCmdParseEntry cmd_handler_table[NUM_GDB_CMDS] = { + [PluginCallback] = { + .handler = handle_plugin_cb, + .cmd_startswith = true, + .cmd = "qemu.plugin_cb", + .schema = "s?", + }, +}; + +void plugin_register_gdbstub_commands(void) +{ + g_autoptr(GPtrArray) set_table = g_ptr_array_new(); + + for (int i = 0; i < NUM_GDB_CMDS; i++) { + g_ptr_array_add(set_table, (gpointer) &cmd_handler_table[PluginCallback]); + } + + gdb_extend_set_table(set_table); +} diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c index 42d735d5c8..ee71bd02c9 100644 --- a/tests/tcg/plugins/mem.c +++ b/tests/tcg/plugins/mem.c @@ -66,8 +66,7 @@ static gint addr_order(gconstpointer a, gconstpointer b) return na->region_address > nb->region_address ? 1 : -1; } - -static void plugin_exit(qemu_plugin_id_t id, void *p) +static void plugin_report(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out = g_string_new(""); @@ -81,6 +80,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } qemu_plugin_outs(out->str); + g_mutex_lock(&lock); if (do_region_summary) { GList *counts = g_hash_table_get_values(regions); @@ -105,6 +105,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) qemu_plugin_outs(out->str); } + g_mutex_unlock(&lock); +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + plugin_report(id, p); qemu_plugin_scoreboard_free(counts); } @@ -375,6 +381,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, counts, CPUCount, mem_count); io_count = qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, io_count); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_gdb_cb(id, plugin_report, NULL); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; } diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 032661f9ea..d272e8e0f3 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -25,6 +25,7 @@ qemu_plugin_read_register; qemu_plugin_register_atexit_cb; qemu_plugin_register_flush_cb; + qemu_plugin_register_gdb_cb; qemu_plugin_register_vcpu_exit_cb; qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb;