From patchwork Wed Jun 26 23:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807517 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539279wrn; Wed, 26 Jun 2024 16:14:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQVL9K3vGz1BbViciuWpXvJmc3mdB47Jrf3m7N30jUc9y4/zhkzMY5rTshRfXIl+2Tp+Fv5GUTXp4SzmRaNgvl X-Google-Smtp-Source: AGHT+IHyUDri4N3o/hNDws+5IgHoWnX7hjuVeflFDiY9aQ0ESaTNGe5hT6LP4TulfTSnXqn8u4hQ X-Received: by 2002:a05:6102:1349:b0:48f:451c:9d38 with SMTP id ada2fe7eead31-48f4f02413fmr12701941137.14.1719443660465; Wed, 26 Jun 2024 16:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443660; cv=none; d=google.com; s=arc-20160816; b=h6HIgXgtObYjwOc7C/5ERMTPQtQAOpz5H9worBC/4uXs8wEHEiJ5IXus9ftq/9qPrt Dn4YCy0nrqdrjSGv4NwUl/TH5JtPVY9+OFD0emT+aUj4DYy8PeNElTaQlr7L7yxEuV43 1uJMDEeaIwW6plq+p8AFBLczWxxpa06r+/JeuvjABPcO1CYIBHf9xq1hp9VYtFMWuwk6 rReL60AVe5bYhEScAYu3vUjyxa8zuDjIyJX4YFZfT47CEFUTsqIJ7/lUQoV2nIny0XQq l/9HWTq9VKSl+xVW2JoATPVk74+W6MCCA6wo9sP9o+lyakid2r6oeMXeBqb/tmjoUdme b/0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=vjQf5CEcubluTglcgKak9+xWJBxjhqg21na75Pxl7e0629+STUSVflCNx3i0tdI08i lQsJPv94VV35vywUitDy5H1rUdnW9tU/FL4kO791KPDTDSt5CNHrlgaSCQ9T25DKb6XV DxX4JHXDqw2NRHdA2FlStHfNrDwexp7euMGeAFh28qtgJAlr/FKCj6vvoeHfBvBNCGfP 664E3eXwprzXQZWw7vpu6ZrvSNvBfCw1qU7HCHNxWo6J964nNpOfNrtNQD/tOucuSEXK pYELTiGmQmMH7Objw4msKkuaQfKuI7kXIBwquMg4xSLBamPsa0ivv1ena2FBq77JMJIK 2z1g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n0Or9Ddj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4464202a499si724011cf.265.2024.06.26.16.14.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14: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=n0Or9Ddj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbp5-00038p-M7; Wed, 26 Jun 2024 19:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMbp1-00037u-Ss for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:03 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp0-0000OA-BA for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:03 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1f64ecb1766so55240115ad.1 for ; Wed, 26 Jun 2024 16:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443580; x=1720048380; 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=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=n0Or9DdjfvPbekEtxWyOr75G1YMsVilhH2jw1uul4adaPCk3owzVLJwIgpXXfQMlLt G1SwQRkK1phO/TDGmRwzJom9DwJOIcp+0HQdqFBLpSdG9Lllr3OEwXxbvhAE4qP4fpdu ej12U2y7IwZE/6e74IJulOHFmzv8gdPMBoK4/ya7qSR9Cvs00OX5CZCceKo6QvB6ctCV gvlDJcUqB7Mi5g6rFaNLU9PXxVMjC74uWz1gl7MA5VI8+J9qdz8yqDeuzDpCdBxwmEkL ChQTezdtGgHIBp0yl0BW1Vi4zT8Pdx3UebJis6g3p8WGIMx4V3P5gsrLKBEzYO2U6ekw hajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443580; x=1720048380; 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=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=CX0PXVNQnnPSDdIoP9002v8IeAYP0DyisFvCKOE0JW6AL3bVunhPMxjMke3DOB+PXV RE4K9Y/bbYis/GRZXOVv11SkJCLi6Bf94E+bNPRJxeJGcifZHrqSqf7IGQJZ6wV38QG3 rbbtwUB1VUhdukHls4T9RB3wZ2UdXISjrDgNzgJnDLsVgkj1SjlYsRTBJQAo2uK2hwF8 /GrHw7orpTnjksGp8HyBXkOHoeAlj4Mf85JSv3f6mBD3xOKmdReU6LuT4art0MIVtQKk 1EnZYbiVrYxn6BNZeMYp3DDWBkaPge4Xdk13KM+PVVUvps4vn1VobXkTddqI06zlX630 Yozw== X-Gm-Message-State: AOJu0YxpQreVcbmecd5poTApUs8oCYyI56N42CgItnlN9YvLVwQFo5SF LLrOR4FeGzUbjMCmWkL7WhAl2l+ly277tKQq0nCGnEQNYgFLo1mj0CGXYq/pQiEbLwOXYAB0SfX mfno= X-Received: by 2002:a17:902:eccb:b0:1f7:1ba5:85ff with SMTP id d9443c01a7336-1fa1d673c80mr136315375ad.57.1719443580340; Wed, 26 Jun 2024 16:13:00 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:12:59 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 1/7] plugins: fix mem callback array size Date: Wed, 26 Jun 2024 16:12:49 -0700 Message-Id: <20240626231255.339353-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x634.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 data was correctly copied, but size of array was not set (g_array_sized_new only reserves memory, but does not set size). As a result, callbacks were not called for code path relying on plugin_register_vcpu_mem_cb(). Found when trying to trigger mem access callbacks for atomic instructions. Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b6bae32b997..ec89a085b43 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -85,8 +85,7 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, len = insn->mem_cbs->len; arr = g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), len); - memcpy(arr->data, insn->mem_cbs->data, - len * sizeof(struct qemu_plugin_dyn_cb)); + g_array_append_vals(arr, insn->mem_cbs->data, len); qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, From patchwork Wed Jun 26 23:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807519 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539315wrn; Wed, 26 Jun 2024 16:14:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUpgkiV1reclGTjyKRvYpTYophgSOJ2hNYJ1Sco62vCve9lHgqTQIhTFpkYMYangmC7dwk4HzvcUEFSuSXbvRb6 X-Google-Smtp-Source: AGHT+IFMS39EdweO66exk5Tth6ccM1vFWFxvfoC4nTMJZLM0Dc95Qq1UvrD0kq7//7UUwJ6MbJ9D X-Received: by 2002:a05:6122:997:b0:4ef:280f:96ea with SMTP id 71dfb90a1353d-4ef6d807250mr10279246e0c.4.1719443668685; Wed, 26 Jun 2024 16:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443668; cv=none; d=google.com; s=arc-20160816; b=O/n1BW2G9Mg605bIvG50av1W6F66IEbkgM3N9FottcEdrgGg9rB2+MrQ4nMtJOjrUy TDg4K93EfqnUjcmh3msWA2D+bFsLDOPu92G69sVMPJC6c7Y8KFNN03MtH2yc2ohyy/Ll thfk6p+R8DKh6/kgqgNaN2TJm91sHvZ8dYerUygSOWEwOox5UNPHurZ1BIpZTMFmr2Qk 0l8vssSxBMzX07LAoWGKeCA0tDd9ikDzIzjG0uESCWCGw5HKfytToq/ENasDQs0+iR54 RIkXC3gNMCrflOukUNVx7pY9SDaLCjdTKRI59SL80zKhFohTDjSUk2i7PVAdez3ekkgN 4Y8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wNUrB5s89at4qVbSixRsMpXHb5fy+r0uHrHpGaYcnnM=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=z5L4rG16lVI6j+j1qD63g1sfnJ71P6Nfk0sYA9PGNsB0PMX3wr4BT5IjqvIFgR3QD0 jGg+PEh9b8PI7vMEK2fjVErOTcCbyUCPYCzICypLZgwrQnDoOv4tdv4tp9u4kWW2PrqB /2H4cT1RJikXz3r18FS24A9949IBZKcpE44QkvCR9pOrKfqI7W6oi0yMoyDXchr5r1Ir UjmfqY2+Cj9Nc4pX/gVIOeZ9dEMPA9/RxaQp21HgfGRbJzvlkgQ23RxMsQerpWR3BWGv c1CFt2PQkGbptPVa1/HcH9VC6p4fIm9DHPFp8TEtocpEDZKTdeyB3w090dTlHjKB4J5G W20w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JuEymtKH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b592416871si867466d6.120.2024.06.26.16.14.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:28 -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=JuEymtKH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpF-0003Bi-GM; Wed, 26 Jun 2024 19:13:17 -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 1sMbp5-00038r-Uk for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:07 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp2-0000OT-93 for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:06 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fa75f53f42so15328285ad.0 for ; Wed, 26 Jun 2024 16:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443582; x=1720048382; 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=wNUrB5s89at4qVbSixRsMpXHb5fy+r0uHrHpGaYcnnM=; b=JuEymtKHG35dTbAQC1ruRvFXVeZ4EEKQqpJFRtHQiHQ8pmK+h1jVSwBgEuQ+nOUpGH oxyVrz/hwPAvUmRKP7Wbd8G3D3ZK8yGsmBLB8QXbCCySYNFmwqbTpclT9b1oMdwaJuRT w6P1b2jn+bpjFDLN+lPuXZ6BpJh1O/b0CGxYIPBzLxZJeNVcWe7twH6fc5ovu0/9Fv9+ Zzp9jhz0tLCh3SCai6252RYo/Og5k+R8lgOMR582iltM9yX/rDsO2u7oLAWLXsJ3vuqq MGQ6wNin//0Fm8jK7Vm2krpYq7em4MFWZQ/vQUOll1qL2KKBHPw+2tVYdk3f9tDfqJxi WnyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443582; x=1720048382; 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=wNUrB5s89at4qVbSixRsMpXHb5fy+r0uHrHpGaYcnnM=; b=of1KoQkZCvFi/BKQtv2JyjWtwxUMwjejQliKZWaysgzKawyYjiXtE64XgV/n0kcikv EKuT8w2Wf4kPlEi0nxXzHi64R4uoWQRjhGudn9A4JanzIufnK6PCrkfWsHh08JfC7k0q 5ZGDT1ESU+e/PeVEITpmtVgw/xjoUSAjhAPNOcf+SEImOnDMWc0c2iQpOFBigxxKRuof AowoFJR/Si69CeQ4utL/Y88Ie2wHY8VIfHYzbbKsGgqCjKymmZjqtoYoiHL5QeGIc39Y G0uUvCTZC3+kcAnGBupIY1Tseiv0KVy4FuH8Eubbvui6nqXNYXKXCJFvSa5VpwXsFrDE CSmw== X-Gm-Message-State: AOJu0YwMjXRM0FfT6D/Tque+oStDIicLAIHP98azq05Q1R7MVGRQjaWs ibrKUeyH7G2qi71aD5NKknmYARBMwQOkAgZwEnK03CNCoMUPMJOFo4dCPBiYbAht4u8vThS2LDk BGGg= X-Received: by 2002:a17:902:6545:b0:1f7:3379:1c71 with SMTP id d9443c01a7336-1fa23f49e0cmr108907745ad.27.1719443581412; Wed, 26 Jun 2024 16:13:01 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:00 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 2/7] plugins: save value during memory accesses Date: Wed, 26 Jun 2024 16:12:50 -0700 Message-Id: <20240626231255.339353-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x636.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 Different code paths handle memory accesses: - tcg generated code - load/store helpers - atomic helpers This value is saved in cpu->plugin_state. 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. Signed-off-by: Pierrick Bouvier --- accel/tcg/atomic_template.h | 64 +++++++++++++++++++++++++++---- include/qemu/plugin.h | 8 ++++ plugins/core.c | 7 ++++ tcg/tcg-op-ldst.c | 72 +++++++++++++++++++++++++++++++---- accel/tcg/atomic_common.c.inc | 13 ++++++- accel/tcg/ldst_common.c.inc | 38 +++++++++++------- 6 files changed, 171 insertions(+), 31 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 1dc2151dafd..0c3ac79a6af 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 UPPER_MEMORY_VALUE(val) int128_gethi(val) +# define LOWER_MEMORY_VALUE(val) int128_getlo(val) +#else +# define UPPER_MEMORY_VALUE(val) 0 +# define LOWER_MEMORY_VALUE(val) val +#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, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(newv), + LOWER_MEMORY_VALUE(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, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(val), + LOWER_MEMORY_VALUE(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, \ + UPPER_MEMORY_VALUE(ret), \ + LOWER_MEMORY_VALUE(ret), \ + UPPER_MEMORY_VALUE(val), \ + LOWER_MEMORY_VALUE(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, \ + UPPER_MEMORY_VALUE(old), \ + LOWER_MEMORY_VALUE(old), \ + UPPER_MEMORY_VALUE(xval), \ + LOWER_MEMORY_VALUE(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, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(newv), + LOWER_MEMORY_VALUE(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, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(val), + LOWER_MEMORY_VALUE(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, \ + UPPER_MEMORY_VALUE(ret), \ + LOWER_MEMORY_VALUE(ret), \ + UPPER_MEMORY_VALUE(val), \ + LOWER_MEMORY_VALUE(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, \ + UPPER_MEMORY_VALUE(old), \ + LOWER_MEMORY_VALUE(old), \ + UPPER_MEMORY_VALUE(xval), \ + LOWER_MEMORY_VALUE(xval), \ + oi); \ return RET; \ } diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bc5aef979e7..112dcdad717 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -142,9 +142,13 @@ struct qemu_plugin_tb { /** * struct CPUPluginState - per-CPU state for plugins * @event_mask: plugin event bitmap. Modified only via async work. + * @mem_value_upper_bits: 64 upper bits of latest accessed mem value. + * @mem_value_lower_bits: 64 lower bits of latest accessed mem value. */ struct CPUPluginState { DECLARE_BITMAP(event_mask, QEMU_PLUGIN_EV_MAX); + uint64_t mem_value_upper_bits; + uint64_t mem_value_lower_bits; }; /** @@ -164,6 +168,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_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw); void qemu_plugin_flush_cb(void); @@ -248,6 +254,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_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { } diff --git a/plugins/core.c b/plugins/core.c index 9d737d82787..957a3efb06d 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -575,14 +575,21 @@ void exec_inline_op(enum plugin_dyn_cb_type type, } void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { GArray *arr = cpu->neg.plugin_mem_cbs; + CPUPluginState *plugin_state = cpu->plugin_state; size_t i; if (arr == NULL) { return; } + + plugin_state->mem_value_upper_bits = value_upper_bits; + plugin_state->mem_value_lower_bits = value_lower_bits; + 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 85101602581..93b338704dc 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -148,14 +148,24 @@ 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, +plugin_gen_mem_callbacks(TCGv_i64 value_upper_bits, TCGv_i64 value_lower_bits, + 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); + TCGv_ptr plugin_state = tcg_temp_ebb_new_ptr(); + tcg_gen_ld_ptr(plugin_state, tcg_env, + offsetof(CPUState, plugin_state) - sizeof(CPUState)); + tcg_gen_st_i64(value_upper_bits, plugin_state, + offsetof(CPUPluginState, mem_value_upper_bits)); + tcg_gen_st_i64(value_lower_bits, plugin_state, + offsetof(CPUPluginState, mem_value_lower_bits)); + tcg_temp_free_ptr(plugin_state); + if (tcg_ctx->addr_type == TCG_TYPE_I32) { if (!copy_addr) { copy_addr = tcg_temp_ebb_new_i64(); @@ -172,6 +182,48 @@ 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) { + TCGv_i64 ext_val = tcg_temp_ebb_new_i64(); + tcg_gen_extu_i32_i64(ext_val, val); + plugin_gen_mem_callbacks(tcg_constant_i64(0), ext_val, + copy_addr, orig_addr, oi, rw); + tcg_temp_free_i64(ext_val); + } +#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) { + plugin_gen_mem_callbacks(tcg_constant_i64(0), val, + 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) { + plugin_gen_mem_callbacks(TCGV128_HIGH(val), TCGV128_LOW(val), + copy_addr, orig_addr, oi, rw); + } #endif } @@ -203,7 +255,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 +324,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 +377,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 +450,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 +660,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 +777,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 95a5c5ff12d..bed56d25d47 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_upper_bits, + uint64_t read_value_lower_bits, + uint64_t write_value_upper_bits, + uint64_t write_value_lower_bits, 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_upper_bits, read_value_lower_bits, + oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + write_value_upper_bits, write_value_lower_bits, + oi, QEMU_PLUGIN_MEM_W); + } } /* diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index 87ceb954873..f6d5613a358 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_upper_bits, + uint64_t value_lower_bits, + 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_upper_bits, value_lower_bits, + 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, 0, ret, 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, 0, ret, 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, 0, ret, 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, 0, ret, 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_gethi(ret), int128_getlo(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_upper_bits, + uint64_t value_lower_bits, + 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_upper_bits, value_lower_bits, + 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, 0, val, 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, 0, val, 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, 0, val, 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, 0, val, 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_gethi(val), int128_getlo(val), oi); } /* From patchwork Wed Jun 26 23:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807515 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539224wrn; Wed, 26 Jun 2024 16:14:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV3NqmDFwo0+aDBOGIsJLiXUU2aAezilpIHOH5/T/U4beIShoEFi97Hj7HH00ZZoGOPM/aNN954uex+Y5Ym1ZVC X-Google-Smtp-Source: AGHT+IGcQshFg/QOEQzDRYUcOb18GBEHH22vClbeHhrZGWQL/TXZFD8pEV/DVjZGUwmof8V/gWVO X-Received: by 2002:a25:ad65:0:b0:dff:2fcc:ea3d with SMTP id 3f1490d57ef6-e030110a9e3mr10862010276.63.1719443650948; Wed, 26 Jun 2024 16:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443650; cv=none; d=google.com; s=arc-20160816; b=BUiUqjqlsQ3Er4zSAUAbwXSU53EnMblfQFTHzcKBWavN0p971DLD3c68LGRMlscOey /j0TdDIPpNV8+k5XD8k27JjSYBrSkM8Re2S9BR4wy/7bqY49Rk5DRc0fnOVJkB6T2fgK CbAiRtZFO7dre9Txhx/4RY1n+E9gHufzSEnqhTZy4r3mL0d3D7WpHZFwXlvvrQRD9tFw d62WxZIF1IV9pZEteCUlEqpn63t/pblXsoCwdPBLh7ZOnq9w6Rp2rUsNBayP1jXe8zIN G5k5M/yhFu2MwoJnW6JMpJa4TdabgObLH/0VZzzWYSBPHL6SCXgQKdsOtAI8SRCZG7Hg IFow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=OKA6agaBH1efxt+Z8lO4d/ZnbKC7MyONn1M/thk8fcVsw5zXEYPmNKMn1hcwVqKp5I UI2UdmGx5QV6GdHrmdaak6SOiF0lPwXbS7OHYaiXq1B8djbkwG8ZNDsHCDVqEllNF0iE +PDtL+87ADDzvrLn3uF1rGIWSuD4k5sJ0vGByl2FFjVv2WMuRRCcuXJgzUZVIcT91U8u zdbrRq5b9kqEpeAkBmjj6OcS1F8PCYyYRv5qUNDDiRqC522LUMkQmdC9uGxEfpXAcqSW Q9MENC8UEAXYXvQpBfI/DMOcsxhVWxauvPh2ISXhU6zBI9m3xRFLA0EFoSOBSyLnuE+P cOWg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wT9xxqW3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44642199e7asi670101cf.503.2024.06.26.16.14.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:10 -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=wT9xxqW3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbp7-000391-1x; Wed, 26 Jun 2024 19:13:09 -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 1sMbp5-00038h-AH for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0: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 1sMbp3-0000Ok-KM for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:07 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1f64ecb1766so55240225ad.1 for ; Wed, 26 Jun 2024 16:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443583; x=1720048383; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=wT9xxqW3L6yVoUEKBBB+r6331cprohHKpgpb18yAFgQ7FkVORpiEyCHxkwCHJY5Qwm 8w3q4b+v+/PM84RBIl/uWYGnziJgyeNOtvIqjbRDd1jRpAVUf1Q+r7Wb15nujkFwfF78 lmlmsawR/yY9tdJy8NeDFsagD62j1yUxnq+pLf0BMCR2xEezjHGvTYucaWtqvMqPRy2d q/x+Uo1FlJZP0j9hFWmos/yEkImlZuGBq6u3iqNiFv9e3V7nnHnCghR7tSrhOyA+tAGY NCdpleltjbE2Ke/XhyBAJCfvlpCnruE5FnwJsW0GUoQcRxG3NqfR53ugXxccxwiTkudo fkQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443583; x=1720048383; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=uypQj2ceUsknLTBe7FaG6NZf3ujwpnOq4cZ1NhqjmrJ+NDrYZLWPRTdUw5hV3Dpwie 7hPCiNHRu3/4v7wftXyieyNtfDSSBO57jsGlGl1MJBxlC+L2gRL0HoF4LkPrcvoacPHY FF64kjLVCZsnCYUb1VTk2r42G5r35CpZGmWiQSZX7isdmC3QE1HPBsiAAImC+fuvCm1m 9aUlpU8oGKGC+T1s9OY1xsz6mNw7RbsU2fL5bJGc6j72sTqpukAe8IycZGDc2xWvJIqt N8G+xAPy4Eu33fZrT9SHnJiEagLxVak7boxrINtS5iQYx4cjp9zBCxcd0NTt+BnMLhM1 Wfmw== X-Gm-Message-State: AOJu0YyApzMNm6JtyeVUi1i4kZloIxhz8kimy6ROg2zMghrUIvz/+hz5 duwLX4FqJxRIXm0ctXzLyP8LrTungv3Neda5mO08yh2EGrrmDGgv3rDqNHn7FBEuIi9QMmjKbx9 c1gI= X-Received: by 2002:a17:902:c944:b0:1f7:ff:b477 with SMTP id d9443c01a7336-1fa1d67101cmr144414285ad.55.1719443583249; Wed, 26 Jun 2024 16:13:03 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:02 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 3/7] plugins: extend API to get latest memory value accessed Date: Wed, 26 Jun 2024 16:12:51 -0700 Message-Id: <20240626231255.339353-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-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=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 Two functions are added to plugins API: - qemu_plugin_mem_get_value_upper_bits - qemu_plugin_mem_get_value_lower_bits This value can be accessed only during a memory callback. Signed-off-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 20 ++++++++++++++++++++ plugins/api.c | 21 +++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 ++ 3 files changed, 43 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c71c705b699..5945f256949 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -551,6 +551,26 @@ 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_value_lower_bits() - return 64 lower bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: lower bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info); + +/** + * qemu_plugin_mem_get_value_upper_bits() - return 64 upper bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: upper bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_upper_bits(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 2ff13d09de6..89e9f6ba5b4 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -351,6 +351,27 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } +uint64_t qemu_plugin_mem_get_value_upper_bits(qemu_plugin_meminfo_t info) +{ + return current_cpu->plugin_state->mem_value_upper_bits; +} + +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info) +{ + uint64_t value = current_cpu->plugin_state->mem_value_lower_bits; + /* tcg values are sign extended, so we must clip them */ + switch (qemu_plugin_mem_size_shift(info)) { + case 0: + return value & 0xff; + case 1: + return value & 0xffff; + case 2: + return value & 0xffffffff; + default: + return value; + } +} + /* * Virtual Memory queries */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index ca773d8d9fe..9f2646fc812 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -13,6 +13,8 @@ qemu_plugin_insn_size; qemu_plugin_insn_symbol; qemu_plugin_insn_vaddr; + qemu_plugin_mem_get_value_upper_bits; + qemu_plugin_mem_get_value_lower_bits; qemu_plugin_mem_is_big_endian; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; From patchwork Wed Jun 26 23:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807520 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539335wrn; Wed, 26 Jun 2024 16:14:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXuEQdYnDciR71YATIgCWi7PZt7lpzsSmaP43RNT4oKMD4letkCrSW/7u/z9nCq0K+2wGv7ToUY2UgXhcEdcXK5 X-Google-Smtp-Source: AGHT+IFilb1OlcUWLNU9WFy4848JYofphs6cbc6ucuvzOyjf1mRVeLz9RUp2uEm3Yi6Wqqy5grFo X-Received: by 2002:a05:620a:1a94:b0:794:b2c9:62ec with SMTP id af79cd13be357-79d5a108391mr146378985a.64.1719443672866; Wed, 26 Jun 2024 16:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443672; cv=none; d=google.com; s=arc-20160816; b=YI1ZHc1DG/1rjAP+57+7muy4o6KRHPUJaBWaWMFgCCHpejiI5Cmi+7nallbpVIPS+S czcjHNE+FUuG/LW7Ms2uVTbloUB7A+PxoT2u7fAXcjZusC3T8QKekiCZX8kEIElIPfIx IUNZacFbODMqRWtXxmQjBowvuAs8oG5dm3DnZKevY7nBizPCwjI+FNinRmpNrMndo+Mq vfiH21zL1pXkqY3i2VKcqo95HX2L9N1/pRsOBESD+kT9Ro6qTsfC+bwldMWEDvZyWQMR gVAfsVd7XhxeFC73pjjcYqhzaYRalAUzYfJoiZvHZ4LVADTnDRT3kU31aE/YTfaVNLB7 zdiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=mi5QgESEunzGvh6jTERYrE1+mkCL5uSuvKChlY/mk9KcbnGzrxMM8wV+z++A+1mS1j atgrKb+WvfSo27Qi1ZH9cjDFM+koXowzal+AXRyHGP/mBP1LJwYtOBgzNUf/ed2rldBM ADVzTz9DrX6b4hXLLDVT77JlaQiN+Ghcb5nyAuHulz//UaoWF5tEIYp/Lxv++/zEGNX6 k5k25Lcy2c1pg3Fda2obA3Ay7za8ndSgTX8g+2p/hnPrsXVOyNfQ2T1aIst7X7EWhGMi kUIJOC9b4jgrseMYqW/xtqD3tzcpys6JHnTuP1mOLHZDqqG8rrRWuX3TzJlyHDw5L0pm 64zA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kPh+jV0/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8a654dsi12973285a.297.2024.06.26.16.14.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:32 -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="kPh+jV0/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpI-0003Dz-FV; Wed, 26 Jun 2024 19:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMbpF-0003Cv-Oa for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:17 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp4-0000Oo-OJ for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:16 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1f9aeb96b93so50208495ad.3 for ; Wed, 26 Jun 2024 16:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443585; x=1720048385; 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=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; b=kPh+jV0/JpWu1FW1OgWeGyym40AzYaFvIk5XBoMXbA2krNquTKEd7Jj5FBNmYVL7+U MHN6WzvQp+Qji4liGohqAAnmiI59kQE6paLE68SQv5+/2KNnILz+CWOe+snLQYidYu64 PrIJnGx78bKx70jsNrDqneuB+ohkAfT64NFcPjBMkVl5RfvFk6sf3VzaijUelMESZvGe NIopLTQ2qmGtYlH4Db5Y7m4edSTgdVyn30UQUwA16Ij2Hm6rMwAzrFlUDeMuj95jTlKd DKIkO1plTcX2ykk2t54oK4FQmMo22xeqQaNlVh5b/oLibUGOF885Y5spkdzmx2v0kAPy /xBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443585; x=1720048385; 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=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; b=hZ2tozTpPuHf+6YWDvZLTXQUmFKm10BelFVDRH0COnjv0/sANYbVyfeL2REO6r+4mE EBhTAFKXaCVKMlhq4/t7Kn7aTq70dUoq1aXlCqHsqhw93rPqd6BmcaVRiDuk5T87FY/z xmPrpVOmrwMkVTSar0dWEbDNyCwz/7zIjIFdfRtGq7g9ch//9yN/DrOfBbeamMONzxIr waurkBG4LgwQuV5VmklecjV1fDJhmRnh4i0Czo+gk4t6KNhrokxOw0Iiv47cx3hzsq7/ JB0+2MTIhjV6o/Y6bxHdq5uZ1tw7+UL+9W2XLbgff0vv2fInJrOZ2amVi1Li0eL08ydF fTjQ== X-Gm-Message-State: AOJu0Yw+fIBkqchMX9XTP70VZrefREqUJ3Je0rnySF+dHCz63gCB3qDv 4Az/l1/QScueL+N8AbeGxi4u6r02hIdhA4pqs9ogxKVWcIc1kHdtKbGEff2xnf0u8dBmB0JX1XH 4UNI= X-Received: by 2002:a17:902:ecce:b0:1f8:46c9:c96f with SMTP id d9443c01a7336-1fa23f01d4amr141234695ad.61.1719443584791; Wed, 26 Jun 2024 16:13:04 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:03 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 4/7] tests/tcg: add mechanism to run specific tests with plugins Date: Wed, 26 Jun 2024 16:12:52 -0700 Message-Id: <20240626231255.339353-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x629.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 Only multiarch tests are run with plugins, and we want to be able to run per-arch test with plugins too. Signed-off-by: Pierrick Bouvier --- 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 f21be50d3b2..dc5c8b7a3b4 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 PLUGINS_TESTS variable. ifneq ($(MULTIARCH_TESTS),) $(foreach p,$(PLUGINS), \ - $(foreach t,$(MULTIARCH_TESTS),\ + $(foreach t,$(MULTIARCH_TESTS) $(PLUGINS_TESTS),\ $(eval run-plugin-$(t)-with-$(p): $t $p) \ $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p)))) endif # MULTIARCH_TESTS From patchwork Wed Jun 26 23:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807516 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539238wrn; Wed, 26 Jun 2024 16:14:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWK1rdqhgKkXoQjn5NOV3FbJQh6OYVqcnlR1Dj+6WJF4Q8xa1ee31MTet/5K60E9MMufVmTdPficJAEbruqPZ82 X-Google-Smtp-Source: AGHT+IGMNlMjM8i6r4O4jbJQWxMZZyitXr8J2BweKTLaLeVH8M/EPE3kq5BEQk7BgXcBQh1oZT5k X-Received: by 2002:a25:680f:0:b0:e02:bac8:427 with SMTP id 3f1490d57ef6-e0304030173mr11349330276.56.1719443653352; Wed, 26 Jun 2024 16:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443653; cv=none; d=google.com; s=arc-20160816; b=otgdcmcnDJ8MzOXP2DhAOCK0zrVeD7JdrBz5J86QrlHCcbWJVYJngER/BlD7zAAZ1V 0fu4JoyuvAFI0VdWsKfJ5hCw63x8pwzau8wdF1qzKAqj0ca6IcHOUXpcYwz3x6ftIDxL UcwGv6Rf7UmNAz1SWyKpWxddC8O2jLvuFG9usKA0lBLcMl/9xvn5GnBoa7RDgw/lcSKU K8vneI3jM4Qd4dhK1L01SKPRXEoqBVyCgdujOyqIltb1JQp7AdFdxmlPSPExoQi6+EjN 7D1XQ3QWcww/CDfhhL5T3+I8NlUe58LVntVkcdPgsswqbL9QKR3DjLgIUJ4BKgXVEakz swGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=lUwGWxLWhevzcO4NILn3p+oskD5pnd8grjyWlOMvk9RKq5x6GV71rkZ9TF4gOt+ze6 DAyENy1OUMFRLHW9D38XGRAdT8zQ5tCbf+UUSLbdBZg3Xnuo8GrjzRcA+8ZyCfeUUD5+ n6hnJ53fQCku8ii9MjQSL+GPjwXFx0sZ+zwXOUgzFeaQh2uKNBgjDn1EM1gAXXJsCzdN gnBAXH0Xk6By2kawGMawUoQDcgHdajGOa7f+Dtlqn5YoMIQGJM6t+PJWi9fEwtttteh5 6vG+VQqbYDNsRhzMMa7siZcgdGpCAiTwzE66UurFJZNlgCiDdF8n14C6DS0frkf13V8V j4Jw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpTviXvN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44641f4903fsi829671cf.212.2024.06.26.16.14.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14: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=PpTviXvN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpG-0003DG-9O; Wed, 26 Jun 2024 19:13:19 -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 1sMbp7-000392-6B for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:09 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0: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 1sMbp5-0000Ou-Iy for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:08 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fa2782a8ccso30404445ad.2 for ; Wed, 26 Jun 2024 16:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443586; x=1720048386; 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=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; b=PpTviXvN/4c7MjKUnYEaPn9TSOlwwp3b8ztjNbi5eWpKtSM/vVLKnGO1kI6zWbIKHK fi1buTqdVzBKxoAiGW3eisatcGS91fIF+rXTNRq/8rFDFSc4dGc2eXTVmyEpbNNgk5Fv xow6JiPJXyOvRpp28km+Reh5IGg7pZ60MQYkZgcCvujDo9/mIhXCUpP/O/evri03z6Is YP9/apHLSwRCUEDGrAhFbGCgePNY7GMoVKCoIYWvkdiahNUK6Di2NfC5Hepv4gK/glTa gD6UgMt+aC14lR4iCvSftx0oY9SHnDZhkzlrX68ybq3Xz1+8qRtoQoIKuWEVAzmX6Ebj JN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443586; x=1720048386; 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=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; b=gihc/l5JSFlq+k10PRpa9W9j9SnJCjuBsU0mC+mZsyCSOg+aSuIj9V3wONVgK4ksGV oYrf4GxZlmdaldSw6bzNXf3KY6Nq6G4N6FaiwQvIfxM/A3/ViVjtYBKP5wEZlWxqgtbN ATMjb6lieSYIDnpGmMXtB0yMDqMzozlLfhKV7mGIdkmO8i4f37+Yfa5o7AcFBs2c9aGZ 5qvm4B02BKAYK52q441B1twsCGaBBdYJB8b4VLglodojrLhMVblaiVOFcMzU2rpAoUOc hic1eMsucorVvSrRexD/x/CJd39tQPsens4V6fsoOQ0ox4C7txCCmMmcsStwBY6Usc/8 sQWQ== X-Gm-Message-State: AOJu0Yyw90piGg/ULWa3l92+ndp7reIGHjs58hH+5b7Dv4udHUbLk7on 1GG40HAs/uqzk0XcmjFinXp1InBJ6UHoOtOqsyR0ixlYjrsdKdY3tPFF7SSb3KasvSV+Vs6DEoi EpiI= X-Received: by 2002:a17:902:680e:b0:1f9:fb0f:b9ec with SMTP id d9443c01a7336-1fa23f35fffmr91719095ad.62.1719443585803; Wed, 26 Jun 2024 16:13:05 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:05 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 5/7] tests/tcg: allow to check output of plugins Date: Wed, 26 Jun 2024 16:12:53 -0700 Message-Id: <20240626231255.339353-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-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 A specific plugin test can now read and check a plugin output, to ensure it contains expected values. Signed-off-by: Pierrick Bouvier --- tests/tcg/Makefile.target | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index dc5c8b7a3b4..55993611cae 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -90,6 +90,7 @@ CFLAGS= LDFLAGS= QEMU_OPTS= +CHECK_PLUGIN_OUTPUT_COMMAND=true # If TCG debugging, or TCI is enabled things are a lot slower @@ -180,6 +181,8 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(call strip-plugin,$<)) + @$(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout || echo \ + $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout failed else run-%: % $(call run-test, $<, \ @@ -194,6 +197,8 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(QEMU_OPTS) $(call strip-plugin,$<)) + @$(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout || echo \ + $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout failed endif gdb-%: % From patchwork Wed Jun 26 23:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807514 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539217wrn; Wed, 26 Jun 2024 16:14:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVYOcUTXRMq4QiGrUvWUW+Bun0BfuBxLmaOQ/qHiDxe+Waj04wNRds7VNH2pLpBOCX2Ol70q8NiPE09XqWECfrU X-Google-Smtp-Source: AGHT+IFx6ZyX4/93WFYmYB9wlXWu+4BXbKlusyw5JatSQQERaDgY9s1yKPRaJV5iXLSNYguF/N4a X-Received: by 2002:a05:6214:57d0:b0:6b5:4435:fe4f with SMTP id 6a1803df08f44-6b544360a71mr103507936d6.64.1719443649832; Wed, 26 Jun 2024 16:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443649; cv=none; d=google.com; s=arc-20160816; b=e3DnjAuqGh/+5p7HvQJFpxCSRmRX31VHXZwFKXxptKX5o8nuEQ5owtVBhSaPl4q/kS AeX+JVORrKK2e9vNJQoIY8M0bBGvumBfRcknoFtLGTkZkarMb4GrOcNH3d0f3HSon5V8 7o/7jJN+tHl0wWYlhi3YtwA6242N5rukbQKWCSz6CcTejDmfmIEMXhJvemRk7XkSR2hF 2xjNs/ap/Jm1oZSOsGBUrybuRHL6IgpCX9zrI0kujLzPAfzWpaWM0znVHExsQ5e0K/Am vOorDTL2Da3kpvCkEScE9K8bX+y6iAUwZM5ou1N+GzNOOLxjNvz7Bl/7qXfPThD9jvGN 0+1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=P4CdkNYonflfBeFl4OP2JHUNK2C6p/vljuEOHC6WLYw5q7XkaI+BgVoJC1JiunGnWJ kKPFRlezUc+grR2hwKb++3lJgcWZTrkZs6js15Vt7ydcv6f9gmvfzjf8dQyjZYjyNtR0 GeQZzz3Nu0PLg9RJhxg985W5oFF5Mx9cr75AwkMFE+zjQEJnDesrLOWKwWmhjQl8eRFx JZL6U/x8W509UCr53EjLkEnyTWVlEkSca99//+0/AmuNWl2KNfnKYL4rmtfltO/xRvm9 Uy1QfQQmxAnmec4HGftGfoLSgjgBAoK11VNlERelmdsJZ09y1cd3RzjkjYwa7nzgxva+ KlWw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=btot52pc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b592416826si839966d6.63.2024.06.26.16.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=btot52pc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpF-0003Bn-Fy; Wed, 26 Jun 2024 19:13:17 -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 1sMbp9-00039S-DF for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:12 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp6-0000PB-KQ for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:10 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1f9fb3ca81bso34335585ad.3 for ; Wed, 26 Jun 2024 16:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443587; x=1720048387; 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=btot52pcmJkIttEQiOHpjsvXZgZeLdvJvW/PGfbaalpnfVuvtuTZA1OdQim7tqqkUw d4b3hIRenCs5HhHoBA+GpGqiMP9hcjiMaGJJKGiJPHn0qmfjHgZxCukceOUXw1DulIvJ dDJr983aIQ/71n81+rhsnvK36o0zJK/fuWvMcDiF56dqYw7EesVHYu8bqJdKaM/fKLWR Osqke8HzkzjV7W8eCEOyHR3ZQ+Fqwz8EHX1rYXg6phxwhmZWzpsS+1CUvdNx+/f9pBrb YicZXq8chXivr7Sro4c62+7cErznxjMjaxvibqEC01A4DFllo8uuBzBVfITNigaquIu6 QtOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443587; x=1720048387; 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=vQOZoynIBmeh8xf1+wJHQpAafPBUClMf0XiQTK5K5HISs6SynYaQw4OLcQk7BI5qPd 78r38LmG9y4xlOH6D/gNPeVk5RprSuAlbuCo4N1avM9fWHKdfWlm79qY/F0jl98+H4pA 2JX0qH7e9aWY7O75WQYNCBS9q+ZeSvoPcC65Lmk5qpddulAu/wgetm15GuHvFXgNhfCL kz0kvSWAF55v9K3vAgwe8bpCzPDXrcGYsKNiTaku6vkUfwDGcd+RuCEFdTn/aW2PdGW/ cLM0rOgCNki817Bw993EknuMcSS5vd24F4Jq/G1+gdnTrfUWfP7hYJUIv3nO6xqGNzL+ RIZg== X-Gm-Message-State: AOJu0Yx+FwUxwCVKu6tmhvPM02369/pWqo18Oe9yurVEwRP/ZNVOEr0W R0RDpG67pUkNZci0RdKIiiueI4hydXiK4BckSZcCQ2AZbPryaSgDsfubJBsKd3tHbwD653YPXcN AU8I= X-Received: by 2002:a17:902:f54c:b0:1f6:225e:67a1 with SMTP id d9443c01a7336-1fa2413cddemr139393005ad.56.1719443586759; Wed, 26 Jun 2024 16:13:06 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:06 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 6/7] tests/plugin/mem: add option to print memory accesses Date: Wed, 26 Jun 2024 16:12:54 -0700 Message-Id: <20240626231255.339353-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 By using "print-accesses=true" option, mem plugin will now print every value accessed, with associated size, type (store vs load) and symbol where this happens. Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index b650dddcce1..d897034a044 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -24,7 +24,7 @@ typedef struct { 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 +60,20 @@ 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) +{ + unsigned size = 8 << qemu_plugin_mem_size_shift(meminfo); + const char *type = qemu_plugin_mem_is_store(meminfo) ? "store" : "load"; + uint64_t upper = qemu_plugin_mem_get_value_upper_bits(meminfo); + uint64_t lower = qemu_plugin_mem_get_value_lower_bits(meminfo); + const char *sym = udata ? udata : ""; + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, "access: 0x%.0"PRIx64"%"PRIx64",%d,%s,%s\n", + upper, lower, size, type, sym); + 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 +93,12 @@ 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) { + const char *sym = qemu_plugin_insn_symbol(insn); + qemu_plugin_register_vcpu_mem_cb(insn, print_access, + QEMU_PLUGIN_CB_NO_REGS, + rw, (void *) sym); + } } } @@ -117,6 +137,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; From patchwork Wed Jun 26 23:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807518 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539290wrn; Wed, 26 Jun 2024 16:14:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXjyafuTVQpVbxr5k/I5SKM/tx7HP3tyJXc9qIL/aWZsvDpczwhobL4KKRR+2w4JjKBx9D0qfnXzk7qQZCORYqV X-Google-Smtp-Source: AGHT+IGyvUxvo5c2HfzrgvukGeRsWJ974yfaDLCOsndsLshPMROYxPZ6kH94h7yz/4Ab9MquqHdH X-Received: by 2002:ac8:5e11:0:b0:444:b2ae:97ac with SMTP id d75a77b69052e-444d6506d6bmr148550361cf.50.1719443662770; Wed, 26 Jun 2024 16:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443662; cv=none; d=google.com; s=arc-20160816; b=Bvmik3e9dYNSccm0lsSftw4Fpx+Usl6hVrtfr3v6UQ3W3EL01JPmiWy3zFQpgWuhPs OHHUik3vd+AgSket2qdWVBLGmQ7jZxt4CgyQoeDr5NBwgasfSx+TyE5p/M7IZLwEb+10 Jmfhs62gtDh0Yd00lMB01apu1G8AUtQFLl9Da7WdNxWHRD0y5sbLsoeIzkhUKTFynz/m ikzAEBMbYEZ0h/W5XoWtuqdMLpMid9PxGqzaEgX0fgoM5V3Z9Ne6mrDhdwjQLBNu7vI1 l26is5Ilw+H6QTP0Wztmfl6UAI/Nd7/bMZemS7BaMptexr1YqNxC+pT+i/qCXLH4VX6x IajA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; fh=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=uYKXSJqBkhk9JNXhj+6S+eIbKNsAE/SdiVgLc3pnQfYflaRkhoKGfNWOvWfPqx/5uA UMOgJvvrWwbrnvYmAWjJzAbcLYAcIc95HiZ+zYeIdN5S49lY7X3CHlzOviLLqsnZ4lWx O0dK7taMir3lG6VGOqL93j6H6oS4ylbISQbhj23hCkSyCAyur9tww4DA/2z6AnGHUXx0 bZ4P/Nh+s4yCRe0C8Jwr3m5L0WQyzTODaRhWWlKR3P+/F48Z/42M+flz+7ngw/mC3K1y ov3zCEZbR3TGrjxD+Pep1zTifoNI2xDZ9ACQoQfavlOrF6bNanqNdBLH6JEdf170e2Cx Vkgw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zb2H4U9h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446421eac8fsi637471cf.600.2024.06.26.16.14.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:22 -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=zb2H4U9h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbpF-0003Cc-JW; Wed, 26 Jun 2024 19:13:17 -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 1sMbpB-00039x-Hi for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:15 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp9-0000PP-5N for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:12 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1f9cd92b146so56981595ad.3 for ; Wed, 26 Jun 2024 16:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443588; x=1720048388; 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=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; b=zb2H4U9ha6Agg1GUJWhf8zl1vgfTpN/u7RoPWiVOtuUl/iGd3VObNgploTVdHUxFwn Gj+8EAuWF8oGAx2KI9Ksr/Z8K5+8wpLXvJQrOORe2OQbMW+3iHlbldwnjSMyRxEuZwdO v3TNyA8q4rPYuN03fPcXbiQoYEsUlD9SR67nyfdx8ui0/93kx+yrJaxw8at8mXsLntTh NgTK4gba2rdN0qbg3UEt5uwfEDSR05Nsa9I25tc/PQZzwQ4XhBt/fRmgqTVTG7DvKsif FWFD1DpmmkRSmbIG/cEvzPRNFOHmXYHmuTFWqCFh+rC5C+U6vFoBxeE4oiHSKAUNvCH5 Bv6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443588; x=1720048388; 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=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; b=FVKoBFWPVIYCbIkGt19FferjqHzruGzhcsO/XDhuCBGEKLWukP+kHSbE0OqvUiEABD dY0vYnQYfuLB32uBZHpNcmGCm+VxogPXZQWg3bHE65IteSQx0PxhSOEtcV6QiPHYFhFF QmAOZ2vGX9hpyma0nROmQxN8CwI/fdz2XTW4YOLsBKXFs+J5Wi/73/ib7LCGfW8kxiDc GMWcMj2a6QEDqpO3Ux12kGJWkodNwoxLYEhzCA4tNNCeTCIFj3BqI3rRBGGCO2HcARlR 23gTObMe8RzKWubNyeMov0/bsRUrOYQqdOTLBQcY6XAfDRjmHKHMx/G6f0XOXM3IFWc4 Sy+w== X-Gm-Message-State: AOJu0YxTsf41a79QZdmyKcmIoFTvtNcfmMIDwucFf8DoVCe7CQL85TQA zreMj51DFXo8gm/HTiqqI3RZUh9uxcVbvuWYaREzLLN81lXg3/e3VqKH29P4JiFPAO0yREoc4N+ z2vQ= X-Received: by 2002:a17:902:ce82:b0:1fa:1ebb:eb79 with SMTP id d9443c01a7336-1fa1ebbeee9mr163193505ad.58.1719443587825; Wed, 26 Jun 2024 16:13:07 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:07 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= Subject: [PATCH 7/7] tests/tcg/x86_64: add test for plugin memory access Date: Wed, 26 Jun 2024 16:12:55 -0700 Message-Id: <20240626231255.339353-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x633.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 Add an explicit test to check expected memory values are read/written. For sizes 8, 16, 32, 64 and 128, we generate a load/store operation. For size 8 -> 64, we generate an atomic __sync_val_compare_and_swap too. For 128bits memory access, we rely on SSE2 instructions. By default, atomic accesses are non atomic if a single cpu is running, so we force creation of a second one by creating a new thread first. load/store helpers code path can't be triggered easily in user mode (no softmmu), so we can't test it here. Can be run with: make -C build/tests/tcg/x86_64-linux-user run-plugin-test-plugin-mem-access-with-libmem.so Signed-off-by: Pierrick Bouvier --- tests/tcg/x86_64/test-plugin-mem-access.c | 89 +++++++++++++++++++++ tests/tcg/x86_64/Makefile.target | 7 ++ tests/tcg/x86_64/check-plugin-mem-access.sh | 48 +++++++++++ 3 files changed, 144 insertions(+) create mode 100644 tests/tcg/x86_64/test-plugin-mem-access.c create mode 100755 tests/tcg/x86_64/check-plugin-mem-access.sh diff --git a/tests/tcg/x86_64/test-plugin-mem-access.c b/tests/tcg/x86_64/test-plugin-mem-access.c new file mode 100644 index 00000000000..7fdd6a55829 --- /dev/null +++ b/tests/tcg/x86_64/test-plugin-mem-access.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +static void *data; + +#define DEFINE_STORE(name, type, value) \ +static void store_##name(void) \ +{ \ + *((type *)data) = value; \ +} + +#define DEFINE_ATOMIC_OP(name, type, value) \ +static void atomic_op_##name(void) \ +{ \ + *((type *)data) = 0x42; \ + __sync_val_compare_and_swap((type *)data, 0x42, value); \ +} + +#define DEFINE_LOAD(name, type) \ +static void load_##name(void) \ +{ \ + register type var asm("eax") = *((type *) data); \ + (void)var; \ +} + +DEFINE_STORE(u8, uint8_t, 0xf1) +DEFINE_ATOMIC_OP(u8, uint8_t, 0xf1) +DEFINE_LOAD(u8, uint8_t) +DEFINE_STORE(u16, uint16_t, 0xf123) +DEFINE_ATOMIC_OP(u16, uint16_t, 0xf123) +DEFINE_LOAD(u16, uint16_t) +DEFINE_STORE(u32, uint32_t, 0xff112233) +DEFINE_ATOMIC_OP(u32, uint32_t, 0xff112233) +DEFINE_LOAD(u32, uint32_t) +DEFINE_STORE(u64, uint64_t, 0xf123456789abcdef) +DEFINE_ATOMIC_OP(u64, uint64_t, 0xf123456789abcdef) +DEFINE_LOAD(u64, uint64_t) + +static void store_u128(void) +{ + _mm_store_si128(data, _mm_set_epi32(0xf1223344, 0x55667788, + 0xf1234567, 0x89abcdef)); +} + +static void load_u128(void) +{ + __m128i var = _mm_load_si128(data); + (void)var; +} + +static void *f(void *p) +{ + return NULL; +} + +int main(void) +{ + /* + * We force creation of a second thread to enable cpu flag CF_PARALLEL. + * This will generate atomic operations when needed. + */ + pthread_t thread; + pthread_create(&thread, NULL, &f, NULL); + pthread_join(thread, NULL); + + data = malloc(sizeof(__m128i)); + atomic_op_u8(); + store_u8(); + load_u8(); + + atomic_op_u16(); + store_u16(); + load_u16(); + + atomic_op_u32(); + store_u32(); + load_u32(); + + atomic_op_u64(); + store_u64(); + load_u64(); + + store_u128(); + load_u128(); + + free(data); +} diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target index 5fedf221174..5f7015fd8b4 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -14,6 +14,7 @@ X86_64_TESTS += noexec X86_64_TESTS += cmpxchg X86_64_TESTS += adox X86_64_TESTS += test-1648 +PLUGINS_TESTS += test-plugin-mem-access TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 else TESTS=$(MULTIARCH_TESTS) @@ -24,6 +25,12 @@ adox: CFLAGS=-O2 run-test-i386-ssse3: QEMU_OPTS += -cpu max run-plugin-test-i386-ssse3-%: QEMU_OPTS += -cpu max +run-plugin-test-plugin-mem-access-with-libmem.so: \ + PLUGIN_ARGS=$(COMMA)print-accesses=true +run-plugin-test-plugin-mem-access-with-libmem.so: \ + CHECK_PLUGIN_OUTPUT_COMMAND= \ + $(SRC_PATH)/tests/tcg/x86_64/check-plugin-mem-access.sh + test-x86_64: LDFLAGS+=-lm -lc test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/x86_64/check-plugin-mem-access.sh b/tests/tcg/x86_64/check-plugin-mem-access.sh new file mode 100755 index 00000000000..3884976af2d --- /dev/null +++ b/tests/tcg/x86_64/check-plugin-mem-access.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -euo pipefail + +die() +{ + echo "$@" 1>&2 + exit 1 +} + +check() +{ + file=$1 + pattern=$2 + grep "$pattern" "$file" > /dev/null || die "\"$pattern\" not found in $file" +} + +[ $# -eq 1 ] || die "usage: plugin_out_file" + +plugin_out=$1 + +expected() +{ + cat << EOF +access: 0xf1,8,store,store_u8 +access: 0x42,8,load,atomic_op_u8 +access: 0xf1,8,store,atomic_op_u8 +access: 0xf1,8,load,load_u8 +access: 0xf123,16,store,store_u16 +access: 0x42,16,load,atomic_op_u16 +access: 0xf123,16,store,atomic_op_u16 +access: 0xf123,16,load,load_u16 +access: 0xff112233,32,store,store_u32 +access: 0x42,32,load,atomic_op_u32 +access: 0xff112233,32,store,atomic_op_u32 +access: 0xff112233,32,load,load_u32 +access: 0xf123456789abcdef,64,store,store_u64 +access: 0x42,64,load,atomic_op_u64 +access: 0xf123456789abcdef,64,store,atomic_op_u64 +access: 0xf123456789abcdef,64,load,load_u64 +access: 0xf122334455667788f123456789abcdef,128,store,store_u128 +access: 0xf122334455667788f123456789abcdef,128,load,load_u128 +EOF +} + +expected | while read line; do + check "$plugin_out" "$line" +done