From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922389; cv=none; d=zohomail.com; s=zohoarc; b=ZnJmC+erJIuxu7AoBk/YHtDPl8KMgQVjTK9Okb/VZgqn4CaV6bTZM1uW5z3Y5+hWtvYvMwoxymb9/n2aNbaCcWy14c73i02crwR1oohnaeOcVpmZnLuTzz/9RRJQV541qr5MRodgbn46kpuH8B8Vd4duLlbafLCQ2WYvH2x/qkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922389; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=blQPNSaTmzJc1fXNWV0nxOVvq9hHCI/3Ss3b4cRuZZo=; b=Z39loyfpQ54th/W/mDpw0O9aaa9UGKUcm/NZf916zkbX6fDVsn/HbCnS36UWWxNwsq87OiTOCBdwY3L1oJxRZGpniRDqbsIP3tdYSBJNoC0YB+FjRYrG3iDvJdygeClz2Db9VWDeu53FrR1KYkuXmxgFJc5TG5HWDAlXP8lj6aM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922389809487.50144784266456; Tue, 17 Nov 2026 05:33:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI6-0002JK-L1; Tue, 17 Nov 2026 08:32:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJHy-0002Gu-Po for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:02 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJHu-0000MW-J4 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:31:57 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-492f0a1b685so3168238f8f.0 for ; Tue, 17 Nov 2026 05:31:53 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922312; x=1795527112; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=blQPNSaTmzJc1fXNWV0nxOVvq9hHCI/3Ss3b4cRuZZo=; b=HQLqhL+NgohUPxClcaDzStQjvDevuAP++NgpdKLF5QqhLJ46ZjDO7GagQzAoI953ZX TCG4ydbPOFW70TLLPiDz6QdLneGiYevd+u46ifQfZPp9GdOFMfeWVb7+0LgZlV/CUD/x CHgGORMeqSh8G0IxnOv7BYsavGtovaT//zDozHeYvWx9hzhEXZB81HflK8M3pnyl49wO GjpAzLcgtrMNRV++LI6MoX3uIuHw127773E58+48c9KCuNiaBAlI9d36n9GOXjYUBBya 3qZcQnK8jKYt7BDqnjx163xw7QrXBjDRqg88mxMKb8tI50UTq3rlIRlLyc3MO/jhnQBl J9eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922312; x=1795527112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=blQPNSaTmzJc1fXNWV0nxOVvq9hHCI/3Ss3b4cRuZZo=; b=QVKsIMvDTo/HBxsyDP+9LHSDeH9agPNfoja11CgTOGrDCCuJasB9Qk/rXlbyEh/SN9 8QlxCIanJiv8IffAidl3yPcbjKC5R7fxwCy+KxvFMxmlx7ywJ1ZU5w1CIAH0LrzAypv2 Hnh6DD942nQowTfPBLBrlnrhVxblvXL3EEzIaQs3FaZZYKRF7i8ArVcSFwVmFuudq4/C ROW4xLkaa4NwLhrJTa2n6TR/0rOvEEtetbP7w3mPKDl7tX/HaDxgtPhPoG/SR2LXExBr Qh27XaPfQxt+GC85XWnqG/c6ayuFdJoWNsHT8n024o2mlFGFhn1B8Bul6wTeQTU4zpyG WLkA== X-Gm-Message-State: APuU4Z+ZDRBeiN98WZ3kJSddd2oTT/cPj5ly2nyQhFds3Vn33s3IPFc9 Fw7Hz2q0kY88DCUG7n5VcqhlMDNIqLtrZ0I9mJgz4PvfTDg9vVB5XhRPZY6guTdLjTNa2gv0Gy0 Oc3I2TgE= X-Gm-Gg: AZFdTZeiU9pajJaitY39jbb21qowTcs4QdeZm1n10rn6mNbuUr7+ugrnTtcd2sDncM3 xekR1+itbbGa6Uvabcak3H17xL44jikzS5rugjJZY51aBfeTvhSfYZKWnNVkmGPYPetfwGE4oLf Ha21lKva9wIoDrdjW8OW6wli5QDkyjw+2u6JUdAuPQCs99YLwoT0uOQ5nH0v4fl23mwJS7s35OB qqbWMwFNt9O9IREYcUc/zbPpfcroXZ/30fSFtvQ7GqZBOjENw8zJJg9HXp519L9/Um+e3uz6zI+ mNiX25XzMrPx27PslKsnO/8iUWe+1+5mUYXLUBGe7b/BTlC1RXcNqmAj+z7EWmIiRTnzVur4Wdd /5Te2MewBrbFt2r37I6/PpiR6Ih4WXKdwrUd8oWqe9Ngf2vgRMa/CxJHdGPfgUliCNDY5XlwSk9 wiP8LfAXQ00tt8m5Aa7qEZ3fIqVy9Mf5jWpcmOUPK3oEP6bSzTIOAQFwr8URCedKHQKdGRM6DfY Oj53UCjN6mguMt3amooyQQKAOeyBP3tqdqhLUpWHSxY1x0OiGYT7TArwjDwsTRfpL9hGXG4yxx4 oy+0+60JZu/ZkqpviPISNbTU5d3NQNnMMZymFWUKdTKPAa3gqDj8Qljgy3iIzabqkDRQVYIYLWF 5+b1HQcmg4gsrtUza6skvJhgXAYgHuoW7DA== X-Received: by 2002:a05:6000:428a:b0:491:8462:20be with SMTP id ffacd0b85a97d-49c70de380emr31783060f8f.12.1794922312185; Tue, 17 Nov 2026 05:31:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/8] Revert "meson: rewrite scripts/qemu-version.sh directly in meson.build" Date: Tue, 17 Nov 2026 13:31:42 +0000 Message-ID: <20261117133149.2108068-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922390315158500 Content-Type: text/plain; charset="utf-8" This reverts commit ab78ac76f44a1241e76fd32d248df62d83f1ea58. The change to create the version header in meson.build loses the dependency needed for the header file to be built when it doesn't exist. This means that: * if you delete the build/qemu-version.h file, an incremental rebuild fails, rather than recreating it * if you do an incremental rebuild from a build tree that pre-dates ab78ac76f44a, it doesn't have qemu-version.h, and the rebuild fails Revert the commit so we can think about how we want to address this. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20261106155858.3779237-2-peter.maydell@linaro.org --- meson.build | 29 +++++++++-------------------- include/qemu/version.h | 8 -------- scripts/qemu-version.h.in | 1 - scripts/qemu-version.sh | 25 +++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 29 deletions(-) delete mode 100644 scripts/qemu-version.h.in create mode 100755 scripts/qemu-version.sh diff --git a/meson.build b/meson.build index d7bcb581c18..93da3e6f2bd 100644 --- a/meson.build +++ b/meson.build @@ -78,7 +78,6 @@ have_user =3D have_linux_user or have_bsd_user ############ =20 sh =3D find_program('sh') -git =3D find_program('git', required: false) python =3D import('python').find_installation() =20 cc =3D meson.get_compiler('c') @@ -3561,25 +3560,15 @@ tracetool_depends =3D files( 'scripts/tracetool/__init__.py', ) =20 -qemu_pkgversion =3D get_option('pkgversion') -git_describe_version =3D [git, 'describe', '--match', 'v*', '--dirty'] -if qemu_pkgversion =3D=3D '' and git.found() and fs.exists('.git') and \ - run_command(git_describe_version, check: false).returncode() =3D=3D 0 - # Refresh the version at build time, so that "make" after a commit updat= es it. - qemu_version =3D vcs_tag(input: 'scripts/qemu-version.h.in', - output: 'qemu-version.h', - command: git_describe_version, - fallback: '') -else - # Unlike vcs_tag(), which always defines QEMU_PKGVERSION, leave it out if - # empty. include/qemu/version.h then omits the parentheses from - # QEMU_FULL_VERSION. - qemu_version_data =3D configuration_data() - if qemu_pkgversion !=3D '' - qemu_version_data.set_quoted('QEMU_PKGVERSION', qemu_pkgversion) - endif - qemu_version =3D configure_file(output: 'qemu-version.h', configuration:= qemu_version_data) -endif +qemu_version_cmd =3D [find_program('scripts/qemu-version.sh'), + meson.current_source_dir(), + get_option('pkgversion'), meson.project_version()] +qemu_version =3D custom_target('qemu-version.h', + output: 'qemu-version.h', + command: qemu_version_cmd, + capture: true, + build_by_default: true, + build_always_stale: true) genh +=3D qemu_version =20 hxdep =3D [] diff --git a/include/qemu/version.h b/include/qemu/version.h index dd0f937f30c..38405495c0e 100644 --- a/include/qemu/version.h +++ b/include/qemu/version.h @@ -7,14 +7,6 @@ #ifndef QEMU_VERSION_H #define QEMU_VERSION_H =20 -/* qemu-version.h defines QEMU_PKGVERSION only if it is not empty. */ #include "qemu-version.h" =20 -#ifdef QEMU_PKGVERSION -#define QEMU_FULL_VERSION QEMU_VERSION " (" QEMU_PKGVERSION ")" -#else -#define QEMU_PKGVERSION "" -#define QEMU_FULL_VERSION QEMU_VERSION -#endif - #endif diff --git a/scripts/qemu-version.h.in b/scripts/qemu-version.h.in deleted file mode 100644 index b62d4c22652..00000000000 --- a/scripts/qemu-version.h.in +++ /dev/null @@ -1 +0,0 @@ -#define QEMU_PKGVERSION "@VCS_TAG@" diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh new file mode 100755 index 00000000000..3f6e7e6d41d --- /dev/null +++ b/scripts/qemu-version.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -eu + +dir=3D"$1" +pkgversion=3D"$2" +version=3D"$3" + +if [ -z "$pkgversion" ]; then + cd "$dir" + if [ -e .git ]; then + pkgversion=3D$(git describe --match 'v*' --dirty) || : + fi +fi + +if [ -n "$pkgversion" ]; then + fullversion=3D"$version ($pkgversion)" +else + fullversion=3D"$version" +fi + +cat < (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922416624609.0682273778624; Tue, 17 Nov 2026 05:33:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI7-0002Ji-7x; Tue, 17 Nov 2026 08:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI0-0002H2-Gf for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:02 -0500 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 1xTJHv-0000TV-Tf for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:31:59 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-6b571979178so7141280a12.2 for ; Tue, 17 Nov 2026 05:31:54 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922313; x=1795527113; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=n5J86D86hRkkGGTVZsvRC5R3HIR9PRKOlDUYg06iqH8=; b=dLp9gDZT7myrfQQdgwNA2PQeycZHUGY2t4FBEaJaPWCu2oextuPAr3tgBgCJNUFNbn 5jQF5PZesG7s9nz6SyzQuS2YzXOt05Vwb83vcZw+ezmtuQ76UmvLzozEblwh7+UIcKr8 svu9Myn+WoqOu6v+jXxU9h4/Oz5AgNslNndUM6GMF5mLGbmXB/Xo2lQ4ZTHIDiWlw/1p JVuBFRO2nB/y8AhyUW63TLiAszPpE83+HB2eHi4rQcwnkur0ykPY4DidDnMLWr4uuuiU otDq1F4o7OAXczJ4xiU2dDQD4U4utlpHw/CXDfLEBI4v57pazFHioX41Zn8zgassvq6P +JWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922313; x=1795527113; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=n5J86D86hRkkGGTVZsvRC5R3HIR9PRKOlDUYg06iqH8=; b=ZzELEflrjW7P2egVxS3aKUPiBTmSfa6cwArnMYVWqFN1dvMScVaaaHst5IhaZxpoeH ugCM1vU3NCTaxdLxM48VWgwyNqXk92EfJx+gAa5RYJvG6ibRQd9VA0/PZo/qtWYRuzFM RPg8XACplvDbKIUP6id7iwSZDZ0nsiVRJJNkWJ/zVItwRbujjjojcXp3ofstkB+TpJtA HSHD6bLYviz0m5gj02io2iS2eonjeGqy+oCPBL33uQxk+cAoYp2fVPrjJpDcq4pYVk/M AgzjaCrjif1d9ZJg+Fm2IhCSQPwLIfnJ/Gu40+fESfr/OGR5Fwxi6fPGLMde++BEGcQC 9TSA== X-Gm-Message-State: APuU4Z9mHY8w7h/egz6JRPIlCC2jS/ESwu1FeI3xN5YXMRNm+5sqUU7O 10+mZ1wA/+5jQTusW+lUryOBo37OHWSKugjiIDnuebDpPMM0cWEFm2XXTO01dHJfORq3zygvOkC rqxzwzEA= X-Gm-Gg: AYBFou2thcGp0LoZJyM6V5+eJXfB3AlW84Bg9/RBY3z35AwEBUzrTt++RFpVjm2pUpm fVFS6HCASd+aKBiUUfqBxLLkubD0ZGOs4lvbNueq5hQJ7FoqjUhviQKWfJ7w06O8EvQV2+r3UYn LQkd0p+fXgSQ/thPNHGaiglp2+6eD9NJzt5eRnvptx8PZXaLvRMfAscoz39OonbMWIZSxSPxlj9 mtndHgKMQHsc8LI6Kre+ccDFGf2ePT/RfhHhrOqn6GKIlHXNMZ0J7jrv11zTns2MZq2PfcVkCss vssABSlZO5S6UlOrXl2IahzUIxLOVhEj8GugYblTayps2NvLpSyF9XXxnvr8L/lULqExpWoeJFj zhXN/Z7WFesoaeZY0BjmJZc1Arz8jc094+tJRe9+O3lBlWD46VBIJuF0RoS+43OLmQnJlBEnkoi bzXAwbFT8QeV1R0oSJR+cBYU1lQKPT4DWNUJ8MYuXezULl50sBpemn4QyRlO++JNfbzm8q8cUa2 zhK46rqlSUbeZEJbk3AlyLERyRbcuzIYe1E7C6nlo/KQQdZaN1OY5PhVegxtUxo2bg8uEg7UcGN VOBSsmmQRNts78mYMSH8lEsgcy9Exvh1YqZVY+I6wE5JHDqf92BcnP7djByJxPJs7rg9cMWry9C gzaNkHYerMWpzQG8xudTsR/+OLs756r71WQ== X-Received: by 2002:a05:6402:1e8f:b0:6b8:5823:1ccf with SMTP id 4fb4d7f45d1cf-6b858231d4emr2806821a12.28.1794922313111; Tue, 17 Nov 2026 05:31:53 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/8] Revert "include: introduce qemu/version.h" Date: Tue, 17 Nov 2026 13:31:43 +0000 Message-ID: <20261117133149.2108068-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=peter.maydell@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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922418473158500 Content-Type: text/plain; charset="utf-8" This reverts commit fc35f24387703da027c242ff17382b89ed5a269f. This commit was made as a pre-requisite for ab78ac76f44a124; now we've reverted that, revert this one as well so we return to the previous version header setup. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20261106155858.3779237-3-peter.maydell@linaro.org --- include/qemu/version.h | 12 ------------ bsd-user/main.c | 2 +- linux-user/main.c | 2 +- monitor/qmp-cmds-control.c | 2 +- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qga/main.c | 2 +- scsi/qemu-pr-helper.c | 2 +- storage-daemon/qemu-storage-daemon.c | 2 +- system/vl.c | 2 +- tools/i386/qemu-vmsr-helper.c | 3 ++- tools/qemu-vnc/qemu-vnc.c | 2 +- util/module.c | 2 +- ui/cocoa.m | 2 +- 15 files changed, 15 insertions(+), 26 deletions(-) delete mode 100644 include/qemu/version.h diff --git a/include/qemu/version.h b/include/qemu/version.h deleted file mode 100644 index 38405495c0e..00000000000 --- a/include/qemu/version.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * QEMU version strings - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef QEMU_VERSION_H -#define QEMU_VERSION_H - -#include "qemu-version.h" - -#endif diff --git a/bsd-user/main.c b/bsd-user/main.c index 6720dbde6f8..29ee59de2cf 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -25,7 +25,7 @@ #include "qemu/help-texts.h" #include "qemu/units.h" #include "qemu/accel.h" -#include "qemu/version.h" +#include "qemu-version.h" #include =20 #include "qapi/error.h" diff --git a/linux-user/main.c b/linux-user/main.c index 2f0c0a50c8a..60a695b7ca3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -21,7 +21,7 @@ #include "qemu/help-texts.h" #include "qemu/units.h" #include "qemu/accel.h" -#include "qemu/version.h" +#include "qemu-version.h" #include #include #include diff --git a/monitor/qmp-cmds-control.c b/monitor/qmp-cmds-control.c index bc938712f3d..8fe0876a3da 100644 --- a/monitor/qmp-cmds-control.c +++ b/monitor/qmp-cmds-control.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" =20 #include "monitor-internal.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qapi-commands-control.h" diff --git a/qemu-img.c b/qemu-img.c index 766d8540bfe..edf75e43aba 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -27,7 +27,7 @@ =20 #include "qemu/help-texts.h" #include "qemu/qemu-progress.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qapi/error.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-visit-block-core.h" diff --git a/qemu-io.c b/qemu-io.c index b5f2ae631a4..598d5b1c9ca 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -34,7 +34,7 @@ #include "block/block_int.h" #include "trace/control.h" #include "crypto/init.h" -#include "qemu/version.h" +#include "qemu-version.h" =20 #define CMD_NOFILE_OK 0x01 =20 diff --git a/qemu-nbd.c b/qemu-nbd.c index 4f7e965edba..fa28609d7dc 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -46,7 +46,7 @@ #include "crypto/init.h" #include "crypto/tlscreds.h" #include "trace/control.h" -#include "qemu/version.h" +#include "qemu-version.h" =20 #ifdef CONFIG_SELINUX #include diff --git a/qga/main.c b/qga/main.c index 06358cb213c..fd19c7037db 100644 --- a/qga/main.c +++ b/qga/main.c @@ -30,7 +30,7 @@ #include "qemu/help_option.h" #include "qemu/sockets.h" #include "qemu/systemd.h" -#include "qemu/version.h" +#include "qemu-version.h" #ifdef _WIN32 #include #include diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 7629f364045..1f97a5c4bfe 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -50,7 +50,7 @@ #include "qobject/qstring.h" #include "io/channel-socket.h" #include "trace/control.h" -#include "qemu/version.h" +#include "qemu-version.h" =20 #include "block/thread-pool.h" =20 diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index b2e29f00054..50dbfbd97ae 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -43,7 +43,7 @@ #include "qapi/qobject-input-visitor.h" =20 #include "qemu/help-texts.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/error-report.h" diff --git a/system/vl.c b/system/vl.c index e7b759d5442..7ae6a8298fc 100644 --- a/system/vl.c +++ b/system/vl.c @@ -37,7 +37,7 @@ #include "qobject/qdict.h" #include "qobject/qstring.h" #include "qobject/qjson.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/help_option.h" #include "qemu/hw-version.h" diff --git a/tools/i386/qemu-vmsr-helper.c b/tools/i386/qemu-vmsr-helper.c index fac7fbe6b61..f12fd3c3e81 100644 --- a/tools/i386/qemu-vmsr-helper.c +++ b/tools/i386/qemu-vmsr-helper.c @@ -34,7 +34,7 @@ #include "qemu/module.h" #include "qemu/error-report.h" #include "qemu/config-file.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/log.h" @@ -42,6 +42,7 @@ #include "io/channel.h" #include "io/channel-socket.h" #include "trace/control.h" +#include "qemu-version.h" #include "rapl-msr-index.h" =20 #define MSR_PATH_TEMPLATE "/dev/cpu/%u/msr" diff --git a/tools/qemu-vnc/qemu-vnc.c b/tools/qemu-vnc/qemu-vnc.c index a668f3f734d..c915589ca7e 100644 --- a/tools/qemu-vnc/qemu-vnc.c +++ b/tools/qemu-vnc/qemu-vnc.c @@ -15,7 +15,7 @@ #include "qemu/option.h" #include "qemu/log.h" #include "qemu/main-loop.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "ui/vnc.h" #include "crypto/secret.h" #include "crypto/tlscredsx509.h" diff --git a/util/module.c b/util/module.c index 6de9ff2e411..8f8e6994f11 100644 --- a/util/module.c +++ b/util/module.c @@ -23,7 +23,7 @@ #include "qemu/config-file.h" #include "qapi/error.h" #ifdef CONFIG_MODULE_UPGRADES -#include "qemu/version.h" +#include "qemu-version.h" #endif #include "trace.h" =20 diff --git a/ui/cocoa.m b/ui/cocoa.m index 36a72d36238..4587547c98c 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -44,7 +44,7 @@ #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "system/blockdev.h" -#include "qemu/version.h" +#include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" #include "qemu/module.h" --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922394; cv=none; d=zohomail.com; s=zohoarc; b=N8Gethx2L206wtm0A0FrJtFdn24SJDWmDo4aRRtldQz/bAku3F7+MWGsj2QaS3aDOANbgjROGylmV+6l49i2iVZFqUiGhFKO6Q6wgnNQElbR3HI8LuZ2MQszyr86HDKT/yAu5WJwGkghLa79yd+sqfW62XQlrO2t/lKQW3zOFTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922394; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=pSa7ptreDk5dKB5WmKzb47P1wr9NhX2Iyt0QzoUiRNQ=; b=nsrm1Z6g7bsVk8hHdHYgUGQkdy0PTOJcC3nzKuKm85pHO/1u97VcqecPZ2Rb704L9XxtF4jo/1bI/Cv7I7lbHYajRPVYpeUxrCVecfa64lGHJu9r+aSs14oMULI+InCfX3j1aBgsPO8+SnQKl9Fp+RBwzVDRWIIErvf/CBv09uA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922394376539.1323179799642; Tue, 17 Nov 2026 05:33:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI7-0002Ka-VS; Tue, 17 Nov 2026 08:32:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI0-0002H0-G8 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:02 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJHx-0000WN-8H for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:31:59 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-48e10a70540so2608952f8f.1 for ; Tue, 17 Nov 2026 05:31:55 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922314; x=1795527114; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=pSa7ptreDk5dKB5WmKzb47P1wr9NhX2Iyt0QzoUiRNQ=; b=P+w9xpy+LsI2G5tOPQ5mq/b2tSoXM964OGQ+LdENE7avwEgPuHK0CcMbuYRtSGuc7G RBwPJfPdZcpVBkibnhlUxshiPGh4xuDu325ZjjDzODTFlVlIZu2J5wTlLEpc/5YkJVTF DIhedfKVSrcTzmrgTNJeBtnMxsCbDou1pLgNcd3JHXq5jJrOvNlBDe/tAb0Gi1l6Z1tz rMcakzPcf/ojTgGpzBmy6virxeLcIZHP30uFYV68zPi/7jI0X2yoqBChUg9GLtMJt1b8 n0XCJcs7JvxZjWJ0+oAwDNTeGH6e602ZRKVLiNfee9HpzNjb1qzc17FcqYlBTUa2wyl2 qZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922314; x=1795527114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=pSa7ptreDk5dKB5WmKzb47P1wr9NhX2Iyt0QzoUiRNQ=; b=eKdSri5bRxNq615u0O7Y+yAou8/Oyfb9WyB6Z4LqgwY1qWG+FxlEkJ6vvJFYZFylFT 4jx4R+GTFGhv098cKcrJHBAamMz1nHrdODc0XR04T+9LMKQl5yReSUw7irkPxkK9yFkz JZ53f4CboJSGfgKmMRfyj4XwGMCroLNwiM3djwUsI6RlJ3oBc8vWkcmfS+cgbdS+n76N ZBKyDMvglgNfWpoKougkUEEwEfRETek4lA8vcjnaOg+sgh6BtQ+A9HnTHR11/ysvZsf+ cwC+9M9OipoZqSwTyuwTxcm5jE0P9M5TRJgxYayr5yn2XQmJLTB4A9ctwPlAt4aEauWg GQ5A== X-Gm-Message-State: APuU4Z+snUsM0IVdThNZ0SQwkYA/8k10TPNl+6BlLqIi6+pCjKzwFgr5 NG7Q/NKCMvng7oE65FO5J8xwYXiParDsZMroJ9WpaX3Xn2fcu57L+KbrWSObN4xeQUNSEXzlJRM qFXwd4Nw= X-Gm-Gg: AZFdTZfhKsn7WUjKgRVfjQKGx1n/uKtS1PTo3X+LbavF1f/6DYamYuRtkY5RyxBZah5 o7NmALy6wQ7r0a0CkTZlqeYDvQ/mQ7eFQfgzfEcEzIuxIOqbKb7C0Oz79QsUdg1cz39AQmQUQqr 1umaM+op0vIjyTYSxzAmEvfpUDr/BUzobtezr1c602jo0SOKcNn2UKuMkdPp2nJXh4QPNKPkY8r mAeOfMtWBv0D9utkx0kGPBaRnLKE5h3gJQkihwGayjKMRlI8xLEwzn95zaN3GEKbRisFl4otgfI jGOYPzXiDUoWkGM60OzVL+M0ut7IMFcrw0VxRltkR8I9C5T4puBIVwgTaGLWL1/prbqQvnePWil 55hsNgdx74JZkK82R99Mb9TX0neueXV/TVxciebkavFjW0eMTeqUI3KC/ITY86a+uuuPU4BVTJJ 4urAd8mJg8JLkNB924A0Sq/9GoNvLTA5QP9N1VasT84lMRLcdfiTi6kIuVdf9t/bHxrFVswlrfJ OeuQQxJawUQUgHILuJV/lvNWRPThoqJtR0CRjfRWS6ynIcuQJIaMWtgl/irK8Q88A6q3fmILYEb aj7+cR1f2Iq54tWELrlMgMiFcGxh7htQbt6wvWrDmmqVYze7t4IiytIa1V2PAbpRfrNC86R6w5l 5AQ1dosKd/1mdh2/h0fgUts9uuAKs12HR01pxOTAGTGdVWFdFro4Uuy4= X-Received: by 2002:a05:6000:2010:b0:4a3:836d:6f61 with SMTP id ffacd0b85a97d-4a3836d7039mr5745228f8f.12.1794922314026; Tue, 17 Nov 2026 05:31:54 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/8] target/arm: Get HVC UNDEF cases for Secure mode right Date: Tue, 17 Nov 2026 13:31:44 +0000 Message-ID: <20261117133149.2108068-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922396598158500 Content-Type: text/plain; charset="utf-8" In the pre_hvc helper, we have a "bool secure =3D false" and a FIXME comment that we should use the actual Secure state. This is a signpost to the fact that we're not getting the UNDEF cases right. Specifically, we get most of them correct but are missing the ones related to Secure state: * For A64: HVC must UNDEF at EL1 if EL2 is not enabled in the current Security state * For v8 A32/T32, HVC must UNDEF in Secure state, if EL2 is not enabled in the current Security state * For v7, HVC must UNDEF in Secure state The v7 requirement is identical to the v8 A32/T32 one, since there is no Secure EL2 in v7. This fixes a bug where HVC should have UNDEFed but instead trapped when in Secure state with Secure EL2 disabled. The bug is unlikely to affect real-world code, because only test code puts itself in a situation where HVC should UNDEF and then executes HVC and requires it to UNDEF. This was noticed by Coverity, because the "if (secure && ...)" check was dead code. CID: 1689834 Cc: qemu-stable@nongnu.org Fixes: 35979d71c401 ("target-arm: A64: Emulate the HVC insn") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20261030092815.573973-1-peter.maydell@linaro.org --- target/arm/tcg/op_helper.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index 22f47f7450a..b6113096b53 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -1302,8 +1302,6 @@ void HELPER(pre_hvc)(CPUARMState *env) { ARMCPU *cpu =3D env_archcpu(env); int cur_el =3D arm_current_el(env); - /* FIXME: Use actual secure state. */ - bool secure =3D false; bool undef; =20 if (arm_is_psci_call(cpu, EXCP_HVC)) { @@ -1313,6 +1311,8 @@ void HELPER(pre_hvc)(CPUARMState *env) return; } =20 + /* Note that we have already UNDEFed HVC from EL0 at translation time = */ + if (!arm_feature(env, ARM_FEATURE_EL2)) { /* If EL2 doesn't exist, HVC always UNDEFs */ undef =3D true; @@ -1323,12 +1323,19 @@ void HELPER(pre_hvc)(CPUARMState *env) undef =3D env->cp15.hcr_el2 & HCR_HCD; } =20 - /* In ARMv7 and ARMv8/AArch32, HVC is undef in secure state. - * For ARMv8/AArch64, HVC is allowed in EL3. - * Note that we've already trapped HVC from EL0 at translation - * time. + /* + * In ARMv7 and ARMv8/AArch32, HVC is undef in Secure state if + * EL2 is not enabled in the current security state (which is + * always for Secure in v7, as Secure EL2 doesn't exist there). + * + * For ARMv8/AArch64, HVC is undef at EL1 if EL2 is not enabled in + * the current security state. + * + * Because we've already dealt with "EL2 not implemented" above, + * arm_is_el2_enabled() is effectively always true here in NonSecure, + * and we don't need to explicitly also check for secure/non-secure. */ - if (secure && (!is_a64(env) || cur_el =3D=3D 1)) { + if (!arm_is_el2_enabled(env) && (!is_a64(env) || cur_el =3D=3D 1)) { undef =3D true; } =20 --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922416; cv=none; d=zohomail.com; s=zohoarc; b=E7I4w9dhsFJr1nljV0PhSkUUvJBRkywQJXxPKTvYce89paz26Ul4EZ40nF82lXezU4/UxwnGAAR7JpnSjxOQ+oQ2GMMAD7x8/seRjWmOqcuggLO70A+00ILuKvyy5hLr7246fjqVYb8d0jH/i6xDreetHvfO4Q2bHNSihQcKdAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922416; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=g/HhL0icM5bUtoKj5yDnzoPXIFsvViyLIg4hdd3bfBA=; b=ib0R2V2km0CHz6XfFOkgfkW1zHUF5qCLTIHVF+bvhfLX/bTCe9QZXJxtS4bI/svyqHHPTKUGKmiT/qks378iQuWq8JDBLr6HaGE26pV/O+Ft5GPmTu9rkufcvDG2DuRZaSnrhEEI2mT3KKBhTQSEeiw+7xdT97BC0l+qd/Y0qgM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922416685993.6323489832766; Tue, 17 Nov 2026 05:33:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI7-0002JL-06; Tue, 17 Nov 2026 08:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI1-0002HG-HE for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:03 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJHy-0000cQ-Bv for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:00 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-48e20ed3b9dso4899303f8f.2 for ; Tue, 17 Nov 2026 05:31:56 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922315; x=1795527115; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=g/HhL0icM5bUtoKj5yDnzoPXIFsvViyLIg4hdd3bfBA=; b=XPKQ+AvHGdISp+xuHOuhoeET3AA8IcMhsIEwaTeagCx+so1eUXp8Cq0yhZupqHqqJH wCNhqLa8CB9m6rb6Y/Agw8kPnDDACBmLgNNnQyk6mYqrXvIhuyGmH6RFX28Jk5tVO09d dU7w2pEjWSdFIRe/TZEEUvIIZ60q2PIMYWL/ON/k9kRItZT77hv/NudMeZeKVhCs5GLd z7b5SwV24W9fZzxiaQRpRQeK5+SgRD7OhqGM/VPiA41ZUCn09gaa0nhRB2QqA3a+pM1v tNXzPPOU2f0HsYrtlnDlbO7XUhaKO19r/V+aQB17vbwHqvWlp24EoEneZt8l9/aPkZc9 8fFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922315; x=1795527115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=g/HhL0icM5bUtoKj5yDnzoPXIFsvViyLIg4hdd3bfBA=; b=qqfj8S53y4n1Yu7BVW8KAVyRfrUi280qCfIFy1MO3NnbMQdz9M/tUmj2g8verFI3+p hlebYO9yCgha9W9cj2nioU6sP1sdx8kKwB/pbHgF/at7bFn8R0XX0re7TGsmxcMZ9Qj5 SJdbOCvmlR4NNWGH5LMvWZe0+WijgKI0H4t7N0jwSMGI7qtFC9bPjNu0Z6mBEUMp+VGI bGSB0MChYl9rqVhhaQpm31xRDNAA9Moz4mcx+iMH9scAcdctiz+QBWPnpi7X2PNYJJeg BZzjzvSPrD6LyMuNUqVbb1hxR8LHeD2uNGIILOaGvlJIK7jQ8qe4o+lzIdsTztGB2lsr KCag== X-Gm-Message-State: APuU4Z+mGuRPqoTiH5KdbQ3QdiwMkl2zdi8Yg1kiFtjTb5Hldz1RKiTG EguNmO4HhIBYtoI7ztC0crnpPU8YrmZ3bNF6VVdpFOTxLimK8z649e5iKnDwF3B70ZKz+Q3VEl9 rCqkpA4o= X-Gm-Gg: AZFdTZczAgir9FGTE5PIcuKg5JLSWEea2lYagYjCmKZCSdGlcBb0e9HCBj1YCDHH5vb 2K3ol8tRdK4+Z4Hdy75Hiz+Kr8syChYtk26SuxQzWOuMgmNQK22VsNCSUPwQz209FjF4T2qHNnv lbp8+YWS12mgaAvTI0+FEIkFjlFw4H7eDoUgwn5OcQO4A4f489hApz2Sw3L6R23l+sGY9Z5dZ7D Sj7nUrTFHleX4PxcamkMo37BeBhT/VzMlZkoAUuygqIIFtrqsDKkJVzMHEe82nXIRa9DRMG/OO7 DhWOFHpjwDFpjJi8fI2QA6bXNaiO446YcfXTQDS1UQBNSb6S1PR2QMBM1HkFA6az/jmZuqpnTyQ LOsmGqUXXXg4J9IETZhP5fQdyrMJODxD0zsdzaejuOwNt5zXEu1N75nWz+bmSPaXMXy1gfEtKPZ 89VCDi911a9gOtOtjc7MNPmQkR188/ZIuPQWF9c6sDES1vOCodP8ayz+aWp8tR0Slo1jhSIcmEr iiQUfG/V9CRkSRbESWMsY6Its3v9MUWO0G/ZeAENVLjhiraA2Bxunwo9f7RwyvICnPeRZsSoEXv Jp5PyJ+giUH6RO/egvK5ztfox4ZG+T33wCdj2mzI8ZMXfoBQeI0fVpVx+2C1ygLdFX2bDpQj95z Qh3OFCQUnbGDtrEJ7MM7KnwEEu0y8fI6ah6NHO8LOv4MbPO7ja50h2tw= X-Received: by 2002:a05:6000:1a8d:b0:4a5:564a:6d50 with SMTP id ffacd0b85a97d-4a5564a6e81mr1843350f8f.2.1794922314977; Tue, 17 Nov 2026 05:31:54 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/8] target/riscv: Fix RCsc ordering of Zalasr store-release Date: Tue, 17 Nov 2026 13:31:45 +0000 Message-ID: <20261117133149.2108068-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922418514158500 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei The Zalasr load-acquire instructions carry an acquire-RCsc annotation and the store-release instructions carry a release-RCsc annotation; the extension has no RCpc variant (Zalasr specification, chapter 2). Per Rule 7 of the RVWMO preserved program order rules ("a and b both have RCsc annotations"), a Zalasr store-release must precede any subsequent RCsc memory operation of the same hart in the global memory order. In particular "sw.rl X=3D1; lw.aq r1=3DY" must be ordered, which is what forbids the [0,0] outcome of a Store Buffering litmus test that runs this pair on two harts. gen_store_release() only emits a barrier before the store, which orders the memory operations preceding the store before the store itself (Rule 6, release semantics). Nothing prevents the store from being reordered with the memory operations that follow it, so under MTTCG the host CPU may execute the load-acquire that immediately follows a store-release before the store has left its store buffer: * on an x86 host (TSO), store-load is the only reordering the hardware may perform, and it is exactly the ordering that is missing here; * on an aarch64 host, no dmb follows the store either. The defect is easily observed with a bare-metal Store Buffering litmus test on a 4 vCPU guest: "sw.rl X=3D1; lw.aq r1=3DY" on hart 0 and "sw.rl Y=3D1; lw.aq r2=3DX" on hart 1 produce the architecturally forbidden [0,0] result in 89881 out of 100000 iterations. Fix this by emitting a full barrier after the store as well, which mirrors the FENCE translation. The TCG_MO_ST_LD bit included in TCG_MO_ALL makes the x86 backend emit a serializing lock-prefixed instruction after the store, draining the store buffer before any subsequent load executes, and the aarch64 backend emit dmb ish; the store therefore becomes globally visible before any subsequent memory operation of the same vCPU, and Rule 7 is satisfied. This is stronger than Rule 7 strictly requires, since the barrier also orders the store with respect to subsequent non-RCsc operations, but this matches how QEMU already implements FENCE and keeps the fix simple. The load-acquire side needs no change: the barrier emitted after the load already orders it with all subsequent memory operations, which covers Rule 5 and the remaining Rule 7 combinations (load-load and load-store). Cc: qemu-stable@nongnu.org Signed-off-by: LIU Zhiwei Co-authored-by: TANG TianCheng Signed-off-by: TANG TianCheng Reviewed-by: Daniel Henrique Barboza Signed-off-by: Peter Maydell --- target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc b/target/risc= v/tcg/insn_trans/trans_rvzalasr.c.inc index 79b0b2c63b8..28d9b13c55e 100644 --- a/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc +++ b/target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc @@ -86,6 +86,14 @@ static bool gen_store_release(DisasContext *ctx, arg_sb_= aqrl *a, MemOp memop) tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL | bar); =20 tcg_gen_qemu_st_tl(data, addr, ctx->mem_idx, memop); + + /* + * Zalasr annotations are always RCsc: per RVWMO Rule 7, the store + * must also be ordered before any subsequent memory operation, + * e.g. a load-acquire in a Store Buffering litmus test. The + * barrier above only orders previous memory ops before the store. + */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); return true; } =20 --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922419; cv=none; d=zohomail.com; s=zohoarc; b=CASSe7EbHlr51TH+tqxTvp0jNbd0RoVOz8yFlFilPTbpxUUg2YpXekmTJb7eoqAuiiy2Tq7jyY2ytMW53hnXqZABGwOiz3I0DSfPZuzVm2KrPQkoQa/7+VPjyYJyZH+wUVJyeH1r3cL8PR44ba4wfEk1o6KPSzNvR8kXnKjrfhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922419; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=8khAikzYPXIWIZdUGIg72IOa1wY2dK1px0iM6iIku6k=; b=W4mE91XdI2mWGLZZen9z9PW5gRzXhLoATSe/1gvbGLqUMm42vVwYg/5w4tqZgXtwclij9AnBwIZmbrfk8tH4XA2gxnYcfUUtUw3aTPhxa8wOLZTgR6EDH3oXPhEdLUbW/glP577C2UmhMqOQNcsOwP4oP7iIcfeBp3eo660KxXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17949224191030.4732402334686867; Tue, 17 Nov 2026 05:33:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI7-0002Jj-8T; Tue, 17 Nov 2026 08:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI1-0002HF-HD for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:03 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJHy-0000hN-CJ for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:01 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-4a2f4ca0dcfso763301f8f.1 for ; Tue, 17 Nov 2026 05:31:57 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922316; x=1795527116; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8khAikzYPXIWIZdUGIg72IOa1wY2dK1px0iM6iIku6k=; b=ik/UoI2b/uqM+kYSWG07YZugaHqQNWjiu9KFnxr+lz2K9DcPXcl1O1otxmv+ET/0tB 6Ukmr70H+ciC8hY5yY+8V8LeghT7O9i4HYZuCgAjvQa5V3kKCz/B4PjnAGw/UqlZAyfJ AcJe4g+GMnsp+b9ZrROYQDlUemH6YqOAEuGXNy07beSFnxQnWlDolA+zsRXbRpzPEzxx 4PTeiDsExPGnuPRKT6sLd4dpxoz4oAqkIdbHJw4sqZf8UtWSj+yfOXljyzwTFN6TQdtj qZbGLdHdp7u7ak1I0EX64nOm/Dc0SeeQiIriusWDBEewKtWO8D5roR8o3HltyembzD7L K9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922316; x=1795527116; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8khAikzYPXIWIZdUGIg72IOa1wY2dK1px0iM6iIku6k=; b=hawlZBTEEFdsli3yoHNFGUPd/FQuZ4Iz2B2753nM1d6+9eZZlldu8EhmmYjshZGLV2 EY2cjmYU39994TCAC3qYaf8xSYzWKZ0QoniIM3IxbYlGGfhgAmhRSk8RmC8uZqV50Fdi H5F7RNR/rfsnM8Crpgt09iiyxgafVtYit4TYb8kBbL4oK4MRWtNbVAEBVTDCXsqlDePz 6B1BRmspuJ+7N6j0BOliMs8YIPkX+vMEfwhGUbRP8ITroTfqqDmXw1H60bJpSxG7gIEu 2Gcy2OT6F9M2jXO1hZklzIKX1Mo/g1nBTnKtrw6Xt+zQih8YdqUZidCMCZdIfD9LmJ9+ kApg== X-Gm-Message-State: APuU4Z+tS3lqLRSwNd7QcuObbZqifLAUj8iT41ZO8dp+GRoZKi8aeh/P rnXQeP7lbWphuUBsAuAh2BCUE2x5focc78dopTLBGXJhn97cJOLW4SfeZb16T+nsM63bwYCdBhU yqrqHW58= X-Gm-Gg: AZFdTZfSTep3dNorKjSrVx54xL9ZyPJNduchBUvJ2EWg6vE8WkSoa3u6hzzdlamkEL2 tFoEt5xb1+xi9Jz8VcAUyUZNwS47Mh/CT//ZndEgv4w2HyTnda0ublloRzDgRxuvX6QzqoSYYtm 2McD7xxntHEIyBXO29aEvqkpXRrUn0hXs3YXAE6EWWEucYEVjKtjKT8217c2jmU5EasI+4m4RVL I2XK0VTdmB9GkeL12jDPC78/dKxCnwL9YqfT0djFaYj4WMR9qboeZABJPPConzme2+x0I2fPvQ8 MB7m5H9YrxqVb9gSoiS8Kt6tCIB2z1t1pEUUgkT2dCr0Mho9xWDbaOQ2xfbN+sjQmQNh0C2+n/K WWCrOxFrvgn3kyYpbu7oQcjb8707jcZo99udEGeFGQr97DhH4JNV1TBVtdgAYameVYMSfiOIx0N 3YuVuze+aCmVAxXzwwR4Uyh/XcRclCzST0MBSKzUUIGcP9bfb+dlnYyKqcLgk/577k+0V+fcfBE 6wm+7byqh855dZTo57ZdJ9Hc0ZhNPNWr60zmoxL9Ad3TE+juFA/CBz3jx9ftBSs83wAMpCBvpJG tiaOwK99xAVc+iREVCvrwamgG++ykdNWN6VCHOEyAsmx+n9Q57WWydf6pNtxPsZLNsudVT4AxUs A37hhJML2vF6YmUZ+rR+B58EABkRfQ82M5aOegEYC2E8dcWfRac0JkIQ= X-Received: by 2002:a5d:59c9:0:b0:48e:5071:420 with SMTP id ffacd0b85a97d-4a378f8daccmr5713307f8f.2.1794922315963; Tue, 17 Nov 2026 05:31:55 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/8] target/arm: Fix RCsc ordering of store-release instructions Date: Tue, 17 Nov 2026 13:31:46 +0000 Message-ID: <20261117133149.2108068-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922420734158500 From: LIU Zhiwei The Armv8 memory model has no RCpc store: every store-release in the architecture, including the AArch64 STLR and STLPUR and the A32/T32 STL, STLB and STLH, carries RCsc semantics (Arm Architecture Reference Manual, DDI 0487, section B2.3.8 "Acquire and release semantics"). The architecture therefore orders a Store-Release tagged RCsc before any subsequent Load-Acquire tagged RCsc of the same shareability domain, which is what forbids the [0,0] outcome of a Store Buffering litmus test that pairs "STLR X=3D1; LDAR Y" on one PE with "STLR Y=3D1; LDAR X" on another. The translators only emit a barrier before the store, which orders the memory operations preceding the store before the store itself (release semantics). Nothing prevents the store from being reordered with the memory operations that follow it, so under MTTCG the host CPU may execute the load-acquire that immediately follows a store-release before the store has left its store buffer: * on an x86 host (TSO), store-load is the only reordering the hardware may perform, and it is exactly the ordering that is missing here; * on an aarch64 host, no dmb follows the store either. The defect is easily observed with a bare-metal Store Buffering litmus test on a 2 vCPU virt guest: "STLR X=3D1; LDAR Y" on CPU 0 and "STLR Y=3D1; LDAR X" on CPU 1 produce the architecturally forbidden [0,0] result in 6 to 7 out of 100000 iterations, while inserting a DMB ISH between the store and the load on each CPU brings the number to 0, which validates the harness. Fix this by emitting a full barrier after the store as well, for STLR/STLLR and STLPUR on the AArch64 side and STL/STLB/STLH on the A32/T32 side. The TCG_MO_ST_LD bit included in TCG_MO_ALL makes the x86 backend emit a serializing lock-prefixed instruction after the store, draining the store buffer before any subsequent load executes, and the aarch64 backend emit dmb ish; the store therefore becomes globally visible before any subsequent memory operation of the same vCPU, and the RCsc store->load ordering is satisfied. This is stronger than the architecture strictly requires, since the barrier also orders the store with respect to subsequent RCpc operations such as LDAPR, but this matches how QEMU already implements FENCE-like ordering and keeps the fix simple. After the fix the litmus test no longer produces the forbidden outcome. The load-acquire side needs no change: the barrier emitted after an RCsc LDAR already orders it with all subsequent memory operations, and QEMU deliberately implements the RCpc LDAPR family as full load-acquire. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4872 Signed-off-by: LIU Zhiwei Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 13 +++++++++++++ target/arm/tcg/translate.c | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 941254983e9..49472f7d975 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3686,6 +3686,13 @@ static bool trans_STLR(DisasContext *s, arg_stlr *a) true, a->rn !=3D 31, memop); do_gpr_st(s, cpu_reg(s, a->rt), clean_addr, memop, true, a->rt, iss_sf, a->lasr); + /* + * STLR is an RCsc store-release: the Armv8 architecture orders it + * before any subsequent RCsc load-acquire, which is what forbids the + * store-buffering litmus test. The barrier above only orders + * previous accesses before the store. + */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); return true; } =20 @@ -4429,6 +4436,12 @@ static bool trans_STLR_i(DisasContext *s, arg_ldapr_= stlr_i *a) /* Store-Release semantics */ tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); do_gpr_st(s, cpu_reg(s, a->rt), clean_addr, mop, true, a->rt, iss_sf, = true); + /* + * Like STLR, STLPUR is an RCsc store-release and must be ordered + * before any subsequent RCsc load-acquire, so it needs a barrier + * after the store as well. + */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); return true; } =20 diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index c1970f93c8f..20a58a24134 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -4296,6 +4296,12 @@ static bool op_stl(DisasContext *s, arg_STL *a, MemO= p mop) tmp =3D load_reg(s, a->rt); tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), mop | MO_ALIGN); + /* + * STL has the same RCsc store-release semantics as the AArch64 STLR + * and must be ordered before a subsequent RCsc load-acquire (LDA). + * The barrier above only orders previous accesses before the store. + */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel | ISSIsWrite); =20 return true; --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922408; cv=none; d=zohomail.com; s=zohoarc; b=jvkCCheicGCZiRcXKyZh6pSrKpodCdgkmGk/1MvK3DLpWbQSQW4EkyJHLZbP1JlzGx4aQzejtePIak9g0owtNCfu5bEiZ9o+F9S9vQX6uQga/4o+ZhzyBgFfU07e7l+09AW2IGeLzH0mTG/yVODoIv1Nqe7tk++t1PC7XNyujzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922408; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=6DvBl4prp1tbtnSVOBObXljk8K67ZY3zSXKpym1/XGA=; b=e6uTJqPROb60G3cDcMinSyaiQg81OJIvZrPGSqW1WJnUYkYFZnTKXrdfnHXU8GPZTRfsN+/TRtQn9JPXerPu0bo+UhAgNuMXAIK54N9I48JTFcKXFk/ug2Mid4tSN44pBMFGf25QUCiW2OeKRAJb0K014hjH0VNhev0QXYuSS6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922408284930.1775602557798; Tue, 17 Nov 2026 05:33:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI6-0002JJ-IO; Tue, 17 Nov 2026 08:32:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI1-0002HI-Vb for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:03 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJI0-0000m8-81 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:01 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-491846221ffso4247008f8f.3 for ; Tue, 17 Nov 2026 05:31:58 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922317; x=1795527117; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=6DvBl4prp1tbtnSVOBObXljk8K67ZY3zSXKpym1/XGA=; b=MHHKCgA4L4pQZyeuPbpyBLkNFja8rmy33xfICmYw8TVfGp9AvIfJcEAcBhMyFwqghK +ri13O71CIyafyDhxFIIIPTq8kaRohAARHA6OxxeNtrspGHGOGq0/i7W4IxzJB+pn26O nuQ/jsy8UK11zwwazcAhm5GXf+hD5li328U8gJDQvDS6+nb8IkF+Z8YGlf5Vq0V5kX7W KkRJkOenyyR1w93PCSROGZTj7gF1eaqCj4iPBfJrFjbd7evjWP+yc6H/KuRWimMhiqOo LONdzX0cckl+UIglrTXKbdpDOIGDBx05BxIdRAG5JBVaUPstbjKpUjR5DZn0XBUjSjVx OXMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922317; x=1795527117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=6DvBl4prp1tbtnSVOBObXljk8K67ZY3zSXKpym1/XGA=; b=WTX22UA5KcoueO9op0TKAhr+oxj6j456vxRY25nDSJebA9oxLPBvN/JCmppWzhVpP3 TaAjKpHQ3rmq4ySnigo99hy7Yw/lmJsaV1hK8wiE6O0g5SUO8zaIFb1+MILr4WTfm13G LpFYnwNZE05lQ8fYo+MxtEzHgmBCo6iS7rdxQjS+FerjRi28ADlITiILjUuIhDumtjrS n3IeiIMQmFI5Z8IH1vmOtXdYpsJ8nh+fGdb8IA3uK0IBgXVjd0uD0JIjoQCym7/P/Hzj 37KUXi1bz3KxG68X48kR/F5PjbjHoDwCwjHvsEkzAtvUE6gVEtp3EEaQ0cwzjIc1qmF6 WjsA== X-Gm-Message-State: APuU4Z+jxJnbvUKZJGvEVpRWComo+jqtDp3W9zzt3cBSH6/T4MBqPhA1 lEBjML3PQO84inQ+sDIGgfx7OMMx2HJKmj9aPRluDK14y4woBGnXcRrrvuUWBbRLv9gwrbLbtYV WPsPL4Qw= X-Gm-Gg: AZFdTZculjlOhXuExeeGwS50zwuXQ8x9YQp0e5PyAk+UkNRAsn//u6a9YW7Sr4/FGy/ XYkgdOWQPIVJwsX12RU9m3Zn8GNh7pb9kSmRg+2JQDCugr4ctC9kvY1Fi5Ez7zfgD2D+s+KMkph Lz8I/e76E/+uyfsiwlQPQ2rG7yayeETqrHsF5Bx2JSXZ4HrTWDgDliec24fUSLXxzskFXIWyek4 WAaHlf+EQarlEz48RhgWD/dPwcRpFCcVmcnijAKMBnPfBjM61SCxCbJQJGLGy3BsNazLhoAyZ+f n9B/Lo/6PB1pLAhP2s9SEpaohhY5RnJnJTD3JCkJt8mRuXX9aa5PzUcP7aWKNUrHIRxSZEzr/2c j66JEgvsxmBbwt0VSM5CLwYaVSTl79yEeWVYVflt0nXTPngQRqgQ4UYc+7HrJCHhvJRVftEOcuL FnmQ7NMSIMrsZ0W2d57GHJkgecmCfTLQ6pN2SKv9jVgiawLzWab4wFP7/9ad4veNzfib7/6x82q 7umHN3r6aCYMvThlyvmpkJ9b952OP2qBoQA4zjl8IijTFV3MKfjuKNv9GgsFxLMKCwUVgtgXbnp 5s0GZ+f85d4YV/ENOLWzPeq9m3Gl7FT5AyInVt7Yex0VkmC8Br4rRFPo/C5xhNuNpVfDOHFdAzo DDeBTv/tjYrrRBGzpiN4rg8wgPteAmlYPJw== X-Received: by 2002:a5d:584b:0:b0:491:f34b:49b4 with SMTP id ffacd0b85a97d-49c729bb9ffmr28737083f8f.44.1794922316894; Tue, 17 Nov 2026 05:31:56 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/8] target/arm: Fix barrier polarity of A32 LDA load-acquire Date: Tue, 17 Nov 2026 13:31:47 +0000 Message-ID: <20261117133149.2108068-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922410450158500 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei The A32 and T32 load-acquire instructions LDA, LDAB and LDAH must be ordered before the memory accesses that follow them, so their translator has to emit a trailing barrier. op_lda() emits that barrier with TCG_BAR_STRL instead of TCG_BAR_LDAQ, inverting the polarity: TCG_BAR_STRL annotates a leading barrier ("previous ops will not be delayed") and TCG_BAR_LDAQ a trailing one ("following ops will not come forward"), as documented in include/tcg/tcg-mo.h. The x86 and aarch64 backends only look at the TCG_MO_* bits, which the wrong annotation does not affect, so the generated host code is unchanged on those hosts. The annotation is still wrong: it violates the TCG barrier contract, it lets the optimizer's barrier merging in fold_mb() combine the barriers of an "LDA; STL" pair into a weaker one than the correctly annotated form (STRL|STRL stays STRL instead of LDAQ|STRL =3D SC), and it diverges from every other load-acquire translation in the target, which all use TCG_BAR_LDAQ. Fix the polarity. Cc: qemu-stable@nongnu.org Signed-off-by: LIU Zhiwei Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tcg/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 20a58a24134..442c34ce84f 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -4458,7 +4458,7 @@ static bool op_lda(DisasContext *s, arg_LDA *a, MemOp= mop) disas_set_da_iss(s, mop, a->rt | ISSIsAcqRel); =20 store_reg(s, a->rt, tmp); - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); return true; } =20 --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922332; cv=none; d=zohomail.com; s=zohoarc; b=hUKKZK/8Uos9kTph0/u18gajlzvuAHnopHwagfUI16wlDklyjl0Sgihe60nMCpypZOFRyZpDL555uLsS2jgbouqZccca26SgmIT2GRSfqaLPwbLlfg76Thw8f60OMWrqmgFqTQ9xsDV/lCu5q9aNBvesbMOXTYV6zW7qTu55YwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922332; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=2qB+TruDA6V/Hg/qEMwbvI5mG5608AYXXpYycfVwoYU=; b=FnkAt1m2wVgVQq08FOl3j5P2GrbcWSDqCQZZ2z8pS3q5Ca6RaxZJNQMKrAkNnBwma5VxifPGYBZYmPiIIxd2iupk+HmOmY0mD2y4ymj4OhG6UQQFdqvGEOeBqkpQ0uW6nRSwRveUlEAhHP6uQtrzkYVRbHjBmcpOHbQittqc4JM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179492233240873.71756168232957; Tue, 17 Nov 2026 05:32:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI5-0002JH-T2; Tue, 17 Nov 2026 08:32:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI2-0002HJ-WB for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:03 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJI0-0000sG-8u for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:02 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-490c3ae81d3so2675439f8f.2 for ; Tue, 17 Nov 2026 05:31:59 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922318; x=1795527118; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=2qB+TruDA6V/Hg/qEMwbvI5mG5608AYXXpYycfVwoYU=; b=m4Juy8Ieyc4P3Rwbi7uS6qbx3z23oC8zDkLa5JbxVB/qlkqxj0YNKXIte+iwrqhNYr WdLEIRlUR52TPvsOCCoEdQqlnZ7oehh4+AyOfiN7fPfBKhu1v279HespHPAUWwsgZKP3 jvx/+qfmYOr0PufDClV6b2O1zETAAmvpP4Q6DXLRvkfCGvTYN935A/AfLmYAkHCnmxXt 8PH+cNnCaPu7MgNTugG1Ak/UJ/XoIuthX7/ukE+KYh/WbVh1qqBy34Gw2s9BSfnM4B8h 3qmaYwE1qG8DBxtseexv2g1LWM7e6+Jc/SjVf5ih6eRBxMy1V1e70Sw4lwj39OrI96jN eS+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922318; x=1795527118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=2qB+TruDA6V/Hg/qEMwbvI5mG5608AYXXpYycfVwoYU=; b=jYKRg8IPHdqkwC0lrvS2MhSXCt+Xc5fdMZ17wtfL+uisVmKSrPCfYffwUXjMosnirj SyR5sjhZjBeZxlSwMnoLjvMmewvHFCAtTs6pxPFN+RYBihHzSedSThdUxzIw4dI84AL/ UHAA/G23Z47k27yoih+LLn/5YgHXYyZtpYsR2EBKOLI9215DXAy0qrtUN2KQJDYr0eWF spR+mFQj3ieb5U6x0MFfPOua1r5+2Idhtx9qOBMLUUIpSG6nod9CqFeQ/CbhKzwmSwao S7T5Klh+LY3Bgu0aFiR7dVNFNycG0lmJeDWs1gFCdPD7gyNcwQTzEAXmo/IM6X1LZZP9 c/2Q== X-Gm-Message-State: APuU4Z/bB7gNvPjPvvuJQkp0rXLzO7e4MkAISHXXPOKFa4De6gb72JMD L5uscy8iVO4Nl02GxHi/E60S4VDgukfPquN4SykAm5jk82nV4YazQZ/fiyfiOhxGa6oaFncufGL xSI7Yumw= X-Gm-Gg: AZFdTZdqVvurIejNPJXhH9eNxCJJZxcAMSTkH68+zNmG/4mp0kTcB+VUn+2JvVrejfe gUuympngJ09GKGKkp+Wn9NmnDUqWCExxizVOhJS06dklmBBRrVhiOKPfOZGV40hiGlJmZS2dxJB HaACJsFc5NHYr7J3VRKAslaWFzGUznscxF00gOIeJbtzTgl6eQsQDBGV5gc0+KrF7kbfRxN/LIi s2parPF1CnsvxFCfylCO0eJ9PFSkVTqGqHQqgKd/81Hui5KlPVxZ8tvEVX5LfG8kU3+U+nWq7rf vdOSeihrUn4IQg3oyX6av8RcbOj+OmD7A5fp2WrdtqoGPemR38UDWwe8mOa/kU3VFEshatqEWJZ Mtr1Jjo/csDKYk74WJe2zW84TRWnLj9AsdzEMB1KmFm9SBkTO9I4yryFDmU7R6XBUw7KOkehjYY jrJnWHAY8H5P1OBW2hOMJy+AG8ZnfvQDzv+aV/tgj/H2F6Ck2de+xd4md5bQ4MoUpfFGEdd2z1q TCEoN7b8kd0lkT/Dh9C1L0Dz9+AvD3LOCoZecapuP6GhVD5uNPti0CtpAS65FEQDBRYwoYur0gI Dwt7UE7XNj8m9ws/kCRmL2hj7ahmHucsv+geV6wB/E8S/2RyLiAa99EnEIzyPiReoKH0R5F3ucS D9WqQeNMhCi1ubGjR1n4pGAEKqgSfrXiUbawUH2w/I80AEqDH/IL9f1s= X-Received: by 2002:a5d:584b:0:b0:490:71a7:6f51 with SMTP id ffacd0b85a97d-49c72ba6509mr28875120f8f.45.1794922317904; Tue, 17 Nov 2026 05:31:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/8] hw/i386/amd_iommu: Mask address when calculating large PTE page size Date: Tue, 17 Nov 2026 13:31:48 +0000 Message-ID: <20261117133149.2108068-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922333546158500 Content-Type: text/plain; charset="utf-8" The amd_iommu handling of the "large PTE page size" (where Next Level bits are 0b111) case is not correct. We calculate the page size using the address in the descriptor (as per table 14 of the spec), but we don't explicitly pick out the Page Address field, instead passing the whole PTE word to cto64(). This means that a PTE which incorrectly sets all the reserved high bits can cause cto64() to return 63 or 64, and we will try to shift by an out of range amount, which is undefined behaviour. Mask the PTE with AMDVI_DEV_PT_ROOT_MASK to get the page address (matching how we do it to get the address for the next page table level in NEXT_PTE_ADDR). Cc: qemu-stable@nongnu.org Fixes: a74bb3110a5b ("amd_iommu: Add helpers to walk AMD v1 Page Table form= at") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3618 Reported-by: huntr bubble Signed-off-by: Peter Maydell Reviewed-by: Alejandro Jimenez Reviewed-by: Sairaj kodilkar Acked-by: Michael S. Tsirkin Message-id: 20261105105816.3012283-1-peter.maydell@linaro.org --- hw/i386/amd_iommu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 948d8611b15..008e882724c 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -216,7 +216,8 @@ /* * Take a PTE value with mode=3D0x07 and return the page size it encodes. */ -#define PTE_LARGE_PAGE_SIZE(pte) (1ULL << (1 + cto64(((pte) | 0xfffULL)= ))) +#define PTE_LARGE_PAGE_SIZE(pte) \ + (1ULL << (1 + cto64((((pte) & AMDVI_DEV_PT_ROOT_MASK) | 0xfffULL)))) =20 /* Return number of PTEs to use for a given page size (expected power of 2= ) */ #define PAGE_SIZE_PTE_COUNT(pgsz) (1ULL << ((ctz64(pgsz) - 12) % 9)) --=20 2.43.0 From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794922421; cv=none; d=zohomail.com; s=zohoarc; b=aJWdesdU4sFCPv4lAL6NImnqGIhDUWH0NoTkyb53edh54uo4V9OJOejCscEWrrfNdTOBIZ21JGSzEQ3jRo8SRp14/NAxVsqtR37CRHohqozLcg4Z65ZsIorDZ1SZ/2dft5u6lc7t52OG8cOHqwZ/vWOpVR3WIYM5RcdVG3YwDpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794922421; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=e+9qf0JtGeL8BjUKZBo1xvDmviC9MBhBG6JLfNI9WtY=; b=Cvh1OnQBhUDb46Xx6bLxnYEIBKEvLYpyA2PxCxB/R4YbGKHmIecI+rlPaoZrEaZXhAq72ypjA0toT0J4KiCy7L5pKvYkdRptCdIZlfuSrFJBlRMnJP+3VOxg/lVbB0yIajRopYQ0Oa2w2vNsD/+XjWQbWTxL3CUq09abD00etD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794922421561106.50985446351251; Tue, 17 Nov 2026 05:33:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTJI7-0002KD-OU; Tue, 17 Nov 2026 08:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTJI3-0002Im-Hj for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:04 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xTJI1-0000yq-95 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 08:32:03 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-491971ac844so4008203f8f.2 for ; Tue, 17 Nov 2026 05:32:00 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c609c8a77sm28516886f8f.49.2026.11.17.05.31.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 05:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794922319; x=1795527119; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e+9qf0JtGeL8BjUKZBo1xvDmviC9MBhBG6JLfNI9WtY=; b=GDY+rbwUkwIB6IORa6sEct4wVxPw9ec6gYYZxzhJs0w+YqOSI4ZyuqA6YPYvt5+IZJ pFczeLoACdiwGo9i+X0q+F+29win3UW1zwQpku2iW4KWL337KGswBjS7WWKAAbcHedwG uJ9MCq2upqKIBZPLi777cN5VE8hpdsqYAGaEt+MwhFx2FvDPOTFHoVlbdXK1tCANFB5J wANBEKIAsMfAAvRh8MeRkG/N27NG9zbCoEfgpKOwL1SMGtHor6tj9he5egMMq5Aoczgk nCcsN8SXZMcSeb43qte6avCE9X0T5x0LLfAnuMt2Kg2y2zsJ56Vtq2VxA6wnGJqljhKM nhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794922319; x=1795527119; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=e+9qf0JtGeL8BjUKZBo1xvDmviC9MBhBG6JLfNI9WtY=; b=de/18wkoHg7FQHV4ir1kJPBeQwd7/RaVEaUi97RhfCtGf15egJFOopfaZMiEJI+TwY 53CMtD8zdP+p+QAOdM4Id5rTAorJuI+lLoZY3F4SAUu0E5SX0N6fKY1A4FyNqNj3rYrs q9QgU+gDl4pMb4AO5bZ+JEilANWuKfxCMumRWo2b7GaGTZpt+xosJV+IR6nfWdlKI/BZ Fx/9DjJArz64PLYUraYdA8aSnHVNfokM4OclNbK5eS7bJm3HaSz3imEPjP12z21Al7Pu AO3M97HfmVNiTorxyV0dro7zrRmJpeIpaa+9bOqWQxmsuytWuv/HZsHg6VK9hRX4Ms63 VbFQ== X-Gm-Message-State: APuU4Z+XwTVBuJTIaA3bTC7gXagiOcqSMAwvaq6Dj3GcKIqEWWWxLI2I Xbc7J3ofdrztntFF1Tc0BTTdVnG1G53KCId+yF20fk0xk9z3WiloYjaHqR7GfM1sHFdGjn4wx8i zQb6EJnM= X-Gm-Gg: AZFdTZe1RFqNdtg/co4Y05jV4C4SO1PFW1diVPDQc4PenssjkLVDIhjebJUv5VxRxWE u+ZV21iKzEFKkgCyxYsTXQUozwcsXr76cH+vvqOi9heJG8t7rj4nEiON4WDUJq5DJpBWtJfs7Pr WU45GMK8qaccaoO3Rd/RTFZmQXUDYCU1kQOX3jutpwi8G8Bi4UF6H7ieMO4+jnC+Ji0Q30X+Os7 106v5ZqReDJVYqkZenqcgQFYF2WtP+XAEpR3jSqdFR6jn666Wf4M+29xe9dwYPlWBITdnP/bdvV 6479q9Jh8QuuM75KMbuW9huyt1AEt/HdfVlu54UQGDbhT33sYQNMBFZbeFivKDBOyhnc3j9V/+4 7OFCyEBldX8+DkM9pnSwnMvwFBgHtBYvZ4O3i9PSACEi5nY6RwLxoOn48wABsatM1Q46k3jpfDW tUvXPfch+D8Oe2DtQcr9PkKkmVqxLaXv4aqsKOdJDYJ2gNP8MAbMi5BIsX8I+c+u8mLEivV8fpI eJu9R93GOneQRaGQteCWxsZ4lDHTqKz6gsQsRZGNyQy7FkWPTVnvG/NFjMRcwXttVxaeYOtoUxr hRjPeXapqDRwMUokkUcQ9YIA+ZOKJXNwiZGsg3l2DxOu57HuBGtqMynrYQvV3ldNIeCCSrEPo4n ajrSlvTjE98gyhWZZ8JgzjFZlOFvBwJQTug== X-Received: by 2002:a05:6000:2309:b0:4a5:33ad:8721 with SMTP id ffacd0b85a97d-4a533ad94a1mr1942896f8f.0.1794922319141; Tue, 17 Nov 2026 05:31:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 8/8] tests/functional/x86_64: Add test for ccid-card-emulated Date: Tue, 17 Nov 2026 13:31:49 +0000 Message-ID: <20261117133149.2108068-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261117133149.2108068-1-peter.maydell@linaro.org> References: <20261117133149.2108068-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1794922422749158500 Add a functional test for ccid-card-emulated. This roughly follows the usage procedure we document in system/devices/ccid.rst of creating some fake certificates, pointing the device at them, and then inside the guest querying the smartcard for the certificates and checking they validate. It deviates slightly from the suggested commands in the docs because the buildroot based rootfs doesn't have glibc and so "NSS-based smartcard integration with coolkey plus certutil" doesn't work. Instead we use opensc's pkcs15-tool to read the certs off the card and check them with openssl. Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20261110134845.1770151-1-peter.maydell@linaro.org --- tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_ccid_emulated.py | 167 ++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100755 tests/functional/x86_64/test_ccid_emulated.py diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/= meson.build index bcda07620ff..9ed55fa99b3 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -35,6 +35,7 @@ endif =20 tests_x86_64_system_thorough =3D [ 'acpi_bits', + 'ccid_emulated', 'hotplug_blk', 'hotplug_scsi', 'hotplug_cpu', diff --git a/tests/functional/x86_64/test_ccid_emulated.py b/tests/function= al/x86_64/test_ccid_emulated.py new file mode 100755 index 00000000000..d8f9bbe9211 --- /dev/null +++ b/tests/functional/x86_64/test_ccid_emulated.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# +# Test of the ccid-emulated device. This roughly follows the lines +# suggested in our documentation of it, but deviates a bit because +# the buildroot-based rootfs we use doesn't have glibc to use the +# certutil + NSS validation process. Instead we use opensc's +# pkcs15-tool to read the certs off the card and openssl to check them. +# +# Copyright (c) 2026 Linaro Ltd +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import shutil +import subprocess + +from qemu_test import (Asset, exec_command_and_wait_for_pattern, + skipIfMissingCommands) +from qemu_test.tuxruntest import TuxRunBaselineTest + + +class CCIDEmulatedTest(TuxRunBaselineTest): + + ASSET_KERNEL =3D Asset( + 'https://storage.tuxboot.com/kernels/20261110/6.18.54/x86_64/bzIma= ge', + 'ba98a8a07d5f3f3e20119341059c0f0096fda499d30e30049c1ea64553b7e7c2') + ASSET_ROOTFS =3D Asset( + 'https://storage.tuxboot.com/buildroot/20261110/x86_64/rootfs.ext4= .zst', + '267172d47dc9594a8f07ec7fec05dc17b0fc21c64d5b635fccd6455128a2eb58') + + def create_certs(self): + # Create a CA and certificates in a dir under our test's + # working dir (removing any stale contents it had first). We + # return the db_spec that the ccid-card-emulated options need, + # plus the filename of the exported CA cert + + certdir =3D self.scratch_file("certs") + shutil.rmtree(certdir, ignore_errors=3DTrue) + os.mkdir(certdir) + + db_spec =3D f'sql:{certdir}' + + # certutil will by default block asking for some keyboard + # input to get randomness; create a noise-file to pass to it + # instead so it will work non-interactively + noise_file =3D self.scratch_file("noise.bin") + with open(noise_file, 'wb') as f: + f.write(os.urandom(2048)) + + subprocess.check_call(['certutil', '-N', '-d', db_spec, + '--empty-password']) + + # We explicitly specify serial numbers (420, 421, 422, 423), + # because certutil's default is to generate a serial based on + # the current time, and when run from a script it will end up + # repeating the same serial for two certificates, which causes + # it to error out. + subprocess.check_call(['certutil', '-S', '-d', db_spec, + '-z', noise_file, + '-s', "CN=3DFake Smart Card CA", + '-x', '-t', 'TC,TC,TC', + '-m', '420', + '--keyUsage', + 'certSigning,crlSigning,critical', + '-n', 'fake-smartcard-ca'], + stdout=3Dsubprocess.DEVNULL, + stderr=3Dsubprocess.DEVNULL) + + subprocess.check_call(['certutil', '-S', '-d', db_spec, + '-z', noise_file, + '-t', ',,', + '-s', "CN=3DJohn Doe", + '-n', 'id-cert', + '-m', '421', + '-c', 'fake-smartcard-ca'], + stdout=3Dsubprocess.DEVNULL, + stderr=3Dsubprocess.DEVNULL) + + subprocess.check_call(['certutil', '-S', '-d', db_spec, + '-z', noise_file, + '-t', ',,', + '-s', "CN=3DJohn Doe (signing)", + '--nsCertType', 'smime', + '-n', 'signing-cert', + '-m', '422', + '-c', 'fake-smartcard-ca'], + stdout=3Dsubprocess.DEVNULL, + stderr=3Dsubprocess.DEVNULL) + + subprocess.check_call(['certutil', '-S', '-d', db_spec, + '-z', noise_file, + '-t', ',,', + '-s', "CN=3DJohn Doe (encryption)", + '--nsCertType', 'sslClient', + '-n', 'encryption-cert', + '-m', '423', + '-c', 'fake-smartcard-ca'], + stdout=3Dsubprocess.DEVNULL, + stderr=3Dsubprocess.DEVNULL) + + # Now export the CA cert to a file + ca_cert =3D self.scratch_file("fake-smartcard-ca.pem") + subprocess.check_call(['certutil', '-L', '-a', '-d', db_spec, + '-o', ca_cert, '-n', 'fake-smartcard-ca']) + + return (db_spec, ca_cert) + + def run_cmd(self, cmd): + # Run a command, and wait for the following prompt + exec_command_and_wait_for_pattern(self, cmd, '# ') + + @skipIfMissingCommands('certutil') + def test_ccid(self): + self.set_machine('q35') + self.require_device('usb-ccid') + self.require_device('ccid-card-emulated') + self.cpu =3D 'Nehalem' + self.root =3D 'sda' + + (kernel, disk, _, _) =3D self.fetch_tuxrun_assets(self.ASSET_KERNE= L, + self.ASSET_ROOTFS) + + (db_spec, ca_cert) =3D self.create_certs() + + certspec =3D f'db=3D{db_spec},cert1=3Did-cert,cert2=3Dsigning-cert= ,cert3=3Dencryption-cert' + + self.vm.add_args('-m', '1G', '-usb', + '-device', 'usb-ccid', + '-device', + f'ccid-card-emulated,backend=3Dcertificates,{cert= spec}', + '-fw_cfg', f'opt/org.qemu/ccid-test,file=3D{ca_ce= rt}') + + self.prepare_run(None, kernel, disk, + drive=3D"driver=3Dide-hd,bus=3Dide.0,unit=3D0") + self.vm.launch() + + ps1 =3D 'root@tuxtest:~#' + self.wait_for_console_pattern(self.kcmd_line) + self.wait_for_console_pattern('tuxtest login:') + exec_command_and_wait_for_pattern(self, 'root', ps1) + + self.run_cmd('cp ' + '/sys/firmware/qemu_fw_cfg/by_name/opt/org.qemu/ccid-= test/raw ' + '/tmp/fake-smartcard-ca.pem') + + # Start the daemon which actually talks to the smartcard + self.run_cmd('pcscd -d') + + # list the certs; having this in the console log may help debugging + self.run_cmd('pkcs15-tool --list-certificates') + + # Read each cert off the card, and get openssl to check that it + # validates against our fake CA cert + for cert in ('0001', '0002', '0003'): + self.run_cmd('pkcs15-tool ' + f'--read-certificate {cert} -o /tmp/cert-{cert}.p= em') + exec_command_and_wait_for_pattern(self, + 'openssl verify ' + '-CAfile ' + '/tmp/fake-smartcard-ca.pem ' + f'/tmp/cert-{cert}.pem', + f'/tmp/cert-{cert}.pem: OK', + failure_message=3D'# ') + self.wait_for_console_pattern('# ') + + +if __name__ =3D=3D '__main__': + CCIDEmulatedTest.main() --=20 2.43.0