From patchwork Mon Oct 14 10:48:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176144 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4340364ill; Mon, 14 Oct 2019 03:51:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbYIJqzlaDS1anOzcs+iJIqsj7J8ceg5xa+0aNvJAgSJHVlJXN8Uk8FknnHizntcT7dszA X-Received: by 2002:a17:906:3946:: with SMTP id g6mr27801694eje.49.1571050316747; Mon, 14 Oct 2019 03:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050316; cv=none; d=google.com; s=arc-20160816; b=X1TLdg2iNaG1W2D7k/RfM0RJgEJzXYmDsZbeqfPKXo2zx4sZKBkMJ+hKT1VOR2bhx2 3OtT/aa8Ay555OyaynXrI1excHhu/u6cL0iVoDlnq3NCIdYwQr6ceXBuPX2exlzDBzEN PaIkRHbhruPn5y0Ork1jUrmeVW8QQDRxuvbuV3sUk134DSt6wUYagQFl9Rp/JHAq+xM9 e0MIgDL9JsITbUluhu5mJmmr917FMsHUQk7mwcveX7uK+Lm4Qyj9FQgJ1m7U0LOsdRan s6mXUdIE5ghlEMzYjNx6vZdQidJemKZ3ri1dou2MFdj1+zbFzcuGo6xM2W1cyGMgq1WN sqYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3VokXMxF70KROu8ZB6/KdoZUveks1jnXB+njMViY1Lk=; b=wBkmcnDMXtNsQbDEsYeReZVE0BoigpKcoDrWh6/llEmKo3pVEeJ5I7nMQQ3/vh9to5 w3yw7opbz4+vXaqN3bNZzReMJHUZCFMDbcCOV+LSmsEXcWF0kK9vhA3trmKorrnmNET8 gYKLJXHjjYOUGAMXyapxhTWasFu3HMGbRJzGRqahpdlAj/GK8J/SXgeg07USfnntRJkd yYT4tqIMnyN6dMGxXicAtRT2DAa9t9nmyZv0z7YkoiZxDpwHfQO53p6SfOvGPG3Htu1i lVQ03gIRmnxi8e3ybPWHChEj59+ox9c5emW9QV/Qp2pcRYWS2L8MckZD0aHNnTgykl1Q lN6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P489Nrtc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w43si12894483edd.332.2019.10.14.03.51.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:51:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P489Nrtc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxxD-0007JS-6v for patch@linaro.org; Mon, 14 Oct 2019 06:51:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvF-0007JC-Pp for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvE-0005v7-JJ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:53 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvE-0005tQ-CU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:52 -0400 Received: by mail-wm1-x343.google.com with SMTP id b24so16248784wmj.5 for ; Mon, 14 Oct 2019 03:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3VokXMxF70KROu8ZB6/KdoZUveks1jnXB+njMViY1Lk=; b=P489Nrtc0/IjWNc/qVw4q4crfquK2QE4UExH/Lovs+pJLl3Nj+uinUGcT+gW7L4RQA ZzjuBS2A3wSmiy2UQ1RPCMSv/SMntyLEG8FeOAV6fXyG/lPRe5CtC7wFWAngzBa3vPOS GRJgpvu50OQBp4ACoeiE+Ubc4+Xd8/XxZyRc/8VWq9xxx5ptaBQGyI0+yx1kS7eSf/eu LqL9h+e+yI4sWj5fuWqPi8w9N9+TfNWD6ykbkOUm1jOM2G3K3A3BCFUZ+lSZciI/FbHg oEQmbsf/4fV9mwCyb7t8DJ1yN+r+trAHDQj9hVEI5H9vChqigM6+m8Slnzl8JXMTSorc 8zgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3VokXMxF70KROu8ZB6/KdoZUveks1jnXB+njMViY1Lk=; b=jVg5N24kyQ/NQ3akYTUy7LgnQKotD+ZLx2WfNHPA9t7iNbhFXKsCzFW13TxrVyYQFV BQf0euMStNCJcSr8JXYUH5E+4CVTkbUpcLFYq0Rc1G2VzRodgVSccoxnxRYz6wKWjmDL Ssf9YFDa+CLS1Nr03mt7b66Kq3TlMNtDmzbWkP0a9g4Zwmylx6sYVL+jEW2N6t1vNqmi Icik3ayob5aT44D0qfj484fu12oBYw3i6yj6D+e0yh54mcbSHstq7/3kwY/U1wEEAvrF kftkEH0eywzGuH8ZA9tYHaVclEqt1Y/Dp8jUNnQvxsaTo2jCe7ojAaycxrNBmdmK3U/s 3anw== X-Gm-Message-State: APjAAAWzxpHl3LCO2+Y4T8txT80ELOuD3M3a/hwD/nbeNaFBkI76e/0M dqCHVLEhOJuv6I69wGhfHl8Skw== X-Received: by 2002:a7b:c413:: with SMTP id k19mr15411791wmi.175.1571050190323; Mon, 14 Oct 2019 03:49:50 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z22sm18266704wmf.2.2019.10.14.03.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 227711FF8C; Mon, 14 Oct 2019 11:49:49 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 01/55] trace: expand mem_info:size_shift to 4 bits Date: Mon, 14 Oct 2019 11:48:54 +0100 Message-Id: <20191014104948.4291-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Stefan Hajnoczi , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This will allow us to trace 32k-long memory accesses (although our maximum is something like 256 bytes at the moment). Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota [AJB: expanded to 3->4 bits] Signed-off-by: Alex Bennée --- v5 - return the tweaks to mem-internal.h --- trace-events | 2 +- trace/mem-internal.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/trace-events b/trace-events index 20821ba545..22133dfd3f 100644 --- a/trace-events +++ b/trace-events @@ -149,7 +149,7 @@ vcpu guest_cpu_reset(void) # Access information can be parsed as: # # struct mem_info { -# uint8_t size_shift : 2; /* interpreted as "1 << size_shift" bytes */ +# uint8_t size_shift : 4; /* interpreted as "1 << size_shift" bytes */ # bool sign_extend: 1; /* sign-extended */ # uint8_t endianness : 1; /* 0: little, 1: big */ # bool store : 1; /* wheter it's a store operation */ diff --git a/trace/mem-internal.h b/trace/mem-internal.h index 3444fbc596..1a010c1b27 100644 --- a/trace/mem-internal.h +++ b/trace/mem-internal.h @@ -10,10 +10,10 @@ #ifndef TRACE__MEM_INTERNAL_H #define TRACE__MEM_INTERNAL_H -#define TRACE_MEM_SZ_SHIFT_MASK 0x7 /* size shift mask */ -#define TRACE_MEM_SE (1ULL << 3) /* sign extended (y/n) */ -#define TRACE_MEM_BE (1ULL << 4) /* big endian (y/n) */ -#define TRACE_MEM_ST (1ULL << 5) /* store (y/n) */ +#define TRACE_MEM_SZ_SHIFT_MASK 0xf /* size shift mask */ +#define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */ +#define TRACE_MEM_BE (1ULL << 5) /* big endian (y/n) */ +#define TRACE_MEM_ST (1ULL << 6) /* store (y/n) */ static inline uint8_t trace_mem_build_info( int size_shift, bool sign_extend, MemOp endianness, bool store) From patchwork Mon Oct 14 10:48:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176146 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4341715ill; Mon, 14 Oct 2019 03:53:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwBQYCNj0yRNJ0swlXxvIyA5ahkVQnKdj9LPsNL+en6PrTGvR1JVwsOq/ffe2qtUx/+blC X-Received: by 2002:a37:6d04:: with SMTP id i4mr29479756qkc.88.1571050412760; Mon, 14 Oct 2019 03:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050412; cv=none; d=google.com; s=arc-20160816; b=OtwGzyeFLa3Efs5+7UP0rs1Co36BVnCo/uNP1qAhSjq35XR9cXvbCIPxay6oOgFYJf 8UaHJKHxXuz72rwR2eORPgfd/OkLl33LP7idiOQy/RzUoQ+FCoJJ0auzycofUvI0DKAt ugNCv715YfT0kQglQIuF+pSIXmyyhIZzoL7+69GBan7vDleprfUeiIzVLua/qWzIAk95 FP7im2iQNyW6u+5tGxjPKe9DVsFNHp65XHioiER2bs7Tz1p6qExdpHKl7DKbXD3yo0JH c8AL9M2JSytC5z/UYBNGoJ/Hvwi2NE25S2wwYDkKRGPhVRth9EqQtcI1ZCBNa2HcXWGN 2ENg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0lNdGpSfBzDNvoyGaxV/lVsZ3aI25OqDjawAwKzIxio=; b=CKd2vM/Ai1EegS4bJ/8jgWXpuS3+yOWuQ5l/+sWl8+D9Wo7I2cEYQJaEYBrnLA/yty DVGjhvU1pJiYrz0GUXVJZ+XL/KMIUtY2N0umK8+gYmpAXHDeQdFwh7bUIlFdhqeC6+cl JNumYUUXvuhCG63R91BlP+v6pERfDb3U4MfFn6tiXca0W9heighkxXKyWioKdSRJ86Ji vQnwCmFZ9B9nPUeFzeKs2UiISumpd1giFPj8i7Fdh/0C8GTcuxOVf1ySPp4AzfWwuMU+ 8niyER12MWfPXfmWJN923tUM50onGw8NePvi3J8tTZeoE9FUKXABgftRPeDrUvLvj53k 0QQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="NF/78zmf"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h5si16154742qvc.95.2019.10.14.03.53.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:53: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=fail header.i=@linaro.org header.s=google header.b="NF/78zmf"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxyl-0002gq-Sa for patch@linaro.org; Mon, 14 Oct 2019 06:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvI-0007JL-CK for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvF-0005wF-Hc for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:56 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvF-0005vJ-A4 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:53 -0400 Received: by mail-wr1-x442.google.com with SMTP id p4so3261069wrm.8 for ; Mon, 14 Oct 2019 03:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0lNdGpSfBzDNvoyGaxV/lVsZ3aI25OqDjawAwKzIxio=; b=NF/78zmfLm9Ufsn0h9jcMT8fcdYr2bFQKTHEbmslC3Gp6vdWMugt3KRhaAnM8pRMVM zJTX+HoyHwqFFindjP2rEbAr85NLvTdFmYl+eWiKb7d599zM5PQThemcWDt/CW66wIr8 lfI9mHirKWb8rO0OKTDmJhG7MntYGn7jh10Bn2pcwTW7HTuaRxH7Q7rN4glSX7oQPV0S Lvw2njQDGFOrWoyPrOS86HurVh7Wnx4T6S8h48wt16nyvPOyrSm+pDTnaObvB97NC9qR d3kqduHnBXNfFI1vyjT/77CuUR/fHUrOoOsdO+Bpjfm5QHi8UC6E1T1N6SpZVsl9BkOu K9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0lNdGpSfBzDNvoyGaxV/lVsZ3aI25OqDjawAwKzIxio=; b=KPJfHOUkZm+vBMUQM9JCWXEFDxJ6/bA45ZSR6Beb2J2GEaD4DcK+o32in1qSquVH36 LDJ9rF+plPyLOPSXNGIsUG/t58BtNkeJrLisqfcU8zjE2BJq/Z8nJ4TMxLINi57XemgL rMrEbRHMrcNCy8KQhF+j+UhzyrZpMNMp2Lsn7UzVlgV0GasG4qGV9n6NFwo1VimgnIUw +Qaewk+z18uJMjoQUettBoUmP82xwpkP83RJAgI6FAE0wU09F2hG0uZU+tlVutzcPqBK NBMbEHefDnvvYrRTb4Jx3bhPR3YPpmItZ9MbllTyNhFY4k1AmHuiTXfY1w8m2t9dPrkv McoQ== X-Gm-Message-State: APjAAAVomxo1Qhfnhzv5JBHoCTs1SLUwkugxTF+d7ASI4BtYYe/g4qws ECSbsfdJ7thcYrjH8ATw6sVnjg== X-Received: by 2002:a5d:4b09:: with SMTP id v9mr24145158wrq.127.1571050192206; Mon, 14 Oct 2019 03:49:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w4sm15863674wrv.66.2019.10.14.03.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 740E11FF8F; Mon, 14 Oct 2019 11:49:49 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 02/55] trace: add mmu_index to mem_info Date: Mon, 14 Oct 2019 11:48:55 +0100 Message-Id: <20191014104948.4291-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Riku Voipio , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Stefan Hajnoczi , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We are going to re-use mem_info later for plugins and will need to track the mmu_idx for softmmu code. [TODO: convert everything to use TCGMemOpIdx?] Signed-off-by: Alex Bennée --- v5 - fix up shifts --- accel/tcg/atomic_template.h | 6 ++--- accel/tcg/cputlb.c | 2 ++ accel/tcg/user-exec.c | 1 + include/exec/cpu_ldst_template.h | 15 +++++------ include/exec/cpu_ldst_useronly_template.h | 6 ++--- scripts/tracetool/transform.py | 1 + tcg/tcg-op.c | 8 +++--- trace-events | 6 +++-- trace/mem-internal.h | 31 ++++++++++++++++------- trace/mem.h | 7 ++--- 10 files changed, 50 insertions(+), 33 deletions(-) -- 2.20.1 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 287433d809..dfeddf6a54 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -60,7 +60,7 @@ #endif #define ATOMIC_TRACE_RMW do { \ - uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, ATOMIC_MMU_IDX); \ \ trace_guest_mem_before_exec(env_cpu(env), addr, info); \ trace_guest_mem_before_exec(env_cpu(env), addr, \ @@ -68,13 +68,13 @@ } while (0) #define ATOMIC_TRACE_LD do { \ - uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, ATOMIC_MMU_IDX); \ \ trace_guest_mem_before_exec(env_cpu(env), addr, info); \ } while (0) # define ATOMIC_TRACE_ST do { \ - uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true, ATOMIC_MMU_IDX); \ \ trace_guest_mem_before_exec(env_cpu(env), addr, info); \ } while (0) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index defc8d5929..1210d8f243 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1811,6 +1811,7 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, #define ATOMIC_MMU_DECLS #define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, retaddr) #define ATOMIC_MMU_CLEANUP +#define ATOMIC_MMU_IDX oi #define DATA_SIZE 1 #include "atomic_template.h" @@ -1853,6 +1854,7 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, #define DATA_SIZE 8 #include "atomic_template.h" #endif +#undef ATOMIC_MMU_IDX /* Code access functions. */ diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 71c4bf6477..e9a58c5331 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -751,6 +751,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #define ATOMIC_MMU_DECLS do {} while (0) #define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, DATA_SIZE, GETPC()) #define ATOMIC_MMU_CLEANUP do { clear_helper_retaddr(); } while (0) +#define ATOMIC_MMU_IDX 0 #define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END)) #define EXTRA_ARGS diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h index af7e0b49f2..5750a26b9e 100644 --- a/include/exec/cpu_ldst_template.h +++ b/include/exec/cpu_ldst_template.h @@ -84,17 +84,16 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, CPUTLBEntry *entry; RES_TYPE res; target_ulong addr; - int mmu_idx; + int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; #if !defined(SOFTMMU_CODE_ACCESS) trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx)); #endif addr = ptr; - mmu_idx = CPU_MMU_INDEX; entry = tlb_entry(env, mmu_idx, addr); if (unlikely(entry->ADDR_READ != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { @@ -123,17 +122,16 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, CPUTLBEntry *entry; int res; target_ulong addr; - int mmu_idx; + int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; #if !defined(SOFTMMU_CODE_ACCESS) trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx)); #endif addr = ptr; - mmu_idx = CPU_MMU_INDEX; entry = tlb_entry(env, mmu_idx, addr); if (unlikely(entry->ADDR_READ != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { @@ -165,17 +163,16 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, { CPUTLBEntry *entry; target_ulong addr; - int mmu_idx; + int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; #if !defined(SOFTMMU_CODE_ACCESS) trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx)); #endif addr = ptr; - mmu_idx = CPU_MMU_INDEX; entry = tlb_entry(env, mmu_idx, addr); if (unlikely(tlb_addr_write(entry) != (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index 2378f2958c..8f7f117ad4 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -73,7 +73,7 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) #else trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + trace_mem_build_info(SHIFT, false, MO_TE, false, 0)); return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); #endif } @@ -105,7 +105,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) #else trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + trace_mem_build_info(SHIFT, true, MO_TE, false, 0)); return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); #endif } @@ -132,7 +132,7 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, { trace_guest_mem_before_exec( env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + trace_mem_build_info(SHIFT, false, MO_TE, true, 0)); glue(glue(st, SUFFIX), _p)(g2h(ptr), v); } diff --git a/scripts/tracetool/transform.py b/scripts/tracetool/transform.py index e18b05315e..2ca9286046 100644 --- a/scripts/tracetool/transform.py +++ b/scripts/tracetool/transform.py @@ -83,6 +83,7 @@ TCG_2_HOST = { HOST_2_TCG_COMPAT = { "uint8_t": "uint32_t", + "uint16_t": "uint32_t", } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index e87c327fbf..1388bd344d 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2795,7 +2795,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop = tcg_canonicalize_memop(memop, 0, 0); trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 0)); + addr, trace_mem_get_info(memop, idx, 0)); orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { @@ -2832,7 +2832,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop = tcg_canonicalize_memop(memop, 0, 1); trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 1)); + addr, trace_mem_get_info(memop, idx, 1)); if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap = tcg_temp_new_i32(); @@ -2875,7 +2875,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop = tcg_canonicalize_memop(memop, 1, 0); trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 0)); + addr, trace_mem_get_info(memop, idx, 0)); orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { @@ -2923,7 +2923,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop = tcg_canonicalize_memop(memop, 1, 1); trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 1)); + addr, trace_mem_get_info(memop, idx, 1)); if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap = tcg_temp_new_i64(); diff --git a/trace-events b/trace-events index 22133dfd3f..42107ebc69 100644 --- a/trace-events +++ b/trace-events @@ -152,12 +152,14 @@ vcpu guest_cpu_reset(void) # uint8_t size_shift : 4; /* interpreted as "1 << size_shift" bytes */ # bool sign_extend: 1; /* sign-extended */ # uint8_t endianness : 1; /* 0: little, 1: big */ -# bool store : 1; /* wheter it's a store operation */ +# bool store : 1; /* whether it is a store operation */ +# pad : 1; +# uint8_t mmuidx : 4; /* mmuidx (softmmu only) */ # }; # # Mode: user, softmmu # Targets: TCG(all) -vcpu tcg guest_mem_before(TCGv vaddr, uint8_t info) "info=%d", "vaddr=0x%016"PRIx64" info=%d" +vcpu tcg guest_mem_before(TCGv vaddr, uint16_t info) "info=%d", "vaddr=0x%016"PRIx64" info=%d" # linux-user/syscall.c # bsd-user/syscall.c diff --git a/trace/mem-internal.h b/trace/mem-internal.h index 1a010c1b27..0a32aa22ca 100644 --- a/trace/mem-internal.h +++ b/trace/mem-internal.h @@ -14,11 +14,13 @@ #define TRACE_MEM_SE (1ULL << 4) /* sign extended (y/n) */ #define TRACE_MEM_BE (1ULL << 5) /* big endian (y/n) */ #define TRACE_MEM_ST (1ULL << 6) /* store (y/n) */ +#define TRACE_MEM_MMU_SHIFT 8 /* mmu idx */ -static inline uint8_t trace_mem_build_info( - int size_shift, bool sign_extend, MemOp endianness, bool store) +static inline uint16_t trace_mem_build_info( + int size_shift, bool sign_extend, MemOp endianness, + bool store, unsigned int mmu_idx) { - uint8_t res; + uint16_t res; res = size_shift & TRACE_MEM_SZ_SHIFT_MASK; if (sign_extend) { @@ -30,25 +32,36 @@ static inline uint8_t trace_mem_build_info( if (store) { res |= TRACE_MEM_ST; } +#ifdef CONFIG_SOFTMMU + res |= mmu_idx << TRACE_MEM_MMU_SHIFT; +#endif return res; } -static inline uint8_t trace_mem_get_info(MemOp op, bool store) +static inline uint16_t trace_mem_get_info(MemOp op, + unsigned int mmu_idx, + bool store) { return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN), - op & MO_BSWAP, store); + op & MO_BSWAP, store, + mmu_idx); } +/* Used by the atomic helpers */ static inline -uint8_t trace_mem_build_info_no_se_be(int size_shift, bool store) +uint16_t trace_mem_build_info_no_se_be(int size_shift, bool store, + TCGMemOpIdx oi) { - return trace_mem_build_info(size_shift, false, MO_BE, store); + return trace_mem_build_info(size_shift, false, MO_BE, store, + get_mmuidx(oi)); } static inline -uint8_t trace_mem_build_info_no_se_le(int size_shift, bool store) +uint16_t trace_mem_build_info_no_se_le(int size_shift, bool store, + TCGMemOpIdx oi) { - return trace_mem_build_info(size_shift, false, MO_LE, store); + return trace_mem_build_info(size_shift, false, MO_LE, store, + get_mmuidx(oi)); } #endif /* TRACE__MEM_INTERNAL_H */ diff --git a/trace/mem.h b/trace/mem.h index 8cf213d85b..9644f592b4 100644 --- a/trace/mem.h +++ b/trace/mem.h @@ -18,15 +18,16 @@ * * Return a value for the 'info' argument in guest memory access traces. */ -static uint8_t trace_mem_get_info(MemOp op, bool store); +static uint16_t trace_mem_get_info(MemOp op, unsigned int mmu_idx, bool store); /** * trace_mem_build_info: * * Return a value for the 'info' argument in guest memory access traces. */ -static uint8_t trace_mem_build_info(int size_shift, bool sign_extend, - MemOp endianness, bool store); +static uint16_t trace_mem_build_info(int size_shift, bool sign_extend, + MemOp endianness, bool store, + unsigned int mmuidx); #include "trace/mem-internal.h" From patchwork Mon Oct 14 10:48:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176141 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4338978ill; Mon, 14 Oct 2019 03:50:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzHDz1wl9ao1ifiazHj5aufwhApoBVOz0x6PzLu9lZK9ssn6JirA2JUJNuooJFYcrKaRZE X-Received: by 2002:a05:6402:149a:: with SMTP id e26mr27351171edv.123.1571050225364; Mon, 14 Oct 2019 03:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050225; cv=none; d=google.com; s=arc-20160816; b=kEa+bW6VYAegM0iNwg/BemI9Dve3mLgp600MJ4yvFw98+0sWKF2pWTSjdk68go4ZOT 1TrPy7BjW0Y13s+bAQxhkBqfDLwYhGbjH4Ki2eZKBcNhhBaRsd0+LuUY1zbvAdRpp4Pr H6KKd2BcTAjrkDUFsRr8NQxEj7fh14IGUOjBIYtNy7TM/xnIKWdiugStrjomMuqJnjyz tVfxJ7cxlicAzCXMlEEj5EJ8ousRQ+2M0FDa5rwoKH6SmWrSujEoZEoT2L6D6DToEh8S oKKQM+YmocG4600nBjtqQ/HD15FgkCyRvqVyKeLbZH1jPo8xvNG44Tm+pmvboaXaT8yO 8CdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xbXPv2RF3r3lJivkBr9kmxKqq17UhIjfz0xNCVqHlWU=; b=sJk1WZ1bJFXarenW1z6/TpXATq7lZAb7RNVmJXrDy8c+/CSnJR1VmIOP7z4duUcHsu E73Kv3z9zAoBG363AaQxrU0iPX0ITXwjyGLz33hrHmgAu+Tzya/Ir+g+u0Hn+aUTTjBl smHOgNBdzpzZpLnI2vcD9Xo6P11Qg5NKESUyMACUDSUH5n4FbKJJ9LqmLKCTOpJhAvZn cslFAEq8QkIN/OuxsU5nAjSwpu/n43DM075ZsYCTpMZE71MVkFWCGOK1lk8XjtiOt7kb qqFaY/PzegJFWadT6Z4Y3sTqxE5HKc47bt8/TWM98J/7lsEaAQ98mODBdhGOQdGw2ap2 LcKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qFaD6LL8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n11si10533021ejb.240.2019.10.14.03.50.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:50:25 -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=fail header.i=@linaro.org header.s=google header.b=qFaD6LL8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvj-0007LT-9g for patch@linaro.org; Mon, 14 Oct 2019 06:50:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44468) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvJ-0007JT-7h for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvH-0005yu-HS for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:56 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvH-0005x4-BX for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:55 -0400 Received: by mail-wr1-x444.google.com with SMTP id v8so19150800wrt.2 for ; Mon, 14 Oct 2019 03:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xbXPv2RF3r3lJivkBr9kmxKqq17UhIjfz0xNCVqHlWU=; b=qFaD6LL8FzEURO4TEhMYUrqi1TkpsSCQ4Qf16bdXVPLyIPP9Hvyt9xVWZs8gVXcVof /L263HeDN6Xs/SWVJHZ0Qp5yjlsJClabCXoazBsaMDBtxs373vaeRWFDR9jUf3sTE0xu rVmy0CwfjtkSjLNDIZe3LhdyD3FCn6GNWuWMBRBlKZ7EepFfAIYPGss+uBtRTuu/b+jn HAVp43PiBoyC++Dn5qW7BRv8A5pgeUZliKarhAqwJDniz+kt9tklkG2pcsjysEcjh/ha C3mXO6yZjjW9WJwpYBWG8FvtReGicrxg+qn7buIuw/XRprOOTcXHDww78IxDkxLzCqza RE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xbXPv2RF3r3lJivkBr9kmxKqq17UhIjfz0xNCVqHlWU=; b=LbiHpgj2TKoX2LjQEi/rrDBsOhltM9mwfeNFrTBcexTrqPrL+9RRcR3cmN7bIbAgtF 91cp8C4JFRe3dlUoKxJaQh+FDtVlobTPoW8581xNggceYtplqcIfj8o3IupIyPkxG8Dx 6BaFbF9biHJXF9pGoVU3Q8XeDe4tRKrZB7FXFn9D746/RpLwExe95nXCWeO5sZ0ZYlKH YvtRHLm79cbev0DctLWlyLMXHqidLPk0UyvVPMubQxwVCV2z9NXrEPIOowp0686k33Nk q2AD02xVEajpeI1ZMuikOIophpFOoRpq4LvD33TIpNCbabp2a29SWfFyXVr5TzyEv5M4 EdBw== X-Gm-Message-State: APjAAAXfFe3mRy90eDcQ4BEl1oFD0Ad2qKd08m4HwgnO6dg1hUbsD2x9 BJfDUZl1kflAlG50lzHWeWZI+Q== X-Received: by 2002:adf:fe8d:: with SMTP id l13mr11845837wrr.365.1571050193565; Mon, 14 Oct 2019 03:49:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l18sm19810331wrc.18.2019.10.14.03.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B1AD61FF90; Mon, 14 Oct 2019 11:49:49 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 03/55] cpu: introduce cpu_in_exclusive_context() Date: Mon, 14 Oct 2019 11:48:56 +0100 Message-Id: <20191014104948.4291-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Suggested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota [AJB: moved inside start/end_exclusive fns + cleanup] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - -> cpu_in_exclusive_context - moved inside start/end exclusive - fixed up cpu_exec_step_atomic --- accel/tcg/cpu-exec.c | 5 +---- cpus-common.c | 4 ++++ include/hw/core/cpu.h | 13 +++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 48272c781b..81c33d6475 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -238,8 +238,6 @@ void cpu_exec_step_atomic(CPUState *cpu) uint32_t flags; uint32_t cflags = 1; uint32_t cf_mask = cflags & CF_HASH_MASK; - /* volatile because we modify it between setjmp and longjmp */ - volatile bool in_exclusive_region = false; if (sigsetjmp(cpu->jmp_env, 0) == 0) { tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); @@ -253,7 +251,6 @@ void cpu_exec_step_atomic(CPUState *cpu) /* Since we got here, we know that parallel_cpus must be true. */ parallel_cpus = false; - in_exclusive_region = true; cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb(tb, pc); @@ -273,7 +270,7 @@ void cpu_exec_step_atomic(CPUState *cpu) assert_no_pages_locked(); } - if (in_exclusive_region) { + if (cpu_in_exclusive_context(cpu)) { /* We might longjump out of either the codegen or the * execution, so must make sure we only end the exclusive * region if we started it. diff --git a/cpus-common.c b/cpus-common.c index af3385a296..eaf590cb38 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -200,11 +200,15 @@ void start_exclusive(void) * section until end_exclusive resets pending_cpus to 0. */ qemu_mutex_unlock(&qemu_cpu_list_lock); + + current_cpu->in_exclusive_context = true; } /* Finish an exclusive operation. */ void end_exclusive(void) { + current_cpu->in_exclusive_context = false; + qemu_mutex_lock(&qemu_cpu_list_lock); atomic_set(&pending_cpus, 0); qemu_cond_broadcast(&exclusive_resume); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 031f587e51..07f2ab0590 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -372,6 +372,7 @@ struct CPUState { bool unplug; bool crash_occurred; bool exit_request; + bool in_exclusive_context; uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; @@ -783,6 +784,18 @@ void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) */ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data); +/** + * cpu_in_exclusive_context() + * @cpu: The vCPU to check + * + * Returns true if @cpu is an exclusive context, for example running + * something which has previously been queued via async_safe_run_on_cpu(). + */ +static inline bool cpu_in_exclusive_context(const CPUState *cpu) +{ + return cpu->in_exclusive_context; +} + /** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain. From patchwork Mon Oct 14 10:48:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176142 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4340310ill; Mon, 14 Oct 2019 03:51:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxLBbzI1/GEOQm/8TkF1DphWF3896P5LtgiehQflYABCXdhhimQdSHZ4qcjnjFBVJm+xX4 X-Received: by 2002:a05:6402:149a:: with SMTP id e26mr27356292edv.123.1571050313524; Mon, 14 Oct 2019 03:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050313; cv=none; d=google.com; s=arc-20160816; b=SOC16tTG/aS7jSwKAlMctXZGCxwxfxvCwG9ZNmAtGuoSl4sln0JlzTOyfN0ERLO4Kd uem8LEBWCVBsDP1xq4mHwT/DoibEx+5yLXDTWYAiuVrwsbCk7hkR/KWL9IjfPc/mKPRl aY6r3nZdQjD3O2rxht7OgtbYjSB7GvuAykNZg7ia93MVXLPwNtGQeIfGLspfyPn+EYyu k1FapykyW6Ljh2db8EAGmdzGBHgxgzZRGC9RiQA7kyRLB1HBwe7RQ70zu2wFODBcAhx6 jKrAeLyGgp8nGFOncvIkirysxy0eGW9AZlmg6V1n8PDj31KT7eT11gwOVR4mdBqhUaVV wZ7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TcDnMTCbqc+SMPI8ZRIhg2t2SAwRlKS9dBsRR316T8M=; b=UcRVqWaQY44H/rouRn6j6NatVRAfTSNQ+ZuEreQsbYe1FYR3Q32dbFZOw+Xv17rDM/ QMXFikpegLBBdfE7/YARHB1q2QhoN0p9/vVyXeS4Lh1UkGX6/M5hN7SIv3cAUbl8w0Dm pYvshwhUeMd40H0o05wB5KG5AwXIutyofg2w58jZc5obl4TukWtkDEsqBtOzHckBE43A e2FZ6RijjZUjjYk8kpSkFcePgWg8dAYSpNU26PiOo07V/AXhFMeJ0S8JzEWx7fn4xOZs GsgINYF2TP7bYzyOyuccSJP0HlInHUpZYdJ2UT5ZlwxY447tkjIfmcyZBqvWZ1N1/Oya wayw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VnTpB8sq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z11si12274664edl.1.2019.10.14.03.51.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:51:53 -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=fail header.i=@linaro.org header.s=google header.b=VnTpB8sq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxxA-0007K9-2k for patch@linaro.org; Mon, 14 Oct 2019 06:51:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44424) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvF-0007JD-Ud for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvE-0005vX-VA for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:53 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvE-0005uk-P9 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:52 -0400 Received: by mail-wr1-x442.google.com with SMTP id j11so19161269wrp.1 for ; Mon, 14 Oct 2019 03:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TcDnMTCbqc+SMPI8ZRIhg2t2SAwRlKS9dBsRR316T8M=; b=VnTpB8sqXBvIvtF5yjTZvEcpflNYrKJhxc8WiUTIuCs8QgtlYbp8+ETdtBf/aZlmxg KPsKx7HgK4Z43ZdttNWYoSw1VYD3zXAmBNEiW/ujR+v4yrAikRnN46I7de3L4nIgF5Dd jMi2VmkthDwbumSM99z+14a7D8QKrnqlyC6HC+piA2a99bdaIgb7LgchgrjoTAnMqgm1 EROzAamFa1HdKpc03SdazTJrKbxbZiw2cf0N0woa4MX7vADSAwF8FwWHohyNhphSLUgH sowYJ5ugpwDqv/NRVufeiL0EklUJfbbsdVTDW9VKZfrSjRpfxFKucsUQyV3v16zUa+lj HS9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TcDnMTCbqc+SMPI8ZRIhg2t2SAwRlKS9dBsRR316T8M=; b=brQ5rztqUgVA2CmiZ4lhPW41ipVLBKD+jpTIUc3mDFMVX7iACChvzDFYzyLk5sAh23 fPh9oP5R5uUMjD1Q5csCYBAwi9CuQhSPQ6yBPGCFlHkuv8D4GRj/K0vELAj/Q0ChYy3U SIFSUdXpsCvmXGd6Cg1UxGtafKAZIY5Domzy57zat6e3zmXDune4zwxmT7EJPdXn0gWY 3gPr2YCivTWM3WKf7/g5vAsvrBhIUg3MW1chM7d2kpvnOLLnPG5IjNpw7wIQW5TKGB45 ZSghCnYU9Ln4wmUYa8wWgrwFApfCgwEnEdVDaECuV8d4Crmt+gAoxIOYRhdCjMMoWRSm KrVg== X-Gm-Message-State: APjAAAVLFPo7d+hGrzPSbJwM5Y7au2bMktmxBP5O+7G/AMuTvHXSF80K i6nBeOJNf1FT2hUEU7GO6SJ+pw== X-Received: by 2002:adf:ee82:: with SMTP id b2mr24823864wro.285.1571050191698; Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t203sm21013915wmf.42.2019.10.14.03.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E5EDD1FF91; Mon, 14 Oct 2019 11:49:49 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 04/55] translate-all: use cpu_in_exclusive_work_context() in tb_flush Date: Mon, 14 Oct 2019 11:48:57 +0100 Message-Id: <20191014104948.4291-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" tb_flush will be called by the plugin module from a safe work environment. Prepare for that. Suggested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/translate-all.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 66d4bc4341..0a08fcda3e 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1268,8 +1268,13 @@ void tb_flush(CPUState *cpu) { if (tcg_enabled()) { unsigned tb_flush_count = atomic_mb_read(&tb_ctx.tb_flush_count); - async_safe_run_on_cpu(cpu, do_tb_flush, - RUN_ON_CPU_HOST_INT(tb_flush_count)); + + if (cpu_in_exclusive_context(cpu)) { + do_tb_flush(cpu, RUN_ON_CPU_HOST_INT(tb_flush_count)); + } else { + async_safe_run_on_cpu(cpu, do_tb_flush, + RUN_ON_CPU_HOST_INT(tb_flush_count)); + } } } From patchwork Mon Oct 14 10:48:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176145 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4341660ill; Mon, 14 Oct 2019 03:53:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuvyjoqH0qtCF3P0KY3ggzu8Dcn9SI0bVPyzVoaET+uuuIxPJ15mK7tHmwqJppVRvAYjzR X-Received: by 2002:ac8:3021:: with SMTP id f30mr31104407qte.80.1571050409069; Mon, 14 Oct 2019 03:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050409; cv=none; d=google.com; s=arc-20160816; b=sPlmgDvu6EZ911zj78GMvTRiguaexp1AJYE3WPQRVgOZBG+6vlFsyZFjbPKTM3OXGQ bMeDO5E+SWXpUjpGMaMTujAKzrIGP0s6Sl0pwf8cEV/l1s9rKpi6wRb4T8Jkov35Zci2 VY9IXJ5zauqlVkPg5mBrdxAWWHcsyK9VcOZmqtkT7NI9956R8jx3Nwl+BpsKRz7zKMON dZkfICHIDqxTsXGZwr3Mvm+SODtV7XTMyV45xn/RJdQOxWGGyhAFFVoq0lFj2pQZr3Ir ZbbnrgtBfbGxM52brx2q4Ud5jdocS23hsuHgD4wOw8eu2GRmBw3RVSRBiArmkOw3nWvR 6nUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Yb3UF5h0z67h7aWNI1Qg9AnW+g8R23U+pnxlZeqlysw=; b=MqCAcfd/d+48U2SqX/BlG6as4Zx4FK6u5B8CtoMPPZKAxkzng2SJyXpPeuIWrUsmdZ Vw7CuSoHuPmAE4ZAkmdAljzGwj9yYErlau6J9qXDj9c2p+u4gmTPNs3YL/Ikumi0S4aN qzHXI8ZakZYdHTgGpap6nOPwLesFgyq3K1MqbAiVKdH/ltiYDzBvbg95N0IfYc2PcSDu BnYKGACo3/2EM6MHpnp9ZLgV/8lvIcy2o4gGjvKGGtjZNBOO6T67yjakv91IbPn3UIvI Q57TKTKf+8FRqE0GeFWIvEERDS/6VYIqZfAUnKHsQlvG0FD0fJ3X16pSYeoxPcxmKCRM 0a6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vyFO8v3O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x10si17305792qkl.274.2019.10.14.03.53.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:53:29 -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=fail header.i=@linaro.org header.s=google header.b=vyFO8v3O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxyi-0002bj-JO for patch@linaro.org; Mon, 14 Oct 2019 06:53:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44498) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvM-0007K6-2d for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvJ-00062X-Hz for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:59 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvJ-0005xx-6T for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:57 -0400 Received: by mail-wr1-x42c.google.com with SMTP id y19so19160045wrd.3 for ; Mon, 14 Oct 2019 03:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yb3UF5h0z67h7aWNI1Qg9AnW+g8R23U+pnxlZeqlysw=; b=vyFO8v3OS/k8Wf471kD3TJnpLGb4zfQWiuYXX+4soW41jv5gFC0KeY0wb7QpqUE0Wd CDZP3fgp+qhLvlcCjG9YopoDz2ro35pMwl9rVr0nXFvefiBam/rmmbqvrXWJoE4+cIPC S8G8eENKH2EWi/Tqi3Y9QS5/rCJUnxqllfIyJO6h/vaETbXpgHekccA8npm0zodsnSOy GEWhpmDkgRvuxNXLi+m5JDm4aPCzDzoNNP9mxEQADmAGweI92Lu8BtHYkattV06O1pPe sCRc16MQB1Lpg2+aQ9SDUaT0dD3roxmzrO59K5WPPAPPgi2w8ulxy/JDJsEk4GE5Poe+ 94ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yb3UF5h0z67h7aWNI1Qg9AnW+g8R23U+pnxlZeqlysw=; b=fkl07Fdk5oQkjmi41ZdQR5nsiPzNhpcQohQcZ3nRmM6Y+BrMQfG5158KHcX+TooNu9 b+sjksW+fIN9hKTYi5a/L+jybbu1mJpsv6sRxzYiJR6exVfpIUW/oJpR4TZsfLVJ05gE NXfYQBzNGu6TNuj0BvJpjDpG9vhprL4ZcH8npyeCNkPv5EjmcjSfZjUJFVdqMWGP/hPj xnTGGw7XonznGmJ2pR6XlcnFi5TIpDCYRq/U6W/y8SoCWgeWMqQ4+gksUB1Mlv01fx2D jz+93bPHJGaWUlEwhseQKWbrV39gX9OwF+PLgtSULVq2xSD4tzuu2cKPNHbSauRReKEf /u7w== X-Gm-Message-State: APjAAAXtyggiXnvgbJjvkTbOfMONV3yl+/2stWmpOCopidZ5ZrXWoLjK FH9Vkyh+baE1Q24lz+W4KN68DA== X-Received: by 2002:a05:6000:12d1:: with SMTP id l17mr14601892wrx.2.1571050194179; Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p5sm24112231wmi.4.2019.10.14.03.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B04B1FF92; Mon, 14 Oct 2019 11:49:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 05/55] docs/devel: add plugins.rst design document Date: Mon, 14 Oct 2019 11:48:58 +0100 Message-Id: <20191014104948.4291-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is mostly extracted from Emilio's more verbose commit comments with some additional verbiage from me. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - some rewording and tweaks - made non-atomicity of inline ops more explicit - expanded description of plugin unload v5 - more explicit statements: - cannot modify system state, only observer - call to action to upstream plugins --- docs/devel/index.rst | 1 + docs/devel/plugins.rst | 112 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 docs/devel/plugins.rst -- 2.20.1 diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 1ec61fcfed..2ff058bae3 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -22,3 +22,4 @@ Contents: decodetree secure-coding-practices tcg + plugins diff --git a/docs/devel/plugins.rst b/docs/devel/plugins.rst new file mode 100644 index 0000000000..b18fb6729e --- /dev/null +++ b/docs/devel/plugins.rst @@ -0,0 +1,112 @@ +.. + Copyright (C) 2017, Emilio G. Cota + Copyright (c) 2019, Linaro Limited + Written by Emilio Cota and Alex Bennée + +================ +QEMU TCG Plugins +================ + +QEMU TCG plugins provide a way for users to run experiments taking +advantage of the total system control emulation can have over a guest. +It provides a mechanism for plugins to subscribe to events during +translation and execution and optionally callback into the plugin +during these events. TCG plugins are unable to change the system state +only monitor it passively. However they can do this down to an +individual instruction granularity including potentially subscribing +to all load and store operations. + +API Stability +============= + +This is a new feature for QEMU and it does allow people to develop +out-of-tree plugins that can be dynamically linked into a running QEMU +process. However the project reserves the right to change or break the +API should it need to do so. The best way to avoid this is to submit +your plugin upstream so they can be updated if/when the API changes. + + +Exposure of QEMU internals +-------------------------- + +The plugin architecture actively avoids leaking implementation details +about how QEMU's translation works to the plugins. While there are +conceptions such as translation time and translation blocks the +details are opaque to plugins. The plugin is able to query select +details of instructions and system configuration only through the +exported *qemu_plugin* functions. The types used to describe +instructions and events are opaque to the plugins themselves. + +Usage +===== + +The QEMU binary needs to be compiled for plugin support: + +:: + configure --enable-plugins + +Once built a program can be run with multiple plugins loaded each with +their own arguments: + +:: + $QEMU $OTHER_QEMU_ARGS \ + -plugin tests/plugin/libhowvec.so,arg=inline,arg=hint \ + -plugin tests/plugin/libhotblocks.so + +Arguments are plugin specific and can be used to modify their +behaviour. In this case the howvec plugin is being asked to use inline +ops to count and break down the hint instructions by type. + +Plugin Life cycle +================= + +First the plugin is loaded and the public qemu_plugin_install function +is called. The plugin will then register callbacks for various plugin +events. Generally plugins will register a handler for the *atexit* +if they want to dump a summary of collected information once the +program/system has finished running. + +When a registered event occurs the plugin callback is invoked. The +callbacks may provide additional information. In the case of a +translation event the plugin has an option to enumerate the +instructions in a block of instructions and optionally register +callbacks to some or all instructions when they are executed. + +There is also a facility to add an inline event where code to +increment a counter can be directly inlined with the translation. +Currently only a simple increment is supported. This is not atomic so +can miss counts. If you want absolute precision you should use a +callback which can then ensure atomicity itself. + +Finally when QEMU exits all the registered *atexit* callbacks are +invoked. + +Internals +========= + +Locking +------- + +We have to ensure we cannot deadlock, particularly under MTTCG. For +this we acquire a lock when called from plugin code. We also keep the +list of callbacks under RCU so that we do not have to hold the lock +when calling the callbacks. This is also for performance, since some +callbacks (e.g. memory access callbacks) might be called very +frequently. + + * A consequence of this is that we keep our own list of CPUs, so that + we do not have to worry about locking order wrt cpu_list_lock. + * Use a recursive lock, since we can get registration calls from + callbacks. + +As a result registering/unregistering callbacks is "slow", since it +takes a lock. But this is very infrequent; we want performance when +calling (or not calling) callbacks, not when registering them. Using +RCU is great for this. + +We support the uninstallation of a plugin at any time (e.g. from +plugin callbacks). This allows plugins to remove themselves if they no +longer want to instrument the code. This operation is asynchronous +which means callbacks may still occur after the uninstall operation is +requested. The plugin isn't completely uninstalled until the safe work +has executed while all vCPUs are quiescent. From patchwork Mon Oct 14 10:48:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176143 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4340341ill; Mon, 14 Oct 2019 03:51:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzx/K+eXmjq0C+OPDPabodNGQdlBI+m0xo94kWl/+uuRuT+kiQjPKBr13EbAKl1pqxWc2lK X-Received: by 2002:a17:906:4a8d:: with SMTP id x13mr27130445eju.317.1571050314930; Mon, 14 Oct 2019 03:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050314; cv=none; d=google.com; s=arc-20160816; b=EGaYGGANxxxL3lD0BFBL7fqWKf8BGUZ1T/NRzXhVCAdjuVHTJZrggOjMBYL9pUBXAK WZm+7AjJbU8MUPGvWjjO4VfvG1Tv1Gj90gTfH5n/lgYryS/vh5yccu8UhXCvWuZqQBx+ /DuLaL4OVHysqoBpDZc9bkZwFkbZILnFSMFREmgwqwr2xS+8CV1uQMGNxEWMPi+mI90m kaFs20MvifphjPDPpNs8oFw+kGfzR3M4+a4qVEUsIJoVyJDHjEz+IaxbDHoU7fRGDJsn mWL3YsB3Kj18J8OfGtOpeXyW2Wu81fgiLAhZM0n0XgS58yZKzyOoJFwCPp+Z0MUPRdyH 6NVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UcgZ75XfpbxdYj2yixtrchwplPEwAU4Z4rGYEtqlY+4=; b=OfZkWy5i49Yun8LUPR64vp3kFAxXSxSkwNZFQulJu/r5oZIoTIOxGMQH8+Qc3QQf5r EPu1UJgJIISbHpuNDo5hWLFo6mG/hSu+g18RnphVAw6DBYZDvuHLv13TN+PvxgETUvQ2 0BJs1mfZJnGZ31e/S0DQlNs5xgJQCrmC1QeX7AApXRQOWiEkzGgRmymupQluScs/a1wK 9AcsT/xshcx1pobt6helzdmPax4CK1ORYC5T9W4L3xSgQxAwpS/PeI71oIijceE1IxAF rOOse6EC/ij/c049SFOoneHuM1zCbtcUQbH37dNwLkXz0ALdJEiLtQ/WY7zEy/lekYP/ C7Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i+Nd8Ids; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i5si11936287edj.107.2019.10.14.03.51.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:51:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i+Nd8Ids; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxxB-0007NQ-HV for patch@linaro.org; Mon, 14 Oct 2019 06:51:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvI-0007JK-1V for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvG-0005xY-EU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:39513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvG-0005w6-37 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:54 -0400 Received: by mail-wr1-x432.google.com with SMTP id r3so19147619wrj.6 for ; Mon, 14 Oct 2019 03:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UcgZ75XfpbxdYj2yixtrchwplPEwAU4Z4rGYEtqlY+4=; b=i+Nd8IdscLjxymcwkshtSmFKmSaCGVo3fxpTzgcHRj3XAEygeEY5Be+yOEZt/ojjCj +QuKy1oqjw2Ye9FyDjLRo0fRujypeGiS0DFhurE+trzpeLz5tg6jSKoGXFajeNWKJaau IpOkkufVesz29fPVIaAk4yTJSHSvR+doBfT2XpazeyQ8hbHqVpNJzklDfcGPbbHAIrMW 7MsBfS7B1OX2m3U+ZIAqlbRE3rAd8ALY+iieaD52pb51InP6LCrmz7b+0FTu3Y3hDdAD NfisLZaXY8WWqreZave2D/+rdfBQOxM2TxxtBz73xfyyCbmPNaZDVpmfWAW4Fe04zbjU 8Ilw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UcgZ75XfpbxdYj2yixtrchwplPEwAU4Z4rGYEtqlY+4=; b=uNuLx9gNngWVxK6AknQ67sxJvARcO1Q74eO2TTRzRP7HGrH7DSa1evAJVFaYHbOj8G 8a+sZxfq1/R4g3UVGiCnExtO5TdZQy9UnEwtzTQ4ecmpOZkYXmCd8ygYD0dXFg+U09sa PIsz1ggfXBqA7AZQ64Z5qSrME6kTJAlD4imU0eWKwO3fZwAuUTTbxzIm+px+PEQyflY0 njSLyWXFRBWcE3lnUFN6RFSpyDbAJ+TXCKSOdAXRgrbE26qO9CQqCcqY+/yXBeCByKvo Xn+b1wqmz959b2LUzagbtoVZz9yyKs/HJ2TaeY/ad65/1wTRFFiFNboIWQ/yLIuFjKHZ M1og== X-Gm-Message-State: APjAAAX2r7y6PqQ9rURdDslYDO1maddV1dOQkHke548zd2pua1LT5by+ VtT957apsZd9eiLWqUTIa6cvbg== X-Received: by 2002:adf:ed43:: with SMTP id u3mr25121113wro.236.1571050193003; Mon, 14 Oct 2019 03:49:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a18sm24852464wrs.27.2019.10.14.03.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4B5F41FF93; Mon, 14 Oct 2019 11:49:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 06/55] configure: add --enable-plugins (MOVE TO END) Date: Mon, 14 Oct 2019 11:48:59 +0100 Message-Id: <20191014104948.4291-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds the basic boilerplate feature enable option for the build. We shall expand it later. XXX: currently this patch is included at the start of development to aid with incremental building. It should be moved to the end once the plugins are feature complete. [AJB: split from larger patch] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.20.1 diff --git a/configure b/configure index 08ca4bcb46..485a9837c9 100755 --- a/configure +++ b/configure @@ -497,6 +497,7 @@ libxml2="" debug_mutex="no" libpmem="" default_devices="yes" +plugins="no" supported_cpu="no" supported_os="no" @@ -1524,6 +1525,10 @@ for opt do ;; --disable-xkbcommon) xkbcommon=no ;; + --enable-plugins) plugins="yes" + ;; + --disable-plugins) plugins="no" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1705,6 +1710,8 @@ Advanced options (experts only): --enable-profiler profiler support --enable-debug-stack-usage track the maximum stack usage of stacks created by qemu_alloc_stack + --enable-plugins + enable plugins via shared library loading Optional features, enabled with --enable-FEATURE and disabled with --disable-FEATURE, default is enabled if available: @@ -6429,6 +6436,7 @@ echo "capstone $capstone" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "plugin support $plugins" if test "$supported_cpu" = "no"; then echo @@ -7256,6 +7264,11 @@ if test "$sheepdog" = "yes" ; then echo "CONFIG_SHEEPDOG=y" >> $config_host_mak fi +if test "$plugins" = "yes" ; then + echo "CONFIG_PLUGIN=y" >> $config_host_mak + LIBS="-ldl $LIBS" +fi + if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" = "sparc64" ; then From patchwork Mon Oct 14 10:49:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176151 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4345570ill; Mon, 14 Oct 2019 03:58:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQjHj6hOwyzm0oIljTErpLvHs1tyBqvRVePFGY/7Ofc0lR+Cy4L0iFuyo+7hFm/n6d8xSV X-Received: by 2002:ac8:5147:: with SMTP id h7mr30793693qtn.119.1571050680780; Mon, 14 Oct 2019 03:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050680; cv=none; d=google.com; s=arc-20160816; b=Nh0CoMlwCUA3H/2Advbk4KMCWuC6/AWI9hvbKZZrsFv/Jw7Jpi4g9U+6VcQLqQViVi zK4g0h9CyxOGmeuuDnxEzHArhA8YlVYkikVRiNKX0s166HbKgo+/5c8Wwhn3W07Z/KRO P65/ZMDAVDixObqTaFMOPhR9RnLlIrhK2BwJt7wUd0AMSnzQki93eMQ+7Orrryo+Mr5H hSHUHBff0QeKmn4EQ9pRlJwc9vC+V2vmdP80J/rZtsVWBXGcu/gQ4x16f8e4nJk2KBoU TD1/3KAJth5+3SWZ/8XHG1EYcDGITIkkX8QYITfttM/o3k5vHzgIHiBf+z3etFBAORm6 b4aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jxSf2lbuW5KJiixqzN79rCXNmB+////wViO7YEre93M=; b=vQdTnRjm7/OObUzZfRUKN8ycRIZrjRByHcMRiczsQpHVsZ99o49tauUUc+0x9ZNzy7 CLkAogzpAkz3XJ0Yo4dgIqZMsewbPw0n6zNLb2rScVVGeYVvG+MrSQsBIbByZsFe0N+G 1tqW+LOKWYx/b8ZtRoOmU4zr6PagiX2fj0zTL/T3/EIqUorYe6smVTqhImKATloci59b eFrLV71DO5VxllBOfbvU6wh2jhQNKsuajow/cUTcrNsyrdcELLdBwh23uBVEPLHD0ugJ REazuaup8fT1IN3OWYycvMvtlGDJzRN85tJdQhPPged64u9bwYDo+8lnr1i69hBsD0oX OZlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vR9naB65; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w57si17159745qta.73.2019.10.14.03.58.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vR9naB65; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy36-00061w-1b for patch@linaro.org; Mon, 14 Oct 2019 06:58:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44509) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvN-0007KC-B3 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvJ-00062z-O3 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:00 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvJ-00061O-8P for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:57 -0400 Received: by mail-wr1-x442.google.com with SMTP id y19so19160153wrd.3 for ; Mon, 14 Oct 2019 03:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jxSf2lbuW5KJiixqzN79rCXNmB+////wViO7YEre93M=; b=vR9naB653DAP3gpjNExJ9EoA5VSyNoUCyYHZRWr1Ls7CAAjOf7F1mXefIm8u6rhtJb ZQ1Ol2Tfqf15+f55wbgMliAklNjuAFqBebdw70KerlGt9epd2Ue0c8vr6fvKvT9F9IRG eELL6P8jIT6sStYyVADJhFGRkxTOMOGP+DWNEElxYhUoHPZf6cA1rth6FB079xD3myCz a0L2B2/GCIlLEnTBg6yXZsQwna/YjVF07YjBr65nN/jygrWWWi+4UMEExNYG68ChEuqS Cn8NXoGk44HrmxCTxvRSLHNMRsBGVO+iQ6NdytPtQ0XcYBq0gt3DRBN6WEAD8g6XP77W Lz/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jxSf2lbuW5KJiixqzN79rCXNmB+////wViO7YEre93M=; b=RKPER9hFQeUFBXzYVkVdstZQIPShQuKp67zZfZz+zO/PJvVFmg210pNLQz5xfcjKs1 prRxOlI1rCOvOPALRr4GF0APUF+6IBI/jtxTwp/FTHv7MUbDl1XD7bHFubPx5+ZRJsBj 9sdhGCNaEUCiiNaMTJcxtJPZALTJpX3l+VLHSGibp747N0aupFreScRjNhGVQatyH5r+ dQhQU7BVcle2pRT7gl5nKv52ou97NByxfhoRxX3MzLF18Hdj9Ab+QOOGZ5/P5DRXB7oV wcMoMeq+MqLZq+aXnm9eC1wzaJyd4VgaA3YkYTjK3/hJcRFsZbUWmW2EiLgrMIQP052T oH+Q== X-Gm-Message-State: APjAAAUmvv1dReVaqhXrDlWoEpuwU1ZxsuP8A5nIcqqilhKC50YbK53e pfAYH7fP8oNzG2WUSoamVjifJA== X-Received: by 2002:a05:6000:1204:: with SMTP id e4mr11271197wrx.23.1571050196072; Mon, 14 Oct 2019 03:49:56 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g185sm24477999wme.10.2019.10.14.03.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7D36F1FF8C; Mon, 14 Oct 2019 11:49:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 07/55] plugin: add user-facing API Date: Mon, 14 Oct 2019 11:49:00 +0100 Message-Id: <20191014104948.4291-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Add the API first to ease review. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - merge in changes to plugin install/reset/uninstall - split api file v4 - s/is/it/ - more docstrings - remove qemu_plugin_register_vcpu_mem_haddr_cb and related bits - add qemu_plugin_get_hwaddr and related bits - drop vcpu_index from tb_trans_cb_t --- include/qemu/qemu-plugin.h | 351 +++++++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 include/qemu/qemu-plugin.h -- 2.20.1 diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h new file mode 100644 index 0000000000..d9c1ca3b4c --- /dev/null +++ b/include/qemu/qemu-plugin.h @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef QEMU_PLUGIN_API_H +#define QEMU_PLUGIN_API_H + +#include +#include + +/* + * For best performance, build the plugin with -fvisibility=hidden so that + * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with + * QEMU_PLUGIN_EXPORT. For more info, see + * https://gcc.gnu.org/wiki/Visibility + */ +#if defined _WIN32 || defined __CYGWIN__ + #ifdef BUILDING_DLL + #define QEMU_PLUGIN_EXPORT __declspec(dllexport) + #else + #define QEMU_PLUGIN_EXPORT __declspec(dllimport) + #endif + #define QEMU_PLUGIN_LOCAL +#else + #if __GNUC__ >= 4 + #define QEMU_PLUGIN_EXPORT __attribute__((visibility("default"))) + #define QEMU_PLUGIN_LOCAL __attribute__((visibility("hidden"))) + #else + #define QEMU_PLUGIN_EXPORT + #define QEMU_PLUGIN_LOCAL + #endif +#endif + +typedef uint64_t qemu_plugin_id_t; + +/** + * qemu_plugin_install() - Install a plugin + * @id: this plugin's opaque ID + * @argc: number of arguments + * @argv: array of arguments (@argc elements) + * + * All plugins must export this symbol. + * + * Note: Calling qemu_plugin_uninstall() from this function is a bug. To raise + * an error during install, return !0. + * + * Note: @argv remains valid throughout the lifetime of the loaded plugin. + */ +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv); + +/* + * Prototypes for the various callback styles we will be registering + * in the following functions. + */ +typedef void (*qemu_plugin_simple_cb_t)(qemu_plugin_id_t id); + +typedef void (*qemu_plugin_udata_cb_t)(qemu_plugin_id_t id, void *userdata); + +typedef void (*qemu_plugin_vcpu_simple_cb_t)(qemu_plugin_id_t id, + unsigned int vcpu_index); + +typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index, + void *userdata); + +/** + * qemu_plugin_uninstall() - Uninstall a plugin + * @id: this plugin's opaque ID + * @cb: callback to be called once the plugin has been removed + * + * Do NOT assume that the plugin has been uninstalled once this function + * returns. Plugins are uninstalled asynchronously, and therefore the given + * plugin receives callbacks until @cb is called. + * + * Note: Calling this function from qemu_plugin_install() is a bug. + */ +void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); + +/** + * qemu_plugin_reset() - Reset a plugin + * @id: this plugin's opaque ID + * @cb: callback to be called once the plugin has been reset + * + * Unregisters all callbacks for the plugin given by @id. + * + * Do NOT assume that the plugin has been reset once this function returns. + * Plugins are reset asynchronously, and therefore the given plugin receives + * callbacks until @cb is called. + */ +void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb); + +/** + * qemu_plugin_register_vcpu_init_cb() - register a vCPU initialization callback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU is initialized. + * + * See also: qemu_plugin_register_vcpu_exit_cb() + */ +void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +/** + * qemu_plugin_register_vcpu_exit_cb() - register a vCPU exit callback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU exits. + * + * See also: qemu_plugin_register_vcpu_init_cb() + */ +void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +/** + * qemu_plugin_register_vcpu_idle_cb() - register a vCPU idle callback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU idles. + */ +void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +/** + * qemu_plugin_register_vcpu_resume_cb() - register a vCPU resume callback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU resumes execution. + */ +void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +/* + * Opaque types that the plugin is given during the translation and + * instrumentation phase. + */ +struct qemu_plugin_tb; +struct qemu_plugin_insn; + +enum qemu_plugin_cb_flags { + QEMU_PLUGIN_CB_NO_REGS, /* callback does not access the CPU's regs */ + QEMU_PLUGIN_CB_R_REGS, /* callback reads the CPU's regs */ + QEMU_PLUGIN_CB_RW_REGS, /* callback reads and writes the CPU's regs */ +}; + +enum qemu_plugin_mem_rw { + QEMU_PLUGIN_MEM_R = 1, + QEMU_PLUGIN_MEM_W, + QEMU_PLUGIN_MEM_RW, +}; + +/** + * qemu_plugin_register_vcpu_tb_trans_cb() - register a translate cb + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a translation occurs. The @cb + * function is passed an opaque qemu_plugin_type which it can query + * for additional information including the list of translated + * instructions. At this point the plugin can register further + * callbacks to be triggered when the block or individual instruction + * executes. + */ +typedef void (*qemu_plugin_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, + struct qemu_plugin_tb *tb); + +void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_tb_trans_cb_t cb); + +/** + * qemu_plugin_register_vcpu_tb_trans_exec_cb() - register execution callback + * @tb: the opaque qemu_plugin_tb handle for the translation + * @cb: callback function + * @flags: does the plugin read or write the CPU's registers? + * @userdata: any plugin data to pass to the @cb? + * + * The @cb function is called every time a translated unit executes. + */ +void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *userdata); + +enum qemu_plugin_op { + QEMU_PLUGIN_INLINE_ADD_U64, +}; + +/** + * qemu_plugin_register_vcpu_tb_trans_exec_inline() - execution inline op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @ptr: the target memory location for the op + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time a translated unit executes. + * Useful if you just want to increment a single counter somewhere in + * memory. + */ +void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, uint64_t imm); + +/** + * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @cb: callback function + * @flags: does the plugin read or write the CPU's registers? + * @userdata: any plugin data to pass to the @cb? + * + * The @cb function is called every time an instruction is executed + */ +void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *userdata); + +/** + * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @cb: callback function + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @ptr: the target memory location for the op + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time an instruction executes. Useful + * if you just want to increment a single counter somewhere in memory. + */ +void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + void *ptr, uint64_t imm); + +/* + * Helpers to query information about the instructions in a block + */ +size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb); + +uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); + +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); + +const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn); + +size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn); + +uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn); +void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn); + +/* + * Memory Instrumentation + * + * The anonymous qemu_plugin_meminfo_t and qemu_plugin_hwaddr types + * can be used in queries to QEMU to get more information about a + * given memory access. + */ +typedef uint32_t qemu_plugin_meminfo_t; +struct qemu_plugin_hwaddr; + +/* meminfo queries */ +unsigned int qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); + +/* + * qemu_plugin_get_hwaddr(): + * @vaddr: the virtual address of the memory operation + * + * For system emulation returns a qemu_plugin_hwaddr handle to query + * details about the actual physical address backing the virtual + * address. For linux-user guests it just returns NULL. + * + * This handle is *only* valid for the duration of the callback. Any + * information about the handle should be recovered before the + * callback returns. + */ +struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, + uint64_t vaddr); + +bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr); +uint64_t qemu_plugin_hwaddr_to_raddr(const struct qemu_plugin_hwaddr *haddr); + +typedef void +(*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *userdata); + +void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *userdata); + +void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm); + + + +typedef void +(*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, + int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8); + +void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_cb_t cb); + +typedef void +(*qemu_plugin_vcpu_syscall_ret_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_idx, + int64_t num, int64_t ret); + +void +qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_ret_cb_t cb); + + +/** + * qemu_plugin_vcpu_for_each() - iterate over the existing vCPU + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called once for each existing vCPU. + * + * See also: qemu_plugin_register_vcpu_init_cb() + */ +void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb); + +void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, void *userdata); + +/* returns -1 in user-mode */ +int qemu_plugin_n_vcpus(void); + +/* returns -1 in user-mode */ +int qemu_plugin_n_max_vcpus(void); + +#endif /* QEMU_PLUGIN_API_H */ From patchwork Mon Oct 14 10:49:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176159 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4356394ill; Mon, 14 Oct 2019 04:07:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzPCS0Q4wrOShBTB0WqAekAvN+RBwQFp30ybiYTwgaLbttyOz4NJoTiMFZcFopQ7HxNMMy X-Received: by 2002:ac8:60c4:: with SMTP id i4mr23456752qtm.129.1571051221331; Mon, 14 Oct 2019 04:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051221; cv=none; d=google.com; s=arc-20160816; b=gZcNHVSjj5G/672aaH5u1K7mEbE2KuyvX2S76sW9LtBb6jtpyrgkV2q+e9wBH7vFvK HnmfpTdAE1ALp8IrvWUn62XVAzDlZdFioCx8GKElhk9TMywHN44CHgjCtb/wgRCi05ns EpVsuSOpUKmnsM21n6lQQoGYvsATFXVEJOn/EyWN6GbOHqTgaMUqQYLx/kKjH6ejnfny TUUIHn8ZXxOnIpJNHnJTqGM8hLyoVFbTRU/4YkPFUrf35RR3JU+ZU+14J34/ZtX/tBHM z+ONwys/+nbhLOvX59x6yH2JedDR/n8hyMf5Q9s04nbObtYbCAztVa0Tdp2Ujvl9K5vA jYCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ptOJoHCSYxD4d4cVN6cK1Dk+QSAbboxewQkgqdIDGx4=; b=ubvPbCe9gO8j49WsHKmVhZgGI34gNi7gKKngas3qzdiGLrcVrSGzTWQwJ2JMwFXyXr uQDnUGDpYg2K2vC5VNLjoVYSkADEVE1LWVQ7Rw1ync51yctQi7yvSeseb3dQC71dVc3m cobV988slj4sCnvbvOZzUt0wn4R+cUc2nLrxkZe3IcmPu2h2NLD8al0bBZ56fjWiVjtT q57Sx9kwh7AEWXTJeVojKj4jHWsEJLBBZ2iG1ELV3cKGaFuCvdrBLWS6xQQkB+quMalx OuAvXm5euzh9Cz78vmbxuhi7uCO6YoTS+4fc5JI1lGtZa+d9kicMIOZz934cnae9XZ7g UA7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BPinNZWR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q8si16548624qtb.104.2019.10.14.04.07.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BPinNZWR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBo-0007HA-B1 for patch@linaro.org; Mon, 14 Oct 2019 07:07:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvT-0007Um-17 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvO-00069u-Ln for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:06 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvO-00064z-8g for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: by mail-wm1-x341.google.com with SMTP id b24so16249229wmj.5 for ; Mon, 14 Oct 2019 03:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ptOJoHCSYxD4d4cVN6cK1Dk+QSAbboxewQkgqdIDGx4=; b=BPinNZWRJ0XNEUObGXcSzqQTCq72QRfKI6Hs2EaSsPWJWOMK7LTUkIdOYgNFSQ7yze NOJ7THy6yrkqyv4NiajqlYlY7aL8Dws/AJZ/m3Jv6EJmHOHoSVtB6czA9szrMlYKUFgZ uBpuieY2NxBIfqfLgbDUvqmEstEsgO+6k+/JIdXaxHF8sWa6KRKaxedpzHk9jLpyXXXL VgoOLfV9Hh7+ywDsFn3+/AyyZRn6Q6Vs2DZkexmGC5HwLlL78vSB1ijPYwtSfxKhZbOc STvz19IyxD3HGX8OTo6QbQ7uRo/Y46JDcn2q4F2ieY+2P065SIh6KJYKPCwImfk5skCp cqlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ptOJoHCSYxD4d4cVN6cK1Dk+QSAbboxewQkgqdIDGx4=; b=KqYlSq8VO4uVjs7rlSPZxsrFavZq1JzxlyG6UIaQvSQG/pvYxPPdY8Rg8Bh7qNYgcf 5+j83MURkrF+nwbxCWxLBMKNK8WgVVr87SrJwTSOkIVcwsTbscNYKc3Hh5QNUgj68TmM h0EyJkDzLJ0EZupSCMNt0mU06rJIUvnsOc65QoLk3aATS7YpvSiRsjN9INFQljwsQI6X gmhw2kn2sNGSJsfQqOCqspyyP+4/H6feqJxTka+j5j40kPDsserZbVZpzUutQKes1+xR kAYmS3msLV+UYCv4q6cGhKX0f7cnkRX/CMgHEI9TicZHCpdkGBnDts8biDQffb/8vEzU pR0Q== X-Gm-Message-State: APjAAAViCE0ipSKwmLbsFtG8MtWj8AKRXqkyUqJKHepRCvLXMogYsCEL AtT+nEL0ydByoP8lwbWmS3/RqA== X-Received: by 2002:a7b:cb54:: with SMTP id v20mr6843735wmj.119.1571050198260; Mon, 14 Oct 2019 03:49:58 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b12sm13699215wrt.21.2019.10.14.03.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D47781FF96; Mon, 14 Oct 2019 11:49:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 08/55] plugin: add core code Date: Mon, 14 Oct 2019 11:49:01 +0100 Message-Id: <20191014104948.4291-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota [AJB: moved directory and merged various fixes] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - moved to plugins/ - merged plugin: remove uninstall_cb_t and just use simple_cb_t plugin: handle uninstall when !current_cpu plugin: introduce qemu_plugin_reset - split into core/loader - use GArray/GByteArray/GPtrArray instead of homegrown funcs v4 - document QEMU_PLUGIN_EV_MAX - move qemu_plugin_ram_addr_from_host to api - drop vcpu_index from trans cb - s/plugin_dyn_cb_type/plugin_dyn_cb_subtype/ in qemu_plugin_dyn_cb - remove haddr from memory hooks - checkpatch fixes v5 - fix up includes of hw/cpu.h - added proper license and copyright headers - restore commented out uninstall --- Makefile | 9 +- Makefile.target | 2 + include/hw/core/cpu.h | 6 + include/qemu/plugin.h | 255 +++++++++++++++++++++ plugins/Makefile.objs | 6 + plugins/core.c | 504 ++++++++++++++++++++++++++++++++++++++++++ plugins/loader.c | 370 +++++++++++++++++++++++++++++++ plugins/plugin.h | 95 ++++++++ 8 files changed, 1246 insertions(+), 1 deletion(-) create mode 100644 include/qemu/plugin.h create mode 100644 plugins/Makefile.objs create mode 100644 plugins/core.c create mode 100644 plugins/loader.c create mode 100644 plugins/plugin.h -- 2.20.1 diff --git a/Makefile b/Makefile index 30f0abfb42..15f4745cf3 100644 --- a/Makefile +++ b/Makefile @@ -846,7 +846,11 @@ endif ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512 -install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-localstatedir \ +install-includedir: + $(INSTALL_DIR) "$(DESTDIR)$(includedir)" + +install: all $(if $(BUILD_DOCS),install-doc) \ + install-datadir install-localstatedir install-includedir \ $(if $(INSTALL_BLOBS),$(edk2-decompressed)) \ recurse-install ifneq ($(TOOLS),) @@ -908,6 +912,9 @@ endif "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop" ifdef CONFIG_GTK $(MAKE) -C po $@ +endif +ifeq ($(CONFIG_PLUGIN),y) + $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h" endif $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps" set -e; for x in $(KEYMAPS); do \ diff --git a/Makefile.target b/Makefile.target index 5e916230c4..5de6c95efb 100644 --- a/Makefile.target +++ b/Makefile.target @@ -119,6 +119,8 @@ obj-y += disas.o obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o LIBS := $(libs_cpu) $(LIBS) +obj-$(CONFIG_PLUGIN) += plugins/ + ######################################################### # Linux user emulator target diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 07f2ab0590..e1c383ba84 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -29,6 +29,7 @@ #include "qemu/rcu_queue.h" #include "qemu/queue.h" #include "qemu/thread.h" +#include "qemu/plugin.h" typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, void *opaque); @@ -344,6 +345,7 @@ struct qemu_work_item; * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all changes * to @trace_dstate). * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask). + * @plugin_mask: Plugin event bitmap. Modified only via async work. * @ignore_memory_transaction_failures: Cached copy of the MachineState * flag of the same name: allows the board to suppress calling of the * CPU do_transaction_failed hook function. @@ -428,6 +430,10 @@ struct CPUState { DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS); DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS); + DECLARE_BITMAP(plugin_mask, QEMU_PLUGIN_EV_MAX); + + GArray *plugin_mem_cbs; + /* TODO Move common fields from CPUArchState here. */ int cpu_index; int cluster_index; diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h new file mode 100644 index 0000000000..3c46a24166 --- /dev/null +++ b/include/qemu/plugin.h @@ -0,0 +1,255 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_PLUGIN_H +#define QEMU_PLUGIN_H + +#include "qemu/config-file.h" +#include "qemu/qemu-plugin.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qemu/option.h" + +/* + * Option parsing/processing. + * Note that we can load an arbitrary number of plugins. + */ +struct qemu_plugin_desc; +typedef QTAILQ_HEAD(, qemu_plugin_desc) QemuPluginList; + +#ifdef CONFIG_PLUGIN +extern QemuOptsList qemu_plugin_opts; + +static inline void qemu_plugin_add_opts(void) +{ + qemu_add_opts(&qemu_plugin_opts); +} + +void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head); +int qemu_plugin_load_list(QemuPluginList *head); +#else /* !CONFIG_PLUGIN */ +static inline void qemu_plugin_add_opts(void) +{ } + +static inline void qemu_plugin_opt_parse(const char *optarg, + QemuPluginList *head) +{ + error_report("plugin interface not enabled in this build"); + exit(1); +} + +static inline int qemu_plugin_load_list(QemuPluginList *head) +{ + return 0; +} +#endif /* !CONFIG_PLUGIN */ + +/* + * Events that plugins can subscribe to. + */ +enum qemu_plugin_event { + QEMU_PLUGIN_EV_VCPU_INIT, + QEMU_PLUGIN_EV_VCPU_EXIT, + QEMU_PLUGIN_EV_VCPU_TB_TRANS, + QEMU_PLUGIN_EV_VCPU_IDLE, + QEMU_PLUGIN_EV_VCPU_RESUME, + QEMU_PLUGIN_EV_VCPU_SYSCALL, + QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, + QEMU_PLUGIN_EV_FLUSH, + QEMU_PLUGIN_EV_ATEXIT, + QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */ +}; + +union qemu_plugin_cb_sig { + qemu_plugin_simple_cb_t simple; + qemu_plugin_udata_cb_t udata; + qemu_plugin_vcpu_simple_cb_t vcpu_simple; + qemu_plugin_vcpu_udata_cb_t vcpu_udata; + qemu_plugin_vcpu_tb_trans_cb_t vcpu_tb_trans; + qemu_plugin_vcpu_mem_cb_t vcpu_mem; + qemu_plugin_vcpu_syscall_cb_t vcpu_syscall; + qemu_plugin_vcpu_syscall_ret_cb_t vcpu_syscall_ret; + void *generic; +}; + +enum plugin_dyn_cb_type { + PLUGIN_CB_INSN, + PLUGIN_CB_MEM, + PLUGIN_N_CB_TYPES, +}; + +enum plugin_dyn_cb_subtype { + PLUGIN_CB_REGULAR, + PLUGIN_CB_INLINE, + PLUGIN_N_CB_SUBTYPES, +}; + +/* + * A dynamic callback has an insertion point that is determined at run-time. + * Usually the insertion point is somewhere in the code cache; think for + * instance of a callback to be called upon the execution of a particular TB. + */ +struct qemu_plugin_dyn_cb { + union qemu_plugin_cb_sig f; + void *userp; + unsigned tcg_flags; + enum plugin_dyn_cb_subtype type; + /* @rw applies to mem callbacks only (both regular and inline) */ + enum qemu_plugin_mem_rw rw; + /* fields specific to each dyn_cb type go here */ + union { + struct { + enum qemu_plugin_op op; + uint64_t imm; + } inline_insn; + }; +}; + +struct qemu_plugin_insn { + GByteArray *data; + uint64_t vaddr; + void *haddr; + GArray *cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTYPES]; + bool calls_helpers; + bool mem_helper; +}; + +/* + * qemu_plugin_insn allocate and cleanup functions. We don't expect to + * cleanup many of these structures. They are reused for each fresh + * translation. + */ + +static inline void qemu_plugin_insn_cleanup_fn(gpointer data) +{ + struct qemu_plugin_insn *insn = (struct qemu_plugin_insn *) data; + g_byte_array_free(insn->data, true); +} + +static inline struct qemu_plugin_insn * qemu_plugin_insn_alloc(void) +{ + int i, j; + struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1); + insn->data = g_byte_array_sized_new(4); + + for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { + insn->cbs[i][j] = g_array_new(false, false, + sizeof(struct qemu_plugin_dyn_cb)); + } + } + return insn; +} + +struct qemu_plugin_tb { + GPtrArray *insns; + size_t n; + uint64_t vaddr; + uint64_t vaddr2; + void *haddr1; + void *haddr2; + GArray *cbs[PLUGIN_N_CB_SUBTYPES]; +}; + +/** + * qemu_plugin_tb_insn_get(): get next plugin record for translation. + * + */ +static inline +struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb) +{ + struct qemu_plugin_insn *insn; + int i, j; + + if (unlikely(tb->n == tb->insns->len)) { + struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc(); + g_ptr_array_add(tb->insns, new_insn); + } + insn = g_ptr_array_index(tb->insns, tb->n++); + g_byte_array_set_size(insn->data, 0); + insn->calls_helpers = false; + insn->mem_helper = false; + + for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { + g_array_set_size(insn->cbs[i][j], 0); + } + } + + return insn; +} + +#ifdef CONFIG_PLUGIN + +void qemu_plugin_vcpu_init_hook(CPUState *cpu); +void qemu_plugin_vcpu_exit_hook(CPUState *cpu); +void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb); +void qemu_plugin_vcpu_idle_cb(CPUState *cpu); +void qemu_plugin_vcpu_resume_cb(CPUState *cpu); +void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8); +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, uint32_t meminfo); + +void qemu_plugin_flush_cb(void); + +void qemu_plugin_atexit_cb(void); + +void qemu_plugin_add_dyn_cb_arr(GArray *arr); + +void qemu_plugin_disable_mem_helpers(CPUState *cpu); + +#else /* !CONFIG_PLUGIN */ + +static inline void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ } + +static inline void qemu_plugin_vcpu_exit_hook(CPUState *cpu) +{ } + +static inline void qemu_plugin_tb_trans_cb(CPUState *cpu, + struct qemu_plugin_tb *tb) +{ } + +static inline void qemu_plugin_vcpu_idle_cb(CPUState *cpu) +{ } + +static inline void qemu_plugin_vcpu_resume_cb(CPUState *cpu) +{ } + +static inline void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6, + uint64_t a7, uint64_t a8) +{ } + +static inline +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, + uint32_t meminfo) +{ } + +static inline void qemu_plugin_flush_cb(void) +{ } + +static inline void qemu_plugin_atexit_cb(void) +{ } + +static inline +void qemu_plugin_add_dyn_cb_arr(GArray *arr) +{ } + +static inline void qemu_plugin_disable_mem_helpers(CPUState *cpu) +{ } + +#endif /* !CONFIG_PLUGIN */ + +#endif /* QEMU_PLUGIN_H */ diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs new file mode 100644 index 0000000000..58940335bc --- /dev/null +++ b/plugins/Makefile.objs @@ -0,0 +1,6 @@ +# +# Plugin Support +# + +obj-y += loader.o +obj-y += core.o diff --git a/plugins/core.c b/plugins/core.c new file mode 100644 index 0000000000..168f673bc9 --- /dev/null +++ b/plugins/core.c @@ -0,0 +1,504 @@ +/* + * QEMU Plugin Core code + * + * This is the core code that deals with injecting instrumentation into the code + * + * Copyright (C) 2017, Emilio G. Cota + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" +#include "qapi/error.h" +#include "qemu/option.h" +#include "qemu/rcu_queue.h" +#include "qemu/xxhash.h" +#include "qemu/rcu.h" +#include "hw/core/cpu.h" +#include "exec/cpu-common.h" +#include + +#include "cpu.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" +#include "sysemu/sysemu.h" +#include "tcg/tcg.h" +#include "tcg/tcg-op.h" +#include "trace/mem-internal.h" /* mem_info macros */ +#include "plugin.h" + +struct qemu_plugin_cb { + struct qemu_plugin_ctx *ctx; + union qemu_plugin_cb_sig f; + void *udata; + QLIST_ENTRY(qemu_plugin_cb) entry; +}; + +QLIST_HEAD(qemu_plugin_cb_head, qemu_plugin_cb); + +struct qemu_plugin_state plugin; + +struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id) +{ + struct qemu_plugin_ctx *ctx; + qemu_plugin_id_t *id_p; + + id_p = g_hash_table_lookup(plugin.id_ht, &id); + ctx = container_of(id_p, struct qemu_plugin_ctx, id); + if (ctx == NULL) { + error_report("plugin: invalid plugin id %" PRIu64, id); + abort(); + } + return ctx; +} + +static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data) +{ + bitmap_copy(cpu->plugin_mask, &data.host_ulong, QEMU_PLUGIN_EV_MAX); + cpu_tb_jmp_cache_clear(cpu); +} + +static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata) +{ + CPUState *cpu = container_of(k, CPUState, cpu_index); + run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask); + + if (cpu->created) { + async_run_on_cpu(cpu, plugin_cpu_update__async, mask); + } else { + plugin_cpu_update__async(cpu, mask); + } +} + +void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, + enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb = ctx->callbacks[ev]; + + if (cb == NULL) { + return; + } + QLIST_REMOVE_RCU(cb, entry); + g_free(cb); + ctx->callbacks[ev] = NULL; + if (QLIST_EMPTY_RCU(&plugin.cb_lists[ev])) { + clear_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__locked, NULL); + } +} + +static void plugin_vcpu_cb__simple(CPUState *cpu, enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_VCPU_INIT: + case QEMU_PLUGIN_EV_VCPU_EXIT: + case QEMU_PLUGIN_EV_VCPU_IDLE: + case QEMU_PLUGIN_EV_VCPU_RESUME: + /* iterate safely; plugins might uninstall themselves at any time */ + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_simple_cb_t func = cb->f.vcpu_simple; + + func(cb->ctx->id, cpu->cpu_index); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__simple(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_FLUSH: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_simple_cb_t func = cb->f.simple; + + func(cb->ctx->id); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__udata(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_ATEXIT: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_udata_cb_t func = cb->f.udata; + + func(cb->ctx->id, cb->udata); + } + break; + default: + g_assert_not_reached(); + } +} + +static void +do_plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + struct qemu_plugin_ctx *ctx; + + qemu_rec_mutex_lock(&plugin.lock); + ctx = plugin_id_to_ctx_locked(id); + /* if the plugin is on its way out, ignore this request */ + if (unlikely(ctx->uninstalling)) { + goto out_unlock; + } + if (func) { + struct qemu_plugin_cb *cb = ctx->callbacks[ev]; + + if (cb) { + cb->f.generic = func; + cb->udata = udata; + } else { + cb = g_new(struct qemu_plugin_cb, 1); + cb->ctx = ctx; + cb->f.generic = func; + cb->udata = udata; + ctx->callbacks[ev] = cb; + QLIST_INSERT_HEAD_RCU(&plugin.cb_lists[ev], cb, entry); + if (!test_bit(ev, plugin.mask)) { + set_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__locked, + NULL); + } + } + } else { + plugin_unregister_cb__locked(ctx, ev); + } + out_unlock: + qemu_rec_mutex_unlock(&plugin.lock); +} + +void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func) +{ + do_plugin_register_cb(id, ev, func, NULL); +} + +void +plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + do_plugin_register_cb(id, ev, func, udata); +} + +void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ + bool success; + + qemu_rec_mutex_lock(&plugin.lock); + plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL); + success = g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, + &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); +} + +void qemu_plugin_vcpu_exit_hook(CPUState *cpu) +{ + bool success; + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXIT); + + qemu_rec_mutex_lock(&plugin.lock); + success = g_hash_table_remove(plugin.cpu_ht, &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); +} + +struct plugin_for_each_args { + struct qemu_plugin_ctx *ctx; + qemu_plugin_vcpu_simple_cb_t cb; +}; + +static void plugin_vcpu_for_each(gpointer k, gpointer v, gpointer udata) +{ + struct plugin_for_each_args *args = udata; + int cpu_index = *(int *)k; + + args->cb(args->ctx->id, cpu_index); +} + +void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + struct plugin_for_each_args args; + + if (cb == NULL) { + return; + } + qemu_rec_mutex_lock(&plugin.lock); + args.ctx = plugin_id_to_ctx_locked(id); + args.cb = cb; + g_hash_table_foreach(plugin.cpu_ht, plugin_vcpu_for_each, &args); + qemu_rec_mutex_unlock(&plugin.lock); +} + +/* Allocate and return a callback record */ +static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) +{ + GArray *cbs = *arr; + + if (!cbs) { + cbs = g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), 1); + *arr = cbs; + } + + g_array_set_size(cbs, cbs->len + 1); + return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); +} + +void plugin_register_inline_op(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb = plugin_get_dyn_cb(arr); + dyn_cb->userp = ptr; + dyn_cb->type = PLUGIN_CB_INLINE; + dyn_cb->rw = rw; + dyn_cb->inline_insn.op = op; + dyn_cb->inline_insn.imm = imm; +} + +static inline uint32_t cb_to_tcg_flags(enum qemu_plugin_cb_flags flags) +{ + uint32_t ret; + + switch (flags) { + case QEMU_PLUGIN_CB_RW_REGS: + ret = 0; + case QEMU_PLUGIN_CB_R_REGS: + ret = TCG_CALL_NO_WG; + break; + case QEMU_PLUGIN_CB_NO_REGS: + default: + ret = TCG_CALL_NO_RWG; + } + return ret; +} + +inline void +plugin_register_dyn_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, void *udata) +{ + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + + dyn_cb->userp = udata; + dyn_cb->tcg_flags = cb_to_tcg_flags(flags); + dyn_cb->f.vcpu_udata = cb; + dyn_cb->type = PLUGIN_CB_REGULAR; +} + +void plugin_register_vcpu_mem_cb(GArray **arr, + void *cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb = plugin_get_dyn_cb(arr); + dyn_cb->userp = udata; + dyn_cb->tcg_flags = cb_to_tcg_flags(flags); + dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->rw = rw; + dyn_cb->f.generic = cb; +} + +void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_TB_TRANS; + + /* no plugin_mask check here; caller should have checked */ + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_tb_trans_cb_t func = cb->f.vcpu_tb_trans; + + func(cb->ctx->id, tb); + } +} + +void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL; + + if (!test_bit(ev, cpu->plugin_mask)) { + return; + } + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_syscall_cb_t func = cb->f.vcpu_syscall; + + func(cb->ctx->id, cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7, a8); + } +} + +void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL_RET; + + if (!test_bit(ev, cpu->plugin_mask)) { + return; + } + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_syscall_ret_cb_t func = cb->f.vcpu_syscall_ret; + + func(cb->ctx->id, cpu->cpu_index, num, ret); + } +} + +void qemu_plugin_vcpu_idle_cb(CPUState *cpu) +{ + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); +} + +void qemu_plugin_vcpu_resume_cb(CPUState *cpu) +{ + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); +} + +void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_IDLE, cb); +} + +void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); +} + +void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_FLUSH, cb); +} + +static bool free_dyn_cb_arr(void *p, uint32_t h, void *userp) +{ + g_array_free((GArray *) p, true); + return true; +} + +void qemu_plugin_flush_cb(void) +{ + qht_iter_remove(&plugin.dyn_cb_arr_ht, free_dyn_cb_arr, NULL); + qht_reset(&plugin.dyn_cb_arr_ht); + + plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); +} + +void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +{ + uint64_t *val = cb->userp; + + switch (cb->inline_insn.op) { + case QEMU_PLUGIN_INLINE_ADD_U64: + *val += cb->inline_insn.imm; + break; + default: + g_assert_not_reached(); + } +} + +void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, uint32_t info) +{ + GArray *arr = cpu->plugin_mem_cbs; + size_t i; + + if (arr == NULL) { + return; + } + for (i = 0; i < arr->len; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(arr, struct qemu_plugin_dyn_cb, i); + int w = !!(info & TRACE_MEM_ST) + 1; + + if (!(w & cb->rw)) { + break; + } + switch (cb->type) { + case PLUGIN_CB_REGULAR: + cb->f.vcpu_mem(cpu->cpu_index, info, vaddr, cb->userp); + break; + case PLUGIN_CB_INLINE: + exec_inline_op(cb); + break; + default: + g_assert_not_reached(); + } + } +} + +void qemu_plugin_atexit_cb(void) +{ + plugin_cb__udata(QEMU_PLUGIN_EV_ATEXIT); +} + +void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, + void *udata) +{ + plugin_register_cb_udata(id, QEMU_PLUGIN_EV_ATEXIT, cb, udata); +} + +/* + * Call this function after longjmp'ing to the main loop. It's possible that the + * last instruction of a TB might have used helpers, and therefore the + * "disable" instruction will never execute because it ended up as dead code. + */ +void qemu_plugin_disable_mem_helpers(CPUState *cpu) +{ + cpu->plugin_mem_cbs = NULL; +} + +static bool plugin_dyn_cb_arr_cmp(const void *ap, const void *bp) +{ + return ap == bp; +} + +static void __attribute__((__constructor__)) plugin_init(void) +{ + int i; + + for (i = 0; i < QEMU_PLUGIN_EV_MAX; i++) { + QLIST_INIT(&plugin.cb_lists[i]); + } + qemu_rec_mutex_init(&plugin.lock); + plugin.id_ht = g_hash_table_new(g_int64_hash, g_int64_equal); + plugin.cpu_ht = g_hash_table_new(g_int_hash, g_int_equal); + QTAILQ_INIT(&plugin.ctxs); + qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, + QHT_MODE_AUTO_RESIZE); + atexit(qemu_plugin_atexit_cb); +} diff --git a/plugins/loader.c b/plugins/loader.c new file mode 100644 index 0000000000..5de5cff8e3 --- /dev/null +++ b/plugins/loader.c @@ -0,0 +1,370 @@ +/* + * QEMU Plugin Core Loader Code + * + * This is the code responsible for loading and unloading the plugins. + * Aside from the basic housekeeping tasks we also need to ensure any + * generated code is flushed when we remove a plugin so we cannot end + * up calling and unloaded helper function. + * + * Copyright (C) 2017, Emilio G. Cota + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" +#include "qapi/error.h" +#include "qemu/option.h" +#include "qemu/rcu_queue.h" +#include "qemu/qht.h" +#include "qemu/bitmap.h" +#include "qemu/xxhash.h" +#include "qemu/plugin.h" +#include +#include "hw/core/cpu.h" +#include "cpu.h" +#include "exec/exec-all.h" + +#include "plugin.h" + +/* + * For convenience we use a bitmap for plugin.mask, but really all we need is a + * u32, which is what we store in TranslationBlock. + */ +QEMU_BUILD_BUG_ON(QEMU_PLUGIN_EV_MAX > 32); + +struct qemu_plugin_desc { + char *path; + char **argv; + QTAILQ_ENTRY(qemu_plugin_desc) entry; + int argc; +}; + +struct qemu_plugin_parse_arg { + QemuPluginList *head; + struct qemu_plugin_desc *curr; +}; + +QemuOptsList qemu_plugin_opts = { + .name = "plugin", + .implied_opt_name = "file", + .head = QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head), + .desc = { + /* do our own parsing to support multiple plugins */ + { /* end of list */ } + }, +}; + +typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **); + +extern struct qemu_plugin_state plugin; + +void qemu_plugin_add_dyn_cb_arr(GArray *arr) +{ + uint32_t hash = qemu_xxhash2((uint64_t)(uintptr_t)arr); + bool inserted; + + inserted = qht_insert(&plugin.dyn_cb_arr_ht, arr, hash, NULL); + g_assert(inserted); +} + +static struct qemu_plugin_desc *plugin_find_desc(QemuPluginList *head, + const char *path) +{ + struct qemu_plugin_desc *desc; + + QTAILQ_FOREACH(desc, head, entry) { + if (strcmp(desc->path, path) == 0) { + return desc; + } + } + return NULL; +} + +static int plugin_add(void *opaque, const char *name, const char *value, + Error **errp) +{ + struct qemu_plugin_parse_arg *arg = opaque; + struct qemu_plugin_desc *p; + + if (strcmp(name, "file") == 0) { + if (strcmp(value, "") == 0) { + error_setg(errp, "requires a non-empty argument"); + return 1; + } + p = plugin_find_desc(arg->head, value); + if (p == NULL) { + p = g_new0(struct qemu_plugin_desc, 1); + p->path = g_strdup(value); + QTAILQ_INSERT_TAIL(arg->head, p, entry); + } + arg->curr = p; + } else if (strcmp(name, "arg") == 0) { + if (arg->curr == NULL) { + error_setg(errp, "missing earlier '-plugin file=' option"); + return 1; + } + p = arg->curr; + p->argc++; + p->argv = g_realloc_n(p->argv, p->argc, sizeof(char *)); + p->argv[p->argc - 1] = g_strdup(value); + } else { + error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", name); + } + return 0; +} + +void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head) +{ + struct qemu_plugin_parse_arg arg; + QemuOpts *opts; + + opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, true); + if (opts == NULL) { + exit(1); + } + arg.head = head; + arg.curr = NULL; + qemu_opt_foreach(opts, plugin_add, &arg, &error_fatal); + qemu_opts_del(opts); +} + +/* + * From: https://en.wikipedia.org/wiki/Xorshift + * This is faster than rand_r(), and gives us a wider range (RAND_MAX is only + * guaranteed to be >= INT_MAX). + */ +static uint64_t xorshift64star(uint64_t x) +{ + x ^= x >> 12; /* a */ + x ^= x << 25; /* b */ + x ^= x >> 27; /* c */ + return x * UINT64_C(2685821657736338717); +} + +static int plugin_load(struct qemu_plugin_desc *desc) +{ + qemu_plugin_install_func_t install; + struct qemu_plugin_ctx *ctx; + char *err; + int rc; + + ctx = qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); + ctx->desc = desc; + + ctx->handle = dlopen(desc->path, RTLD_NOW); + if (ctx->handle == NULL) { + error_report("%s: %s", __func__, dlerror()); + goto err_dlopen; + } + + /* clear any previous dlerror, call dlsym, then check dlerror */ + dlerror(); + install = dlsym(ctx->handle, "qemu_plugin_install"); + err = dlerror(); + if (err) { + error_report("%s: %s", __func__, err); + goto err_symbol; + } + /* symbol was found; it could be NULL though */ + if (install == NULL) { + error_report("%s: %s: qemu_plugin_install is NULL", + __func__, desc->path); + goto err_symbol; + } + + qemu_rec_mutex_lock(&plugin.lock); + + /* find an unused random id with &ctx as the seed */ + ctx->id = (uint64_t)(uintptr_t)ctx; + for (;;) { + void *existing; + + ctx->id = xorshift64star(ctx->id); + existing = g_hash_table_lookup(plugin.id_ht, &ctx->id); + if (likely(existing == NULL)) { + bool success; + + success = g_hash_table_insert(plugin.id_ht, &ctx->id, &ctx->id); + g_assert(success); + break; + } + } + QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); + ctx->installing = true; + rc = install(ctx->id, desc->argc, desc->argv); + ctx->installing = false; + if (rc) { + error_report("%s: qemu_plugin_install returned error code %d", + __func__, rc); + /* + * we cannot rely on the plugin doing its own cleanup, so + * call a full uninstall if the plugin did not yet call it. + */ + if (!ctx->uninstalling) { + qemu_plugin_uninstall(ctx->id, NULL); + } + } + + qemu_rec_mutex_unlock(&plugin.lock); + return rc; + + err_symbol: + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + err_dlopen: + qemu_vfree(ctx); + return 1; +} + +/* call after having removed @desc from the list */ +static void plugin_desc_free(struct qemu_plugin_desc *desc) +{ + int i; + + for (i = 0; i < desc->argc; i++) { + g_free(desc->argv[i]); + } + g_free(desc->argv); + g_free(desc->path); + g_free(desc); +} + +/** + * qemu_plugin_load_list - load a list of plugins + * @head: head of the list of descriptors of the plugins to be loaded + * + * Returns 0 if all plugins in the list are installed, !0 otherwise. + * + * Note: the descriptor of each successfully installed plugin is removed + * from the list given by @head. + */ +int qemu_plugin_load_list(QemuPluginList *head) +{ + struct qemu_plugin_desc *desc, *next; + + QTAILQ_FOREACH_SAFE(desc, head, entry, next) { + int err; + + err = plugin_load(desc); + if (err) { + return err; + } + QTAILQ_REMOVE(head, desc, entry); + } + return 0; +} + +struct qemu_plugin_reset_data { + struct qemu_plugin_ctx *ctx; + qemu_plugin_simple_cb_t cb; + bool reset; +}; + +static void plugin_reset_destroy__locked(struct qemu_plugin_reset_data *data) +{ + struct qemu_plugin_ctx *ctx = data->ctx; + enum qemu_plugin_event ev; + bool success; + + /* + * After updating the subscription lists there is no need to wait for an RCU + * grace period to elapse, because right now we either are in a "safe async" + * work environment (i.e. all vCPUs are asleep), or no vCPUs have yet been + * created. + */ + for (ev = 0; ev < QEMU_PLUGIN_EV_MAX; ev++) { + plugin_unregister_cb__locked(ctx, ev); + } + + if (data->reset) { + g_assert(ctx->resetting); + if (data->cb) { + data->cb(ctx->id); + } + ctx->resetting = false; + g_free(data); + return; + } + + g_assert(ctx->uninstalling); + /* we cannot dlclose if we are going to return to plugin code */ + if (ctx->installing) { + error_report("Calling qemu_plugin_uninstall from the install function " + "is a bug. Instead, return !0 from the install function."); + abort(); + } + + success = g_hash_table_remove(plugin.id_ht, &ctx->id); + g_assert(success); + QTAILQ_REMOVE(&plugin.ctxs, ctx, entry); + if (data->cb) { + data->cb(ctx->id); + } + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + plugin_desc_free(ctx->desc); + qemu_vfree(ctx); + g_free(data); +} + +static void plugin_reset_destroy(struct qemu_plugin_reset_data *data) +{ + qemu_rec_mutex_lock(&plugin.lock); + plugin_reset_destroy__locked(data); + qemu_rec_mutex_lock(&plugin.lock); +} + +static void plugin_flush_destroy(CPUState *cpu, run_on_cpu_data arg) +{ + struct qemu_plugin_reset_data *data = arg.host_ptr; + + g_assert(cpu_in_exclusive_context(cpu)); + tb_flush(cpu); + plugin_reset_destroy(data); +} + +void plugin_reset_uninstall(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb, + bool reset) +{ + struct qemu_plugin_reset_data *data; + struct qemu_plugin_ctx *ctx; + + qemu_rec_mutex_lock(&plugin.lock); + ctx = plugin_id_to_ctx_locked(id); + if (ctx->uninstalling || (reset && ctx->resetting)) { + qemu_rec_mutex_unlock(&plugin.lock); + return; + } + ctx->resetting = reset; + ctx->uninstalling = !reset; + qemu_rec_mutex_unlock(&plugin.lock); + + data = g_new(struct qemu_plugin_reset_data, 1); + data->ctx = ctx; + data->cb = cb; + data->reset = reset; + /* + * Only flush the code cache if the vCPUs have been created. If so, + * current_cpu must be non-NULL. + */ + if (current_cpu) { + async_safe_run_on_cpu(current_cpu, plugin_flush_destroy, + RUN_ON_CPU_HOST_PTR(data)); + } else { + /* + * If current_cpu isn't set, then we don't have yet any vCPU threads + * and we therefore can remove the callbacks synchronously. + */ + plugin_reset_destroy(data); + } +} diff --git a/plugins/plugin.h b/plugins/plugin.h new file mode 100644 index 0000000000..641f006dd7 --- /dev/null +++ b/plugins/plugin.h @@ -0,0 +1,95 @@ +/* + * Plugin Shared Internal Functions + * + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _PLUGIN_INTERNAL_H_ +#define _PLUGIN_INTERNAL_H_ + +/* global state */ +struct qemu_plugin_state { + QTAILQ_HEAD(, qemu_plugin_ctx) ctxs; + QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX]; + /* + * Use the HT as a hash map by inserting k == v, which saves memory as + * documented by GLib. The parent struct is obtained with container_of(). + */ + GHashTable *id_ht; + /* + * Use the HT as a hash map. Note that we could use a list here, + * but with the HT we avoid adding a field to CPUState. + */ + GHashTable *cpu_ht; + DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); + /* + * @lock protects the struct as well as ctx->uninstalling. + * The lock must be acquired by all API ops. + * The lock is recursive, which greatly simplifies things, e.g. + * callback registration from qemu_plugin_vcpu_for_each(). + */ + QemuRecMutex lock; + /* + * HT of callbacks invoked from helpers. All entries are freed when + * the code cache is flushed. + */ + struct qht dyn_cb_arr_ht; +}; + + +struct qemu_plugin_ctx { + void *handle; /* dlopen */ + qemu_plugin_id_t id; + struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX]; + QTAILQ_ENTRY(qemu_plugin_ctx) entry; + /* + * keep a reference to @desc until uninstall, so that plugins do not have + * to strdup plugin args. + */ + struct qemu_plugin_desc *desc; + bool installing; + bool uninstalling; + bool resetting; +}; + +struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); + +void plugin_register_inline_op(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm); + +void plugin_reset_uninstall(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb, + bool reset); + +void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func); + +void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, + enum qemu_plugin_event ev); + +void +plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata); + +void +plugin_register_dyn_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, void *udata); + + +void plugin_register_vcpu_mem_cb(GArray **arr, + void *cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata); + +void exec_inline_op(struct qemu_plugin_dyn_cb *cb); + +#endif /* _PLUGIN_INTERNAL_H_ */ From patchwork Mon Oct 14 10:49:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176153 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4349163ill; Mon, 14 Oct 2019 04:01:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMT/UZLoCY11l4CMFDTwDp0Ud68Y9sNJV1To9da8uaEAgZlYGd3oK0Vlx03rsd+P5w6uXw X-Received: by 2002:a17:906:1542:: with SMTP id c2mr54267ejd.80.1571050888979; Mon, 14 Oct 2019 04:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050888; cv=none; d=google.com; s=arc-20160816; b=xYsola2zh81cSc5iLK1GdhKrNGFCypHxFXUhMR1ThcbUW0YaZtKrolsH7arySvhSDF TogflsjwH8siZmZU1LFOBbJfCuuaN8uK9ZKWaehZq7vX3ma66uLoL4y4u0bXMoaZ++VH 1BnW+/9L7LIgsj2JZ/J4rUN8X0iBMniOCpuYQu6DwpgRRy2y7barDN61uobd+F2wjBUl pAi/q/9Oc3RLPOPtqPrE0QaVwPf71sA+5B/cb9Yn8D16QVJeZz6DP7ZZaUGGtSmN6x8y P52MSoxohonH8FAj5NvB18eh9cYHAmJ5x2ZceaoRrjwTP2pDGxK/6CV5qC8cIHHctPc5 vu9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aWosiEmfAHwfRAkWSG4KOdORJMPLEdhWkH8ZZEz3mMs=; b=EzGTvLTxp76gKpcfmgXD1jq8KdqPz70QJwiD27JDM7vwl+VhRsiQjpeoVCDLSSsw3U 2jBVwAVkuswvJbjbhRN6WWVRgWaaQOIJtw10vq2Vj/8otsc5OWLErYO5Cizyr2G3jKC0 JsquqBY065Ke30GRLUkaTDnQPMW1NNeRj+1wDbVbtG7Xrcb0397ochfj0vHgSNuBA39u AcT1iX42rYQbvMxD8z03TN3dI+WauPOKL1XCJ3lCdMNiJTS6iL5bZlTxTJN2fi0URgnE xXBsahYIehUBJl1PNkobxx/OK06/P6O7/KuYscsm5NwxJ35rtQGDQ72Ruk/Elw6Gp/Bg Avwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="idegc3E/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h14si12217754edb.425.2019.10.14.04.01.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:01: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=fail header.i=@linaro.org header.s=google header.b="idegc3E/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy6R-0001tJ-Nz for patch@linaro.org; Mon, 14 Oct 2019 07:01:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44511) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvO-0007KH-9P for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvL-00064g-8N for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:01 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvK-00061v-8g for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:58 -0400 Received: by mail-wr1-x443.google.com with SMTP id j11so19161580wrp.1 for ; Mon, 14 Oct 2019 03:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aWosiEmfAHwfRAkWSG4KOdORJMPLEdhWkH8ZZEz3mMs=; b=idegc3E/yON+fcbsAWafyZpIBzED+7ij5Ab4MqeELd8RZxu6rxUCCerzhl4J6ULD9f cN6sKyl13dpm101o2C1PYLpnW/tdtWs0FudAeciTh3FA8Q7svD1fZJ6XnJx8sgLzKWzg utoo6Th0M69MixB8YN++XrEerPbahOXTx0OCxuiEQx/ipd8WPbk5TsL8qDm0YGFBSNqQ LIdA+8opQ9wEQ8AR4/fp3wg1D9l02VShwOClQxcYWr2v91aekfjoHK5hJumRz0gShU9M HRqumRMSbxSjhMlJq9v37lGdNQUQhhDf5djko2L7HiitflZkchKouSNEhKOGzHe5W0wc qtPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aWosiEmfAHwfRAkWSG4KOdORJMPLEdhWkH8ZZEz3mMs=; b=CFBJfZzBTT7RB1zIPyEzh6z4ovbx/tI1ND9BDyrQ46M6ke+FMhhhUfowuLBsJ4Dutj Y8AnVNnIhTRxNN4JZGP/SEEPoRSEXuItkLlONB2McCWxv1ZEXW6g5tNtrB/qsK7E/H1B 0lYSXN2hkAXFdso12SjThHihoFXH0hjyrt4DkLNKduuU12mb2/O3VHBPSdq+qO5QwIpd VfmOq5aNqvlclDU8QvnoFxcg1dB0M/FFyeaaWjnD5YNYOrmFjCje242Ft7Ablp4zbyJ2 ag4IUOcVqu/N5Hxo1nR4MlL4xMahREM+hT+jiyHLsza2d7HjX4zOG8FDJAJLjk/lmmLW Bn5A== X-Gm-Message-State: APjAAAVI9FYy7ywQppwQZKQIDdQ7nnwHPD9dxq9qtxwmd8Zecn82SYBn cMGfJ7HwWqp8w1OV93IXO6HznQ== X-Received: by 2002:adf:a4cf:: with SMTP id h15mr24981868wrb.222.1571050196562; Mon, 14 Oct 2019 03:49:56 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e15sm19605792wrs.49.2019.10.14.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1F2D81FF87; Mon, 14 Oct 2019 11:49:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 09/55] plugin: add implementation of the api Date: Mon, 14 Oct 2019 11:49:02 +0100 Message-Id: <20191014104948.4291-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" [AJB: split from the core code commit] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - add qemu_plugin_ram_addr_from_host - remove _haddr api calls v5 - remove stray #if 0 --- plugins/Makefile.objs | 1 + plugins/api.c | 287 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 plugins/api.c -- 2.20.1 diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs index 58940335bc..95baabf3d2 100644 --- a/plugins/Makefile.objs +++ b/plugins/Makefile.objs @@ -4,3 +4,4 @@ obj-y += loader.o obj-y += core.o +obj-y += api.o diff --git a/plugins/api.c b/plugins/api.c new file mode 100644 index 0000000000..3de05719a8 --- /dev/null +++ b/plugins/api.c @@ -0,0 +1,287 @@ +/* + * QEMU Plugin API + * + * This provides the API that is available to the plugins to interact + * with QEMU. We have to be careful not to expose internal details of + * how QEMU works so we abstract out things like translation and + * instructions to anonymous data types: + * + * qemu_plugin_tb + * qemu_plugin_insn + * + * Which can then be passed back into the API to do additional things. + * As such all the public functions in here are exported in + * qemu-plugin.h. + * + * The general life-cycle of a plugin is: + * + * - plugin is loaded, public qemu_plugin_install called + * - the install func registers callbacks for events + * - usually an atexit_cb is registered to dump info at the end + * - when a registered event occurs the plugin is called + * - some events pass additional info + * - during translation the plugin can decide to instrument any + * instruction + * - when QEMU exits all the registered atexit callbacks are called + * + * Copyright (C) 2017, Emilio G. Cota + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "qemu/osdep.h" +#include "qemu/plugin.h" +#include "cpu.h" +#include "sysemu/sysemu.h" +#include "tcg/tcg.h" +#include "trace/mem-internal.h" /* mem_info macros */ +#include "plugin.h" +#ifndef CONFIG_USER_ONLY +#include "hw/boards.h" +#endif + +/* Uninstall and Reset handlers */ + +void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) +{ + plugin_reset_uninstall(id, cb, false); +} + +void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) +{ + plugin_reset_uninstall(id, cb, true); +} + +/* + * Plugin Register Functions + * + * This allows the plugin to register callbacks for various events + * during the translation. + */ + +void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INIT, cb); +} + +void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXIT, cb); +} + +void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *udata) +{ + plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], + cb, flags, udata); +} + +void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) +{ + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, imm); +} + +void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *udata) +{ + plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], + cb, flags, udata); +} + +void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) +{ + plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], + 0, op, ptr, imm); +} + + + +void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata) +{ + plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], + cb, flags, rw, udata); +} + +void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm) +{ + plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], + rw, op, ptr, imm); +} + +void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_tb_trans_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_TB_TRANS, cb); +} + +void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb); +} + +void +qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_ret_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, cb); +} + +/* + * Plugin Queries + * + * These are queries that the plugin can make to gauge information + * from our opaque data types. We do not want to leak internal details + * here just information useful to the plugin. + */ + +/* + * Translation block information: + * + * A plugin can query the virtual address of the start of the block + * and the number of instructions in it. It can also get access to + * each translated instruction. + */ + +size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb) +{ + return tb->n; +} + +uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb) +{ + return tb->vaddr; +} + +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx) +{ + if (unlikely(idx >= tb->n)) { + return NULL; + } + return g_ptr_array_index(tb->insns, idx); +} + +/* + * Instruction information + * + * These queries allow the plugin to retrieve information about each + * instruction being translated. + */ + +const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn) +{ + return insn->data->data; +} + +size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn) +{ + return insn->data->len; +} + +uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn) +{ + return insn->vaddr; +} + +void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn) +{ + return insn->haddr; +} + +/* + * The memory queries allow the plugin to query information about a + * memory access. + */ + +unsigned qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info) +{ + return info & TRACE_MEM_SZ_SHIFT_MASK; +} + +bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_SE); +} + +bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_BE); +} + +bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_ST); +} + +/* + * Virtual Memory queries + */ + +struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, + uint64_t vaddr) +{ + return NULL; +} + +bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr) +{ + return false; +} + +uint64_t qemu_plugin_hwaddr_to_raddr(const struct qemu_plugin_hwaddr *haddr) +{ + return 0; +} + +/* + * Queries to the number and potential maximum number of vCPUs there + * will be. This helps the plugin dimension per-vcpu arrays. + */ + +#ifndef CONFIG_USER_ONLY +static MachineState * get_ms(void) +{ + return MACHINE(qdev_get_machine()); +} +#endif + +int qemu_plugin_n_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return get_ms()->smp.cpus; +#endif +} + +int qemu_plugin_n_max_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return get_ms()->smp.max_cpus; +#endif +} From patchwork Mon Oct 14 10:49:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176149 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4345145ill; Mon, 14 Oct 2019 03:57:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwB16yVcwg9uPOtHdNKG137EtsWtUazWPe1lgmrU+PXgNz2KSmp4PGrJ6UDPuaWCBJti5iU X-Received: by 2002:a05:620a:1328:: with SMTP id p8mr28047929qkj.481.1571050648706; Mon, 14 Oct 2019 03:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050648; cv=none; d=google.com; s=arc-20160816; b=Styc17/odjQAVlQn5fZigFs0GFaQ4UBfMq65Gb11587f8zLLAmTYTSk8Fs/QQKPjUt iXC/jHx1lgxzW3NsWDlC+NAuVnS7/XIo1R4Tl22Sq4K8NieR52pHx1OxsOHTs5UPzROd /SAUFK6I5uqxj2A0fq6ZNyeD/CxNSx/uI017gU0gdh/JrvxXh+Pv23G84gvdjucZ4sBM VIeK/+p661tyE8rRw0C8bg3wpLH54f98HsgmsE+D935Z8oCOAuTSSc+Re+R8aijXC8qB qMlgQpYR+poYGTqRWqSd2FADcAEiOz9GPp7G0+uYGRw+XAEdq9+66wrcFiXYHc1a9N19 JiOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4u0DAyRPQyWfOOgltou2F/pxj6T1sopcMhD6CsKad8c=; b=aEhTHyVpLkGeE2opA6gc7A165bjtSja3nPPMhC1zCG2CoiDfNXapOwIyWEB9EASj+w Yp3TvjTjBSmh7uc3DgE2pF+0q88gKMgrefLCzlEQAewLk4tHlbNLIJvK7LBBvG8nTeW8 PTENhuQwO6sHED6WZnfumZSmfLvgSm4Q5dQE9IXfhmBWvtqXjrVBNajHISFKVWmahiuQ eIkNc5+FkhhHcA7rvPxk8QF84oF53QM0cGPNfOlGrFMmrNBr2XzuQjZ+0jSY8LFRUScK PLlMWiX1ziHQgRuSYgoKqUJoRvzxvwjBFCtVTBpFa8FZbuUmDJwsxxKI0iM3h+UfHfpy 4mnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OWJPvOmU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m35si16786681qtd.389.2019.10.14.03.57.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:57: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=fail header.i=@linaro.org header.s=google header.b=OWJPvOmU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2Y-0006KE-Ui for patch@linaro.org; Mon, 14 Oct 2019 06:57:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44512) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvO-0007KJ-9h for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvL-000654-EH for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:01 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvL-00063Z-82 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:49:59 -0400 Received: by mail-wr1-x444.google.com with SMTP id y19so19160229wrd.3 for ; Mon, 14 Oct 2019 03:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4u0DAyRPQyWfOOgltou2F/pxj6T1sopcMhD6CsKad8c=; b=OWJPvOmU6vFfD4sBY0QJ9GlIZZOKF04Wio5sifydOP/5V9X5RGZyB+1jiPsshDX5QR zuTW2t5g3aV3LBSWzG3n1FQm8/sLgZjrU6F1O7s5yHT1VCzb1vaQHH6ZsIUW0sQreY3l Ohcr5plk8v/Wqixo4qHqUHegjFFN0LASpL+My4BaMKvByvJq3A/QMMxLdn9/+QygFXfP LWYUeVcHfMd6hXn3jzEx5lRuInnXlO/1zcTjRPb2IRzOyEsL14Rn/DkXb4r927xFiFOI WZi/4L6XxeRijepEEFZwIlZ+4o2WKatDWjnXt04u/sCCfWDPl/V0VmCBgmeW5U0fVdRD crhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4u0DAyRPQyWfOOgltou2F/pxj6T1sopcMhD6CsKad8c=; b=m3pVWXtpU0eQqdA9YI0mH4uqFZEOMx7veLihOj8Oc2KSiC/bxSYuBIZ/pF4pwU9Gdl oDaXFV/t7Q0FovCsAX+6nULXvaq/njQINtoh/3nagAnRSyPpe+yiqMzrXOAT6SJB0CKz aiTGx0oH+60efAmOAKbGQU8xmhSmhlBXlHwflZnX4+XGgsSw+y1xK5YrXf4n/AsHgYbF pk837qlwGemXHmtfVg++g8oRHVQTHWnyXot9YGqX/UyIzg+8qKdDgDBNebPwe49WG+Cw dr+9mP/239tmO8gWsio/K6kqHy/ggkkccnbcxWN6n+B+g95st2DkrMlUbcvTsbtLb9Z4 dvuw== X-Gm-Message-State: APjAAAWbZly3VDQsy2Bl7Bb1V7uookNXht9VGwRiTHIHBzNDgJAzBrqj OGPNJGORpl19Q/D5JApPEsT3rQ== X-Received: by 2002:adf:ba07:: with SMTP id o7mr26366823wrg.50.1571050197738; Mon, 14 Oct 2019 03:49:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l9sm15311790wme.45.2019.10.14.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4D0891FF98; Mon, 14 Oct 2019 11:49:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 10/55] queue: add QTAILQ_REMOVE_SEVERAL Date: Mon, 14 Oct 2019 11:49:03 +0100 Message-Id: <20191014104948.4291-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This is faster than removing elements one by one. Will gain a user soon. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/qemu/queue.h | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.20.1 diff --git a/include/qemu/queue.h b/include/qemu/queue.h index 73bf4a984d..4764d93ea3 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -420,6 +420,16 @@ union { \ (elm)->field.tqe_circ.tql_prev = NULL; \ } while (/*CONSTCOND*/0) +/* remove @left, @right and all elements in between from @head */ +#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do { \ + if (((right)->field.tqe_next) != NULL) \ + (right)->field.tqe_next->field.tqe_circ.tql_prev = \ + (left)->field.tqe_circ.tql_prev; \ + else \ + (head)->tqh_circ.tql_prev = (left)->field.tqe_circ.tql_prev; \ + (left)->field.tqe_circ.tql_prev->tql_next = (right)->field.tqe_next; \ + } while (/*CONSTCOND*/0) + #define QTAILQ_FOREACH(var, head, field) \ for ((var) = ((head)->tqh_first); \ (var); \ From patchwork Mon Oct 14 10:49:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176148 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4343889ill; Mon, 14 Oct 2019 03:56:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKkuXIxJAAEG5GblkvM8i5n/z8QBcVmMeD17T3UMM0JCCzJTKOgUty5oFr8dDkt6YVKuud X-Received: by 2002:ac8:740b:: with SMTP id p11mr31253078qtq.71.1571050564807; Mon, 14 Oct 2019 03:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050564; cv=none; d=google.com; s=arc-20160816; b=BmGSAeCPQKqCfEge8Dcq5Am+Dfljke8JJddq+oqvaD21pwlJse+evkXSUc0XSQYvdx BoQv6OcbcI0svukVgmXAfou1ofHGY25n9nA5hOMQq4vSFwEP/RpU+FFQn39ZLDm5bzOm HeEergq8AcNY+MmXeZBktO+eaN42ejcRIbzK8zeB0TdsvTjiYyfery9pJoBoFiuWXjhp pgGRvmOhiIw9kkqeZviaPgLOVXgx+Vps31rAnAtOR5PZuaKp+f0mxi9sE6Yh4ZH9kCQI caLD8J7wGCQltSl00Y3c8QcgqZdvhKo5ioXa5cm1iI9BPdT94z38gW1UG3oxj0oEbR+d 2ShQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=E4BbTLUhgH0gtmNgtyAxk8tGYN84mDNVyOEt1ck3Wbk=; b=EhccCNdYNDBttn8fX3EXadNZA1h1hY3k266bxUYDTGgezrOefxZiNh7svJu+C/7F4D 71Xx9/sD5IXA4ljFLU6aiddX7JPTau7U4zGiU5yFk41hXSO98D75VCQ3ESpocx+vFPQq KW4ZRX/NU3UC6zaFlCaN75xtbwfgsBDFF3vr8OG4Yy28PLnpwRKKCZxe4p78B70dmMl8 vvRurEo+EYyBHlR5PgbnZD96uDf8ZjOlqgGBxII1r9biCEfBOcbrvAqpBecpuJ4ps+vO 2cNOwD6ySgXeK1L/Gc3Y7mEL39w704IZ1Fzrv7SxEvN3ziGP29qW9G5Eq/mkm5v1NpW2 GnhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XGLIPR6X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x25si19469849qtm.32.2019.10.14.03.56.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:56:04 -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=fail header.i=@linaro.org header.s=google header.b=XGLIPR6X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy1C-00041K-Qv for patch@linaro.org; Mon, 14 Oct 2019 06:56:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44565) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvP-0007OU-S9 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvO-00069H-GY for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:39768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvO-00064l-9R for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: by mail-wr1-x442.google.com with SMTP id r3so19147941wrj.6 for ; Mon, 14 Oct 2019 03:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E4BbTLUhgH0gtmNgtyAxk8tGYN84mDNVyOEt1ck3Wbk=; b=XGLIPR6Xsw7LwxRHkhq6p6RCCGAAm7ICoPIEhGXbcTHBpVYqraazUia9Pj2fIzwWpg oM3eR8Mv5FfnFtsK0Jnu86/HgrT+H3PE/rzFuny+t0WlLcDidPh84I9aTeq8UTy4e7I+ eBBVMsS6JniwfLc/ZdRc4DrZVl0QnNX+VUIECqSCkRDKZdMe28TmmscKR5QYkPkeLomn NrbPBHyApHqpaJmrQpvpjKYRBnq0ohdlpMUUR6IFi/aOzC08nGss3BF/hgcS+yOCdiEP wBtHCC6Vzp27CT2eGWFBOsIqoddYD5M11c+85uzcjTwAF2vjae6aP2KlFmPvtvZJsCHk uW5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4BbTLUhgH0gtmNgtyAxk8tGYN84mDNVyOEt1ck3Wbk=; b=fD5tvOPo/oVZ//0mt/hS8MId1CMHVK26aVCvO9F2iLfkiU474dLpN1fCZbzBXqru4+ 4IhglMvlQoEg2rn42JqK8tY0PQY6Cba6zmgjVnZRlbiz6GOW+2l3dRxpBECINkGDsFIo MAmnF07juhl+pr9P5bxy73KoAotvE1RYED6noa3kR+YsXeUMRcCyDluNRAghkZ7E1NQR 0bnHIpSukRFFPxoXVjpPr7GfXbObxi2gKXmwziXTdi5iutNcTpLvXp8HGdI7pJaa2Iie Vz7G+f0sx+3AG3OgtQT0LrVOp2jWnm50lv26qqREobKNHa2SuwyCsryVDy4fTe+5TbPU Zg1g== X-Gm-Message-State: APjAAAVx2uyfdiAG+972mhefADA0pT+INVsYKUd8sW18UMdzm1NtK+fn HDZpal0j/rGUKs8xYCokXgsAiQ== X-Received: by 2002:a5d:638b:: with SMTP id p11mr18986022wru.372.1571050198810; Mon, 14 Oct 2019 03:49:58 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y13sm26345055wrg.8.2019.10.14.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 810321FF99; Mon, 14 Oct 2019 11:49:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 11/55] cputlb: document get_page_addr_code Date: Mon, 14 Oct 2019 11:49:04 +0100 Message-Id: <20191014104948.4291-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Suggested-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/exec-all.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 49db07ba0b..6352316de1 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -487,7 +487,15 @@ void mmap_lock(void); void mmap_unlock(void); bool have_mmap_lock(void); -static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) +/** + * get_page_addr_code() - user-mode version + * @env: CPUArchState + * @addr: guest virtual address of guest code + * + * Returns @addr. + */ +static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, + target_ulong addr) { return addr; } @@ -495,8 +503,18 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} -/* cputlb.c */ -tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); +/** + * get_page_addr_code() - full-system version + * @env: CPUArchState + * @addr: guest virtual address of guest code + * + * If we cannot translate and execute from the entire RAM page, or if + * the region is not backed by RAM, returns -1. Otherwise, returns the + * ram_addr_t corresponding to the guest code at @addr. + * + * Note: this function can trigger an exception. + */ +tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr); void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, target_ulong vaddr); From patchwork Mon Oct 14 10:49:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176152 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4347231ill; Mon, 14 Oct 2019 03:59:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCWKTj1oQcxj7Fk3mMf8q+1e8avnaHE1yrxnJUDta+h5O4CEIZAejdqE8uyjOGwMnDg3hN X-Received: by 2002:ae9:e413:: with SMTP id q19mr27382521qkc.404.1571050797305; Mon, 14 Oct 2019 03:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050797; cv=none; d=google.com; s=arc-20160816; b=NvNIRigW0qLWIA9/amjNYBSbDcvI6gNkIblP31RCpxf92eDl25i6vHTBSIbnck3IDN nZlQcwYd26OQX9UC+/25nuWTJ2Iu55Odii5N3E5xXxTtl5jxRSrhl4cuBiNxjO/tqLli gOBrzf0L+Jq5Lm7OpCWEV6hMMGEil8eryWsffp/xnCghPpeGoG9CLODS6MsFJuOKyjQ2 jqgMVT55okBPKjRGT57Y6xwOD4lbBOJgh2a3LZ4scQNZQKaA0SW+e/qknqsEU1Em/A4l BhH7on/YfFH6nPsz26QuZ07lyP3V4QCjmVMYnLoMVa+tdSFjuXE+bmY3c/QiY7AkTZop M+Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WimkXAC+2b42fYTOEN4XhY4stl9WHM4N3+w4ZNeNDzc=; b=1H4yaFRVWEJs+gM58gc0O4Kmb3SHZJGxIbiVEd/5Z2r2JW5jbhUCOUi/owRpA7J9DK ikd7NP2wpSGCkjT8MtRQLz311kwUBXSJPyUUcPwnGaIRKimVnz0OZcNDOHtijD0Th92H vaPzqirJ6HO0joJLFufWpogz3/tgwbRUyO+Qe7Cddx4m+R34x9yMQrmMfaXZAnV2bUlF rlII3JNigRQCRw5nMWLtT84VEU4W+dacENf5wORtOy9ZAzsfAo2rIhcIZ00adfo/zyl/ QiaFk4M/5Bgiyj2de647H9Z4kOI3hqZzZeLyWUuKCFa13EqLlD9zfj3kDbQl6Y+kzxr2 1n5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hPXzwCdm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x2si16775881qkf.367.2019.10.14.03.59.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:59:57 -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=fail header.i=@linaro.org header.s=google header.b=hPXzwCdm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy4y-0008KQ-7L for patch@linaro.org; Mon, 14 Oct 2019 06:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44566) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvQ-0007PM-0U for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvO-00069U-JJ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvO-00065t-A6 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: by mail-wm1-x341.google.com with SMTP id 3so16262930wmi.3 for ; Mon, 14 Oct 2019 03:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WimkXAC+2b42fYTOEN4XhY4stl9WHM4N3+w4ZNeNDzc=; b=hPXzwCdmON6epOUgNhdwW3Qk8pK0p6/+ZG/O257wOMqPy/3J0JKVvJKtS4CF3+EbEN P8ixXU0W3HtbuwxABeexE++Qv1/l5LM6zs2ABeiaWb+U6rb63ejDv5uNYQQYAwg48evP 5jFl5axmQsgnvePslNz0bXT6nntEkCNzeQzoEiiV7ipP99lyoTAkEZH7Q7QJqieaqvVN 534WtadIE+XmJ6GunSYzjLlAAX9B0VJuSzsAEkcwBNa4+N0MluHpwasZs43BsBB7qDR0 eg8WV5sB4HNok6bEuHM0Bp056TEOdaYi0/9Yn8KcPKEhYO1XFFpxu7rMTpaPLgrcmdUo gIjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WimkXAC+2b42fYTOEN4XhY4stl9WHM4N3+w4ZNeNDzc=; b=BJqSOQZw5EFL0yCr79tewcFqK8u7Wrc+E9Dgy9x3+AKCKMHTO01kKvzY6rhW6fx3vK yNbkqfb+eqk9drngJsOOfhriwW/ag2JgCdYv37DCZN10mjyKf0/zlXNe73SR88d8nt+b PoSzEVsX0UNo/IeGMDKOosP8arfbO+DTTjaPPhZIQejTqT5ftLl4IJyeqZMxCwSyDjMQ 3NXAvm/1RwkL/VQwhkt7PQwKbR6tFCgxVqizh+n4vwXmXL/7yUgB8PqlXI+IzgxO5oUr KOkTxfUSYDstGlVBWvEaCbBBQlC0W10M8oIFy0LFozG8gslPi5f1OXBP9inRS/bGlxFa C8Eg== X-Gm-Message-State: APjAAAWeGBbiBlOeopW7Xp7Nni1IF+4afmXQJNV8s49LZNRgUBDtY4iZ QTaolcpLfZsfgT1JdZi1bTVtJA== X-Received: by 2002:a1c:7401:: with SMTP id p1mr13844399wmc.144.1571050199353; Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v20sm16777480wml.26.2019.10.14.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BDA6C1FF91; Mon, 14 Oct 2019 11:49:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 12/55] cputlb: introduce get_page_addr_code_hostp Date: Mon, 14 Oct 2019 11:49:05 +0100 Message-Id: <20191014104948.4291-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This will be used by plugins to get the host address of instructions. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/cputlb.c | 14 +++++++++++++- include/exec/exec-all.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 1210d8f243..9cf9e6455e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1051,7 +1051,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, * NOTE: This function will trigger an exception if the page is * not executable. */ -tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) +tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, + void **hostp) { uintptr_t mmu_idx = cpu_mmu_index(env, true); uintptr_t index = tlb_index(env, mmu_idx, addr); @@ -1077,13 +1078,24 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) if (unlikely(entry->addr_code & TLB_MMIO)) { /* The region is not backed by RAM. */ + if (hostp) { + *hostp = NULL; + } return -1; } p = (void *)((uintptr_t)addr + entry->addend); + if (hostp) { + *hostp = p; + } return qemu_ram_addr_from_host_nofail(p); } +tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) +{ + return get_page_addr_code_hostp(env, addr, NULL); +} + static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, CPUIOTLBEntry *iotlbentry, uintptr_t retaddr) { diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 6352316de1..ba2f501f0f 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -22,6 +22,7 @@ #include "cpu.h" #include "exec/tb-context.h" +#include "exec/cpu_ldst.h" #include "sysemu/cpus.h" /* allow to see translation results - the slowdown should be negligible, so we leave it */ @@ -499,6 +500,26 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, { return addr; } + +/** + * get_page_addr_code_hostp() - user-mode version + * @env: CPUArchState + * @addr: guest virtual address of guest code + * + * Returns @addr. + * + * If @hostp is non-NULL, sets *@hostp to the host address where @addr's content + * is kept. + */ +static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, + target_ulong addr, + void **hostp) +{ + if (hostp) { + *hostp = g2h(addr); + } + return addr; +} #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} @@ -516,6 +537,23 @@ static inline void mmap_unlock(void) {} */ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr); +/** + * get_page_addr_code_hostp() - full-system version + * @env: CPUArchState + * @addr: guest virtual address of guest code + * + * See get_page_addr_code() (full-system version) for documentation on the + * return value. + * + * Sets *@hostp (when @hostp is non-NULL) as follows. + * If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp + * to the host address where @addr's content is kept. + * + * Note: this function can trigger an exception. + */ +tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, + void **hostp); + void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, target_ulong vaddr); From patchwork Mon Oct 14 10:49:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176181 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4381913ill; Mon, 14 Oct 2019 04:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxotDg5xohxWQBosckHbyggHJtJAwefeq5Fp4sIhKGT38O8wYJ+hcn8Qvsv7YNAKWnzMZWi X-Received: by 2002:a17:906:448e:: with SMTP id y14mr28583306ejo.136.1571052586322; Mon, 14 Oct 2019 04:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052586; cv=none; d=google.com; s=arc-20160816; b=i/tigBVnX24EhS03+atpPQFkyd1J5f0m5+z7Q6v14GekrZrsALV21EfUFb35IbpVcv ZEq4oEW53tDjJVnxYNC8lRLqNUyNFtOJmF+pSIScv8jAMlF2GKqoaT6GC7TgISpPvtU2 RHAl8A9tFz4mvsTa2SmrnSUkeZMibs0SUpsVHDak5CWpuO9e7r9wHUoo+1nk6P/xj2vO 3O3I7Es/bOAfeqrRdov9g0sIAjpDLBtW+DCeNr1XTiXsnXLzvDRNS8G8TCMRCHSvDHCS 8/rMa5dhCJnfAZ74s1nMk/0z4fvXdwquweiEdkoJ+k8zRLhVAnINj0ToL+o4vNckuSdz 7Izg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eKrMpcgiWZC+DVZc7vkQy9WeCAb7Sz4gQtueyAwrb/8=; b=oVbKycCZ2AKTO3D+CQmqHNythkRogRAzSFI2KP1KV0KoqIfTX21g19L5gCjUncOc7r cTtJQdW8OxnUHouwjUV7V2o6TpKcOZlSw/cwtWrlFzlguR3+8OO8bZ+SOZfMKpiY4I9Y PH5So5hz4XDQwv7r1sJ2ERNNxsr+Z3LOS/5xisPqQw1cNzeX07BVrqREG1v5Nx68QPuI 53P0F9K6JIzlivhtDStDVCN3+1MyHXKP31b+EI3I7zPw2NAGs+SBgKCaVeyhmhNc3r7G SMgBQDUUi8E+oQBWYrJ3ZhhxTmlZxqobpBcE+0JaPlX/Qz3l4BsKQVeOl/cjZbNceRhR 0jWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D7Ojxmkw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id op4si10837389ejb.77.2019.10.14.04.29.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:29:46 -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=fail header.i=@linaro.org header.s=google header.b=D7Ojxmkw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyXo-0000r9-Mx for patch@linaro.org; Mon, 14 Oct 2019 07:29:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45550) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2E-0006mz-Ny for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy2D-0005FR-Hj for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:06 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:56160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy2D-0005E3-Bo for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:05 -0400 Received: by mail-wm1-x342.google.com with SMTP id a6so16737470wma.5 for ; Mon, 14 Oct 2019 03:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eKrMpcgiWZC+DVZc7vkQy9WeCAb7Sz4gQtueyAwrb/8=; b=D7Ojxmkw4cvmOzKkado6gVVj2DOcKqQissrY8svyjqVXwvgtogHyBPZBopxgQbpWiN rp2Mij1G96sxQm80gyLWoCf+iSDW3nJqHsONi3vCG1C1B7pEq/Fy2lQbYhPrmtxjlks8 9rtS/5at8YuKIMOsl958FpdIBkSEvZPA/xcFNxogInaRFnv5TFPHrWFwhXIPUl3PPL1O tAFKGuHk/qaVqWZ65zuljf+qEggzaY7G3qr837zzN2OQ+y1aUAQAQKataHqxFa3d/QcY FClQW7HOUExAbFgUJarAet+Pdk9KGTKyfuSekI8NqYGotxbckowgkgK3+vSub0HAcYdx dmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eKrMpcgiWZC+DVZc7vkQy9WeCAb7Sz4gQtueyAwrb/8=; b=I5COyhTcDDW+IQinW03Bgsk0MD6n3KGXAqbsFdScOo+7wBaITbXIS/hQjSrEH1S4E5 aV2KwC22PVM2asUAz8BNXjCng5AkbA5C6uTPvgWUrxox+MqAIesFPMHYCCqu+QkDRCNz Wtq+ztYsKBn1vEmVpOjDHNJMdyXfKGq4rp1EyczcpLWJZM87/oJ8zdtcxOZ08C0HIwu6 ldDp9AyOePBWgJPERY4b6D0E5QxsZcHln5a+I5mCoXRhAyK5hmGiD+fPcYyuB0IDqPma U8Z8iPXHqxKjBRMHSDRv2ornMHRFqxEeFVuL//HjiMbJbaXoPpidHq5r8CYvvvjKphat f0MA== X-Gm-Message-State: APjAAAUMblsIfbw3lRgRt7vj7Juc3ql6hUfH3XuyTyCjmImDmFpDqHFT 6Hc/zH9n/ClD3FhmylWi0eO/cA== X-Received: by 2002:a1c:804d:: with SMTP id b74mr14868065wmd.170.1571050624091; Mon, 14 Oct 2019 03:57:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r2sm28759471wrm.3.2019.10.14.03.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:57:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EF01B1FF9A; Mon, 14 Oct 2019 11:49:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 13/55] tcg: add tcg_gen_st_ptr Date: Mon, 14 Oct 2019 11:49:06 +0100 Message-Id: <20191014104948.4291-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Will gain a user soon. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- tcg/tcg-op.h | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index e9cf172762..7c778f96f3 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -1249,6 +1249,11 @@ static inline void tcg_gen_ld_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) glue(tcg_gen_ld_,PTR)((NAT)r, a, o); } +static inline void tcg_gen_st_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) +{ + glue(tcg_gen_st_, PTR)((NAT)r, a, o); +} + static inline void tcg_gen_discard_ptr(TCGv_ptr a) { glue(tcg_gen_discard_,PTR)((NAT)a); From patchwork Mon Oct 14 10:49:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176191 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4391667ill; Mon, 14 Oct 2019 04:38:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2+SdQLDYpQeBmU1JgEeggH4o+VGC8B4oAPAoMPL2EXQdE/ETqUq8Tu1UCa5bNAsQgf6X6 X-Received: by 2002:a05:6402:2028:: with SMTP id ay8mr27569533edb.273.1571053105576; Mon, 14 Oct 2019 04:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053105; cv=none; d=google.com; s=arc-20160816; b=UAiSMFKPq7zk6Ph7aDNKIrAZ4/X8ZdQ2JtuqwpW0PXvkIfV1tHY8cepEHDT/2ix5Uq iSBoS8friG7CXilv2O+JV7MptZm5vSoTgVZvs1mN71rWjuOsfdovEkM0HtVWf4DyAATJ FHjGdxTLQNEjQyZqD7Ey5u38uB36JfHSjyPmy6iBIiF5BxaFdckgf85aGalHbVViLzv6 0MfL/mY1gzTPxsgnBQuj/Nv1biWsEVEDLvl2fRyh6wshB/esK0LQzldSbn0gmT7XKLZe DyMJyXJdy4HVObLgO7DHR/e/cQ6dQpzmIi7kLMh0+PCquK4Ughfo6kVMSsYNedsd3mV3 4fQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sN+1PGMlfbnxZNbnAfEb5019UmDYnZdg3C/aPcdYgxg=; b=k0T0WkEL9jCAnRx/jzXwqeh7W9QArp/5GtmI9c+o/o/uicwzYKetlHBapWt7i696zp vq5yFKeaakbX8ZMgIztP5nXcOVefO5p74roZwBT0uYAYuiNV2M78dQsvyQOwAKjgVqvl PM/P959Scyg64YpTMHm5WCP9ZCOb9WCmxz89y4UlHqVojJRECl9/Vm3MdvqqsgKFvbEW DYzMmzHqvFwzNM5gKfKpiMJErohjDyVX3d4zJNnyASYrCUDCWBy5ptWLcm2JjHvzuRBl BDxAtCgUSVDjJIKzZO9nXtmODYUTE3aipLefCRUSJ4BaJox1DZFuktcG0tCPqPso0Nk8 6OUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fb2Vm8VD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v5si13281730ede.126.2019.10.14.04.38.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:38:25 -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=fail header.i=@linaro.org header.s=google header.b=fb2Vm8VD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJygC-00018k-1b for patch@linaro.org; Mon, 14 Oct 2019 07:38:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45580) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2H-0006oN-KA for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy29-0005Az-TZ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:09 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:40117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy29-00058r-H9 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: by mail-wr1-x42c.google.com with SMTP id h4so19187784wrv.7 for ; Mon, 14 Oct 2019 03:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sN+1PGMlfbnxZNbnAfEb5019UmDYnZdg3C/aPcdYgxg=; b=fb2Vm8VDIQpNzqKBxPbh5GBCYmSoON55q5FpS3LLdH/xr9uvn7ULnIYuZIqTRA7wx/ rcdx8BybmM9rDvboPpE/i1YpbKKqWvGUJwBnfOl3SS4nEqppqBDmIw7Bbyk3FQ6n52qr 6Zp3bLxbz8mP7t0cNaruwc+YncFv3yQX4jLvrqzfU01WUftOjD3BXZ3F21Gg6oN8J8Tn gKkUk8xG94ulDXUtSV3vFyn69P09eCECofFs+lorqyad+k2ISjA8eDFsECoiIZRzCX9f OXgoF3tCZrOF1WYvTVENjDvY4rtsucJFhaU+l9NzZBgO+aiB2EJ+z3wdaAJ2M4r5p4qc BeBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sN+1PGMlfbnxZNbnAfEb5019UmDYnZdg3C/aPcdYgxg=; b=PCn8oDxfsbz8+dSMfIdHDoIvWPegmi2E2dbwJ5PM/NWfc/2L+lUYN5AvFF2jmBF0EV 6xboMfABG3lYXaJk3ADiyDzeHlZG6hf1jMAMsLltZ1bkDF0ZNXjUXr16OEHtoDuKEnwb qGWuza4aOnLlJ8ZRwzt7PRCMP2qgN+oeXF0/zWgPrxignFJSJBMDoIwYeh15rOefPEpu jPfUzeOPzPIetGt+GdeggJgzXTXwRNq48QGov5pAhVXRTQNT3jx8npLWiB83DV9/7/ST 2sldcioned1BUasc4orhQvWt4S1Da0FzhEmyxw1s15ojGqN7ykll8pwO+62UxtA3g7Sn PODw== X-Gm-Message-State: APjAAAX/LBxNCg9n+hNqPoaFgagQzbPLnCSUAOyppRGolG3Hkc/zCuTc l6qDpf+9OUtotJRItKQuLRCrNA== X-Received: by 2002:a5d:6506:: with SMTP id x6mr24749896wru.366.1571050619297; Mon, 14 Oct 2019 03:56:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q124sm36454453wma.5.2019.10.14.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 61EB91FF8F; Mon, 14 Oct 2019 11:49:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 14/55] plugin-gen: add module for TCG-related code Date: Mon, 14 Oct 2019 11:49:07 +0100 Message-Id: <20191014104948.4291-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" We first inject empty instrumentation from translator_loop. After translation, we go through the plugins to see what they want to register for, filling in the empty instrumentation. If if turns out that some instrumentation remains unused, we remove it. This approach supports the following features: - Inlining TCG code for simple operations. Note that we do not export TCG ops to plugins. Instead, we give them a C API to insert inlined ops. So far we only support adding an immediate to a u64, e.g. to count events. - "Direct" callbacks. These are callbacks that do not go via a helper. Instead, the helper is defined at run-time, so that the plugin code is directly called from TCG. This makes direct callbacks as efficient as possible; they are therefore used for very frequent events, e.g. memory callbacks. - Passing the host address to memory callbacks. Most of this is implemented in a later patch though. - Instrumentation of memory accesses performed from helpers. See the corresponding comment, as well as a later patch. Signed-off-by: Emilio G. Cota [AJB: add alloc_tcg_plugin_context, use glib, rm hwaddr] Signed-off-by: Alex Bennée --- v3 - introduce alloc_tcg_plugin_context - allocate GPtrArray for tracking insns v4 - remove hwaddr variants of callbacks - pass full 32bit meminfo - remove now unused code - move plugin_gen_from into .c file v5 - fix offsets when storing mem callbacks. - remove #if 0 code no longer needed --- accel/tcg/Makefile.objs | 1 + accel/tcg/plugin-gen.c | 932 ++++++++++++++++++++++++++++++++++++ accel/tcg/plugin-helpers.h | 5 + include/exec/helper-gen.h | 1 + include/exec/helper-proto.h | 1 + include/exec/helper-tcg.h | 1 + include/exec/plugin-gen.h | 57 +++ tcg/tcg-op.h | 11 + tcg/tcg-opc.h | 3 + tcg/tcg.c | 22 + tcg/tcg.h | 20 + 11 files changed, 1054 insertions(+) create mode 100644 accel/tcg/plugin-gen.c create mode 100644 accel/tcg/plugin-helpers.h create mode 100644 include/exec/plugin-gen.h -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs index d381a02f34..a92f2c454b 100644 --- a/accel/tcg/Makefile.objs +++ b/accel/tcg/Makefile.objs @@ -6,3 +6,4 @@ obj-y += translator.o obj-$(CONFIG_USER_ONLY) += user-exec.o obj-$(call lnot,$(CONFIG_SOFTMMU)) += user-exec-stub.o +obj-$(CONFIG_PLUGIN) += plugin-gen.o diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c new file mode 100644 index 0000000000..51580d51a0 --- /dev/null +++ b/accel/tcg/plugin-gen.c @@ -0,0 +1,932 @@ +/* + * plugin-gen.c - TCG-related bits of plugin infrastructure + * + * Copyright (C) 2018, Emilio G. Cota + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * We support instrumentation at an instruction granularity. That is, + * if a plugin wants to instrument the memory accesses performed by a + * particular instruction, it can just do that instead of instrumenting + * all memory accesses. Thus, in order to do this we first have to + * translate a TB, so that plugins can decide what/where to instrument. + * + * Injecting the desired instrumentation could be done with a second + * translation pass that combined the instrumentation requests, but that + * would be ugly and inefficient since we would decode the guest code twice. + * Instead, during TB translation we add "empty" instrumentation calls for all + * possible instrumentation events, and then once we collect the instrumentation + * requests from plugins, we either "fill in" those empty events or remove them + * if they have no requests. + * + * When "filling in" an event we first copy the empty callback's TCG ops. This + * might seem unnecessary, but it is done to support an arbitrary number + * of callbacks per event. Take for example a regular instruction callback. + * We first generate a callback to an empty helper function. Then, if two + * plugins register one callback each for this instruction, we make two copies + * of the TCG ops generated for the empty callback, substituting the function + * pointer that points to the empty helper function with the plugins' desired + * callback functions. After that we remove the empty callback's ops. + * + * Note that the location in TCGOp.args[] of the pointer to a helper function + * varies across different guest and host architectures. Instead of duplicating + * the logic that figures this out, we rely on the fact that the empty + * callbacks point to empty functions that are unique pointers in the program. + * Thus, to find the right location we just have to look for a match in + * TCGOp.args[]. This is the main reason why we first copy an empty callback's + * TCG ops and then fill them in; regardless of whether we have one or many + * callbacks for that event, the logic to add all of them is the same. + * + * When generating more than one callback per event, we make a small + * optimization to avoid generating redundant operations. For instance, for the + * second and all subsequent callbacks of an event, we do not need to reload the + * CPU's index into a TCG temp, since the first callback did it already. + */ +#include "qemu/osdep.h" +#include "cpu.h" +#include "tcg/tcg.h" +#include "tcg/tcg-op.h" +#include "trace/mem.h" +#include "exec/exec-all.h" +#include "exec/plugin-gen.h" +#include "exec/translator.h" + +#ifdef CONFIG_SOFTMMU +# define CONFIG_SOFTMMU_GATE 1 +#else +# define CONFIG_SOFTMMU_GATE 0 +#endif + +/* + * plugin_cb_start TCG op args[]: + * 0: enum plugin_gen_from + * 1: enum plugin_gen_cb + * 2: set to 1 for mem callback that is a write, 0 otherwise. + */ + +enum plugin_gen_from { + PLUGIN_GEN_FROM_TB, + PLUGIN_GEN_FROM_INSN, + PLUGIN_GEN_FROM_MEM, + PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_N_FROMS, +}; + +enum plugin_gen_cb { + PLUGIN_GEN_CB_UDATA, + PLUGIN_GEN_CB_INLINE, + PLUGIN_GEN_CB_MEM, + PLUGIN_GEN_ENABLE_MEM_HELPER, + PLUGIN_GEN_DISABLE_MEM_HELPER, + PLUGIN_GEN_N_CBS, +}; + +/* + * These helpers are stubs that get dynamically switched out for calls + * direct to the plugin if they are subscribed to. + */ +void HELPER(plugin_vcpu_udata_cb)(uint32_t cpu_index, void *udata) +{ } + +void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *userdata) +{ } + +static void do_gen_mem_cb(TCGv vaddr, uint32_t info) +{ + TCGv_i32 cpu_index = tcg_temp_new_i32(); + TCGv_i32 meminfo = tcg_const_i32(info); + TCGv_i64 vaddr64 = tcg_temp_new_i64(); + TCGv_ptr udata = tcg_const_ptr(NULL); + + tcg_gen_ld_i32(cpu_index, cpu_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_extu_tl_i64(vaddr64, vaddr); + + gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, vaddr64, udata); + + tcg_temp_free_ptr(udata); + tcg_temp_free_i64(vaddr64); + tcg_temp_free_i32(meminfo); + tcg_temp_free_i32(cpu_index); +} + +static void gen_empty_udata_cb(void) +{ + TCGv_i32 cpu_index = tcg_temp_new_i32(); + TCGv_ptr udata = tcg_const_ptr(NULL); /* will be overwritten later */ + + tcg_gen_ld_i32(cpu_index, cpu_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + gen_helper_plugin_vcpu_udata_cb(cpu_index, udata); + + tcg_temp_free_ptr(udata); + tcg_temp_free_i32(cpu_index); +} + +/* + * For now we only support addi_i64. + * When we support more ops, we can generate one empty inline cb for each. + */ +static void gen_empty_inline_cb(void) +{ + TCGv_i64 val = tcg_temp_new_i64(); + TCGv_ptr ptr = tcg_const_ptr(NULL); /* overwritten later */ + + tcg_gen_ld_i64(val, ptr, 0); + /* pass an immediate != 0 so that it doesn't get optimized away */ + tcg_gen_addi_i64(val, val, 0xdeadface); + tcg_gen_st_i64(val, ptr, 0); + tcg_temp_free_ptr(ptr); + tcg_temp_free_i64(val); +} + +static void gen_empty_mem_cb(TCGv addr, uint32_t info) +{ + do_gen_mem_cb(addr, info); +} + +/* + * Share the same function for enable/disable. When enabling, the NULL + * pointer will be overwritten later. + */ +static void gen_empty_mem_helper(void) +{ + TCGv_ptr ptr; + + ptr = tcg_const_ptr(NULL); + tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); + tcg_temp_free_ptr(ptr); +} + +static inline +void gen_plugin_cb_start(enum plugin_gen_from from, + enum plugin_gen_cb type, unsigned wr) +{ + TCGOp *op; + + tcg_gen_plugin_cb_start(from, type, wr); + op = tcg_last_op(); + QSIMPLEQ_INSERT_TAIL(&tcg_ctx->plugin_ops, op, plugin_link); +} + +static void gen_wrapped(enum plugin_gen_from from, + enum plugin_gen_cb type, void (*func)(void)) +{ + gen_plugin_cb_start(from, type, 0); + func(); + tcg_gen_plugin_cb_end(); +} + +static inline void plugin_gen_empty_callback(enum plugin_gen_from from) +{ + switch (from) { + case PLUGIN_GEN_AFTER_INSN: + gen_wrapped(from, PLUGIN_GEN_DISABLE_MEM_HELPER, + gen_empty_mem_helper); + break; + case PLUGIN_GEN_FROM_INSN: + /* + * Note: plugin_gen_inject() relies on ENABLE_MEM_HELPER being + * the first callback of an instruction + */ + gen_wrapped(from, PLUGIN_GEN_ENABLE_MEM_HELPER, + gen_empty_mem_helper); + /* fall through */ + case PLUGIN_GEN_FROM_TB: + gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb); + gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); + break; + default: + g_assert_not_reached(); + } +} + +union mem_gen_fn { + void (*mem_fn)(TCGv, uint32_t); + void (*inline_fn)(void); +}; + +static void gen_mem_wrapped(enum plugin_gen_cb type, + const union mem_gen_fn *f, TCGv addr, + uint32_t info, bool is_mem) +{ + int wr = !!(info & TRACE_MEM_ST); + + gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, type, wr); + if (is_mem) { + f->mem_fn(addr, info); + } else { + f->inline_fn(); + } + tcg_gen_plugin_cb_end(); +} + +void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info) +{ + union mem_gen_fn fn; + + fn.mem_fn = gen_empty_mem_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_MEM, &fn, addr, info, true); + + fn.inline_fn = gen_empty_inline_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_INLINE, &fn, 0, info, false); +} + +static TCGOp *find_op(TCGOp *op, TCGOpcode opc) +{ + while (op) { + if (op->opc == opc) { + return op; + } + op = QTAILQ_NEXT(op, link); + } + return NULL; +} + +static TCGOp *rm_ops_range(TCGOp *begin, TCGOp *end) +{ + TCGOp *ret = QTAILQ_NEXT(end, link); + + QTAILQ_REMOVE_SEVERAL(&tcg_ctx->ops, begin, end, link); + return ret; +} + +/* remove all ops until (and including) plugin_cb_end */ +static TCGOp *rm_ops(TCGOp *op) +{ + TCGOp *end_op = find_op(op, INDEX_op_plugin_cb_end); + + tcg_debug_assert(end_op); + return rm_ops_range(op, end_op); +} + +static TCGOp *copy_op_nocheck(TCGOp **begin_op, TCGOp *op) +{ + *begin_op = QTAILQ_NEXT(*begin_op, link); + tcg_debug_assert(*begin_op); + op = tcg_op_insert_after(tcg_ctx, op, (*begin_op)->opc); + memcpy(op->args, (*begin_op)->args, sizeof(op->args)); + return op; +} + +static TCGOp *copy_op(TCGOp **begin_op, TCGOp *op, TCGOpcode opc) +{ + op = copy_op_nocheck(begin_op, op); + tcg_debug_assert((*begin_op)->opc == opc); + return op; +} + +static TCGOp *copy_extu_i32_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* mov_i32 */ + op = copy_op(begin_op, op, INDEX_op_mov_i32); + /* movi_i32 */ + op = copy_op(begin_op, op, INDEX_op_movi_i32); + } else { + /* extu_i32_i64 */ + op = copy_op(begin_op, op, INDEX_op_extu_i32_i64); + } + return op; +} + +static TCGOp *copy_mov_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* 2x mov_i32 */ + op = copy_op(begin_op, op, INDEX_op_mov_i32); + op = copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + /* mov_i64 */ + op = copy_op(begin_op, op, INDEX_op_mov_i64); + } + return op; +} + +static TCGOp *copy_movi_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* 2x movi_i32 */ + op = copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] = v; + + op = copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] = v >> 32; + } else { + /* movi_i64 */ + op = copy_op(begin_op, op, INDEX_op_movi_i64); + op->args[1] = v; + } + return op; +} + +static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) +{ + if (UINTPTR_MAX == UINT32_MAX) { + /* movi_i32 */ + op = copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] = (uintptr_t)ptr; + } else { + /* movi_i64 */ + op = copy_movi_i64(begin_op, op, (uint64_t)(uintptr_t)ptr); + } + return op; +} + +static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) +{ + return copy_movi_i64(begin_op, op, v); +} + +static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TARGET_LONG_BITS == 32) { + /* extu_i32_i64 */ + op = copy_extu_i32_i64(begin_op, op); + } else { + /* mov_i64 */ + op = copy_mov_i64(begin_op, op); + } + return op; +} + +static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* 2x ld_i32 */ + op = copy_op(begin_op, op, INDEX_op_ld_i32); + op = copy_op(begin_op, op, INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op = copy_op(begin_op, op, INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* 2x st_i32 */ + op = copy_op(begin_op, op, INDEX_op_st_i32); + op = copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op = copy_op(begin_op, op, INDEX_op_st_i64); + } + return op; +} + +static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* all 32-bit backends must implement add2_i32 */ + g_assert(TCG_TARGET_HAS_add2_i32); + op = copy_op(begin_op, op, INDEX_op_add2_i32); + } else { + op = copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + +static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + /* st_i32 */ + op = copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op = copy_st_i64(begin_op, op); + } + return op; +} + +static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, + void *func, unsigned tcg_flags, int *cb_idx) +{ + /* copy all ops until the call */ + do { + op = copy_op_nocheck(begin_op, op); + } while (op->opc != INDEX_op_call); + + /* fill in the op call */ + op->param1 = (*begin_op)->param1; + op->param2 = (*begin_op)->param2; + tcg_debug_assert(op->life == 0); + if (*cb_idx == -1) { + int i; + + /* + * Instead of working out the position of the callback in args[], just + * look for @empty_func, since it should be a unique pointer. + */ + for (i = 0; i < MAX_OPC_PARAM_ARGS; i++) { + if ((uintptr_t)(*begin_op)->args[i] == (uintptr_t)empty_func) { + *cb_idx = i; + break; + } + } + tcg_debug_assert(i < MAX_OPC_PARAM_ARGS); + } + op->args[*cb_idx] = (uintptr_t)func; + op->args[*cb_idx + 1] = tcg_flags; + + return op; +} + +static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *cb_idx) +{ + /* const_ptr */ + op = copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); + if (*cb_idx == -1) { + op = tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* call */ + op = copy_call(&begin_op, op, HELPER(plugin_vcpu_udata_cb), + cb->f.vcpu_udata, cb->tcg_flags, cb_idx); + + return op; +} + +static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, + int *unused) +{ + /* const_ptr */ + op = copy_const_ptr(&begin_op, op, cb->userp); + + /* ld_i64 */ + op = copy_ld_i64(&begin_op, op); + + /* const_i64 */ + op = copy_const_i64(&begin_op, op, cb->inline_insn.imm); + + /* add_i64 */ + op = copy_add_i64(&begin_op, op); + + /* st_i64 */ + op = copy_st_i64(&begin_op, op); + + return op; +} + +static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *cb_idx) +{ + enum plugin_gen_cb type = begin_op->args[1]; + + tcg_debug_assert(type == PLUGIN_GEN_CB_MEM); + + /* const_i32 == movi_i32 ("info", so it remains as is) */ + op = copy_op(&begin_op, op, INDEX_op_movi_i32); + + /* const_ptr */ + op = copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); + if (*cb_idx == -1) { + op = tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* extu_tl_i64 */ + op = copy_extu_tl_i64(&begin_op, op); + + if (type == PLUGIN_GEN_CB_MEM) { + /* call */ + op = copy_call(&begin_op, op, HELPER(plugin_vcpu_mem_cb), + cb->f.vcpu_udata, cb->tcg_flags, cb_idx); + } + + return op; +} + +typedef TCGOp *(*inject_fn)(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *intp); +typedef bool (*op_ok_fn)(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb); + +static bool op_ok(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) +{ + return true; +} + +static bool op_rw(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) +{ + int w; + + w = op->args[2]; + return !!(cb->rw & (w + 1)); +} + +static inline +void inject_cb_type(const GArray *cbs, TCGOp *begin_op, inject_fn inject, + op_ok_fn ok) +{ + TCGOp *end_op; + TCGOp *op; + int cb_idx = -1; + int i; + + if (!cbs || cbs->len == 0) { + rm_ops(begin_op); + return; + } + + end_op = find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + op = end_op; + for (i = 0; i < cbs->len; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + + if (!ok(begin_op, cb)) { + continue; + } + op = inject(cb, begin_op, op, &cb_idx); + } + rm_ops_range(begin_op, end_op); +} + +static void +inject_udata_cb(const GArray *cbs, TCGOp *begin_op) +{ + inject_cb_type(cbs, begin_op, append_udata_cb, op_ok); +} + +static void +inject_inline_cb(const GArray *cbs, TCGOp *begin_op, op_ok_fn ok) +{ + inject_cb_type(cbs, begin_op, append_inline_cb, ok); +} + +static void +inject_mem_cb(const GArray *cbs, TCGOp *begin_op) +{ + inject_cb_type(cbs, begin_op, append_mem_cb, op_rw); +} + +/* we could change the ops in place, but we can reuse more code by copying */ +static void inject_mem_helper(TCGOp *begin_op, GArray *arr) +{ + TCGOp *orig_op = begin_op; + TCGOp *end_op; + TCGOp *op; + + end_op = find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + /* const ptr */ + op = copy_const_ptr(&begin_op, end_op, arr); + + /* st_ptr */ + op = copy_st_ptr(&begin_op, op); + + rm_ops_range(orig_op, end_op); +} + +/* + * Tracking memory accesses performed from helpers requires extra work. + * If an instruction is emulated with helpers, we do two things: + * (1) copy the CB descriptors, and keep track of it so that they can be + * freed later on, and (2) point CPUState.plugin_mem_cbs to the descriptors, so + * that we can read them at run-time (i.e. when the helper executes). + * This run-time access is performed from qemu_plugin_vcpu_mem_cb. + * + * Note that plugin_gen_disable_mem_helpers undoes (2). Since it + * is possible that the code we generate after the instruction is + * dead, we also add checks before generating tb_exit etc. + */ +static void inject_mem_enable_helper(struct qemu_plugin_insn *plugin_insn, + TCGOp *begin_op) +{ + GArray *cbs[2]; + GArray *arr; + size_t n_cbs, i; + + cbs[0] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs[1] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + + n_cbs = 0; + for (i = 0; i < ARRAY_SIZE(cbs); i++) { + n_cbs += cbs[i]->len; + } + + plugin_insn->mem_helper = plugin_insn->calls_helpers && n_cbs; + if (likely(!plugin_insn->mem_helper)) { + rm_ops(begin_op); + return; + } + + arr = g_array_sized_new(false, false, + sizeof(struct qemu_plugin_dyn_cb), n_cbs); + + for (i = 0; i < ARRAY_SIZE(cbs); i++) { + g_array_append_vals(arr, cbs[i]->data, cbs[i]->len); + } + + qemu_plugin_add_dyn_cb_arr(arr); + inject_mem_helper(begin_op, arr); +} + +static void inject_mem_disable_helper(struct qemu_plugin_insn *plugin_insn, + TCGOp *begin_op) +{ + if (likely(!plugin_insn->mem_helper)) { + rm_ops(begin_op); + return; + } + inject_mem_helper(begin_op, NULL); +} + +/* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ +void plugin_gen_disable_mem_helpers(void) +{ + TCGv_ptr ptr; + + if (likely(tcg_ctx->plugin_insn == NULL || + !tcg_ctx->plugin_insn->mem_helper)) { + return; + } + ptr = tcg_const_ptr(NULL); + tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); + tcg_temp_free_ptr(ptr); + tcg_ctx->plugin_insn->mem_helper = false; +} + +static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op) +{ + inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR], begin_op); +} + +static void plugin_gen_tb_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op) +{ + inject_inline_cb(ptb->cbs[PLUGIN_CB_INLINE], begin_op, op_ok); +} + +static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + + inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], begin_op); +} + +static void plugin_gen_insn_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + inject_inline_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], + begin_op, op_ok); +} + +static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + inject_mem_cb(insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], begin_op); +} + +static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const GArray *cbs; + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + + cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + inject_inline_cb(cbs, begin_op, op_rw); +} + +static void plugin_gen_enable_mem_helper(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + inject_mem_enable_helper(insn, begin_op); +} + +static void plugin_gen_disable_mem_helper(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); + inject_mem_disable_helper(insn, begin_op); +} + +static void plugin_inject_cb(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, + int insn_idx) +{ + enum plugin_gen_from from = begin_op->args[0]; + enum plugin_gen_cb type = begin_op->args[1]; + + switch (from) { + case PLUGIN_GEN_FROM_TB: + switch (type) { + case PLUGIN_GEN_CB_UDATA: + plugin_gen_tb_udata(ptb, begin_op); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_tb_inline(ptb, begin_op); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_FROM_INSN: + switch (type) { + case PLUGIN_GEN_CB_UDATA: + plugin_gen_insn_udata(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_insn_inline(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_ENABLE_MEM_HELPER: + plugin_gen_enable_mem_helper(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_FROM_MEM: + switch (type) { + case PLUGIN_GEN_CB_MEM: + plugin_gen_mem_regular(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_mem_inline(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_AFTER_INSN: + switch (type) { + case PLUGIN_GEN_DISABLE_MEM_HELPER: + plugin_gen_disable_mem_helper(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + default: + g_assert_not_reached(); + } +} + +/* #define DEBUG_PLUGIN_GEN_OPS */ +static void pr_ops(void) +{ +#ifdef DEBUG_PLUGIN_GEN_OPS + TCGOp *op; + int i = 0; + + QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + const char *name = ""; + const char *type = ""; + + if (op->opc == INDEX_op_plugin_cb_start) { + switch (op->args[0]) { + case PLUGIN_GEN_FROM_TB: + name = "tb"; + break; + case PLUGIN_GEN_FROM_INSN: + name = "insn"; + break; + case PLUGIN_GEN_FROM_MEM: + name = "mem"; + break; + case PLUGIN_GEN_AFTER_INSN: + name = "after insn"; + break; + default: + break; + } + switch (op->args[1]) { + case PLUGIN_GEN_CB_UDATA: + type = "udata"; + break; + case PLUGIN_GEN_CB_INLINE: + type = "inline"; + break; + case PLUGIN_GEN_CB_MEM: + type = "mem"; + break; + case PLUGIN_GEN_ENABLE_MEM_HELPER: + type = "enable mem helper"; + break; + case PLUGIN_GEN_DISABLE_MEM_HELPER: + type = "disable mem helper"; + break; + default: + break; + } + } + printf("op[%2i]: %s %s %s\n", i, tcg_op_defs[op->opc].name, name, type); + i++; + } +#endif +} + +static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb) +{ + TCGOp *op; + int insn_idx; + + pr_ops(); + insn_idx = -1; + QSIMPLEQ_FOREACH(op, &tcg_ctx->plugin_ops, plugin_link) { + enum plugin_gen_from from = op->args[0]; + enum plugin_gen_cb type = op->args[1]; + + tcg_debug_assert(op->opc == INDEX_op_plugin_cb_start); + /* ENABLE_MEM_HELPER is the first callback of an instruction */ + if (from == PLUGIN_GEN_FROM_INSN && + type == PLUGIN_GEN_ENABLE_MEM_HELPER) { + insn_idx++; + } + plugin_inject_cb(plugin_tb, op, insn_idx); + } + pr_ops(); +} + +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb) +{ + struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; + bool ret = false; + + if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_mask)) { + ret = true; + + QSIMPLEQ_INIT(&tcg_ctx->plugin_ops); + ptb->vaddr = tb->pc; + ptb->vaddr2 = -1; + get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1); + ptb->haddr2 = NULL; + + plugin_gen_empty_callback(PLUGIN_GEN_FROM_TB); + } + return ret; +} + +void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) +{ + struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; + struct qemu_plugin_insn *pinsn; + + pinsn = qemu_plugin_tb_insn_get(ptb); + tcg_ctx->plugin_insn = pinsn; + pinsn->vaddr = db->pc_next; + plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + + /* + * Detect page crossing to get the new host address. + * Note that we skip this when haddr1 == NULL, e.g. when we're + * fetching instructions from a region not backed by RAM. + */ + if (likely(ptb->haddr1 != NULL && ptb->vaddr2 == -1) && + unlikely((db->pc_next & TARGET_PAGE_MASK) != + (db->pc_first & TARGET_PAGE_MASK))) { + get_page_addr_code_hostp(cpu->env_ptr, db->pc_next, + &ptb->haddr2); + ptb->vaddr2 = db->pc_next; + } + if (likely(ptb->vaddr2 == -1)) { + pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr; + } else { + pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2; + } +} + +void plugin_gen_insn_end(void) +{ + plugin_gen_empty_callback(PLUGIN_GEN_AFTER_INSN); +} + +void plugin_gen_tb_end(CPUState *cpu) +{ + struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; + int i; + + /* collect instrumentation requests */ + qemu_plugin_tb_trans_cb(cpu, ptb); + + /* inject the instrumentation at the appropriate places */ + plugin_gen_inject(ptb); + + /* clean up */ + for (i = 0; i < PLUGIN_N_CB_SUBTYPES; i++) { + if (ptb->cbs[i]) { + g_array_set_size(ptb->cbs[i], 0); + } + } + ptb->n = 0; + tcg_ctx->plugin_insn = NULL; +} diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h new file mode 100644 index 0000000000..1916ee7920 --- /dev/null +++ b/accel/tcg/plugin-helpers.h @@ -0,0 +1,5 @@ +#ifdef CONFIG_PLUGIN +/* Note: no TCG flags because those are overwritten later */ +DEF_HELPER_2(plugin_vcpu_udata_cb, void, i32, ptr) +DEF_HELPER_4(plugin_vcpu_mem_cb, void, i32, i32, i64, ptr) +#endif diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h index 22381a1708..236ff40524 100644 --- a/include/exec/helper-gen.h +++ b/include/exec/helper-gen.h @@ -70,6 +70,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ #include "trace/generated-helpers.h" #include "trace/generated-helpers-wrappers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" #undef DEF_HELPER_FLAGS_0 #undef DEF_HELPER_FLAGS_1 diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h index 74943edb13..1c4ba9bc78 100644 --- a/include/exec/helper-proto.h +++ b/include/exec/helper-proto.h @@ -33,6 +33,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ #include "helper.h" #include "trace/generated-helpers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" #undef DEF_HELPER_FLAGS_0 #undef DEF_HELPER_FLAGS_1 diff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h index 268e0f804b..573c2ce2e9 100644 --- a/include/exec/helper-tcg.h +++ b/include/exec/helper-tcg.h @@ -55,6 +55,7 @@ #include "helper.h" #include "trace/generated-helpers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" #undef str #undef DEF_HELPER_FLAGS_0 diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h new file mode 100644 index 0000000000..de519883b1 --- /dev/null +++ b/include/exec/plugin-gen.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * plugin-gen.h - TCG-dependent definitions for generating plugin code + * + * This header should be included only from plugin.c and C files that emit + * TCG code. + */ +#ifndef QEMU_PLUGIN_GEN_H +#define QEMU_PLUGIN_GEN_H + +#include "qemu/plugin.h" +#include "tcg/tcg.h" + +struct DisasContextBase; + +#ifdef CONFIG_PLUGIN + +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb); +void plugin_gen_tb_end(CPUState *cpu); +void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db); +void plugin_gen_insn_end(void); + +void plugin_gen_disable_mem_helpers(void); +void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info); + +#else /* !CONFIG_PLUGIN */ + +static inline +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb) +{ + return false; +} + +static inline +void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db) +{ } + +static inline void plugin_gen_insn_end(void) +{ } + +static inline void plugin_gen_tb_end(CPUState *cpu) +{ } + +static inline void plugin_gen_disable_mem_helpers(void) +{ } + +static inline void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info) +{ } + +#endif /* CONFIG_PLUGIN */ + +#endif /* QEMU_PLUGIN_GEN_H */ + diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 7c778f96f3..4af272daa5 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -833,6 +833,17 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); +static inline void tcg_gen_plugin_cb_start(unsigned from, unsigned type, + unsigned wr) +{ + tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); +} + +static inline void tcg_gen_plugin_cb_end(void) +{ + tcg_emit_op(INDEX_op_plugin_cb_end); +} + #if TARGET_LONG_BITS == 32 #define tcg_temp_new() tcg_temp_new_i32() #define tcg_global_reg_new tcg_global_reg_new_i32 diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index 242d608e6d..9288a04946 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -198,6 +198,9 @@ DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | IMPL(TCG_TARGET_HAS_goto_ptr)) +DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) +DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) + DEF(qemu_ld_i32, 1, TLADDR_ARGS, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS) DEF(qemu_st_i32, 0, TLADDR_ARGS + 1, 1, diff --git a/tcg/tcg.c b/tcg/tcg.c index 16b2d0e0ec..5475d49ed1 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -736,6 +736,15 @@ void tcg_region_init(void) #endif } +static void alloc_tcg_plugin_context(TCGContext *s) +{ +#ifdef CONFIG_PLUGIN + s->plugin_tb = g_new0(struct qemu_plugin_tb, 1); + s->plugin_tb->insns = + g_ptr_array_new_with_free_func(qemu_plugin_insn_cleanup_fn); +#endif +} + /* * All TCG threads except the parent (i.e. the one that called tcg_context_init * and registered the target's TCG globals) must register with this function @@ -780,6 +789,10 @@ void tcg_register_thread(void) g_assert(n < ms->smp.max_cpus); atomic_set(&tcg_ctxs[n], s); + if (n > 0) { + alloc_tcg_plugin_context(s); + } + tcg_ctx = s; qemu_mutex_lock(®ion.lock); err = tcg_region_initial_alloc__locked(tcg_ctx); @@ -976,6 +989,8 @@ void tcg_context_init(TCGContext *s) indirect_reg_alloc_order[i] = tcg_target_reg_alloc_order[i]; } + alloc_tcg_plugin_context(s); + tcg_ctx = s; /* * In user-mode we simply share the init context among threads, since we @@ -1681,6 +1696,13 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) flags = info->flags; sizemask = info->sizemask; +#ifdef CONFIG_PLUGIN + /* detect non-plugin helpers */ + if (tcg_ctx->plugin_insn && unlikely(strncmp(info->name, "plugin_", 7))) { + tcg_ctx->plugin_insn->calls_helpers = true; + } +#endif + #if defined(__sparc__) && !defined(__arch64__) \ && !defined(CONFIG_TCG_INTERPRETER) /* We have 64-bit values in one register, but need to pass as two diff --git a/tcg/tcg.h b/tcg/tcg.h index a37181c899..d234b4c9a5 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -538,6 +538,9 @@ typedef struct TCGOp { /* Next and previous opcodes. */ QTAILQ_ENTRY(TCGOp) link; +#ifdef CONFIG_PLUGIN + QSIMPLEQ_ENTRY(TCGOp) plugin_link; +#endif /* Arguments for the opcode. */ TCGArg args[MAX_OPC_PARAM]; @@ -639,6 +642,23 @@ struct TCGContext { TCGLabel *exitreq_label; +#ifdef CONFIG_PLUGIN + /* + * We keep one plugin_tb struct per TCGContext. Note that on every TB + * translation we clear but do not free its contents; this way we + * avoid a lot of malloc/free churn, since after a few TB's it's + * unlikely that we'll need to allocate either more instructions or more + * space for instructions (for variable-instruction-length ISAs). + */ + struct qemu_plugin_tb *plugin_tb; + + /* descriptor of the instruction being translated */ + struct qemu_plugin_insn *plugin_insn; + + /* list to quickly access the injected ops */ + QSIMPLEQ_HEAD(, TCGOp) plugin_ops; +#endif + TCGTempSet free_temps[TCG_TYPE_COUNT * 2]; TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */ From patchwork Mon Oct 14 10:49:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176154 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4350843ill; Mon, 14 Oct 2019 04:02:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxppjSmiqF3escyGboSXjZ1ZEPdXF1E/tBGmgYQXoVcPOSGZQ4hDw2ZnL6WFFmlwtDD+Kl/ X-Received: by 2002:a17:906:c317:: with SMTP id s23mr29088169ejz.251.1571050959129; Mon, 14 Oct 2019 04:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050959; cv=none; d=google.com; s=arc-20160816; b=pvCy1PU3IL6ReQrQLT217okQYSkBOWM6iiBeyp6mg5epX5+AdNcByenoUOJgQVQdKN +hj0I5aRzJXya4PG8w0oXS8Sr0/uc5+gbhqyYy/E5S7if93pL+EkEE0ivaSgCYdIr43N pRfRPNIeHyiJUQvF2mIrXOGxPxutdhe7mEeS7fjOtQJuXZnI15JFYA5E8xSRWnxvS2GL CDBuG359WzAc34ZXNV3M8JHvDwWBUSY7kVr0YJbll9g4WSAh/JN8ZEpEBI5Q/qDttVh2 J7TIZUi5GqUe2IHkbtGLnjgCR8dQ621eGhHyboLb8Pn/bdlk1MWS8k0k9pq/elxKKTCH Wryw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OPHR3FDnorxwSLN6B/4Vffmr6cAfEAKtvE60j77ozvM=; b=XbdLpoGSCm2P6BoyjNsQieW9vyYvTFM3m/sz5S0/D6A7x5NQ9176FGPYq6Q1WPDTZU pHswuqOQoe/0EbFcZ7Xv4YnjIn2On6Hj+cM3aPM1pGHiO6qINCDIRyej2pri6S1mY3AH R2Dr5FTCjBwbG2hlaSAySsRQVRIm04AYb1GgANvc6PbeR9YkFbuITcntgt2HtqJkM4x8 xMWjkUW7oquKfczyOS8nlMMTyqSEEAlWOR8mVKDLX71jYnnPUgdbso5DiVew0nahEHjt kAN9D3RIgCQFh7/YLwta3T+LZp6Z6mI+a3vDQ9+jL5cyGGMNW8K7PVTnsfKBCr9kjlJ7 7New== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mmq61Aci; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e43si13082234eda.296.2019.10.14.04.02.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mmq61Aci; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy7Z-0001Oq-D5 for patch@linaro.org; Mon, 14 Oct 2019 07:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44612) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvR-0007Rt-Br for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvP-0006B2-EX for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:05 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvP-0006A8-72 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: by mail-wm1-x343.google.com with SMTP id m18so16268678wmc.1 for ; Mon, 14 Oct 2019 03:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OPHR3FDnorxwSLN6B/4Vffmr6cAfEAKtvE60j77ozvM=; b=mmq61AciFapoyrV7yGR9r3uBOuHJkEQ1acmbnoSeW8et+QEoFUvVtb0sxA5tijJYwE dd4gi0dI5cM65MAPcsq/Ywtl7+XL97Q3a7+lrc4Kb5TNg4U+D1s38LyR76pRuy3GCrQq Ss9n0NU7Zv0NaQ8sbhO/vq1YoA8iBL1660a0nrdNxqNch5pikhpLMWXgzYgyF6QMki9A MN9Z6PvIEgWJXvDosH38JmkOGwSo9Na8KibHE/cAJmgsioQO9iPjX0i0okRR+AQoxSlL Ta5gX1xFKx16zfl2ogx/2IPmeIMshE2WZcL2tWuQofvFWgK8e3RdjZ5OVKFqWNqWPDZ9 HYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OPHR3FDnorxwSLN6B/4Vffmr6cAfEAKtvE60j77ozvM=; b=uJDRPMuGWQGqmQriCKFI6lQP5YG0kp+o0sXcgnaDUXsm5+vbMUVZGZBN9E6eo0Evm8 WKdVHvDAmAJN2SScXCaCscbd3QFpYh1mq6lIn5/0W58g1KqieOW6jE4ajJdj1AUSmJlq ukbYeW8snO6oy4aajFe3Gl6HEHnUPJ3BO5FJ9R9Emz42KAe/Qm9gIdjSEvM10Szh86FV nX3Mbtqj+bXjS+iiYo04rP1gtrwb/Y/gZyDY5Z2wFLWW+MfOvElwwlWl3tOdOyf8uUE0 /Gd3Ya6E0F6V6dWVgqvZDt4lcwgIlB7et/5rDO6sszn+lp+eKPlvxX6pCqZ2x6iZh8IS DEUw== X-Gm-Message-State: APjAAAXbybSYh/i2/v6zkcoB0CPDl1mSYgTt6yjgLFgqI+pm41+KXMd7 dMRzA36E9MS31Ac6e0htwvOKqQ== X-Received: by 2002:a7b:cb54:: with SMTP id v20mr14054345wmj.91.1571050202105; Mon, 14 Oct 2019 03:50:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c6sm19283985wrm.71.2019.10.14.03.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A54CE1FF9B; Mon, 14 Oct 2019 11:49:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 15/55] atomic_template: add inline trace/plugin helpers Date: Mon, 14 Oct 2019 11:49:08 +0100 Message-Id: <20191014104948.4291-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Riku Voipio , Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" In preparation for plugin support. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - move common stuff to atomic_common.inc.c - fix ups for widened uint16_t info - drop haddr in helpers - fix wide lines --- accel/tcg/atomic_common.inc.c | 50 +++++++++++++++++++ accel/tcg/atomic_template.h | 93 +++++++++++++++++++++-------------- accel/tcg/cputlb.c | 2 + accel/tcg/user-exec.c | 2 + 4 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 accel/tcg/atomic_common.inc.c -- 2.20.1 diff --git a/accel/tcg/atomic_common.inc.c b/accel/tcg/atomic_common.inc.c new file mode 100644 index 0000000000..a86098fb2d --- /dev/null +++ b/accel/tcg/atomic_common.inc.c @@ -0,0 +1,50 @@ +/* + * Common Atomic Helper Functions + * + * This file should be included before the various instantiations of + * the atomic_template.h helpers. + * + * Copyright (c) 2019 Linaro + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +static inline +void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint16_t info) +{ + CPUState *cpu = env_cpu(env); + + trace_guest_mem_before_exec(cpu, addr, info); + trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST); +} + +static inline void +atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, uint16_t info) +{ +} + +static inline +void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint16_t info) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline +void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, uint16_t info) +{ +} + +static inline +void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint16_t info) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline +void atomic_trace_st_post(CPUArchState *env, target_ulong addr, uint16_t info) +{ +} diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index dfeddf6a54..84d3370bf0 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -59,26 +59,6 @@ # define ABI_TYPE uint32_t #endif -#define ATOMIC_TRACE_RMW do { \ - uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, ATOMIC_MMU_IDX); \ - \ - trace_guest_mem_before_exec(env_cpu(env), addr, info); \ - trace_guest_mem_before_exec(env_cpu(env), addr, \ - info | TRACE_MEM_ST); \ - } while (0) - -#define ATOMIC_TRACE_LD do { \ - uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, ATOMIC_MMU_IDX); \ - \ - trace_guest_mem_before_exec(env_cpu(env), addr, info); \ - } while (0) - -# define ATOMIC_TRACE_ST do { \ - uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true, ATOMIC_MMU_IDX); \ - \ - trace_guest_mem_before_exec(env_cpu(env), addr, info); \ - } while (0) - /* Define host-endian atomic operations. Note that END is used within the ATOMIC_NAME macro, and redefined below. */ #if DATA_SIZE == 1 @@ -98,14 +78,17 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE == 16 ret = atomic16_cmpxchg(haddr, cmpv, newv); #else ret = atomic_cmpxchg__nocheck(haddr, cmpv, newv); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, info); return ret; } @@ -115,10 +98,13 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, info); return val; } @@ -127,10 +113,13 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_ST; + atomic_trace_st_pre(env, addr, info); atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_st_post(env, addr, info); } #endif #else @@ -140,10 +129,13 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret = atomic_xchg__nocheck(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, info); return ret; } @@ -154,10 +146,14 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \ + false, \ + ATOMIC_MMU_IDX); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret = atomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, info); \ return ret; \ } @@ -186,8 +182,11 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ XDATA_TYPE cmp, old, new, val = xval; \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \ + false, \ + ATOMIC_MMU_IDX); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ cmp = atomic_read__nocheck(haddr); \ do { \ @@ -195,6 +194,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ cmp = atomic_cmpxchg__nocheck(haddr, old, new); \ } while (cmp != old); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, info); \ return RET; \ } @@ -232,14 +232,18 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, + false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE == 16 ret = atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv)); #else ret = atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, info); return BSWAP(ret); } @@ -249,10 +253,14 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, + false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, info); return BSWAP(val); } @@ -261,11 +269,16 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, + true, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_ST; + val = BSWAP(val); + atomic_trace_st_pre(env, addr, info); val = BSWAP(val); atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_st_post(env, addr, info); } #endif #else @@ -275,10 +288,14 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; ABI_TYPE ret; + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, + false, + ATOMIC_MMU_IDX); - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret = atomic_xchg__nocheck(haddr, BSWAP(val)); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, info); return BSWAP(ret); } @@ -289,10 +306,14 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \ + false, \ + ATOMIC_MMU_IDX); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret = atomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, info); \ return BSWAP(ret); \ } @@ -319,8 +340,11 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ XDATA_TYPE ldo, ldn, old, new, val = xval; \ + uint16_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, \ + false, \ + ATOMIC_MMU_IDX); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ ldn = atomic_read__nocheck(haddr); \ do { \ @@ -328,6 +352,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ldn = atomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ } while (ldo != ldn); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, info); \ return RET; \ } @@ -355,10 +380,6 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef MEND #endif /* DATA_SIZE > 1 */ -#undef ATOMIC_TRACE_ST -#undef ATOMIC_TRACE_LD -#undef ATOMIC_TRACE_RMW - #undef BSWAP #undef ABI_TYPE #undef DATA_TYPE diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 9cf9e6455e..b587d910f8 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1825,6 +1825,8 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, #define ATOMIC_MMU_CLEANUP #define ATOMIC_MMU_IDX oi +#include "atomic_common.inc.c" + #define DATA_SIZE 1 #include "atomic_template.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index e9a58c5331..6b20510994 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -756,6 +756,8 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, #define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END)) #define EXTRA_ARGS +#include "atomic_common.inc.c" + #define DATA_SIZE 1 #include "atomic_template.h" From patchwork Mon Oct 14 10:49:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176182 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4381917ill; Mon, 14 Oct 2019 04:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNvZzjQwwqAGl8C4QoS/zc2ADK2fJFfVi5jVsVhyZbzDqFMrNJAMsJeU4QK9uh7tR2vzS8 X-Received: by 2002:a50:ed05:: with SMTP id j5mr27464804eds.251.1571052586667; Mon, 14 Oct 2019 04:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052586; cv=none; d=google.com; s=arc-20160816; b=MwWvucNy+L3sdqVKkEhNO/E5Ik9djxN26Iy4ELgdpxxcBQwEQ8xRVAziP05Xvobb46 +3OBeX7jnkdIhDzUDK5XlKB+gSTjTy2rYPO5BmNk3Dt8aNd1Ah0t8X4J9oBzovWwvAx0 anaG0XNdIBJPqxavyHwpELqrV8LdnqrxazUBZqLIuPj/9FIYDIWQq61v+aww2/J/a7uu np2l4g5GMiX2W2FB/RDhz7PJQJV9eLJ7+1d19u3b+Dun0VL9PL/xMExqThtiJxgHWawW A3QtsEoOSPxRab2SJ4YzyiEG+AwiKYU+gbx+i41ep/0Vn9r1bBdE9fWgvjJh+3dEPjXL 1dKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ybk4QY0vRgs7MwF2Fxebs+SGrjeIlHHXWH5s6ZhuRPg=; b=sqbw9LC40Kv0sEgg78r5BoNhhPNi4EQndynRp/yqXMf3TngLu5acYLWwGo86kVUeZO Sg6/JtML7Rdb+Ul1jrqCxeIFqB9NdwcdD5Sz0tLgyJXh2sM+741XQfLfuo/IhqARgcP0 cGXpNnu58FcraEMMA8wkCtuX04yBdlS3ZhSvhCip23NpDYPm2SmBS5E6d5BApofmu0p2 lDzoL9DvGWirJaE7E/8Q2jOozBWhzEMAmw56jX8SEvOj8W8qQIUlmRQMNKcgtBE95cQb 9X+qcyCvczaZYlKpIdjI1DSCJFxC3oXkFt9zTYPDGisZgvEfdFugTeol7mzCk6fZ3K20 16nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=s8pVD8ye; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y23si13404744edb.208.2019.10.14.04.29.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:29:46 -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=fail header.i=@linaro.org header.s=google header.b=s8pVD8ye; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyXo-0008AE-Vj for patch@linaro.org; Mon, 14 Oct 2019 07:29:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45577) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2H-0006nq-Cw for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy2E-0005Hh-Um for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:09 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy2E-0005Fp-Mt for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:06 -0400 Received: by mail-wm1-x341.google.com with SMTP id 5so16783843wmg.0 for ; Mon, 14 Oct 2019 03:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ybk4QY0vRgs7MwF2Fxebs+SGrjeIlHHXWH5s6ZhuRPg=; b=s8pVD8yefydJC2GHSC69L1NQyQMWwpvzeqZ+OP97zJxxby0SJKyTQej03u+FS/7ry1 85zykZuausMvG+CAYrLvG15bXiIe8IT2zU/Dw4sOzK6WE3HHpKhQOsb1MXAveHsVEbXz 0kC0cMYIidaDTAHh59PJLnS63ihBO9F7LZGyhDOSNpfN7PoDQ/XJV8OYRhmP2TyZ++ol FeyACA3hy67ERJGW5QoA8+tgPhoalpTxXgvqJqwUkE4HdG9F081QI+4zx5KmiZJwS6NB IN9dTEre8Nzjd4vQ0fC755I4T07xkldJ69m//Et/OFRL29WjgTVGkEfaQkJsXp/9s6Jm QmhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ybk4QY0vRgs7MwF2Fxebs+SGrjeIlHHXWH5s6ZhuRPg=; b=IZzMfSBkVxHCqa+QEQAyin6Lz3bThjMf9e3ib6SjQYU6HGEExinQ3IvP9zxkxBqL8L o42u+kfJTwVlmC91C0yUPC3FI8ySTYJ60/XFcs+GhOc/hHSxnb88KBaUyM+xRDztDwga g46d4wvXk3JYE7gfnlt7Va/TybFt/kXMZNO6E+BXuHNv8sjTw9ThR50TibaoWIZCCJYe p6rcpXfQr/F9OAqpEm2Q0x67GbSij6PCocpATMLwA/AaROyx2UegDqWy1KlUMidjEO1E dX2eszv6iI+GuRD96ZNAUG7gJ+GDHu++BtQOgINFdC9yqiLNCLy51eFY/4+iygLSMMzJ iWGQ== X-Gm-Message-State: APjAAAXR7FnZZKFURdZR+hOzOTBauaJ6R9ed/RKNs5K6SGFpjc74YZGK CnobqHTe6oG6gMxlP8eBRvX5XA== X-Received: by 2002:a7b:c006:: with SMTP id c6mr14855013wmb.45.1571050625012; Mon, 14 Oct 2019 03:57:05 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f9sm21400902wre.74.2019.10.14.03.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:57:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EBD371FF9C; Mon, 14 Oct 2019 11:49:52 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 16/55] tcg: let plugins instrument virtual memory accesses Date: Mon, 14 Oct 2019 11:49:09 +0100 Message-Id: <20191014104948.4291-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" To capture all memory accesses we need hook into all the various helper functions that are involved in memory operations as well as the injected inline helper calls. A later commit will allow us to resolve the actual guest HW addresses by replaying the lookup. Signed-off-by: Emilio G. Cota [AJB: drop haddr handling, just deal in vaddr] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - fixes for cpu_neg() v4 - rebase fixups, moved cpu_neg() fixes down the stack - drop haddr support - will be restored with later helper - reword commit --- accel/tcg/atomic_common.inc.c | 4 +++ accel/tcg/atomic_template.h | 1 + accel/tcg/cpu-exec.c | 3 ++ include/exec/cpu-defs.h | 1 + include/exec/cpu_ldst_template.h | 28 +++++++++------- include/exec/cpu_ldst_useronly_template.h | 29 ++++++++-------- tcg/tcg-op.c | 40 ++++++++++++++++++----- tcg/tcg.h | 1 + 8 files changed, 71 insertions(+), 36 deletions(-) -- 2.20.1 diff --git a/accel/tcg/atomic_common.inc.c b/accel/tcg/atomic_common.inc.c index a86098fb2d..344525b0bb 100644 --- a/accel/tcg/atomic_common.inc.c +++ b/accel/tcg/atomic_common.inc.c @@ -25,6 +25,8 @@ void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint16_t info) static inline void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, uint16_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info | TRACE_MEM_ST); } static inline @@ -36,6 +38,7 @@ void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint16_t info) static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, uint16_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); } static inline @@ -47,4 +50,5 @@ void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint16_t info) static inline void atomic_trace_st_post(CPUArchState *env, target_ulong addr, uint16_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, info); } diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 84d3370bf0..837676231f 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -18,6 +18,7 @@ * License along with this library; if not, see . */ +#include "qemu/plugin.h" #include "trace/mem.h" #if DATA_SIZE == 16 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 81c33d6475..c01f59c743 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -268,6 +268,7 @@ void cpu_exec_step_atomic(CPUState *cpu) qemu_mutex_unlock_iothread(); } assert_no_pages_locked(); + qemu_plugin_disable_mem_helpers(cpu); } if (cpu_in_exclusive_context(cpu)) { @@ -701,6 +702,8 @@ int cpu_exec(CPUState *cpu) if (qemu_mutex_iothread_locked()) { qemu_mutex_unlock_iothread(); } + qemu_plugin_disable_mem_helpers(cpu); + assert_no_pages_locked(); } diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index be946ba1ce..8c44abefa2 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -214,6 +214,7 @@ typedef struct CPUTLBCommon { * Since this is placed within CPUNegativeOffsetState, the smallest * negative offsets are at the end of the struct. */ + typedef struct CPUTLB { CPUTLBCommon c; CPUTLBDesc d[NB_MMU_MODES]; diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h index 5750a26b9e..6f0d340797 100644 --- a/include/exec/cpu_ldst_template.h +++ b/include/exec/cpu_ldst_template.h @@ -28,6 +28,7 @@ #include "trace-root.h" #endif +#include "qemu/plugin.h" #include "trace/mem.h" #if DATA_SIZE == 8 @@ -86,11 +87,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; - #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, mmu_idx); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -104,6 +103,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, uintptr_t hostaddr = addr + entry->addend; res = glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); +#endif return res; } @@ -124,11 +126,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; - #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx)); + uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, mmu_idx); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -142,6 +142,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, uintptr_t hostaddr = addr + entry->addend; res = glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); +#endif return res; } @@ -165,11 +168,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx = CPU_MMU_INDEX; TCGMemOpIdx oi; - #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, mmu_idx); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -183,6 +184,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, uintptr_t hostaddr = addr + entry->addend; glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); +#endif } static inline void diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index 8f7f117ad4..5cd0fa3b99 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -64,18 +64,17 @@ static inline RES_TYPE glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { -#ifdef CODE_ACCESS RES_TYPE ret; +#ifdef CODE_ACCESS set_helper_retaddr(1); ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr)); clear_helper_retaddr(); - return ret; #else - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false, 0)); - return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, 0); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); + ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr)); #endif + return ret; } #ifndef CODE_ACCESS @@ -96,18 +95,18 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, static inline int glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { -#ifdef CODE_ACCESS int ret; +#ifdef CODE_ACCESS set_helper_retaddr(1); ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr)); clear_helper_retaddr(); - return ret; #else - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false, 0)); - return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, 0); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); + ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); #endif + return ret; } #ifndef CODE_ACCESS @@ -130,10 +129,10 @@ static inline void glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, RES_TYPE v) { - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true, 0)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, 0); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); glue(glue(st, SUFFIX), _p)(g2h(ptr), v); + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, meminfo); } static inline void diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 1388bd344d..c245126f98 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -30,6 +30,7 @@ #include "tcg-mo.h" #include "trace-tcg.h" #include "trace/mem.h" +#include "exec/plugin-gen.h" /* Reduce the number of ifdefs below. This assumes that all uses of TCGV_HIGH and TCGV_LOW are properly protected by a conditional that @@ -2684,6 +2685,7 @@ void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx) tcg_debug_assert(idx == TB_EXIT_REQUESTED); } + plugin_gen_disable_mem_helpers(); tcg_gen_op1i(INDEX_op_exit_tb, val); } @@ -2696,6 +2698,7 @@ void tcg_gen_goto_tb(unsigned idx) tcg_debug_assert((tcg_ctx->goto_tb_issue_mask & (1 << idx)) == 0); tcg_ctx->goto_tb_issue_mask |= 1 << idx; #endif + plugin_gen_disable_mem_helpers(); /* When not chaining, we simply fall through to the "fallback" exit. */ if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { tcg_gen_op1i(INDEX_op_goto_tb, idx); @@ -2705,7 +2708,10 @@ void tcg_gen_goto_tb(unsigned idx) void tcg_gen_lookup_and_goto_ptr(void) { if (TCG_TARGET_HAS_goto_ptr && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { - TCGv_ptr ptr = tcg_temp_new_ptr(); + TCGv_ptr ptr; + + plugin_gen_disable_mem_helpers(); + ptr = tcg_temp_new_ptr(); gen_helper_lookup_tb_ptr(ptr, cpu_env); tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr)); tcg_temp_free_ptr(ptr); @@ -2788,14 +2794,24 @@ static void tcg_gen_req_mo(TCGBar type) } } +static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint16_t info) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn == NULL) { + return; + } + plugin_gen_empty_mem_callback(vaddr, info); +#endif +} + void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) { MemOp orig_memop; + uint16_t info = trace_mem_get_info(memop, idx, 0); tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop = tcg_canonicalize_memop(memop, 0, 0); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, idx, 0)); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { @@ -2807,6 +2823,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) } gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { @@ -2828,11 +2845,11 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) { TCGv_i32 swap = NULL; + uint16_t info = trace_mem_get_info(memop, idx, 1); tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop = tcg_canonicalize_memop(memop, 0, 1); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, idx, 1)); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap = tcg_temp_new_i32(); @@ -2852,6 +2869,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) } gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); if (swap) { tcg_temp_free_i32(swap); @@ -2861,6 +2879,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) { MemOp orig_memop; + uint16_t info; if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { tcg_gen_qemu_ld_i32(TCGV_LOW(val), addr, idx, memop); @@ -2874,8 +2893,8 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop = tcg_canonicalize_memop(memop, 1, 0); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, idx, 0)); + info = trace_mem_get_info(memop, idx, 0); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); orig_memop = memop; if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { @@ -2887,6 +2906,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) } gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { @@ -2914,6 +2934,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) { TCGv_i64 swap = NULL; + uint16_t info; if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { tcg_gen_qemu_st_i32(TCGV_LOW(val), addr, idx, memop); @@ -2922,8 +2943,8 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop = tcg_canonicalize_memop(memop, 1, 1); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, idx, 1)); + info = trace_mem_get_info(memop, idx, 1); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap = tcg_temp_new_i64(); @@ -2947,6 +2968,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) } gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); if (swap) { tcg_temp_free_i64(swap); diff --git a/tcg/tcg.h b/tcg/tcg.h index d234b4c9a5..a38659ea5b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -29,6 +29,7 @@ #include "exec/memop.h" #include "exec/tb-context.h" #include "qemu/bitops.h" +#include "qemu/plugin.h" #include "qemu/queue.h" #include "tcg-mo.h" #include "tcg-target.h" From patchwork Mon Oct 14 10:49:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176177 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4375743ill; Mon, 14 Oct 2019 04:23:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTC9kcFGpRGHPweNXoxW5Y0iK+XgrdiOBqk26B9SobhIcFLI9ldDcjfiEQP7nHNmgFpW7v X-Received: by 2002:aed:228e:: with SMTP id p14mr31905163qtc.190.1571052223027; Mon, 14 Oct 2019 04:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052223; cv=none; d=google.com; s=arc-20160816; b=1KhKqzkSn4ssoIOpXCvF+QfLQsZIhr8o3D4gcslFOFqiIpIdOJ67A5+p4/0fnuAkAk vyOU/+DWMpcXNZzvmYJutA8PGeyXjE1L1D0fKp+El0Gpsw0nmcZkgL9R+OV20IOqhRRK RfbSW0ckMVTd16TPqdayZ5Z3GegQCEtwtz5prh+YjuZA9fKall65fksbG11a8WWS+gVw /4fTSw7Qp3ndnW5Dy6aSp7gpsP94elgjpd1EAxdZSntPaGy5WxwO73kGNgCqXjV3uExD bMLDjT6pGLeNoeYoiiiFVvzEk7WdTQjXMC0yxXirQpiy3VxqDKRbgoB5zjs1loWIux2L nXjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=oN1mnKuiyoRPUYVWg4mbq/TduDJ+Zln9LyiIfU1AE/I=; b=JZmXJ8eQk171ZiOkjX6HTb2/u5uO9bbHB+xQfseEuo9d1T9KcJEWjNtYizTp6lJ1O9 nhvD0wy57pYIumVtiOnooOZki063HRNQS6MMpyBRw4QoVipI7kKrhv87jZ0rdrjb6Swe fvJ8Gkoe/iOoVnHJExSny4jJ/yzrnw407LqlUAqUP/JNN8I/0Nl1CP1idsaIS3OmEFPO RoqgnBu2j4LcqBDzCk/N7DFOXL8+Pnoj/5zzOxYI3ftl/sKLV9jy3s02UT24F7m3OWT8 ERCC+nojvVjUE5MgKZj0hZiZgSZY3KhvZDmg7jhCYvbDnfuGUaGjAxavH8oDo6NuGyGS RgLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ELAYYCE9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 48si17229725qvh.202.2019.10.14.04.23.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:23:43 -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=fail header.i=@linaro.org header.s=google header.b=ELAYYCE9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyRy-00027v-0j for patch@linaro.org; Mon, 14 Oct 2019 07:23:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45470) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy29-0006a8-Jt for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy28-000589-2I for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy27-00056k-R6 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:00 -0400 Received: by mail-wr1-x444.google.com with SMTP id r3so19173443wrj.6 for ; Mon, 14 Oct 2019 03:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oN1mnKuiyoRPUYVWg4mbq/TduDJ+Zln9LyiIfU1AE/I=; b=ELAYYCE9wO2Pxa6cvtOlk3xEi0wTbV74U2+gI+mwaGGMljj9wetrsCZZao01FFSmT6 xLo+uN0Cws4Ovfg/BVpyPb2YJJQr2ebNwsIdVkIvTVdcYp6CzfdVzI3ChPvujpbW/l5F cvq32IlEUQLvHXG7m4+yGwf6JnOpEt/Jc/0E6DD/R0D6Liwq8SIVoL/eOW+90mjO+Y6D idbxudWbersoHeKtARMxJxkxBof3HdHK9y6oL3t7xIm2gcLDjVpm0ZojU9OCnO7rscCU kc07qk4qPH+Y7zB4Kr0+ZNO3Sd8I6HzORQzbwD0so8wrC6clk1aWEnXd5nLVOb8PM4/M pMMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oN1mnKuiyoRPUYVWg4mbq/TduDJ+Zln9LyiIfU1AE/I=; b=a2ksKiyfVrnTPYiAJWYTpC234waBps62Ht2fjYzwS7LUoTd4l0BlcYUlHuIt3HVfoL iVZbr/xzCuuMo18zZVgPQqInzengotMiMzxDAVjeAUjZgvvTSbCB5NLSrIE7kCh6eym3 LaleJAkYIguf3ooqJzecP/SkQpLkJs6ssMiE7A8kH03D+LDAVcPNTxvdLEznr8vJraGY gxJ/+1xpXKnx9w+f5Fv1WFn8/s7iSczstkpzh/2DSyWyuebgUxgprmOE3CD/zFtqWfdF DVAhWQz+ZaDQgDdxDtF6xeGQwXKII6MvC5hm3ITeXsSlffO+4oW7nGwGyfX8qOjScGLB PRmQ== X-Gm-Message-State: APjAAAXpRE+xRNmYYWCxn8kSohFVKQTIn3pujAAu6H+/+Vs82nUdRhzy ALXuYUUslbF5EONRv/4tLWIAUFR5U7s= X-Received: by 2002:a5d:51d1:: with SMTP id n17mr25291390wrv.125.1571050618706; Mon, 14 Oct 2019 03:56:58 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n7sm19363697wrt.59.2019.10.14.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3E4451FF93; Mon, 14 Oct 2019 11:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 17/55] plugins: implement helpers for resolving hwaddr Date: Mon, 14 Oct 2019 11:49:10 +0100 Message-Id: <20191014104948.4291-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We need to keep a local per-cpu copy of the data as other threads may be running. We use a automatically growing array and re-use the space for subsequent queries. Signed-off-by: Alex Bennée --- v5 - use TLS instead of racy GArray - add more commentary regarding success - error_report if we fail --- accel/tcg/cputlb.c | 35 +++++++++++++++++++++++++++++++++++ include/exec/exec-all.h | 20 ++++++++++++++++++++ include/qemu/plugin.h | 6 ++++++ plugins/api.c | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 94 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b587d910f8..2937dac7a5 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1247,6 +1247,41 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, return (void *)((uintptr_t)addr + entry->addend); } + +#ifdef CONFIG_PLUGIN +/* + * Perform a TLB lookup and populate the qemu_plugin_hwaddr structure. + * This should be a hot path as we will have just looked this path up + * in the softmmu lookup code (or helper). We don't handle re-fills or + * checking the victim table. This is purely informational. + * + * This should never fail as the memory access being instrumented + * should have just filled the TLB. + */ + +bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx, + bool is_store, struct qemu_plugin_hwaddr *data) +{ + CPUArchState *env = cpu->env_ptr; + CPUTLBEntry *tlbe = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = is_store ? tlb_addr_write(tlbe) : tlbe->addr_read; + + if (likely(tlb_hit(tlb_addr, addr))) { + if (tlb_addr & TLB_MMIO) { + data->hostaddr = 0; + data->is_io = true; + /* XXX: lookup device */ + } else { + data->hostaddr = addr + tlbe->addend; + data->is_io = false; + } + return true; + } + return false; +} + +#endif + /* Probe for a read-modify-write atomic operation. Do not allow unaligned * operations, or io operations to proceed. Return the host address. */ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index ba2f501f0f..47a071fee0 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -261,6 +261,20 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, void tlb_set_page(CPUState *cpu, target_ulong vaddr, hwaddr paddr, int prot, int mmu_idx, target_ulong size); + +/** + * tlb_plugin_lookup: query last TLB lookup + * @cpu: cpu environment + * + * This function can be used directly after a memory operation to + * query information about the access. It is used by the plugin + * infrastructure to expose more information about the address. + * + * It would only fail if not called from an instrumented memory access + * which would be an abuse of the API. + */ +bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx, + bool is_store, struct qemu_plugin_hwaddr *data); #else static inline void tlb_init(CPUState *cpu) { @@ -310,6 +324,12 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap) { } +static inline bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, + int mmu_idx, bool is_store, + struct qemu_plugin_hwaddr *data) +{ + return false; +} #endif void *probe_access(CPUArchState *env, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 3c46a24166..657345df60 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -182,6 +182,12 @@ struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb) return insn; } +struct qemu_plugin_hwaddr { + uint64_t hostaddr; + bool is_io; +}; + + #ifdef CONFIG_PLUGIN void qemu_plugin_vcpu_init_hook(CPUState *cpu); diff --git a/plugins/api.c b/plugins/api.c index 3de05719a8..fbacd78df6 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -39,7 +39,7 @@ #include "cpu.h" #include "sysemu/sysemu.h" #include "tcg/tcg.h" -#include "trace/mem-internal.h" /* mem_info macros */ +#include "exec/exec-all.h" #include "plugin.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h" @@ -240,11 +240,30 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) * Virtual Memory queries */ +#ifdef CONFIG_SOFTMMU +static __thread struct qemu_plugin_hwaddr hwaddr_info; + +struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, + uint64_t vaddr) +{ + CPUState *cpu = current_cpu; + unsigned int mmu_idx = info >> TRACE_MEM_MMU_SHIFT; + + if (!tlb_plugin_lookup(cpu, vaddr, mmu_idx, + info & TRACE_MEM_ST, &hwaddr_info)) { + error_report("invalid use of qemu_plugin_get_hwaddr"); + return NULL; + } + + return &hwaddr_info; +} +#else struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, uint64_t vaddr) { return NULL; } +#endif bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr) { @@ -253,7 +272,20 @@ bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr) uint64_t qemu_plugin_hwaddr_to_raddr(const struct qemu_plugin_hwaddr *haddr) { +#ifdef CONFIG_SOFTMMU + ram_addr_t ram_addr = 0; + + if (haddr && !haddr->is_io) { + ram_addr = qemu_ram_addr_from_host((void *) haddr->hostaddr); + if (ram_addr == RAM_ADDR_INVALID) { + error_report("Bad ram pointer %"PRIx64"", haddr->hostaddr); + abort(); + } + } + return ram_addr; +#else return 0; +#endif } /* From patchwork Mon Oct 14 10:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176176 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4375173ill; Mon, 14 Oct 2019 04:23:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzX+WFNEBndunTwhaZs0Cb46ZsGgMoCrhUYJY0+cqdTtbBSCTvs1J5dFcrSYssTvkFR/Igb X-Received: by 2002:ac8:162f:: with SMTP id p44mr29414355qtj.331.1571052193109; Mon, 14 Oct 2019 04:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052193; cv=none; d=google.com; s=arc-20160816; b=GlVMmJ2v5RslHz5f9R1j+4u802XZNdf6/+h2Bjhj9y7dJOCMVnp7lVwFr+c3ojTIye J9hhYnRDZ0zeIp/Pf0p329cYbEq3gV6ky0eKqhzxenlRFs+Nd+bDDlAZzhPZ5HSDxHBL TVH8i2KcQarJvLrXt+Nl4I192Q5hWa6K/Mc+XrtXs21jtLizC6KN8cpgR9Db3FIZUXwL HlLjHOXNV8q+OLKAa2gttegLEw+pMIu4YLOykuEvYRiXQvUtdOfFGu1nBiee16X3YWrD qPq1G2/zg5dPuRaydggfJQPt2J9FYJgspWJOznJ3Mqxp//vWR91uZ95m9kjSTC7kaJXK nSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=WC/COO61toOB4tIIQCKCoaqBSXVi1g2WHoYcvCd5VQyeu9S0JYru/cjA2vgbQ8lFYG +4LZQhbLCHc8bBCkNh+FtHszDgPRnKuK19/nt9qSb+5+X8wzPx+2PLSuVgNqHjMABN13 zRKzFw7YjGrKKi2PfIw7TekEu4Q6zZUy50tRUeO9gyEyTIu2gFAEaKidl9BSYv9aaylL z504GAr4WOnEgMugNq4hoXFSvO3s2Stb1VOyzo2//rqaTseNrwjGxJaQHItfMEYBxemO nneu+qAgUOnyTbzOfd0dC7YbSMTktN7jTj/wv8EH/LnCCJ7SnuVCdK8WVNoi2plogxEJ kPgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KptkjTR4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l30si16490624qtn.360.2019.10.14.04.23.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:23: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=fail header.i=@linaro.org header.s=google header.b=KptkjTR4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyRU-0000Zv-7W for patch@linaro.org; Mon, 14 Oct 2019 07:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45448) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy28-0006ZW-Mo for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy26-00055p-ND for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:00 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:34512) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy26-00054S-Gt for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:58 -0400 Received: by mail-wm1-x341.google.com with SMTP id y135so14227029wmc.1 for ; Mon, 14 Oct 2019 03:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=KptkjTR4iho6sjULn/JZnjxZXcKwj6eDc9kROudfYuqhS96mo39RmT9VWreX20ymBD shMtkC8HQ4MrAcrn+CubmT2aYnjkknv7PdWNsgne95NpR3rkRztygnBKRgz2n73BcEZT J79Za0ytM23d8sefg7erpOsNpUuHNUCdSUnbXW8h+Ak4Fk6ujAjrE2+4LQQ+qYAWV5x5 DWS85o3lNHDCMzhadotqaJVRat4ti/0ft0Yz205vLIAmZVVWc9YGY8/blQh1ZgG/ybNe K/6I1e/MyPS8BLgxKhu2aZ2XCM6IURn1xXnY2pausRtLZISTE4o+T0AHWe77uMJtCBgF YlLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=OTNngGbqBB/kASGPd8Ww1rlbdG7j630c3KrllOqydndJLsrJ/5cgRb18q/2a6/Cbbl K4TqTEr3I2KEh8zUFFgtB8P3NC5gb1IJtZMOs1T+hjZ9XYhdXZuaboALEhCjt6FFit5S ehLB4UGI1A7M/zwUA9HfEVqbIDcf9TKKMITycg2TQ0KO/FcoTnm2dfr1BGkMhkQ2FRvG C1YLu0hJJlRnLXPAF4IJnwPVyEbiDNHBowifesD2Ej1I/bxmjQ5WMHd3cww25llq60fR UW9lVj+aOzhtLKvbHY5KL9dQ/s00NuZ8NiBPXqT8mLAtCA1zKu1tWhluzZ373R56Pfy4 DN2Q== X-Gm-Message-State: APjAAAXR3467aV/u2rAdPtXp+bYlXXHOpEKm6GYLy0tHt84BEr7RLDjf LhUavk27IDTqse4u0+cGR3sfnQ== X-Received: by 2002:a05:600c:20c4:: with SMTP id y4mr13169870wmm.87.1571050617284; Mon, 14 Oct 2019 03:56:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 26sm13814874wmf.20.2019.10.14.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:55 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 684391FF9D; Mon, 14 Oct 2019 11:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 18/55] translate-all: notify plugin code of tb_flush Date: Mon, 14 Oct 2019 11:49:11 +0100 Message-Id: <20191014104948.4291-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Plugins might allocate per-TB data that then they get passed each time a TB is executed (via the *userdata pointer). Notify plugin code every time a code cache flush occurs, so that plugins can then reclaim the memory of the per-TB data. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 0a08fcda3e..6d1b0ecd69 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1231,6 +1231,8 @@ static gboolean tb_host_size_iter(gpointer key, gpointer value, gpointer data) /* flush all the translation blocks */ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) { + bool did_flush = false; + mmap_lock(); /* If it is already been done on request of another CPU, * just retry. @@ -1238,6 +1240,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) if (tb_ctx.tb_flush_count != tb_flush_count.host_int) { goto done; } + did_flush = true; if (DEBUG_TB_FLUSH_GATE) { size_t nb_tbs = tcg_nb_tbs(); @@ -1262,6 +1265,9 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) done: mmap_unlock(); + if (did_flush) { + qemu_plugin_flush_cb(); + } } void tb_flush(CPUState *cpu) From patchwork Mon Oct 14 10:49:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176183 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4382029ill; Mon, 14 Oct 2019 04:29:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPAM2LjWeelI0gNU2QYqaTOwNvN8cF568424XWTKrQ/G7jUrjCdcS089lk17XGjurqBBlv X-Received: by 2002:aa7:d5d3:: with SMTP id d19mr27115042eds.213.1571052593324; Mon, 14 Oct 2019 04:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052593; cv=none; d=google.com; s=arc-20160816; b=k2GYq95cD3oDiV2050YDv4WVa8Ngl9pfvfB2ZXSQnbXSP1aeLNbGGCR1oVIm9k4/1X jWgdNrYR8BtuPVs94LbfYVFUmb9MPln9Hs1ntfCistzpMuzBlGi2jZ7bF5tqsxBxHoI6 18zbvH0g1rqsT6gaMZcUAdvvVRMIGXffJ8iPRDaYjal8ptznRddMdDfaSMgL1q/HyM91 Xw+ubeMFfRZPUuxnzuVI33gx+++R8mWUTvhAe+/3D+pTPEbpuzFGkzL/D6XAsiZdhkjn 984RKYE5vflmSLY7dkh6DIru1qkwRg2xFIEPt0fjGe55BtgtC50mL6AVdkNC397rBJdN YY6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uTKqy+wnCWVLTWShRSYu/D5n/xFvdeK0I9HBQnZtYcw=; b=rBAuejbdeVXWLJ8WO94Gpp9LLHRvYOoG2nUf360Y4Azb9pr8GwvqoHzCenh1x5XACz 7NdEOA+T1ec7+vhvtiKLmc1Q8tLXU2PaNH/tFsy9fb4FLD3hVvTR/3/uRQJ95qDSm4US sCjPmP9TyW+OuCljRfVHDKy2hfatktIrwZzMgpB6c9ZlWIBjK1IDDeYDyWG80FbWeJwI DswogriB1iE/W0+Lv8Q6E3LZPXy5opY/+9yBOr9D2zVaCIoh5Sxnj/GYy0qEj8DUwX5e 2SByhNENUSqjQrsfpT//pdj9Ihja2zXD2Kkf5o11Z5MdlAay/OJHGuomgLkqmnpV+kdJ N0jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bPEc75TG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z6si12369002edm.316.2019.10.14.04.29.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:29:53 -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=fail header.i=@linaro.org header.s=google header.b=bPEc75TG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyXu-0008Hk-Na for patch@linaro.org; Mon, 14 Oct 2019 07:29:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46776) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBl-0007hr-7t for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyBk-0007Ci-3z for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:57 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyBj-0007BK-U5 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:56 -0400 Received: by mail-wr1-x444.google.com with SMTP id n14so19163319wrw.9 for ; Mon, 14 Oct 2019 04:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uTKqy+wnCWVLTWShRSYu/D5n/xFvdeK0I9HBQnZtYcw=; b=bPEc75TGH5H05SVrt3SlZHujeshZlKXmrmtKV2XMOml93zAQRqqq7Pjs7VW2Pq6Ob7 MHJZrFRPfHH8chx9Mf7udbaZ369grO8GEXGX02q2SAtlCBXf7i+F/InICx784eCydmmu 4SyMNTTfWuAONG1ioPmoxCOTghjRdsyFsTgmc9gAnZh60A4MM/NcNdDVmLlDjqJG2bWL wmoJ13EpZZesnIswfn1bb4/38wIHn5q2r4Fbfo4ye5Ezpb6YpT2Z5esSc5PMYpA3urFV /dZNk1jbxpOFNX4wEXVHywJHxG41zhYCZoRWI3ErA3JdZN2c0ZrKjVh18hYJu/wGGDza BcSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uTKqy+wnCWVLTWShRSYu/D5n/xFvdeK0I9HBQnZtYcw=; b=Asmnj8kpHK3lqu9U9Jw64HwLRBZ8V2hITk9pPoKLAYWZD2u7OP2GYv8WjSxoNbtkl3 H8MBLRw4/EpFb3BvWl0gbn8D4tBb3bkUrIY2SidRMeJJto1ustyl0eWJA2E1qruTcQuU hSGSK3Nfiv8Mc5xOad0IxtHZk90dWHLVRDXI8SsjL6tWCB/Zvj6bIE9PzMbtXZ61Psj/ semUccUDB0gifs9k9jxC7/r92WM0s14a6bB0fd6raRnHQULyd+LBR+bHCl7YMwjFQLjY R9g7+WBao3FI2vkOTLDegxt7+7yG5xiuAv1hG6LVx9xv/fgpNLtLyvuyvpVUjmZ7oTpL ju0Q== X-Gm-Message-State: APjAAAWYjF7P/7PUiG6IkSF0wIrjNTfzOs5MtAyXaJS5NT5Ye9QIkH+b rFsFpFvVVOapDMYDHB85QS8kRg== X-Received: by 2002:adf:ec84:: with SMTP id z4mr25286908wrn.254.1571051214828; Mon, 14 Oct 2019 04:06:54 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z189sm32394786wmc.25.2019.10.14.04.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A44511FF90; Mon, 14 Oct 2019 11:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 19/55] *-user: notify plugin of exit Date: Mon, 14 Oct 2019 11:49:12 +0100 Message-Id: <20191014104948.4291-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Riku Voipio , Richard Henderson , Laurent Vivier , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- bsd-user/syscall.c | 3 +++ linux-user/exit.c | 1 + 2 files changed, 4 insertions(+) -- 2.20.1 diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 1ee6195d9f..84a983a9a1 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -332,6 +332,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ @@ -430,6 +431,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ @@ -505,6 +507,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ diff --git a/linux-user/exit.c b/linux-user/exit.c index bdda720553..a362ef67d2 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -35,4 +35,5 @@ void preexit_cleanup(CPUArchState *env, int code) __gcov_dump(); #endif gdb_exit(env, code); + qemu_plugin_atexit_cb(); } From patchwork Mon Oct 14 10:49:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176158 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4355857ill; Mon, 14 Oct 2019 04:06:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQkMTEbdSL9dzLVZjF70Rp5KKb0Kv8KsUW+OLWDdtQaxXyfIrt6x7C5zhBw0OxqOa1l0xD X-Received: by 2002:a50:ee81:: with SMTP id f1mr27250630edr.243.1571051193691; Mon, 14 Oct 2019 04:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051193; cv=none; d=google.com; s=arc-20160816; b=TxYh6r0fdZr2YI/Q+U8MO+gxb9CCWPw1rdnt0IKrBJsieI968IjWMT524qfe09PRwL Ch46WpapiWuWe9lG8IDlHqRkXQn3X5f28GI0G+TEwAdLIztKMEO9/Oj6W/FkdKlG/6Us hdcZropvgRM5JuWqGhh28+JMxCAMlCx0diMHmMJ5VqPrA1hCpP6LJNewHLpuBVJGdX+j wMFvwU6NH5BIyXCb7ZH0Zolavn1siR1b7rdMBst5k0pkwpi2W/wRBW2FP3TfFiX7Ifyg czAu/zpOR+ei8GaXnHAMcH86HQVsUI4elNk2EYT1pd0nT457BwQJhy5PLPsdmH0RFc8V uhUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=etDCqYHg2LYQtZa+T5XCKHLqmFEuamg260f6vcRF/Qs=; b=TGbALdLevvGmZgUkQmwiqxG28ueJJuwXKel2pLW+SuZwXPE2Gsg9EoatuDDkixADh7 TDhc1x4mOkbxrESoONFb/7nISKms9Xlj7ocoMmg7q8f2XA6N8/SMU+3imxmqh6nsMIoA i4wg28bsYrKeOnje0EBxbVobH+ynOE0dHrE/MmD3y8VUUbJuMNYU+JBuRFpkm7Y9UrIb z4qU6ERq4nGn2T9qK/kOVzQVXgCYZJmzymcy/hlXlGInkeaiU+fr1TBjQzgjt1jKJKAe R3ml0+Xx8sfu02ABEsgrOQ/Cl7Xogq0VUB6Ab5LdxKsaXsOKINLzNTijmW0ZCUMwHLrY tj7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4nPEaYI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v27si10669219ejb.182.2019.10.14.04.06.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:06:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4nPEaYI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBM-0005XL-3R for patch@linaro.org; Mon, 14 Oct 2019 07:06:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44634) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvS-0007Ti-DU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvQ-0006Db-UX for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:06 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39493) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvQ-0006CO-Nj for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:04 -0400 Received: by mail-wm1-x342.google.com with SMTP id v17so16247101wml.4 for ; Mon, 14 Oct 2019 03:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=etDCqYHg2LYQtZa+T5XCKHLqmFEuamg260f6vcRF/Qs=; b=C4nPEaYI9W5ytcgj11DsaGHtoskijPN7u8oRbLulaXg6uAZT6Be8Zaj1AoGximIrTs wpsciD5PvhfZ9EzVnzl3JKUqcjAAqYaVhuB+YFZUR81xuj+Og6ifsJweMhspHsFKW0Rq AfxzUjgzbLdNqjYWqahOBhk0QY5iIoz1GpgudxbkhtOf+sNVbC8rhamNEOfOoYVfniYo 4fQlJ4Aab1fInh+qmD/11sszXOzky5S3FYhTVCXxm1Gowbrk8kIDbzvv7fqB/k1J0hyC 6xXH7EtR+dI4rE6t5e3rcEb5iqtkAA21UF9KMqlNZG3Pb3urT8jqyD0l8aCRH0FMisZd ZliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=etDCqYHg2LYQtZa+T5XCKHLqmFEuamg260f6vcRF/Qs=; b=RnQuesIQFbYShHfW9As7JOh5b0ZOCO1m1v5bz7EdQddTFSktH6V6tH56uWEguRVVlo a28P9wuCMLmNIljd5vftvPHYwNKE0tOT8uPLU0L8QshoP/aYgudAkU9EGdnKor1QVaUY M+EN01Ad/la8xdjFn5mDo5uvzSOQ9AKT4hQh+hAc0yfCUmKZ0a5kfWcQbUJ2aWgbdCOZ VnQDImupckITO5Kyn5ATGQ2W+raFbQ4aW5NkzCODd2c/g8NZB+ggtBnzl8IcPy+b4meZ 2Ul6CBGb9YEW5NqICaNCgDrZf1CKgI7hFZ4K3wI5llTPWoFqDH0NH4Z/aUXX+263gJon Br8A== X-Gm-Message-State: APjAAAUMSLWaD3g2DZj7BEanLEa8HTeKye5C3ND5FNeTa9ZYxLL/GZX4 qbOhXXnrC0gM12dCGJeopbsuvQ== X-Received: by 2002:a7b:caea:: with SMTP id t10mr11165741wml.38.1571050203567; Mon, 14 Oct 2019 03:50:03 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a192sm15972917wma.1.2019.10.14.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E298D1FFA3; Mon, 14 Oct 2019 11:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 20/55] *-user: plugin syscalls Date: Mon, 14 Oct 2019 11:49:13 +0100 Message-Id: <20191014104948.4291-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Riku Voipio , Richard Henderson , Laurent Vivier , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" To avoid too much duplication add a wrapper that the existing trace and the new plugin calls can live in. We could move the -strace code here as well but that is left for a future series as the code is subtly different between the bsd and linux. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson [AJB: wrap in syscall-trace.h, expand commit msg] Signed-off-by: Alex Bennée --- bsd-user/syscall.c | 21 +++++++++++++------ include/user/syscall-trace.h | 40 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 7 ++++--- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 include/user/syscall-trace.h -- 2.20.1 diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 84a983a9a1..0d45b654bb 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -26,6 +26,7 @@ #include "qemu.h" #include "qemu-common.h" +#include "user/syscall-trace.h" //#define DEBUG @@ -322,7 +323,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef DEBUG gemu_log("freebsd syscall %d\n", num); #endif - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + if(do_strace) print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -403,7 +405,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, #endif if (do_strace) print_freebsd_syscall_ret(num, ret); - trace_guest_user_syscall_ret(cpu, num, ret); + + record_syscall_return(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; @@ -421,7 +424,9 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef DEBUG gemu_log("netbsd syscall %d\n", num); #endif - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + + record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + if(do_strace) print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -479,7 +484,8 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, #endif if (do_strace) print_netbsd_syscall_ret(num, ret); - trace_guest_user_syscall_ret(cpu, num, ret); + + record_syscall_return(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; @@ -497,7 +503,9 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef DEBUG gemu_log("openbsd syscall %d\n", num); #endif - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + + record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + if(do_strace) print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -555,7 +563,8 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, #endif if (do_strace) print_openbsd_syscall_ret(num, ret); - trace_guest_user_syscall_ret(cpu, num, ret); + + record_syscall_return(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h new file mode 100644 index 0000000000..9e60473643 --- /dev/null +++ b/include/user/syscall-trace.h @@ -0,0 +1,40 @@ +/* + * Common System Call Tracing Wrappers for *-user + * + * Copyright (c) 2019 Linaro + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _SYSCALL_TRACE_H_ +#define _SYSCALL_TRACE_H_ + +/* + * These helpers just provide a common place for the various + * subsystems that want to track syscalls to put their hooks in. We + * could potentially unify the -strace code here as well. + */ + +static inline void record_syscall_start(void *cpu, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, + abi_long arg7, abi_long arg8) +{ + trace_guest_user_syscall(cpu, num, + arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + qemu_plugin_vcpu_syscall(cpu, num, + arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); +} + +static inline void record_syscall_return(void *cpu, int num, abi_long ret) +{ + trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); +} + + +#endif /* _SYSCALL_TRACE_H_ */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e2af3c1494..77e87a959f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -112,6 +112,7 @@ #include "qemu.h" #include "qemu/guest-random.h" +#include "user/syscall-trace.h" #include "qapi/error.h" #include "fd-trans.h" @@ -11981,8 +11982,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } #endif - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); + record_syscall_start(cpu, num, arg1, + arg2, arg3, arg4, arg5, arg6, arg7, arg8); if (unlikely(do_strace)) { print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -11994,6 +11995,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg5, arg6, arg7, arg8); } - trace_guest_user_syscall_ret(cpu, num, ret); + record_syscall_return(cpu, num, ret); return ret; } From patchwork Mon Oct 14 10:49:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176150 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4345267ill; Mon, 14 Oct 2019 03:57:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFIwAnyMJNNkgC60nY6jMJ4A9fG2FkuubMX+LVeqXK0JD/8Ae2KYdNUM6Gu3wWkxM5Ibq1 X-Received: by 2002:ac8:1409:: with SMTP id k9mr11012369qtj.123.1571050658847; Mon, 14 Oct 2019 03:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571050658; cv=none; d=google.com; s=arc-20160816; b=ETND6x08yZrSjWxOKzqwNvvidciLg8udPxz+Vqd/Ha29Q7PLjDI0Znk3ngP+u7SYuE OeIPYJ7wx2I7FvxpYlRh6X/tZNZ+JhtJ5bUtYET8Op+1f5q8WYFBvxFNBmBf0vzEZG3P RHx5cs8IlNFpY8GKuIKuqB+fZ1XUJGEVOEAidsXyz3DYuMfjvcDHcooYwEDuIrc2I/fT iH3C9pOtGWGD9NQ3dazSJwDUPuptB5ZyC2oxsfxueXDrl2FFWkSKs2972LVxE7FDSfGI t8pzXvKiikUsk4JYIfdqSFLWVEk7NoAEcUM7Hsu/OL/pjUVl78v9RLbFZRm4BpS+5y5M oWcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=UjvHWieYAqCdBHW93DyEpWKzi7c6unFLBG6RKSZa/WGJ8tKNyUV73BJ+LXvZiiMrHI 9m83ZOsojDivvqZmrwG0j59ptBiNAyscvqwxjjw4DciFyozADhjVKU9zesN8hRg0Kwcc 8MX3OL0PDZIBQMa7Z3ApfqglLOTyEtEPB2YwSbYcd2gRiCX9OloipJZJgQXG/sZFIGUO LXJkVElz2FE4kbA8E2GC8JFOEoaYFIi40lXJK+Mil6jmS8VJ2XHY7AgmriGrGObVAQ8+ l/pbBUVLco1j0kVXJL+ypt9hWTqGLJdpJHgC4FhSz5s3OqGkf6fytRIh7OAX3p1QbDFK C93A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZV4UF0qW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e34si17611394qtc.268.2019.10.14.03.57.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 03:57:38 -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=fail header.i=@linaro.org header.s=google header.b=ZV4UF0qW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2j-000718-TW for patch@linaro.org; Mon, 14 Oct 2019 06:57:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44713) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvV-0007YQ-2d for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvQ-0006C6-05 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvP-0006Aj-Pm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: by mail-wr1-x442.google.com with SMTP id r5so19091396wrm.12 for ; Mon, 14 Oct 2019 03:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=ZV4UF0qWD7rw1Lw82K8YUQjXqUDe1AKrCsnHw50HvXWPYaQmmSaNZhtUgPXXEzlrCK JK7Mw4FcSBiyOObR3orFFGTyq6iMk3UVWfrY7EZc4R7zMYyWsWR1+0PSy5+B8+LtnNcd Gk0c63zJJA/1ImzoQ7eMSPIqp17sicz6sBVBh5QwJ8FFjJAx+NoVolZBhG4NzK0Gk14V ddoAkoZk2m/nLB0MI3LB2fAuxQgwxSoyOmnkO63z151aIdbekXuycKcXCMEimKuJ6WHP +lq40Tu4dbXiV3B2ded3RbyQXCjrT8aqAJIAarmZUpvdibVov8sHuwSBO+LZZ5Jz4Ri4 Ih9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uvacSGmjYgiAWweJmrehENexJyDt68fPjc90zp076LQ=; b=CcsxH+nF7PRmN/FX3BJ905VWQPP7sqYpj9D/24RDyI+O8kxRLxw8RhDq0XrVf+eVQR i0AnWy43lKBH1rbw3QiYrovRRCLWrgBIk+UzsJS2bBnBSzRb2Uu+frxUSHtexYE0tBcN AAydYqUp5NO6O0l5+DlUZji6HuoVd/E3QfjGp4xi+YKMUWRzpyEkAErYgmtSvYv4KZR8 pr0JH2fwwOuxgI19b/H++Ln7WdT33JeIHRh5gkbQetb8RPVedlZ7+ERwruan9G0Kg1YB r0/BRJ+3z3gsp8C+ZPNUd5n/3uk1hbepVxQuojHthr+O/L2ZGkQ2kKno70kiP1ohu8mH iz8g== X-Gm-Message-State: APjAAAVTPS6+nHBjj5VtSLZ8//vVe9wRy/8p4UJCX5CuYcUmKFuYOAh5 +3amugwSolpaOooq1PDy5zRWjg== X-Received: by 2002:a5d:6a02:: with SMTP id m2mr539987wru.120.1571050202758; Mon, 14 Oct 2019 03:50:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f143sm30441224wme.40.2019.10.14.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3099B1FFAA; Mon, 14 Oct 2019 11:49:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 21/55] cpu: hook plugin vcpu events Date: Mon, 14 Oct 2019 11:49:14 +0100 Message-Id: <20191014104948.4291-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- cpus.c | 10 ++++++++++ exec.c | 2 ++ hw/core/cpu.c | 2 ++ 3 files changed, 14 insertions(+) -- 2.20.1 diff --git a/cpus.c b/cpus.c index d2c61ff155..98f00ffba7 100644 --- a/cpus.c +++ b/cpus.c @@ -45,6 +45,7 @@ #include "exec/exec-all.h" #include "qemu/thread.h" +#include "qemu/plugin.h" #include "sysemu/cpus.h" #include "sysemu/qtest.h" #include "qemu/main-loop.h" @@ -1255,9 +1256,18 @@ static void qemu_tcg_rr_wait_io_event(void) static void qemu_wait_io_event(CPUState *cpu) { + bool slept = false; + while (cpu_thread_is_idle(cpu)) { + if (!slept) { + slept = true; + qemu_plugin_vcpu_idle_cb(cpu); + } qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } + if (slept) { + qemu_plugin_vcpu_resume_cb(cpu); + } #ifdef _WIN32 /* Eat dummy APC queued by qemu_cpu_kick_thread. */ diff --git a/exec.c b/exec.c index bdcfcdff3f..7be7adb8f5 100644 --- a/exec.c +++ b/exec.c @@ -975,6 +975,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) } tlb_init(cpu); + qemu_plugin_vcpu_init_hook(cpu); + #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 73b1ee34d0..db1a03c6bb 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -32,6 +32,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" +#include "qemu/plugin.h" CPUInterruptHandler cpu_interrupt_handler; @@ -352,6 +353,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Error **errp) CPUState *cpu = CPU(dev); /* NOTE: latest generic point before the cpu is fully unrealized */ trace_fini_vcpu(cpu); + qemu_plugin_vcpu_exit_hook(cpu); cpu_exec_unrealizefn(cpu); } From patchwork Mon Oct 14 10:49:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176157 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4355317ill; Mon, 14 Oct 2019 04:06:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFDKuiV4+vrXRjeOpAYwNMmc2SKutQNdEOwO4XmNlfJw5QarZMGAYtJZtYnBrMAF81XF1W X-Received: by 2002:ac8:82e:: with SMTP id u43mr32057834qth.176.1571051167852; Mon, 14 Oct 2019 04:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051167; cv=none; d=google.com; s=arc-20160816; b=Cn7e2Dr4IwWZI7Cwt+5vMT8Wy2BITJB/eL8CoQwp8y5n5r8vAhawQTRHk3BzR6q3R0 XkQ/YwDua3pXcJtKIhIEXdfSpMoxZzmhgoCE4moWI480Gr16GgBntDeNwknTXGQcW6cg goeYcu6OiPbjlptOuflK9JzZGo1O5U/tNrnO36PxwZyO+20F6oicqAk6tR6LgwFzIK2e PzWl8OxelA9a4qfNxxTgJi1RkM+xikLOAtkPsLqmWj2PpGw8HkYo0J9sQPe7XknDSZxL D9pQzXrldjyGD/jeZK1g/l7a2Zkp06R9mLknLUU78ZCkjL3NC4UfqBD3Ds7QHVIaHje9 z8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=t6U3oBlc6u1UdxE1uAu8xMOurpvpIFfvpufH8BjBIdw=; b=NFvdUASIVlNvwICdwig5tZpxX3b6uVT+wR01V6UxJU+2htQsEoOaZSvBlXJUJh4uXd i3wBS/r6FIRqBPbyYmGqefjzC0Dgxu+V1KG2AbAEgBUwyT8QHBOzCG/iqsqsq1ooy6RW VhcCn0uNyvfDUGaRYiR1mqf7mmMLtLH2MEQqqPvSxxpMenAYvuT/1xtL5hRAVkWUJ6Ht GTaITXr4IvVYahT5X+0dSgCd/FI6jMdJF1D63CgbKxmeADeQLCqlIvsWwa4GT7NUju6Y viB1JXQ7CWCim2bB6vJq/SjNJPLUhrE00MBaqN8Gzjrp5YLiu11REnjPm0Hpeg79T4L/ pwNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fJOwChp4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f46si17773250qte.354.2019.10.14.04.06.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:06:07 -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=fail header.i=@linaro.org header.s=google header.b=fJOwChp4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyAw-0005yT-Uh for patch@linaro.org; Mon, 14 Oct 2019 07:06:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44571) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvQ-0007PV-0n for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvO-0006AH-Pn for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvO-00068c-Jm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: by mail-wm1-x341.google.com with SMTP id 7so16758920wme.1 for ; Mon, 14 Oct 2019 03:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t6U3oBlc6u1UdxE1uAu8xMOurpvpIFfvpufH8BjBIdw=; b=fJOwChp4bMBjNwazG0QV8ZPxEsC7CCi2q3piXYzbEJrTvSwWaiB7fHyc5GE+ArfL3+ M72vgVBDN5hOOHYAKy8mkb0+K/THDwJ07c06Ck1HaJHzoi/I1FMoQEmNpCKGgw7WcY4w wOiWix/UrIMynAA7VoYa7IUOVBg7kYjW8g2FXS3lie5ctN4TExw9snmte7e97/VqdmkQ boHIeYsvd8iB+7O6RjWBbImno76rzfynKMvjRJcXJuxCjNbHPg0DS/5L4mIRHr/CSH/U WkYMIM/hmpBr/m13CWg/lbvPYbloSVs+25Q2v/zG5GUON6XnMbIMyua47Ptyqsqczjyb aCGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t6U3oBlc6u1UdxE1uAu8xMOurpvpIFfvpufH8BjBIdw=; b=Wf76U52rTyEt8fm+uR14UDeXo1PyXD6q47bnmBu3ETQ2XkLQd4vjaAqhr6FUrwNvjL Brim28xf3wadhmTD09fsjsB65r4unI/6AbDFRAsX5lIR9wj5Seg+5bmBD8ScEoMVT+td UeA7w3OurTh67XsFMsck+hEnBxYWsatkPYcGfPO69CJafXxA2WR0YYnKomiOAAWMX1DA olfhoMtP5pUNIwcz/Btbd6eh0ufPTiXytxFAbHHYJNVbqWU+9Gv8mmfUek67xOt0tvq8 x3phTLh1yMGFW83magR2Teo7gfhUfbwNXG4NhoPIvW+WzxyJ8LG4CyQ+9eSeoBlerG5P D9Yw== X-Gm-Message-State: APjAAAV+pK+C7bJH/L/t1xkY16/vstnOKyPXgCMDrlwGl45OmEAbI2UF KWu/ED5BqgAq6aJZ5h6pwVncPA== X-Received: by 2002:a05:600c:2054:: with SMTP id p20mr15336666wmg.76.1571050201549; Mon, 14 Oct 2019 03:50:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z189sm32321718wmc.25.2019.10.14.03.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6090E1FF92; Mon, 14 Oct 2019 11:49:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 22/55] plugin-gen: add plugin_insn_append Date: Mon, 14 Oct 2019 11:49:15 +0100 Message-Id: <20191014104948.4291-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" By adding it to plugin-gen's header file, we can export is as an inline, since tcg.h is included in the header (we need tcg_ctx). Signed-off-by: Emilio G. Cota [AJB: use g_byte_array] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - use g_byte_array --- include/exec/plugin-gen.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.20.1 diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h index de519883b1..4834a9e2f4 100644 --- a/include/exec/plugin-gen.h +++ b/include/exec/plugin-gen.h @@ -27,6 +27,17 @@ void plugin_gen_insn_end(void); void plugin_gen_disable_mem_helpers(void); void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info); +static inline void plugin_insn_append(const void *from, size_t size) +{ + struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn; + + if (insn == NULL) { + return; + } + + insn->data = g_byte_array_append(insn->data, from, size); +} + #else /* !CONFIG_PLUGIN */ static inline @@ -51,6 +62,9 @@ static inline void plugin_gen_disable_mem_helpers(void) static inline void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info) { } +static inline void plugin_insn_append(const void *from, size_t size) +{ } + #endif /* CONFIG_PLUGIN */ #endif /* QEMU_PLUGIN_GEN_H */ From patchwork Mon Oct 14 10:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176190 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4391187ill; Mon, 14 Oct 2019 04:37:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXFd3v9gHa1r1oljpfnAj4Vcv6xHzIt9ip4997C52VYn0RSRlkl56MPbQZKARurYZ9BarQ X-Received: by 2002:a05:6402:154e:: with SMTP id p14mr7066705edx.274.1571053079622; Mon, 14 Oct 2019 04:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053079; cv=none; d=google.com; s=arc-20160816; b=JcGZcxYLrSZcX/i+rKEGLKeTcEdkO3cOK4/ZmpepUajPffYfWgFTs+jmpwRY/e6a8z Uk6UywlJEKqWpBKUgcA8ZCIXoWGbm6ui6Zri81+U4X5A3xSPuDTNpRvV7YK641UkM+hL B31eTJcajIOoV/+hHEOf0uYZqHT0SMc5uHSzl2+5ouO/tVH0n7uTJ+ZEpxtM44INnYA7 cc/5ZBn4i7IBsIa/5dlB0dEaFAi91hLcvt2u8CVc5/Wm8bP2bPz4/SV7DXZAjgv3bGXA NwWUVy7N/WYUZEAgeeUbrhKznWtpZcezQcglkSevTttXvuIv7q1kUdl3hju2icWuVD1h tMLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UmjqCmwbmhQzwY3KN2Q9UhV5BJN5OMPhX9Z6rr8BWhM=; b=mZkx8Z2BA5X8BlDsgPTDMkooLkoVlLl2gJ/zk3gNr9fvQ8VLz9rH9MGKnJCRSIMUBi sgPO2RXSwtJLrBUMnPIt7GHrgomUD0CPzOJLslLmz/ZiEfGw3ZdH3Ac22/y3LcgT6AMq GN4/xZuhcBEufkRTP5U3SXd+m+P8nH7iWDM8Qr10x63EHXsbGXs/rr6ms7ehnttoUMlZ ubtTZY/RyX5fsQetPg+uyAVrArzLeWNSCD6dXPGNO3NYHZscGk2bxDqRETGXC+X0aj4H Tz1V3m7JoS1IuxcB0dPisiueiYTBr3gSWvKLSRGEY690FYQoTYvIrHGqt+yMMO1ORgCZ WtSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wlUiZfx6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w12si10754823edx.223.2019.10.14.04.37.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wlUiZfx6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyfm-0000IZ-3P for patch@linaro.org; Mon, 14 Oct 2019 07:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46789) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBm-0007ja-Cs for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyBk-0007DQ-N7 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:58 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53077) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyBk-0007CV-Fs for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:56 -0400 Received: by mail-wm1-x343.google.com with SMTP id r19so16802104wmh.2 for ; Mon, 14 Oct 2019 04:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UmjqCmwbmhQzwY3KN2Q9UhV5BJN5OMPhX9Z6rr8BWhM=; b=wlUiZfx6xF81J09wWzT/wL3q/PdUZlLM3p0JXUvOuYGKYEMooDU2GVAlwRA+eCQSbu HRGqgbNBkFQPOBUezZQl1F4AlL/6z7pNdAzfGMV5MHXAapq84DVtvd8tbUH4dN4HfCkV u4anDhGwXuX+OI/u87lSngQUtjJUXAzk04Oyk9nEAvnpwzYCzivAekT2WWBf14Hkz/NH a6Ut04l6feYfKWv36EBXRjUvYqOUjzEjI+YQUnziLGX2plhtkbNmn6K+YzCQ1hCbAs5I T2FmRNicQl6ediR+A1jw8pm04Uh98nhvBhzVzfzC6AFbW56Ik8CMIPjPExU+SXicFdR1 Ix6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UmjqCmwbmhQzwY3KN2Q9UhV5BJN5OMPhX9Z6rr8BWhM=; b=Zrt1I/BqFEixcwd/49ABcLjo7DHm940iMkpvLnlDQ+JxXVJzLNKHN3CuIh6iRE2JRT WhygeVk48TcjLq8lTSXqC8i2JYCTTx7zkhB3aEDRUnpx4wMSLpMlWdy/djZCUfh4J5xB eQxZUe68oA+kvCfERGjrGJlrY89uRliyt14BUN4hORHMaU4VcxEiugDdEHCl/KLE0QNc qYjoJCK2c76CKitT6t4ROEXY970+rAq0TyfKL3DoW+GBZmMKs/EqzMfCmjBZcHEJ+ZsM w3AmvfIDJ1KTb8z9G08IBv15oyonfOa/t1Nm2imzgwkNtv5Gjn/VwXLMKGAM5SXZISNy OuDA== X-Gm-Message-State: APjAAAVFXdyraz8wnXTwjJ31Hz4+T1CrVucdpLRIyKKhoZkBQJ808J3x jxyoGuBrkqCvCudom1hQOVfagA== X-Received: by 2002:a1c:ed0d:: with SMTP id l13mr14723200wmh.76.1571051215371; Mon, 14 Oct 2019 04:06:55 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z6sm17185468wro.16.2019.10.14.04.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AAE441FFAB; Mon, 14 Oct 2019 11:49:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 23/55] translator: add translator_ld{ub,sw,uw,l,q} Date: Mon, 14 Oct 2019 11:49:16 +0100 Message-Id: <20191014104948.4291-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" We don't bother with replicating the fast path (tlb_hit) of the old cpu_ldst helpers as it has no measurable effect on performance. This probably indicates we should consider flattening the whole set of helpers but that is out of scope for this change. Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota [AJB: directly plumb into softmmu/user helpers] Signed-off-by: Alex Bennée --- v4 - don't use the cpu_ldst helpers, plumb directly into the lower level - mark the CODE_ACCESS/SOFTMMU_CODE_ACCESS as deprecated v5 - expand commit message w.r.t. fast path. --- include/exec/cpu_ldst.h | 11 ++++++++ include/exec/translator.h | 58 ++++++++++++++++++++++++++++++++++++++- include/qemu/bswap.h | 5 ++++ tcg/tcg.h | 2 ++ 4 files changed, 75 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 9151fdb042..fd499f7e2f 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -129,6 +129,11 @@ static inline void clear_helper_retaddr(void) #include "exec/cpu_ldst_useronly_template.h" #undef MEMSUFFIX +/* + * Code access is deprecated in favour of translator_ld* functions + * (see translator.h). However there are still users that need to + * converted so for now these stay. + */ #define MEMSUFFIX _code #define CODE_ACCESS #define DATA_SIZE 1 @@ -427,6 +432,12 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx, #undef CPU_MMU_INDEX #undef MEMSUFFIX +/* + * Code access is deprecated in favour of translator_ld* functions + * (see translator.h). However there are still users that need to + * converted so for now these stay. + */ + #define CPU_MMU_INDEX (cpu_mmu_index(env, true)) #define MEMSUFFIX _code #define SOFTMMU_CODE_ACCESS diff --git a/include/exec/translator.h b/include/exec/translator.h index 180c51d509..7a9dc1b937 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -19,7 +19,10 @@ */ +#include "qemu/bswap.h" #include "exec/exec-all.h" +#include "exec/cpu_ldst.h" +#include "exec/plugin-gen.h" #include "tcg/tcg.h" @@ -142,4 +145,57 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, void translator_loop_temp_check(DisasContextBase *db); -#endif /* EXEC__TRANSLATOR_H */ +/* + * Translator Load Functions + * + * These are intended to replace the old cpu_ld*_code functions and + * are mandatory for front-ends that have been migrated to the common + * translator_loop. These functions are only intended to be called + * from the translation stage and should not be called from helper + * functions. Those functions should be converted to encode the + * relevant information at translation time. + */ + +#ifdef CONFIG_USER_ONLY + +#define DO_LOAD(type, name, shift) \ + set_helper_retaddr(1); \ + ret = name ## _p(g2h(pc)); \ + clear_helper_retaddr(); + +#else + +#define DO_LOAD(type, name, shift) \ + int mmu_idx = cpu_mmu_index(env, true); \ + TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx); \ + ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); + +#endif + +#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn) \ + static inline type \ + fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ + { \ + type ret; \ + DO_LOAD(type, name, shift) \ + \ + if (do_swap) { \ + ret = swap_fn(ret); \ + } \ + plugin_insn_append(&ret, sizeof(ret)); \ + return ret; \ + } \ + \ + static inline type fullname(CPUArchState *env, abi_ptr pc) \ + { \ + return fullname ## _swap(env, pc, false); \ + } + +GEN_TRANSLATOR_LD(translator_ldub, ldb, uint8_t, 0, /* no swap needed */) +GEN_TRANSLATOR_LD(translator_ldsw, lduw, int16_t, 1, bswap16) +GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16) +GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32) +GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64) +#undef GEN_TRANSLATOR_LD + +#endif /* EXEC__TRANSLATOR_H */ diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 2a9f3fe783..4f70727874 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -306,6 +306,11 @@ static inline int ldub_p(const void *ptr) return *(uint8_t *)ptr; } +static inline int ldb_p(const void *ptr) +{ + return ldub_p(ptr); +} + static inline int ldsb_p(const void *ptr) { return *(int8_t *)ptr; diff --git a/tcg/tcg.h b/tcg/tcg.h index a38659ea5b..302533b463 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1317,6 +1317,7 @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr, # define helper_ret_stl_mmu helper_be_stl_mmu # define helper_ret_stq_mmu helper_be_stq_mmu # define helper_ret_ldw_cmmu helper_be_ldw_cmmu +# define helper_ret_lduw_cmmu helper_be_ldw_cmmu # define helper_ret_ldl_cmmu helper_be_ldl_cmmu # define helper_ret_ldq_cmmu helper_be_ldq_cmmu #else @@ -1330,6 +1331,7 @@ uint64_t helper_be_ldq_cmmu(CPUArchState *env, target_ulong addr, # define helper_ret_stl_mmu helper_le_stl_mmu # define helper_ret_stq_mmu helper_le_stq_mmu # define helper_ret_ldw_cmmu helper_le_ldw_cmmu +# define helper_ret_lduw_cmmu helper_le_ldw_cmmu # define helper_ret_ldl_cmmu helper_le_ldl_cmmu # define helper_ret_ldq_cmmu helper_le_ldq_cmmu #endif From patchwork Mon Oct 14 10:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176162 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4359045ill; Mon, 14 Oct 2019 04:09:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoEjekOyTBjpz7tIQ5SNlyqec/s9z1qS2JkHirn9+fGK0KgFdHutQA98uWgzcOsaoXc4OL X-Received: by 2002:a05:6402:28c:: with SMTP id l12mr12446059edv.145.1571051343681; Mon, 14 Oct 2019 04:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051343; cv=none; d=google.com; s=arc-20160816; b=ecMmORCwmD0NN8mgpZZ/kdVxErXG2prmtkQ0zdfFTyu/BkNXUf5PKBQx7gQGs8J22Y c010AnruL0b7RtHsdg3QPtt1P8udh5ifRKo5hT9BC38VLmbP46bmG3W2nr5x/OEmMco6 HuqxRqZsDL1Bw21Bbe/2dhgTGjV5vAnYBbTNL88X2R1ssmzsu9eWsf4dr15oaajkK/j/ n9hnXgdebbPzEK2RmIkhuZMzWB2H+XSQs3jZz1pZkTspBuUhjbc1IVwOY2XZQWLUOuuv OcFRpzc6Ex3z3y7on7ZrJZpU4IMSf9w0q2XxS58LohrqhdMVy99E3VTtPLCcss/9iD5E EASA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=m4scFyBAux7omI9dWRwoni82M9uy+xh8rsre9KWj8Gc=; b=B3gbFlgQjjLGPOZJUYp+eDWez8iFGoepTX6HamqAdd3XnGNwU0YJoxp5qVCI/I6iwe neosaWuTyfRPLHzfn3ihCZtCUL/O3GsOrIWYP7bbCzl1/S5HsdhLFwb6qP+lKKCihLa2 u5WzPiHZteqV3khQf/ZOmAbTNUWkLk3zFnpnD2DET+j7GJu6hsdjRlRqwa+7g98U2qHh mhtf7XkmuOfHtCa8U2Apzqf6ONpKRK8kNlIMNl7gNU20r/TbEApy9a1gbVa2eM4xS8To DeMnJ18jIRoDysVAHM3tsWD7dc0PrI0iNkC7nLuuBNU019HHXeb2+L1ZWVmlnom+z16t tkwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ixzKDEDq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l22si10239435edq.174.2019.10.14.04.09.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:09:03 -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=fail header.i=@linaro.org header.s=google header.b=ixzKDEDq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyDm-0001HL-3f for patch@linaro.org; Mon, 14 Oct 2019 07:09:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44568) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvQ-0007PQ-0z for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvO-00069e-JN for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:03 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35669) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvO-000676-9t for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:02 -0400 Received: by mail-wr1-x444.google.com with SMTP id v8so19151213wrt.2 for ; Mon, 14 Oct 2019 03:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m4scFyBAux7omI9dWRwoni82M9uy+xh8rsre9KWj8Gc=; b=ixzKDEDqwTfH2etxANMqaOVs1pohVls0R5oSxR4AItQcP65hF/1gn8eyJpQyNmR/qy Ow0NiVv15FZLuDw+6UV4gM17Yj9ayWZYLeljmkH6l4RkdlD/AmwoYodIiRWdQfv1Yhqz e6Yjseq5yZgVd5PHNtM868lt4Wr/QmfUWkdRyjw89hW4XxnwItjM5pBGZ4LBgZYtOxK9 tOp/zzk5+P5HJ2Z73Fz0/WMWau9brkPoI+526urBDXvmHAHTTPnvaXl6IMdrNgslNkBU w/IoLmrOALBWd9906EO0vSlfz0bqVJ0UW711SU3HRUXpZpX4Zpx9y5Qpl4yxHUFh+NhN LOBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m4scFyBAux7omI9dWRwoni82M9uy+xh8rsre9KWj8Gc=; b=cn3J6ZWccHz3M7K5RjAt3veHjCFTeuy8wuuGBTn0IZIgfgh0HfjoeJ5YAWW2JkRfe+ yiHdnloaa6n5Ko32BL1M0Fy7rYdVOstUClzey8C78o5UVUBKYfj79cXDoeJtPD8ayxtx 6bHr5MG8WuELpbOElb9iHOt6b0R3dp8lk2LG+stHveXeFU7k+OgcWLj94I27n4NqEBQo 2MqAOQu7Q89fRIsCd3RI7SELLRMWJaC+DpG9VcthriUwfQowHEEUbO7VxwpXY9Z0pMxz BOuTfdhvVxu7SLW2oitw2ko7Wo9AkU0L3DNKcty8Vkajv0ATqrlmMVZqgpE89+QkDllF F2Sw== X-Gm-Message-State: APjAAAVmkw7RZJMmppf02b8/eftt+1F6rD8FgJMIohLz98DSPbW+SPoT m9GPkx+v5MpnLEGCBiGBv4IUQg== X-Received: by 2002:a5d:50c9:: with SMTP id f9mr24181232wrt.36.1571050200337; Mon, 14 Oct 2019 03:50:00 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h17sm14980217wmb.33.2019.10.14.03.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:49:55 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DB45F1FFAC; Mon, 14 Oct 2019 11:49:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 24/55] target/arm: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:17 +0100 Message-Id: <20191014104948.4291-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Now the arm_ld*_code functions are only used at translate time we can just pass down to translator_ld functions. Signed-off-by: Emilio G. Cota [AJB: convert from plugin_insn_append to translator_ld] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - use translator_ld like the rest of them --- target/arm/arm_ldst.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/target/arm/arm_ldst.h b/target/arm/arm_ldst.h index 5e0ac8bef0..45edb108f6 100644 --- a/target/arm/arm_ldst.h +++ b/target/arm/arm_ldst.h @@ -20,25 +20,20 @@ #ifndef ARM_LDST_H #define ARM_LDST_H -#include "exec/cpu_ldst.h" +#include "exec/translator.h" #include "qemu/bswap.h" /* Load an instruction and return it in the standard little-endian order */ static inline uint32_t arm_ldl_code(CPUARMState *env, target_ulong addr, bool sctlr_b) { - uint32_t insn = cpu_ldl_code(env, addr); - if (bswap_code(sctlr_b)) { - return bswap32(insn); - } - return insn; + return translator_ldl_swap(env, addr, bswap_code(sctlr_b)); } /* Ditto, for a halfword (Thumb) instruction */ static inline uint16_t arm_lduw_code(CPUARMState *env, target_ulong addr, bool sctlr_b) { - uint16_t insn; #ifndef CONFIG_USER_ONLY /* In big-endian (BE32) mode, adjacent Thumb instructions have been swapped within each word. Undo that now. */ @@ -46,11 +41,7 @@ static inline uint16_t arm_lduw_code(CPUARMState *env, target_ulong addr, addr ^= 2; } #endif - insn = cpu_lduw_code(env, addr); - if (bswap_code(sctlr_b)) { - return bswap16(insn); - } - return insn; + return translator_lduw_swap(env, addr, bswap_code(sctlr_b)); } #endif From patchwork Mon Oct 14 10:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176167 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4363240ill; Mon, 14 Oct 2019 04:12:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy18WpEAcmKY3prANRk9KNYmTPSDTgopGb3jD/84lgaUuFWeutGjbZ9qWICitEFIeY3jFyJ X-Received: by 2002:aa7:d304:: with SMTP id p4mr27616264edq.224.1571051560745; Mon, 14 Oct 2019 04:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051560; cv=none; d=google.com; s=arc-20160816; b=WaHo2BO5sJI+ynNKR9vK/oBJ3SCZV6VHCegn6kVTz+w0SMkPEDHFGef0+5r2QGHjrH bENSoJgsIznlJevC9PWXfy3zTs3aXtW2a1Pcs9nuSpc/9ShbXl1gJjpRTk21e7h8/aBV DDBWqF5RRuP3KE3zxAyfSDJeglhotxalD6r1gObiWTigTkqCzeEGVFXE4Q1npZpa7KpR BXyvu0kjC/3uc2xv41oWXDPi1ExoY8bMk1vi3psp5nIqbHhzY0nSEkZwUHg4FXPRo/zU OrJsXhINZJL3TcRU/NfjC7gY3Nmh5W1Ea4M5eEEPH/ItiCOknw76+fA23yOVmwIr5Yql o5sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wkKvV4m59QNrxbn2cShYQVtK2L5V4Z2RfTcq3RzCI+A=; b=kNd6BtEK+H0dlnpXiZgOV8zdTgHnkAS7TSmKfwZCd64DC4OV5mlIIS9ev1EBMgcE8v vkcoI96OOCIzUKp/h+ItZ9aaB8tT2UP074j7MakzqXesozonIDz+MYRtYxB9QRO+luy5 Mc1z7sA6WPYGBUk1Iw9c76v97ddK31e/iFzt/9wnRPODUbquWP45l/Nt6OA3RU5bfwsA 71Q9EdVnPeE5tDn3GWmMQrPIH5OrTLEAifDTelnsOlwaqT0C0lXUvxxVNs4g65CkSyOB Z6cP7JsBNFvSzllygkuuAhnMGs//JWPgfzddef7gINbezYgk6NhzyicowWDb7/lBKsp3 Ydaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ib8GIKxG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h90si12494684edd.178.2019.10.14.04.12.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ib8GIKxG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyHH-0004zJ-Ja for patch@linaro.org; Mon, 14 Oct 2019 07:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvT-0007UN-3L for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvR-0006Ea-M3 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:06 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvR-0006DR-E1 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:05 -0400 Received: by mail-wr1-x443.google.com with SMTP id y18so9677410wrn.5 for ; Mon, 14 Oct 2019 03:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wkKvV4m59QNrxbn2cShYQVtK2L5V4Z2RfTcq3RzCI+A=; b=ib8GIKxGCj/S/SDhI+albNwezZ2VxDgbviecKDonjK3TkO1GR/t65pLI9WNFa3n7aO /0N+ZK24IsVFGDYLo3EXrkeTCygZVlW3bLbkIOu2nzCGs+U06mErsezjOIByskWrCyMq FgRbU0pWgesd7nxf+kTNuAlKuI8dE8+qG5HXcoWn7ubrrEym0NI5vVT5EMVc+KbJzMn1 ab+f+uO/cYlP+TH/YWL5OLwhgRF8hPzZvceGLU1+78O5CnNZULH1o+R1BCpmaRbtvuAX 8WxE8ttrQINMRWjOgeFUY5TFm1Pp0+Jvocgbq5YZ0XySOObe97ntalfAhiN36lEU4A1T U/Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wkKvV4m59QNrxbn2cShYQVtK2L5V4Z2RfTcq3RzCI+A=; b=j0M91AYWHN2vl7GYZa6MWeA1pdQ8QllxTkN8So86VK8fxz3g+ZjZlfCdJoH1TprVAQ VNXI1yChHsgeOydE0Z6O8bhNif6cjTVG6VW+aaZoC+EgoJhyREqiKgZmISDW0uJu9n39 zzEu+4x8cZhMV1ZDFW0Cg2l+F1HahohKFLuSFNLFg+lcW9C0a/m6ueBaN5p1mdBcpGxi XqRRiPJc9X8vPLv9htb4pznmqdxRfTA156PNYlcdaCkC4qf1s23mwYscURrrKJsU5/hQ DjBd+meWv/uje2Sa3UxaqcskzDM5stnxtqXuHKL57nLghWNKx7YqC2UKhrrdXBmJ5kLU pMLQ== X-Gm-Message-State: APjAAAWTmgAf0GoIZwl9Lzrsj8I0nMI9TMEsxTtiJIyB/6h+Cyae5993 zkgSBH1ZZAWS0LEi6V8cFFqGcQ== X-Received: by 2002:adf:f547:: with SMTP id j7mr26755221wrp.26.1571050204391; Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f9sm21372680wre.74.2019.10.14.03.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1A73E1FFAE; Mon, 14 Oct 2019 11:49:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 25/55] target/ppc: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:18 +0100 Message-Id: <20191014104948.4291-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, "open list:PowerPC TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Acked-by: David Gibson Signed-off-by: Alex Bennée --- target/ppc/translate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index adb8fd516f..f5fe5d0611 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7853,11 +7853,9 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n", ctx->base.pc_next, ctx->mem_idx, (int)msr_ir); - if (unlikely(need_byteswap(ctx))) { - ctx->opcode = bswap32(cpu_ldl_code(env, ctx->base.pc_next)); - } else { - ctx->opcode = cpu_ldl_code(env, ctx->base.pc_next); - } + ctx->opcode = translator_ldl_swap(env, ctx->base.pc_next, + need_byteswap(ctx)); + LOG_DISAS("translate opcode %08x (%02x %02x %02x %02x) (%s)\n", ctx->opcode, opc1(ctx->opcode), opc2(ctx->opcode), opc3(ctx->opcode), opc4(ctx->opcode), From patchwork Mon Oct 14 10:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176186 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4387009ill; Mon, 14 Oct 2019 04:34:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwh5jkoUKr1t4LZFoIyYsyFkf8qFiwXuoKuDPRDLUC2Z7VhT1sD+2g0ip9O44Nh0wWlkApC X-Received: by 2002:ac8:1732:: with SMTP id w47mr32583928qtj.167.1571052846122; Mon, 14 Oct 2019 04:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052846; cv=none; d=google.com; s=arc-20160816; b=bcA/9pycaaHz6imxB13V+6soP0GfcPBQXN6jhDyN0VHSFcu3tES23LdAscVdhvr6Ey eCcETiIXyGvKIqH14u+HjLmIh/+t8H5YEu1NXvRDCioj6HE59lUUtpkBFnwOWZ4t1FO+ l/gsygrGtji2wsXm56apZY+Vk8RGdL4WKJCZC+pnUIFX3sAYPdU3AAwFRKcmGshkMAHy gXH6Bqvgm1X/JSx5bl0MZolJTYtRZlYTKzoY5fMQRGbWf3fjO+qXTjO/xogA9HiwVWdC YM/rUknt5Q+E8FCsyJg43/zQIYpTAk5vFDvoDlSqawCz9V1QMZwKcgGa5qa7ByGQ7stP iQDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LYziuWTaDyCvsXZWL+7dYTQAPkm19wADCHnlP8tL2bI=; b=s3jc+0GNehPY52i/j8rNAie2WeRb5Pf4yE4IAHaim27Zq4PkyKKCFtR5z3R4BevW6L Q+Mzo6CgaW4+XVwKjCTsO908SYsrF3CJ8UOGRuttHE5v0KWcTa4zI/fc/aX2lpWKnqmZ G6BUh84H/bNcqqyhQPa2Ts2LykCW1p6nkxZj/huP+6gLfx/1pXFnXA+paE585vyqqLUx rQxHvWbJVfVzW8FIj+lBO8fzjgGH8aYbOastvqQOQfRgfjAIjq+dyivmkqFQe/L2BHX9 M+FwRflXec0uVW3lEBII+AgtXSZxzBmAuk6fAiLjbvxXIaN5o2+52QHxwS8obUxUc2Tb oXRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brs8qxFc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c125si16029269qkb.283.2019.10.14.04.34.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brs8qxFc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyc1-000463-KI for patch@linaro.org; Mon, 14 Oct 2019 07:34:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45551) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2E-0006n0-OK for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy2D-0005F5-E1 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:06 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40233) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy2C-0005Ce-Sm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:05 -0400 Received: by mail-wr1-x444.google.com with SMTP id h4so19188014wrv.7 for ; Mon, 14 Oct 2019 03:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LYziuWTaDyCvsXZWL+7dYTQAPkm19wADCHnlP8tL2bI=; b=brs8qxFczQtTd/1c2IMBukmhANpiz8431JaxL0m9HQOdhzQUK7mHLY3XI6mSuSj8zE kc7kAE/EZMWbMAs9y3el0MIUQGljPoTEgE5GYBfn/ssxFhgNsYJpW07ox3nj98pnZxf2 kj9EZo3GGN8uSwObZiDpWgtYDrjMxAmJojgTs49PX/gr91nY+VMwHuAVa38qnkZwaJA0 69lzulNLbnF2J3zrYfEWdBvC8oQ12lWWT5d7IDPpumVa+tY5HWyizIDA30LiVb+pp8aG wUoh4kGNbj0Fe1UdfgEa1AmpakXUvqMsBkd4nHutk52kfNOgAYSxLNNmZJ3hmjMsl1/A ufiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LYziuWTaDyCvsXZWL+7dYTQAPkm19wADCHnlP8tL2bI=; b=f0N0trPzCW9fYlxlBDvrht/z5QqXzAj0psJNmxz3uGEuBTr+BLgzFyo7hp7IEdcLcv H+ERdPiCne9/xBOWu5eFELFs9yyb5NR6x2glGwJHVszGBaBLALJDBzJbQmdkp7aH40t4 aR5/bw2hXSmPif5yZDvO1Pl12fg3UtSiEz1owfL4ljtHEKWE2nhofMM4ZMWR51d8tOAV NpKuciTzUoFwnfmwoN7JyURS19NzP6Kt/5O+UejfjanH06GWR7SCUPnFRe48BtF8Oy00 X0fQ+JKceyALL1nyrE+rNIdIKvkjfNaIAYJ8tgaSKM/AKc3VNlWKmbDYxJojv4xG4HWS 525A== X-Gm-Message-State: APjAAAWnSQLl3BB8G/pWH2VgsQPzr9Ln1bqyrgRWok8WSkzkZzz7c1gG ut+s8vlptOdnellWUBX96ZoIlw== X-Received: by 2002:adf:e5cc:: with SMTP id a12mr11019845wrn.258.1571050622889; Mon, 14 Oct 2019 03:57:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u10sm17067030wmm.0.2019.10.14.03.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:59 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 482951FFB1; Mon, 14 Oct 2019 11:49:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 26/55] target/sh4: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:19 +0100 Message-Id: <20191014104948.4291-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" There is a small wrinkle with the gUSA instruction. The translator effectively treats a (known) gUSA sequence as a single instruction. For the purposes of the plugin we end up with a long multi-instruction qemu_plugin_insn. If the known sequence isn't detected we shall never run this translation anyway. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/sh4/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 5a7d8c4535..922785e225 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -1917,7 +1917,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env) /* Read all of the insns for the region. */ for (i = 0; i < max_insns; ++i) { - insns[i] = cpu_lduw_code(env, pc + i * 2); + insns[i] = translator_lduw(env, pc + i * 2); } ld_adr = ld_dst = ld_mop = -1; @@ -2332,7 +2332,7 @@ static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) } #endif - ctx->opcode = cpu_lduw_code(env, ctx->base.pc_next); + ctx->opcode = translator_lduw(env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next += 2; } From patchwork Mon Oct 14 10:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176194 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4393910ill; Mon, 14 Oct 2019 04:40:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9k/jHr5Amb8jHCMpONk6G0XPlSrk71oXzy768rf8Cc29WaIUAJquYBK1g0EGR2FVo9+om X-Received: by 2002:a37:bc44:: with SMTP id m65mr28034478qkf.179.1571053241210; Mon, 14 Oct 2019 04:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053241; cv=none; d=google.com; s=arc-20160816; b=gTYpadzfYN3oK99KczylazFNN5YGbnalWvEsZXZ3NPq8WTU6/7pz6OyqMjlTW+sfLZ 2ecTLgWmApfWYWQWVycYElN6YM0lJf1Iuqn5aU64vGD7z35rDUC97uCuHPHWc+4YkvUB veg+EvBBDuN/1w2lZLJSOfzH9KgzSNiiZrSVXNMzOLm2wWsT++6oVySFlsH0GlMy908I 38uknLWEQG8j911PJZC5SBZXQ9tKN+cnajBg+lvKt1/C81N6W+O20f74JXmDy5huTyTe 7t+pg0gI17Cz+cm0nmB5rA8snN7KMpOceoy2u98gAiAv+TXjWYVmrVbwK/WpgFIENmrY cy0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Bu4rKDpgnn8IvteRUio5V7sQbtET4I/Wc2TO4RaQ0LI=; b=0rsKgDw10GJKLs0+DwU/RBSxtjgCm02cBQ0gjtNPY2QMCoC3HKwybhYWHCpVV1UJZ3 c3SjuZLJSgBv0NidQ0heKl4bkXwU/jSNUbwgq60m0HNoThQbvbym9OstLiHNJ+26LtmR VCpwpCRPgLdydKv+ifNFAN901WpVOHack8YVCk4+3ulItocfuCGQlbxsIZ1sqc9eCDjJ d0xTb7j0ZLsagxkuiNfEqQhHtgmV6YDMt5QuuZjfeZZjCTo/aBPHjPbXMnrDGqvKUf4Q xRq5Ji8VKOOpCupMBXoaBRt/PbfqdnkgrDWI+HTZp/F/6Mb8jSfmc4qbhN9gb8pd1gg3 bwaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=avE1GDIV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l62si17509833qkd.358.2019.10.14.04.40.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:40:41 -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=fail header.i=@linaro.org header.s=google header.b=avE1GDIV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyiO-0005FO-42 for patch@linaro.org; Mon, 14 Oct 2019 07:40:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46831) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyC9-00081q-0d for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC7-0007ey-Kd for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:20 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC7-0007e7-EW for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:19 -0400 Received: by mail-wr1-x441.google.com with SMTP id r5so19157227wrm.12 for ; Mon, 14 Oct 2019 04:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bu4rKDpgnn8IvteRUio5V7sQbtET4I/Wc2TO4RaQ0LI=; b=avE1GDIV7mgZMHRqjx8TRvmCzXoYOPxowBAhMsi/coT2yH8fv4kcjbr9/m6rDsmJyM P12Nhb/XHGZW8xtlkwppeR2te1SxaImvLiRYFOY+n5RNLWUytPpd0XPdG21eJ647fZcm iLAGHn6yT3mlc6BRv23KSGufccBIkOPUhwD7QKeyD1QaeC+P/Lh/+gBUTrg8Pn9+LWp8 M4LUobp4U67ZYQ8nZ04ryizEgdWzOTA/vyi7qgNnAsRz+xVpfKkF7fNjsZf59RRVpDYY pGVhoRQ1DVCgqqz6ef7E2nlNyw1e1i2gyaNxTbgpMj2wbxw26L2IoIPWLUYRyh55sv+E CGeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bu4rKDpgnn8IvteRUio5V7sQbtET4I/Wc2TO4RaQ0LI=; b=aRRwptvxoPuu6P7iuFGJn3N/QMqCGb3a4Nzh0B1RI0eg/w1xILUPhBlCtB094VfqfY bldV5pzvYERCo0UDUwc/Giwr0mpbd/ZXIzPrv3Ao6wIwLAH0MfuNbGMtTgyfhuwQAGTR vCILg60Lg+kaAKTuOXf36UkNsIC0jeKezOZqte8DTkWCufipC+nWicqXeJDKo7seO6zo ec3oJ70KaeZKZNiH8gCRAEPDUmR7SnHWALHKDS8y1+cOTNVg+83O+NheXmWJUGScZAvF jpTFy9Wj5ZjvHuMDicVId9IcOZzThygaqo38zsXPVMourP6vkni4fQfBo+P+yPj0RxSN 2ZQA== X-Gm-Message-State: APjAAAVOJah+G62espgM8ZvKwB8JZ10FANtre68f/wQ0Lo9UExuXbhhJ B4x8rbrSWFLs2ZpuzA2WC7YIXg== X-Received: by 2002:adf:f50f:: with SMTP id q15mr25759756wro.293.1571051238484; Mon, 14 Oct 2019 04:07:18 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q22sm15585249wmj.5.2019.10.14.04.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7788A1FFB3; Mon, 14 Oct 2019 11:49:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 27/55] target/i386: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:20 +0100 Message-Id: <20191014104948.4291-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/i386/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/i386/translate.c b/target/i386/translate.c index 868b0acafe..77e932d827 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -1925,28 +1925,28 @@ static uint64_t advance_pc(CPUX86State *env, DisasContext *s, int num_bytes) static inline uint8_t x86_ldub_code(CPUX86State *env, DisasContext *s) { - return cpu_ldub_code(env, advance_pc(env, s, 1)); + return translator_ldub(env, advance_pc(env, s, 1)); } static inline int16_t x86_ldsw_code(CPUX86State *env, DisasContext *s) { - return cpu_ldsw_code(env, advance_pc(env, s, 2)); + return translator_ldsw(env, advance_pc(env, s, 2)); } static inline uint16_t x86_lduw_code(CPUX86State *env, DisasContext *s) { - return cpu_lduw_code(env, advance_pc(env, s, 2)); + return translator_lduw(env, advance_pc(env, s, 2)); } static inline uint32_t x86_ldl_code(CPUX86State *env, DisasContext *s) { - return cpu_ldl_code(env, advance_pc(env, s, 4)); + return translator_ldl(env, advance_pc(env, s, 4)); } #ifdef TARGET_X86_64 static inline uint64_t x86_ldq_code(CPUX86State *env, DisasContext *s) { - return cpu_ldq_code(env, advance_pc(env, s, 8)); + return translator_ldq(env, advance_pc(env, s, 8)); } #endif From patchwork Mon Oct 14 10:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176161 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4358300ill; Mon, 14 Oct 2019 04:08:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa58xJ3UZp2dKMth1wF0mhBjmZ4UZ1BQWhP2+LYevZv5ChDrbL8iqiZPEzmXQgkeR7B92g X-Received: by 2002:a37:a948:: with SMTP id s69mr29119124qke.87.1571051308929; Mon, 14 Oct 2019 04:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051308; cv=none; d=google.com; s=arc-20160816; b=rUjn4UeHzEEEcM8i9PTSkY17zfOnqID4m3wIplXkLKHvtlSFUyX13LTzJGxNfD8szv gysM2EQxk0ChVGCvDN5/SAOXdMAOGQUpzAaM5ur+jrRLbOF9ANbShe5feaoUNX5DyzQK CktkmulMXOeLRnIoiU1Ed3j3/4fkckdxz/PNZjTOoM44vFpTGGaqa7ayKlr2V/LyU8I7 BSRfPrUq3i+NzVUWYcN/okAB3VJb+XSY4/zLpw1ee8EmkRIKaWsnVBwrXs7WB9hXIl3C 3BIuoSw7GfNINkLLfl9JtBeMId6+1ACvgxaimbJjvby4VfFInvdXkPtZ0aepr2gHH941 Zjfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=X0Zojohlrp9hFXtLnwWUFyqJ6AI3VRmKHspf1lmW8O0=; b=wYopnH/evCgb9MQZJfW3y2U4UNdJ4B58/SI2rOCc791LeLkyg98HLHH9EvyHOeXmqn +m/5+q5VX9IRnsf/fHVd0R9yiPoAUPMVqRDBcRQ0wivOWniaqlhJeAIsDcEt4EqNO/0g 9y4o8IY0EFdrgty7Te4tLJEBaXdFPfxKUAVSw5eu8eDzxGnLshdCSOrskWNaeL7AQNwq B1AeMje3QuajoZ3qrK3IQ9vr7EWJDBIigjJimAr6+QK+vqKY5x16UYnqMZ/Aib2E5drS jyP5BTTrKEHKt5kt2mtLCljTWC30vgLQd2BY2U6vxGMvlC1095KvMh1hlJJHsub/lta8 KElQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y8WL9jcZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x11si16243214qkf.314.2019.10.14.04.08.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:08: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=fail header.i=@linaro.org header.s=google header.b=y8WL9jcZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyDE-0000oA-7L for patch@linaro.org; Mon, 14 Oct 2019 07:08:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46749) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBk-0007fj-7B for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyBi-0007Af-SR for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:55 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyBi-00078T-LF for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:54 -0400 Received: by mail-wm1-x343.google.com with SMTP id b24so16301977wmj.5 for ; Mon, 14 Oct 2019 04:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X0Zojohlrp9hFXtLnwWUFyqJ6AI3VRmKHspf1lmW8O0=; b=y8WL9jcZEL8j8g5ZUFblK07JKH9jMhPNspIfxwRpIuCiXHmFls01aQlmbA1xCu36qr HB1s2dgPku02tKlPJE3u7G339kgbPVeRVtIy/cafAAfQ4ENU5FTohGo7KoGPA1YAkZ9s 1WNVvJXoMIdanFp50LiL39wLBI7imsU9pAjw/Ucj6CjuWdEvDDka2iCLo5jDPWbYrj4S PzmpA26rz/wklL67lGzR/p/GDFQdDDQTFbDU5Z6QOlfsTE9WH98sCKMFPJo9te18txOT Ol0lwstNLxqJsHJPwnQvnqd7h7u10ti3fULc8cifBQRRkcEZpsGvFc3Kj0j3Z7nzOfaJ FlVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X0Zojohlrp9hFXtLnwWUFyqJ6AI3VRmKHspf1lmW8O0=; b=Hhaz9IOBJWpWV4znlWsl4jq8eQW8wjkfDSkt+2qmi2n+EpB3Wx84EU+VFAygqC0VgO rCm4aYYOj0a2V2myebCO46RkxNH1mT0h3iSyB7RiL6PEyzR8LigVtrw/LEIjFJcz0W4h n8fuqYJZdO+tlaaENQHrteONp3qO5O9+gMx8O2pNILC3y9JEJO39A3L9QH0TPfIizD4h LEsFhJIjyab+c579X3dHyx7Y2881EVvVf9wf6o6VJK43YZhTgb77sBcy38zicpS/2XJL T3PL+EWHTuwWa6SHYMdJQ7tXRjA3FPTqG6KfRPYpmKoVv6Tau8uabz9cooSFLQjSgwc5 p9kw== X-Gm-Message-State: APjAAAV+j76OZb/Ehz6OUpIHYplGtBNBa7uYRmLJ5LQecq7Q1N2cU7is hz6wysmcTGJMP+JGSL/uSwqNvw== X-Received: by 2002:a7b:c444:: with SMTP id l4mr14323942wmi.21.1571051212873; Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x2sm22107558wrn.81.2019.10.14.04.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A6B6E1FFB4; Mon, 14 Oct 2019 11:49:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 28/55] target/hppa: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:21 +0100 Message-Id: <20191014104948.4291-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index c1b2822f60..2f8d407a82 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4221,7 +4221,7 @@ static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { /* Always fetch the insn, even if nullified, so that we check the page permissions for execute. */ - uint32_t insn = cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn = translator_ldl(env, ctx->base.pc_next); /* Set up the IA queue for the next insn. This will be overwritten by a branch. */ From patchwork Mon Oct 14 10:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176180 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4379090ill; Mon, 14 Oct 2019 04:26:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe0kcMxo6LPz6ybc2cCMtx5ayvW8CvSMT5HoSHly8gA7GlZ605lSLeef0daDVW+3Sai79O X-Received: by 2002:ac8:1c49:: with SMTP id j9mr32639716qtk.364.1571052408012; Mon, 14 Oct 2019 04:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052408; cv=none; d=google.com; s=arc-20160816; b=K0uO72k9iP+ZCDMTIKjd5DUPFaEeGSn15nqQDJmdtXrHISedC9t0eMK4Ar/pjF95QS NWM2i7TLC3Ueo/1Uj2QQFNEiOt/tpm1vUKCyGQ9360K63gpIZhiwjmyxG2yRu2UXGPVc NiA7x1FsKIEhmYsbvmK+2QeDnPnn3bq8La5BlKd2w4X/AAbo1SNi2W7Cxcw/xNewuZL+ epATXueqBaezYUpLGi9xnR6Ru7OvWQq3vs65d8XnRxIvPWMHatyf3krsC3X5NyoB0kLp 18TqUjUs2JX8AEu1OykW6SM+KgUR40IPGTXDJUkUMDJTjIQYEasiWLrmDL+Bvv/FMM8I vo4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xLFSa4w57TB2L7dDfU1OySLvcjk7v8MeCLcxQIOKNAo=; b=JIhO/vPqVCb00TmBae/M5nF3XztE5ivgCVRlj1niOV2yh5PluGE2C52VlvR5SRngPU I++mGKytpwAQWoKDNsPZ0i9QWoUjofGGnE7DtwifJulaEEfXjrnUa7bhbxZV4o2ZsPZM 59FOx4sRXBkuWCi4komqQmeueu+dvUsz65sVMW9M5DByDFsJtjhzdjzb0yXFNzpQlEtY lHK1uNqmpO8Sl3PACqc3CRlZZuEG4YHCypx3wMnn/W/FiDEPRX/jX6JNqZsIfkGvzaRe J0FouFCnteLAfdv3sVBRWOiJ6CzkfGuCG2WhFIhZdxFyQ5kHohrhXPi0bSgZlHo/ZFI0 1XHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CT8C5r72; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k35si17183625qvc.18.2019.10.14.04.26.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:26:48 -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=fail header.i=@linaro.org header.s=google header.b=CT8C5r72; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyUx-0004cg-4I for patch@linaro.org; Mon, 14 Oct 2019 07:26:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45533) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2D-0006mC-RX for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy2C-0005EP-Sq for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:05 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:44290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy2B-0005B8-CX for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: by mail-wr1-x441.google.com with SMTP id z9so19149137wrl.11 for ; Mon, 14 Oct 2019 03:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xLFSa4w57TB2L7dDfU1OySLvcjk7v8MeCLcxQIOKNAo=; b=CT8C5r725CT2KWfWLaMhgBz3CglamerMDXY79bsg6Cl9r2GSY6iJiXwQRlj1miX/Hb xlyqa32VoQpWwuROZaAe0pRmKoXiq6oeZPMlw1qM48IHXG/sN4KmOhwpGanhXRaWzfl1 Fq71inf8SqRXuhhCtFSKcvZNa9boXW7rvqGRIxn2G/jSe2qaPuvWmrVGSk7pvXMWqGhs gpB28C3q8vvcn5R+7cA5QNblv3ZMTkaF1gPQSRZeQQHZuAGc/olijzrtno3dm3TW8ocr +CmdfTrib0j4/k+6nudQIzGJnPcQbIE3WdMmjnru6wCCHNXlFw8kTPO8olvbXr+v6zu+ s/cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xLFSa4w57TB2L7dDfU1OySLvcjk7v8MeCLcxQIOKNAo=; b=O2A4pzj+7Cq/DsuFsAAbaejEbOb+VOkQGeQtOQCTBpT9oiWZFQ6rBW3xs5qBbdBLhj Eye/MNSiO0R0bADYSoy5bGOTWExPSr2F052YJsO1pk8roViI6MT0P1OYvIfabBJ3C/Qp WKwlXEQgF3TpfG+qMcxuxAFO+td+XxqGyamHmfUHbG58Sy5U4S3RGNo/lhfrnQ9k+v5W gDjaDZWvR16jilTdNR+PhQkzheMAPyG/1/zR6TGyn9NR7V+Lp2wwCuzy4zgPPltuhw4W zO+ugoK9ZXonIZaVdMSN8rYPbnhbpYWneHVaE+OiHqxeksl0WxFQ3h7IvMemUGZz2LP/ Y3vw== X-Gm-Message-State: APjAAAVZOCr8unCaj34JbKIL6Gewfqth9qChY0NC7hhmM9421ihcHtdw QajU22BtH1+DKJ8uosOs1Jdtmg== X-Received: by 2002:a5d:6384:: with SMTP id p4mr11123783wru.379.1571050621388; Mon, 14 Oct 2019 03:57:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r20sm22819850wrg.61.2019.10.14.03.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D86D31FFB5; Mon, 14 Oct 2019 11:49:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 29/55] target/m68k: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:22 +0100 Message-Id: <20191014104948.4291-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , Laurent Vivier , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/m68k/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 24c1dd3408..fcdb7bc8e4 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -384,7 +384,7 @@ static TCGv gen_ldst(DisasContext *s, int opsize, TCGv addr, TCGv val, static inline uint16_t read_im16(CPUM68KState *env, DisasContext *s) { uint16_t im; - im = cpu_lduw_code(env, s->pc); + im = translator_lduw(env, s->pc); s->pc += 2; return im; } From patchwork Mon Oct 14 10:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176178 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4375781ill; Mon, 14 Oct 2019 04:23:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+GK+iipScnJdpW1f3T1m4XHNqU1t+RYW/9CNApKS1rsHhQNhyuklxXxEScPGw/efvVJNU X-Received: by 2002:a37:ef04:: with SMTP id j4mr28952804qkk.75.1571052225139; Mon, 14 Oct 2019 04:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052225; cv=none; d=google.com; s=arc-20160816; b=ibe95bLXRwxupETFPlyL0206Ea5863eK4OYjDBeAoFbmrlZJArOShxTgmiw1iFgmS5 bhOVWILaqgriIW31yp/rc0eHnsXTpxChAIaESki76ZDK7Rno5pO2PtR82z8eVG7ABI7F CdCA4WVtQ0ZQdENpeO/gwUVc9ySZuElTjbBY3gX/85Q8OV0huP2uDeCbEReXfKuk6n07 LrxWxb93yWa8m+3RnwLqfrt47FSahnmRREbKGMSbj7PNHLdPRYJB5Npf3uVJJ1gUBVSA 5bHeFrbAKodHCiC+TqyeJUdumtnRv8TQ1Ct1SlqrqsvpSKYGj9TPF5epM4IaBJFlyYHW IHSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mpf3Fhzk3B9PbwCFqYApvOLgEupxrJceH9hSjq15/sI=; b=l2iIeaE9nBeas6vJp/ErKvxcB+UdvtC8/HoxQpqtdTDkIEDx5Gr725Bj9dWPFsVQuD pWIYfh2JrXoeLWFM7rkLBVeKoaFUKpGhtWynhbzzlH36N4IFugdY14DeCEtIszljmiIr HdnxwTeW7ZnIv7kI9ndIWdpcPzWDowympZTp2/zsjLesaKR34YkYqXTZ3Pwv12hVbEXQ l7iPSbrgECXFVcrYdjEOHejSR0UxolG0IoDKflm4e+GG7d1rvua+3V0ZYafVTPo5pYgT kTdW7jWl/ZWNw/Xn/FUEQ3cxpUUH1E+ssWllxDaccnxEIRPosASmibu/DZ9cdw5slcpE XlyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=R4IJOT1o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j31si17964013qtj.115.2019.10.14.04.23.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:23:45 -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=fail header.i=@linaro.org header.s=google header.b=R4IJOT1o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyS0-0001AG-6D for patch@linaro.org; Mon, 14 Oct 2019 07:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45502) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2B-0006fB-E6 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy29-0005Ac-Pp for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy29-00059f-Im for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: by mail-wr1-x441.google.com with SMTP id r3so19173554wrj.6 for ; Mon, 14 Oct 2019 03:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mpf3Fhzk3B9PbwCFqYApvOLgEupxrJceH9hSjq15/sI=; b=R4IJOT1o1jOjjGhkIgF9MHKi0M+Qx5IEuXP79ISbqzcuKGRRc7Id8uLJFUnbk6IiRn Rl5lG+CJsE0JpeOFc5WTDXc4k5WfDYSPbQfE6XepuGcOkEnTOrFS1P0AqJypA7dTcTuv 8eQkDsvP6uMCnyukSIMdQAopgjWJa+1tzzdF5IDtGt6jv4jCFSG8AATpRvmLdM+VLFrq 4/uR7vLdD/Y7YBIpn9yZYiJGevzJLacX5AE5avUL4IjJuaawZOUmSkm2BI7GXpPz/Fq2 ZPN8+ddRV7m1D5jcVqqoWfKD2Byoc37TDCfdwSF1ZT7eCpYpbY5R9gYiTsHwvr33SyR9 7nhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mpf3Fhzk3B9PbwCFqYApvOLgEupxrJceH9hSjq15/sI=; b=qMIdLZaiKhfI1KQznDUhMpn6CJ48MFe9hre8cDp9eurj03/NqqS6dUSVZZfG1xPa34 qFF6wyw2tXvrf7AnKlRRqDLHpvLZxKnqNt8jACWTqhTuvIe3ev+KsQ9QqRbuKOGMQx3F Tt1AFrmASsD5Gps8q+lV3j3dTWcwKOYFe9cQCqKSVaij+39pKQWnR9lDmTHsAoaizZU4 wMLs/z1em5XM2Iaz0dkTiXD70xy+zGrvFC0WVINCUbt8XZGCXa00n+sIIfq+6MQLX3vt C25wVDzkSGWrKCXoPe80VzpN0legWEkwUq0RxoWpQe38tJVrp+VmMNDtK4GnL43uF16g 75tw== X-Gm-Message-State: APjAAAVRVvN1vP7j8cVlueRlT9A4A6ZZk9JJsyFIccv7baz4YAVE5235 K6n0286rVw8w4ZTmvfXkuYd85Q== X-Received: by 2002:adf:bd8f:: with SMTP id l15mr24807414wrh.362.1571050620522; Mon, 14 Oct 2019 03:57:00 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u2sm9583732wml.44.2019.10.14.03.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 067D91FFB8; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 30/55] target/alpha: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:23 +0100 Message-Id: <20191014104948.4291-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/alpha/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/alpha/translate.c b/target/alpha/translate.c index a69f58bf65..f7f1ed0f41 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -2987,7 +2987,7 @@ static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *ctx = container_of(dcbase, DisasContext, base); CPUAlphaState *env = cpu->env_ptr; - uint32_t insn = cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn = translator_ldl(env, ctx->base.pc_next); ctx->base.pc_next += 4; ctx->base.is_jmp = translate_one(ctx, insn); From patchwork Mon Oct 14 10:49:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176175 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4373445ill; Mon, 14 Oct 2019 04:21:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK066CJY+xpVfBIYDkhxNu9hSa7ImKW2bV/XYBXLq6pWq5QJmiB5f7QlIF6swJylyf8z2G X-Received: by 2002:a17:906:82cf:: with SMTP id a15mr28239683ejy.279.1571052086737; Mon, 14 Oct 2019 04:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052086; cv=none; d=google.com; s=arc-20160816; b=LQmFPr6pUA1Waa18UnrRE7nvaNTsUMpX69tnKQVF1B+6WJuEhOwHJK8RZusziif5u8 SrdHOu4XdytRlFJ6HNzTgDGhwXteVIUBPdD9lv5mgIxpEkZYjvJkk1URYDF1j3M/HuV+ /gjBVKpU9VQ8RQtahrtv/WJqLNSUadn3XC526s2J+5pdIud3CAzLa8BHWGPI2Ioq1Sq0 Fh+B5UVwtvvSg6mKYFJfOMvQbjiP01pxLhZHExqvk8u8ipUqxoEY2qTYznE2WszBxBp0 d9UFdS6cUUhJMvZWM49s9hWOEn0vJ09hgOhxwJ9iK2KDNAc7t1qbUs7bVJt7nbR+BjgL zJbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+MF52Dp1tIuy0gH0L5TXn68Hzokx6/nbmqPRJPtyksM=; b=tf+5vjXHB/+yT/4VCNeUb9ZFAujKCbZSvF5rSncSxMuQXts3/J2HxXh7ElcjzxqqOm FoQkCdToHHPDsabdxL9WA0/Or38fpTI1hu+SmQ70TzohUSAhQ869vdmRPAgCcLVM/Wl6 qpiCrJgbw4/GvUDQHddrnHjY27+0AZOIHx8/ZPK8OJDbM/UuAgRd12y2IxLQFUVzLxaa grSR4JefVunWdrEERjTu3v70HKC8G4MgO4WCIcUGzJKHNMaxXa1/vtShAAg7bklKR6Mn WMoRLIvcdAw1jRIIyIhJpGmckFHKuYFx5O4zCc4x1Cv9j82aRyEVuvpTpJ+I11hEOSfr oqLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tOsfDhQr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f29si11102404ejj.110.2019.10.14.04.21.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:21:26 -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=fail header.i=@linaro.org header.s=google header.b=tOsfDhQr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyPl-0006Re-IO for patch@linaro.org; Mon, 14 Oct 2019 07:21:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45469) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy29-0006a7-Le for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy28-00058d-7P for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:34513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy28-00055D-1D for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:00 -0400 Received: by mail-wm1-x342.google.com with SMTP id y135so14227037wmc.1 for ; Mon, 14 Oct 2019 03:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+MF52Dp1tIuy0gH0L5TXn68Hzokx6/nbmqPRJPtyksM=; b=tOsfDhQrvWGnrPVlnmK5f/TXut0hgwt19BVb3kVnHdg7JIntLwUKOuGk3Fex87sNFR ua29FaRJ944GmxxOQ//ypy/qqlukJYMb3mqxVyFDroPTMLD2u4depBlyruhBXYiQw2tF If+TmHeHP7dXxUZGmdTVVOkDbXJapok2RhVK7TXwF+N+eekRisc+jBBAfKI2m+O2yeXq Zs+VKBsLO07sGKafYHMMOqdG98VV6tT8/G8ABwQmlILJpT7IycWM7sxEoIRvemobI+TR JHriRBpULPNIr3vyWfS6UXitMRyfxj+l/NjwnbOqaf5GZgVOtqozjEHQn4n8mvVSCJB7 BCkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+MF52Dp1tIuy0gH0L5TXn68Hzokx6/nbmqPRJPtyksM=; b=BWDYqjjukhMUdkAQsmIKwO17aKW0maedFRfJtknrTmK6N3Ez6l13iQ5BzsIyoU8mtJ 1wRuJPSg1KCVwdCh0spN0JodpXlifh8ZnH5B1ewUJKHKZ1MBSgHFKCPNOdh0c1vDUgI1 zeGw8tY0ADvfN5btbvCZEHMbJxTkdVrM8/AHE0RRKixbEoZgN6587JRmidDxdO5VSAik 5QwszCYsN5lgzVqrok3tXSpMPbSV2X/26jwEJOkhpF1PbDW4ELKCCGSCKXuyf4YhW9QN avaEziep76TYm8ufcMw9YCisivJnNh5xpup2QONCxLiutajegRTpD3/z7g/yrrTjecRN kCwg== X-Gm-Message-State: APjAAAUCZmCgBLty2hd2wZyYkAIj0rpSL16uko05dSnj1O29CKG/h4jT rF8hUU+7f+pxvQ1ATfnHFakejifz4tU= X-Received: by 2002:a1c:41c1:: with SMTP id o184mr15324749wma.81.1571050617771; Mon, 14 Oct 2019 03:56:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f13sm16009547wmj.17.2019.10.14.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 30E8C1FF8C; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 31/55] target/riscv: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:24 +0100 Message-Id: <20191014104948.4291-32-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:RISC-V TCG CPUs" , Sagar Karandikar , Bastian Koppelmann , robert.foley@futurewei.com, Palmer Dabbelt , Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Alistair Francis , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/riscv/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Alistair Francis Acked-by: Palmer Dabbelt diff --git a/target/riscv/translate.c b/target/riscv/translate.c index adeddb85f6..b26533d4fd 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -779,7 +779,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) DisasContext *ctx = container_of(dcbase, DisasContext, base); CPURISCVState *env = cpu->env_ptr; - ctx->opcode = cpu_ldl_code(env, ctx->base.pc_next); + ctx->opcode = translator_ldl(env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next = ctx->pc_succ_insn; From patchwork Mon Oct 14 10:49:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176174 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4373402ill; Mon, 14 Oct 2019 04:21:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlkqLOTxvFjOEVr2vC5x8Rp8IK61tt9FxU2r+WbX1YXuwq1SYDv/L36ckVxVFMH4DCXHOi X-Received: by 2002:a17:906:4e92:: with SMTP id v18mr27434402eju.242.1571052084087; Mon, 14 Oct 2019 04:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052084; cv=none; d=google.com; s=arc-20160816; b=UYVy6UpJA6P819aGi4wtAJULVXwxhV7OwKFEAhkdcMypnIyvnSQY3hX3WX6p4mnBfy YlHkRUIgfvjMHKiWXsWLzwQsJqD4TC2rRWrXQuA6HbjlpR7SEn7XfOAG+Z6yqmWjrMMG FLar4U1+T5EYE4YcjBo9RMnoDjGQ8mk7Tm0JQosC6/M43azjvu0ISGwhEtVCziqkjzQL +wLZbxDy2H1m/s4Wh/5TArAa2CWtsC47gurXU4CRZ/s2bnVaVW8BaBf8lyEiar2aO/k2 mE6XAGMTc34xj55u6bOveJHfUryrJ22x4HB2V/BoaaBtn4PKAyMHey/t+X50XUL1uhJB LpPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=s/Kxt0sJmOqiRHlmaA5zdwUg0XEvdkyMNiTJ70WsIM0=; b=mrKY8ApsuWYP8eIQK6BloI/XI1ls4ztuipcD43zqSTYnQJLSvFUK7y56hKs6zCJp1p ztNVjWcG+sFksG6pa7Ar22ciZH5yj35EfuJNyuwO7SczuXtlOyY3NpG9kO0uNMKmQ9u5 IQbJK29nTVn43erT/YU7gvj4MuIe+/SKWWqTaS4M/hcnAyXSObS5ECso7CUd0R818h5u asOSCXX2cCA9epJ0OWN9CewXAXV5fDWKMIQxXknsS/ydYyYC/sOF5ZRaoBr/z784dScs 7Wrn7V+8g+NebKSYvSM4lD+73oi6SmszK6qIuUVHA20KEKhluB8Xw8xbX+AeY3pOOmfz rssw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="w/nWkjRN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y3si12439018ede.38.2019.10.14.04.21.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:21:24 -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=fail header.i=@linaro.org header.s=google header.b="w/nWkjRN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyPi-0007ER-Pj for patch@linaro.org; Mon, 14 Oct 2019 07:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45417) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy27-0006Xd-RV for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy26-00055v-Na for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:59 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy26-00052L-HR for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:58 -0400 Received: by mail-wm1-x341.google.com with SMTP id 7so16780402wme.1 for ; Mon, 14 Oct 2019 03:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s/Kxt0sJmOqiRHlmaA5zdwUg0XEvdkyMNiTJ70WsIM0=; b=w/nWkjRNXKlnA+PYL6hBeRzOc+3Ky3RofHHqHE406V4pk+mEUUiA5AFqwUdM7JACJX 4ZNbkPdNSRSk5bwnQa2yBQxQgLFZo8UQFE1t5FTKYwPMu9wcQzdlEdEgiWylLRKH5V0f uLu/1Ts2TuW6EemTH4uq1WAsDjRmDsVNbR156i372GuBenrSQFWQB547XlJQYpT74Ejv V/w6IGOAKathLXkVE7f9Ko6a6N/Iv3uKD4X+28kpsLJaOK1FLK96aykdGwQ2uDUnBxfg UWRku/qhC5qASK14P0BK3Kri7/9MITx7Zl9STBVDrZKWsOWr9onum0Tb5uZOWSmW1k4j PGmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s/Kxt0sJmOqiRHlmaA5zdwUg0XEvdkyMNiTJ70WsIM0=; b=EzryneJ3Lbkp6Hrfydba3Ey1iKMROJPdqyZigfKwrEZul+5BHxSNV5qdip0n7k4lSl LSF2wSdgvUn2+4Ij5XmnRQm2Ocd52fLQ4blyjF2mWhz3g8KjgbMEUJbAJmnGTXLCa/rU 3tLJsDMXWhnqkXplytEFou9EWBZif7OYtoTDt9HsTjX8aJMAD0YaYPsB6wrSK5ATNua/ /A5ThiZANBtj7woxkNjCPIbsWV7cX1XXFWSXntPSJrA7R7pPhvq4rKFHRDRviC1oEZiU BiCBHIpDaOZy/LqhfIVmOrQOyk7149xeLv55J+vGExFFARizzyCAWI0Vrx0DAJGDNUph 8Q6A== X-Gm-Message-State: APjAAAWAfJjT6BU0N+DJOMh3VXvZQ6mcSTntGxx1t7SYJwiX/10GtF9w KLkS4KxnrKKvSCfGqQ136tSL1Q== X-Received: by 2002:a7b:cab1:: with SMTP id r17mr14135756wml.106.1571050615326; Mon, 14 Oct 2019 03:56:55 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c132sm26763719wme.27.2019.10.14.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 688701FFBD; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 32/55] target/sparc: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:25 +0100 Message-Id: <20191014104948.4291-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index c68bf4a2e4..edc23a7c40 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5884,7 +5884,7 @@ static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) CPUSPARCState *env = cs->env_ptr; unsigned int insn; - insn = cpu_ldl_code(env, dc->pc); + insn = translator_ldl(env, dc->pc); dc->base.pc_next += 4; disas_sparc_insn(dc, insn); From patchwork Mon Oct 14 10:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176155 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4352039ill; Mon, 14 Oct 2019 04:03:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOniZ35G9mEcQ0QSs63zvOD87EUxAd1h7+g/q0WaL2gIzWsgp2V4nkWlt4iqjYMQL5uPAO X-Received: by 2002:a0c:f702:: with SMTP id w2mr29491287qvn.111.1571051013292; Mon, 14 Oct 2019 04:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051013; cv=none; d=google.com; s=arc-20160816; b=yN/H3MssggmucAZ06sfc74NN6rW/kv3CNOGEADTePutTlWXCBNDlCJQbySUAYuUtlP UygzaUvyD8qMV6voq1DgDTdthL+lZtMmaxh4qwlZv5yH016m/M2U0BCkPSt0eyT10dMv D5X/DwQns1KyU8ic2ScSlF2pWaeC5aEbv8L1b3pT6a72pse3Ix2ojZbSbflYxiVvgIsk VG+DtZeCxFhFfzfzzM1mnXZC3SbWL8dcM3aKpMzOx0BdYW4TbE66trgYsknz2WbqBA6G oesoo6dPy8E+5DJj6Sv05bOzPuIo80BTZSjERThKbgMyGF11xelToDFiSlDVMn5CA9e9 iJHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ouhbdjwj8mfD0TiFH/h8tXJayT2ifkgem8zqWo4b7jU=; b=P033rQy5IHyy2LM3b83UZwZxoNndDCapv6IEpEp90pra/+c520t4jUTpsuPvAGwpvY FUvG88bPDHhplEP4XImGqs9qDBsfaR9flU0bPsC6bGPfs8DrGCHl4uYxxg2gDr1RG8CV 3aEeF4tlnsoZ08loRAFSC0sl3XGNP2eLunRAdSM5TzDzCeviDUXN74rwLyKxKNeAC22O 1kdGvdJee7vfJdn40iQpKS7Ghx/6cdFPozf5COiqfYvngFL0a6yZIGdZ7XhJUANNrJ7a +Hq4N/5lBVaXtp2YQXCTUrlVeIA9vOdZlrFbld7x/GyJQ/N3FSjG7piGTkrxdMCAuSjG 3yRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v9WBT6g9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g43si17330374qtc.379.2019.10.14.04.03.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v9WBT6g9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy8S-000371-4W for patch@linaro.org; Mon, 14 Oct 2019 07:03:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45362) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy23-0006TP-It for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy22-00050T-F2 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:55 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:34903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy22-0004za-8Q for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:54 -0400 Received: by mail-wm1-x343.google.com with SMTP id y21so16283819wmi.0 for ; Mon, 14 Oct 2019 03:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ouhbdjwj8mfD0TiFH/h8tXJayT2ifkgem8zqWo4b7jU=; b=v9WBT6g9jwv5whm8VpF8ZW63fhYRq2OUCbxJ/bzgG04sSQbzSbQ7uloTcvJ0BCryfY 3j5f2NT/rX7W7NN1nH81Eex7M1HZt1IWzzqY91Lbq2OT9/1+VP8ge8snLqPK3pWxekCx XwlUEwDxsgYP6iJJxraWpXqn1mrop3hWZVnCBFCQUO/ts3JpkF8Sa+AQ5JsGLb9BYpv3 TUy+jVB5MvnPkiBb0idzqDjKmQzlZJ7ddXFoMg4Nnq9KgNsH1Ee5q6LxzUtz4KzG+Rw5 x6KHlwR0lhj8zfnDJfOzwa5KNPeODamMd424UbheNtoxXx6Em8TYRLlXCak7T5hgVtcK tJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ouhbdjwj8mfD0TiFH/h8tXJayT2ifkgem8zqWo4b7jU=; b=NLhihYkM/gqnrfUJ6gOmMWRnDPpGgRdH1KH9KwNRBS10JMFuaIhCdjMZirGUJ8rsKS u+iOqUQyDg7VrqREC0mbvkxxQy0x4HgCC1zqDKxU0XatT1+Bjf9Fpt47n/DwCkndGjOb 06KREjBzBFdj4r8pZR21WEqqHKe8DmR24PCGNPApjBp1570kqv898ZnsolylsdKobmpc xvuDs9Ca8XUS2ExrooOj7CD3B7eGOvpWw6lf2bp3D9CSSH0v9kctG0ewvxAaO13A+2Ml l5NPlDQgdotWdFaTM8WIU/KPtKso8keYWRxhlWn/7sC+Ly4cnBBzz9vrdB6GT2kTO6ZU QhZQ== X-Gm-Message-State: APjAAAVOr+Uxp6LGxpvsrels1yvaJT/41mCDlPO/be/akR9i6CZ1/9kC YCBIE5RQ4K5hlSuJoiBjKuZRAg== X-Received: by 2002:a1c:e404:: with SMTP id b4mr15499090wmh.90.1571050613042; Mon, 14 Oct 2019 03:56:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r2sm40163867wma.1.2019.10.14.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 91ABD1FF87; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 33/55] target/xtensa: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:26 +0100 Message-Id: <20191014104948.4291-34-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, Max Filippov , aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/xtensa/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index d20e60ce77..a99f5296e2 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -859,7 +859,7 @@ static int arg_copy_compare(const void *a, const void *b) static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) { xtensa_isa isa = dc->config->isa; - unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)}; + unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)}; unsigned len = xtensa_op0_insn_len(dc, b[0]); xtensa_format fmt; int slot, slots; @@ -883,7 +883,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) dc->base.pc_next = dc->pc + len; for (i = 1; i < len; ++i) { - b[i] = cpu_ldub_code(env, dc->pc + i); + b[i] = translator_ldub(env, dc->pc + i); } xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len); fmt = xtensa_format_decode(isa, dc->insnbuf); From patchwork Mon Oct 14 10:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176187 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4388167ill; Mon, 14 Oct 2019 04:35:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqBAMYk7gPPJv4OWMSn+YuPH+EHPFa55aWthZuZDeN9d8wN3j6VYJa7+hrqOJUV1EABpKo X-Received: by 2002:ac8:19f4:: with SMTP id s49mr31919695qtk.371.1571052906860; Mon, 14 Oct 2019 04:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052906; cv=none; d=google.com; s=arc-20160816; b=XkHPjXRl8fzYhl/9GzeexoM+y4J1YHQYMt8HaWK4YiE5eDlSL/EXp8s4qdVYucqnMV tAxfTikw7rU3wSAhCxdswp9UV0ORfLoliDJhKPYniNQL3FrqQjR8o/y8BZSh+U4wFdJz RSL4aexlhEgYdv0ooXZb2Lvq2lG4boeeARkdt8dRd3rLOClX3bMBODJNT8zqw8f2ve7g TyTodxwmAyBJbPeMmtFCaqTrkbCc+61PCreMrZeof8ym2cAztSkGLfp69eTYWIrHb2yk OQhViAJa3/VyDAbc8xEdmSLws5KU5IlSztfGd4CLE5wY5Fs/jaNJgu+Cgkitn/qv5I2g 7+ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZiZ/jjbBIoVwkmOcALd/5dVI1/K7ovHMSAFhO/Jn2Ls=; b=wdMXTPcUZBshNw9L+3989ZZSRCd5hR+UDPWRhNUOkeSGfeTPeQuNoR28tzMCxeBqAj OIqsSp+MP8QzHgWptEIA4dxhAv+/eZVfKx6cfj9+m34M1JUV3ax2R9NZ95FJo3/YgAVN N+P8v1B/+dL0BVIqBd6rt+Z8qZOnlK5xl4UsXbZFJ1Mnh6ZLiz0gqn5fnCxkIChdrehA T6wBpBV7Jc74UddZcz/meAs/xu0fAqNFKzg375I9f67pR0MDJbsweYLanWC4Ez4HRUnI 7qG26ST0Pr9vgnfVTANKAE/sQNcItqP8OczUOcCErNDd787w0XGx6qFgcdKA9IGjF9nx bAyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vBeicO2H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l62si17500072qkd.358.2019.10.14.04.35.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vBeicO2H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyd0-000613-6Q for patch@linaro.org; Mon, 14 Oct 2019 07:35:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBk-0007h1-Mm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyBj-0007Bs-HR for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:56 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyBj-0007AL-BY for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:55 -0400 Received: by mail-wr1-x441.google.com with SMTP id h4so19227380wrv.7 for ; Mon, 14 Oct 2019 04:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZiZ/jjbBIoVwkmOcALd/5dVI1/K7ovHMSAFhO/Jn2Ls=; b=vBeicO2HOdNu2/iT9QsLjmbnAvfBHkrpDoaaAxu/31tuneH0ono5KWCMuq4qx50R/z nkTgcUQK+b9+x9nVHJoXSUoXfY7bfBhNMOTVj4/kZBq0d2YHPgeZ7Pe5VnXd4bEhM9Zd NMeP1cHHNThFvtBk/UnTD+rpqCcvUDDNbYVygYbF051z4ccE2mLBdR+ZBkgHZFoV2i5r YRVDcadHIVE/+oBKaX9OMDEAH4NYazO+GVpVpUV1q5hBhVSKHh3v7oeVVn5APhGCdhzp vdEdVoOh+pZ2Bo0uk9dJV0/j780PAdsP4+x6+AoxvdI0hfOtbFiSv5HsYZYWjGL3BWDB M5SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZiZ/jjbBIoVwkmOcALd/5dVI1/K7ovHMSAFhO/Jn2Ls=; b=YKL0sNyJWF7kVahu5ReJD4HIDSkzFDaLvVUWMnxWRbIEd0SKx4vjJOLuSarT7W/4ze XmnO/wc5ZQpWNax26MGTsu7PgmeDU12gNYcsHfj3tggnA1XgOCoYl6nyUYHRG19IOION 6dPYYNSSlqElq2J+MHESQ0RcTlJjTF+ueZ9eikQLETaky5wMLB+SqENKNjMwGWq5m9EO 3tTdyhmCqU1wxjCDyu0DHSWBudrgs42C+wt81d2QC+QrQCOr0vcb0/fDTWXkgNVAHULI RGwFNGNkWGtXbY8K5TDFAFKYCPwAyLFmJ7boOWYnsJgPrt7lCHXyHWicwy/hd5+Gj4nL h5nQ== X-Gm-Message-State: APjAAAVa3yIsjagdgjl30ulZg/pUOq1azogSiCTzMeWtzNgBqK1PR1+4 odswjZuv5t0bUGNe20jaRpsppw== X-Received: by 2002:adf:f90f:: with SMTP id b15mr25344553wrr.76.1571051214031; Mon, 14 Oct 2019 04:06:54 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p5sm24188293wmi.4.2019.10.14.04.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B105D1FFBF; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 34/55] target/openrisc: fetch code with translator_ld Date: Mon, 14 Oct 2019 11:49:27 +0100 Message-Id: <20191014104948.4291-35-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Stafford Horne , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 6addbac8d6..8dd28d6cf1 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1645,7 +1645,7 @@ static void openrisc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); OpenRISCCPU *cpu = OPENRISC_CPU(cs); - uint32_t insn = cpu_ldl_code(&cpu->env, dc->base.pc_next); + uint32_t insn = translator_ldl(&cpu->env, dc->base.pc_next); if (!decode(dc, insn)) { gen_illegal_exception(dc); From patchwork Mon Oct 14 10:49:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176184 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4386112ill; Mon, 14 Oct 2019 04:33:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOWy44aOg6pQVz+RBPc6SaOkfo0BfkA+OtNUCzg2OGvODjweCVI/ERKWAy9IMOP5xdMD2e X-Received: by 2002:ac8:729a:: with SMTP id v26mr31219096qto.18.1571052802199; Mon, 14 Oct 2019 04:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052802; cv=none; d=google.com; s=arc-20160816; b=DyGrwSD30r0Rvc05B8duNjxMVWXgmBFUez1BWusqow+C9QKdnKaZKisIoVuDl6bgss 39i25Cp88e16xHC9/EcJJbH0gmseYWuNEXgQ/3hFK2lCZYMGc1wTIXvDnlgTzeFYeQNI iQyzmi3FPOEAjtbSn+M3Ot+fVGMdfmoNMHedWx4CfV43zMuPIwSjk8aifBfjZpZmD8Y5 bAbdItM/X8xAv8zb3aEx+JQuDXl4ySb13SIfqyQPQ+tYc9xJWqNdFKbtXd0UN1a2kr9Z HBD5gT63uLnmG+Id8G9lDK3hyvF1VQxGieEXFWYV2e7vOvbFcl4V5is/TmJ7V3VFkITV LnBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=coCttQh1DJ7CtKBy6WU9Qj5nCrM3kKgVRgB552jvYCY=; b=x7tvs4TRNHKgcLeF9oz04pifDsLP8ZaHE8x33GMBEi3vWHhrss5lqAIZnleZ6xcGIf 6ZXo6bRY1ft/B7P3zdGd3BFD8V63fCEdwHUvdrfvMdE69K3yPlqUcqOcnODh5/QaNOhN +BR3/HrryjErjfLNJNmX+mgH4GYFct6QmHQI0lpeiW0HwlhC4Y9f4no5BZ+SOFAnfLjQ UGj4Al/kovKxL99s5FGlYnKt8joiscX8SFlBimwWer7LrXsT15sXf13osyxziJfx8sAJ T7yP0ghhsygtXl8+jld7GqAHW6TzYVDi5sj49HX9WSeLy9e/CqbWixyvvxIluBDQUZsH umDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PBsiOf7K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v129si15651762qka.262.2019.10.14.04.33.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:33: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=fail header.i=@linaro.org header.s=google header.b=PBsiOf7K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJybJ-00039V-E7 for patch@linaro.org; Mon, 14 Oct 2019 07:33:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46751) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyBk-0007g2-4X for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyBi-0007An-SU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:55 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyBi-00079d-Lg for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:06:54 -0400 Received: by mail-wm1-x343.google.com with SMTP id f22so16304920wmc.2 for ; Mon, 14 Oct 2019 04:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=coCttQh1DJ7CtKBy6WU9Qj5nCrM3kKgVRgB552jvYCY=; b=PBsiOf7KV3rByI4fr27OGVvzX2cIiiioQ+aj1OCgo/vWt8f7JUhVq195VrAUr3JVkv QyC3rjZn0ckqYVV6ulDMH2hcTBW4K9WCeZ9hj/n1a6ZXZBCmzsXKbJVhHJZLrWjaVpVI Wna6aoYkX1CNrxDAEjkSiLzD7toTorLzZlliokwnkG7Xp6WcAkqx1Xh0ZuNElMz5/kqH soSGGwMmfgW0C1TJXTpymRq+UeOhac0CGJrN22XaFIKjSRWnGwsEvVBUYNak0guAmU02 aG4LuL4DmN4hTdIICNzSHzaZY6FHDWJELFftNkJhhP8f1GMSCW1h/GAZWkq/4Z456EWK xssg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=coCttQh1DJ7CtKBy6WU9Qj5nCrM3kKgVRgB552jvYCY=; b=eetowDrgS/Y0IzwFBsaiS5/48d1o+r4hLkVBkrCIH/xigBf2+bf7X3RMGC/aLPRnES PNljE1SrSo76BAtpYhkmQpy4hmgGjg6bnIIBRBliNR7A2iceSGHCVp+WPLkfPkkVOPY0 yJX1aWhRyb1PW0OlozHlhWGvFV8XIf7VcowI9oODbWDh292tQWuT+MF+T2rXh3fFkwcT Hnkbmt2+yxTIMpdHg0LMSJ1Asdici1KJjkrXcUIpA6RRUQ8hdQr6Hbcf4kU90VCCx7pH L05K6sKwLFtXZ21z/b6sSb3cWkW87SbmuahyUXSDTUw1zrrxeDVk8FGnVlWRtMECTnrh dNYQ== X-Gm-Message-State: APjAAAXZK4ZoBVFJfjvcJDCFypXWZd8FwlgxYgYs29u/jwzb9DBKuz+l R8ytUCeY/OrFslv4B6IuGOCFcA== X-Received: by 2002:a1c:7e10:: with SMTP id z16mr14087292wmc.11.1571051213375; Mon, 14 Oct 2019 04:06:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r3sm4014734wre.29.2019.10.14.04.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:06:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DBBBA1FFC1; Mon, 14 Oct 2019 11:49:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 35/55] translator: inject instrumentation from plugins Date: Mon, 14 Oct 2019 11:49:28 +0100 Message-Id: <20191014104948.4291-36-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - note we can't inject instrumentation if ! DISAS_NEXT --- accel/tcg/translator.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.20.1 diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 70c66c538c..f977682be7 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -16,6 +16,7 @@ #include "exec/gen-icount.h" #include "exec/log.h" #include "exec/translator.h" +#include "exec/plugin-gen.h" /* Pairs with tcg_clear_temp_count. To be called by #TranslatorOps.{translate_insn,tb_stop} if @@ -34,6 +35,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, CPUState *cpu, TranslationBlock *tb, int max_insns) { int bp_insn = 0; + bool plugin_enabled; /* Initialize DisasContext */ db->tb = tb; @@ -55,11 +57,17 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ + plugin_enabled = plugin_gen_tb_start(cpu, tb); + while (true) { db->num_insns++; ops->insn_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ + if (plugin_enabled) { + plugin_gen_insn_start(cpu, db); + } + /* Pass breakpoint hits to target for further processing */ if (!db->singlestep_enabled && unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) { @@ -99,6 +107,14 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, break; } + /* + * We can't instrument after instructions that change control + * flow although this only really affects post-load operations. + */ + if (plugin_enabled) { + plugin_gen_insn_end(); + } + /* Stop translation if the output buffer is full, or we have executed all of the allowed instructions. */ if (tcg_op_buf_full() || db->num_insns >= db->max_insns) { @@ -111,6 +127,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->tb_stop(db, cpu); gen_tb_end(db->tb, db->num_insns - bp_insn); + if (plugin_enabled) { + plugin_gen_tb_end(cpu); + } + /* The disas_log hook may use these values rather than recompute. */ db->tb->size = db->pc_next - db->pc_first; db->tb->icount = db->num_insns; From patchwork Mon Oct 14 10:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176189 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4388859ill; Mon, 14 Oct 2019 04:35:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT6W8hEWMXF1VJmdtMXSd4kTUGVfpiETtRNOvzrc/GzZ1JFtFnPQ/77J/HH1wWmg01VVXC X-Received: by 2002:ac8:363c:: with SMTP id m57mr31873734qtb.290.1571052945352; Mon, 14 Oct 2019 04:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052945; cv=none; d=google.com; s=arc-20160816; b=okMaL+30EWmPcJVXfnfHh+RIHW5y4wJVKz1aN51t8XqOsgpb8aNPLicuGWFnVz2w5L SAEpCa/xBiMenBsv2X9ted7FvNpV3xBRTz3qvIm3NNm9FyAmIkrf9sIXkBU5qQhmiKq9 Ju8wuH2CXMYW5ZMX2lCC/3h1BNvYflk8IDOQo9beUfx9YeBEyF2kYljgYNRvCi67Yaq7 4EoRPMkjGJcR1pDiQ6GMZ0+xuAxfeyCwsFof7iIaCFzGUOULBPFpPQSFl8MolUMAGjf3 5cx/qohqeTaufNTjFHZpJMIAt3sRjmaV45LCElaDzxRg9akXM6kfFaUMy96OvujvvU5y aT4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=crw16Ubz+md1UknF7Ek+z0EbuUyNC3Q+RBvq7bGGoJI=; b=YYFStWtx1iQ1l4EcFEuwUdyHXLfi+rbTJpsiQD0JDrjwu6cRTrMe40IlLnaAvS67Jr 1YJr23NCSVrdu/JqGWGKXZIps0ddeA4vpmpDxY+p+zFUKolwBuZgkzkovwfdKlRDiGGj 6Xq7yrhD5QiZlGIBntuKhFi2WBab0p7C3IKRrJF6yyYui/aU7LKoI34nilsWwhV7EloQ Xc3VPhqqis3AUQtkNmdwGrDu8NMy6RiIkFkOIpoAr0+XGPulYgXPGlsm6DsZy+13AOQw nZz4vNv4WkT4cgDpn0R3Qgrhka7nz+VOIxhclrS91V3Vm5qRzsi6xJXGiXqKccgAhk8W RHyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RtERnifm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2si17573743qkj.366.2019.10.14.04.35.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:35:45 -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=fail header.i=@linaro.org header.s=google header.b=RtERnifm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJydc-00062T-H9 for patch@linaro.org; Mon, 14 Oct 2019 07:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46891) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCD-00087r-NG for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyCB-0007jp-3x for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:24 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyCA-0007iR-TN for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:23 -0400 Received: by mail-wr1-x443.google.com with SMTP id v8so19217345wrt.2 for ; Mon, 14 Oct 2019 04:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crw16Ubz+md1UknF7Ek+z0EbuUyNC3Q+RBvq7bGGoJI=; b=RtERnifmGf+4oL7gLvdC4pomT5jrlctM+a9lrLPq6Spl9IkDmtbnTLafU6jvwHkAx4 ZWmbK5DZcarmOwOORIY6CfJmwqMT3GYaLy6zdPq40wh2UITggfRbz7b3NHKCf6aYu9bf 5zJrCy8fydA3/hilxO+qNklczdLqZR/crrGkoUtDZHTWvV5i0+GMswNsc70Nr185lgHr dc/yawqyDHDV6gO20nM9Oo4ypxQpv0h3Yt0jrEnG3sye93YAF6BNb3vivMSOQKJuhc6d uuQrVVGKO3Q0fRE2sDTMjjk0mQ2MmJvViGnQf5F7buhIryi+xDQsS63QugqyhukoZ0CK B8Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=crw16Ubz+md1UknF7Ek+z0EbuUyNC3Q+RBvq7bGGoJI=; b=qaloYDvGl9abbYzf51fVRBdkzgxwyx34IlKArDv1Ay7yeckefNeeGIhEUR988wr89x vSN3hkToKiCMZnWLej2XOpSiWAZZ5ul/3GIWptmE4B0kcqvHMw9YWyiqCKCyH6NoDpxl prC+cQV2Cs0UgxYt5xxYsR+VTKnOEUDSVQjDggT5Nulnvy9r37LeoKhAvwkA88pNfmFJ v/YRFXYXp1NHUYRk2M9B4TwLGG++2gWgmFWSFGP4VMSsI5WoGXQjukkfJWW4NRjFK6R/ Xw7P95Y6kJecXlH6qwBexRF6KMD/yOUe2RDgPEJfjGFMAz7IAUJ0iXL+bNw3XujaSj1D ionA== X-Gm-Message-State: APjAAAXb2FP+jJTwZSNbvaetAHl7ktIR4/81UC8jJtAocOXha6dp1RTV ZLubaWpGW6Nfs5r353iVDPpYLg== X-Received: by 2002:a5d:6189:: with SMTP id j9mr15899899wru.21.1571051241757; Mon, 14 Oct 2019 04:07:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c9sm16764103wrt.7.2019.10.14.04.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2B4041FFC3; Mon, 14 Oct 2019 11:49:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 36/55] plugin: add API symbols to qemu-plugins.symbols Date: Mon, 14 Oct 2019 11:49:29 +0100 Message-Id: <20191014104948.4291-37-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota [AJB: moved into plugins] Signed-off-by: Alex Bennée --- v3 - moved to plugins/ - include qemu_plugin_reset v5 - re-trigger configure if symbols are updated - wrap ld checks inside if static = no --- Makefile | 7 ++++ configure | 72 ++++++++++++++++++++++++++++++++++++ plugins/.gitignore | 2 + plugins/Makefile.objs | 14 +++++++ plugins/qemu-plugins.symbols | 38 +++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 plugins/.gitignore create mode 100644 plugins/qemu-plugins.symbols -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/Makefile b/Makefile index 15f4745cf3..370eb9ad8d 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,12 @@ CONFIG_ALL=y config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION @echo $@ is out-of-date, running configure @./config.status + +# Force configure to re-run if the API symbols are updated +ifeq ($(CONFIG_PLUGIN),y) +config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols +endif + else config-host.mak: ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) @@ -730,6 +736,7 @@ distclean: clean rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp rm -f qemu-doc.vr qemu-doc.txt + rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols rm -f config.log rm -f linux-headers/asm rm -f docs/version.texi diff --git a/configure b/configure index 485a9837c9..75632b1df1 100755 --- a/configure +++ b/configure @@ -30,6 +30,7 @@ TMPO="${TMPDIR1}/${TMPB}.o" TMPCXX="${TMPDIR1}/${TMPB}.cxx" TMPE="${TMPDIR1}/${TMPB}.exe" TMPMO="${TMPDIR1}/${TMPB}.mo" +TMPTXT="${TMPDIR1}/${TMPB}.txt" rm -f config.log @@ -5464,6 +5465,61 @@ if compile_prog "" "" ; then atomic64=yes fi +######################################### +# See if --dynamic-list is supported by the linker +ld_dynamic_list="no" +if test "$static" = "no" ; then + cat > $TMPTXT < $TMPC < +void foo(void); + +void foo(void) +{ + printf("foo\n"); +} + +int main(void) +{ + foo(); + return 0; +} +EOF + + if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then + ld_dynamic_list="yes" + fi +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +ld_exported_symbols_list="no" +if test "$static" = "no" ; then + cat > $TMPTXT <> $config_host_mak LIBS="-ldl $LIBS" + # Copy the export object list to the build dir + if test "$ld_dynamic_list" = "yes" ; then + echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak + ld_symbols=qemu-plugins-ld.symbols + cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols + elif test "$ld_exported_symbols_list" = "yes" ; then + echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak + ld64_symbols=qemu-plugins-ld64.symbols + echo "# Automatically generated by configure - do not modify" > $ld64_symbols + grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \ + sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols + else + error_exit \ + "If \$plugins=yes, either \$ld_dynamic_list or " \ + "\$ld_exported_symbols_list should have been set to 'yes'." + fi fi if test "$tcg_interpreter" = "yes"; then diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 0000000000..7b8aaa1f10 --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1,2 @@ +qemu-plugins-ld.symbols +qemu-plugins-ld64.symbols diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs index 95baabf3d2..6f14d91ccb 100644 --- a/plugins/Makefile.objs +++ b/plugins/Makefile.objs @@ -5,3 +5,17 @@ obj-y += loader.o obj-y += core.o obj-y += api.o + +# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_list +# when the final binary includes the plugin object. +# +# Note that simply setting LDFLAGS is not enough: we build binaries that +# never link plugin.o, and the linker might fail (at least ld64 does) +# if the symbols in the list are not in the output binary. +ifdef CONFIG_HAS_LD_DYNAMIC_LIST +api.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols +else +ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST +api.o-libs := -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols +endif +endif diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols new file mode 100644 index 0000000000..40c0d1abd2 --- /dev/null +++ b/plugins/qemu-plugins.symbols @@ -0,0 +1,38 @@ +{ + qemu_plugin_uninstall; + qemu_plugin_reset; + qemu_plugin_register_vcpu_init_cb; + qemu_plugin_register_vcpu_exit_cb; + qemu_plugin_register_vcpu_idle_cb; + qemu_plugin_register_vcpu_resume_cb; + qemu_plugin_register_vcpu_insn_exec_cb; + qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_mem_cb; + qemu_plugin_register_vcpu_mem_haddr_cb; + qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_ram_addr_from_host; + qemu_plugin_register_vcpu_tb_trans_cb; + qemu_plugin_register_vcpu_tb_exec_cb; + qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_flush_cb; + qemu_plugin_register_vcpu_syscall_cb; + qemu_plugin_register_vcpu_syscall_ret_cb; + qemu_plugin_register_atexit_cb; + qemu_plugin_tb_n_insns; + qemu_plugin_tb_get_insn; + qemu_plugin_tb_vaddr; + qemu_plugin_insn_data; + qemu_plugin_insn_size; + qemu_plugin_insn_vaddr; + qemu_plugin_insn_haddr; + qemu_plugin_mem_size_shift; + qemu_plugin_mem_is_sign_extended; + qemu_plugin_mem_is_big_endian; + qemu_plugin_mem_is_store; + qemu_plugin_get_hwaddr; + qemu_plugin_hwaddr_is_io; + qemu_plugin_hwaddr_to_raddr; + qemu_plugin_vcpu_for_each; + qemu_plugin_n_vcpus; + qemu_plugin_n_max_vcpus; +}; From patchwork Mon Oct 14 10:49:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176160 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4358155ill; Mon, 14 Oct 2019 04:08:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4znxgo9TO3s8JiCRfS5BRFz9bN54jCJsGYWJdykPJUIVEoATc8IUE8cY3kXQWEyNZFseG X-Received: by 2002:ae9:f30e:: with SMTP id p14mr28167817qkg.71.1571051303482; Mon, 14 Oct 2019 04:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051303; cv=none; d=google.com; s=arc-20160816; b=gX++9qaZ0jjGulNQiu1xdSQHEFoEqGJS8vMnEuW/qAHrXukVi2TOAN97C+JMg6vd/B UGed9G52O68htZHO/88ojzQv3VDrcatvDmwseut7fRWtB48wVVez3dAoxTPQgZ8VaEsg NaISvjo8Dr6XquxYoAJT7fQiRQ8gSl5dijhVrPufnF/QUvhsMOX++bGR8hQemmivLqtU eb5fTv0o/VjoPchq0fjojbI+lv9nJKprxtmUcThfWNhYkAfkI1JDqBfQPSY1TPCTjL8U uq2DA8NN53Zu40AQa2BjaMLKj4Hft0QCEEPrEWbuYMSkbMWgOZhQzCiknL9NpILoFJ6B EOuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Tals8a9mIFmx+icrckx2DF+DPIwwPX+blavRmLxcPdQ=; b=OG51gaoatY2ApaX7Ldw2I5uZz+KQ+N4oaS0J4CbGa3/XwjleqROM3ek5YEQXnyGj0v 1mxPbrK5f2ElmBCkkvCwJjJqk5X0zwQfgDR2j8wxlYBEWVLTxnkLVYNV2kWZk5GMLmaw umsrsZ/fsfT8Zzni5ih9p3n88+oDUFsJtdcpgE7RR4ESC8a0JlR8ueZ1fqq7uaD3vjnz U/n5RHl6oqPF3dhmQCiMBiYMeI7ROhRxYh+MBnOtQdFB0eNPhcklyOU5f+fYFgRfhQ68 80jSgM/lQO9HbOjnS1sUFj0WMQ7dc/dXCYCl7J/Be+bS7VE2h6gLRlMME3RsF9X1R7dX azmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AVQ93vwk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u16si17086519qka.86.2019.10.14.04.08.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:08:23 -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=fail header.i=@linaro.org header.s=google header.b=AVQ93vwk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyD8-0000gi-JZ for patch@linaro.org; Mon, 14 Oct 2019 07:08:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44685) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvU-0007Wc-0w for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvS-0006GR-NK for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:07 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvS-0006FE-Go for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:06 -0400 Received: by mail-wr1-x444.google.com with SMTP id y18so9677482wrn.5 for ; Mon, 14 Oct 2019 03:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tals8a9mIFmx+icrckx2DF+DPIwwPX+blavRmLxcPdQ=; b=AVQ93vwkw9sJQ6r6kitpmB3sS7F0wtz+A2OzrXXZDBthuEqWmBgg4hfc1jIhlq9DWw eMAUjmsacGZpsNyV9ZII5wI6I5+eis2WC39Qml6Pfsi/QOpHDWsOKg/fcH9xWjHMfetA 2ivuU7QsQmOH1FDcguRUJ3l3HX1P696BvFoaCm8jxtyB7JO1wGshkY56BrTg41juVuhE FhCV2xs3OYQUA8Z4glxWq+MpKCDBKZ1bOmJKmYrHZFBaJ4BNJPBflyPTKr5ocs225kz9 3LIVILg4Vpj6sp912epegj9CSxEzy67diUHwfNoGQX6ij1nl5KjJAN86znNGJc6bYYxd lLwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tals8a9mIFmx+icrckx2DF+DPIwwPX+blavRmLxcPdQ=; b=TMWSBNa00vIoSca9hUNeMW1ze0EaQifilXDhsLodJho51zUEdmxLCnELg1X3HBdKDt BTE1Lp8uBIoNPqHw6g2OJ1ZgkGZFzC3L2nAiyckWFafs5/SA9c92+/JkgT45hZfYSI5P gtMaq0xFm+4AQjCgtelv2zLN1Gdf36zfbk5ojVNYEV3jiZnZd9oioHcxj9mLrQGP1VB6 zqCT9U8YGLXPSlaDTD8StIYKAikqdsDr7Q+qVYNtbGfxPzGivu3MW7iBak9ecGPA/+az gTy9B7bnGRCj7UGBK3oi7h8AYdIKmbvSSOvK9IigfET7B7+7Z60GMmFfOJW84Exg2Q54 WJYw== X-Gm-Message-State: APjAAAVyB+ZdNM0eSe8oRTBb/NewXuLB2RYZQ72lN+dFJQk+fTh/9Jf4 C5ViOXZDLap/wWU8uE+uKD1aIOzSWb8= X-Received: by 2002:adf:ed52:: with SMTP id u18mr26668454wro.16.1571050205477; Mon, 14 Oct 2019 03:50:05 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n7sm19335803wrt.59.2019.10.14.03.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5CA631FFC6; Mon, 14 Oct 2019 11:49:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 37/55] vl: support -plugin option Date: Mon, 14 Oct 2019 11:49:30 +0100 Message-Id: <20191014104948.4291-38-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Llu=C3=ADs_Vilanova?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lluís Vilanova Signed-off-by: Lluís Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- qemu-options.hx | 17 +++++++++++++++++ vl.c | 11 +++++++++++ 2 files changed, 28 insertions(+) -- 2.20.1 diff --git a/qemu-options.hx b/qemu-options.hx index 2a04ca6ac5..8dcc88e5ae 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4144,6 +4144,23 @@ HXCOMM HX does not support conditional compilation of text. @findex -trace @include qemu-option-trace.texi ETEXI +DEF("plugin", HAS_ARG, QEMU_OPTION_plugin, + "-plugin [file=][,arg=]\n" + " load a plugin\n", + QEMU_ARCH_ALL) +STEXI +@item -plugin file=@var{file}[,arg=@var{string}] +@findex -plugin + +Load a plugin. + +@table @option +@item file=@var{file} +Load the given plugin from a shared library file. +@item arg=@var{string} +Argument string passed to the plugin. (Can be given multiple times.) +@end table +ETEXI HXCOMM Internal use DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_ARCH_ALL) diff --git a/vl.c b/vl.c index 002bf4919e..4bdd526029 100644 --- a/vl.c +++ b/vl.c @@ -110,6 +110,7 @@ int main(int argc, char **argv) #include "trace-root.h" #include "trace/control.h" +#include "qemu/plugin.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" @@ -2904,6 +2905,7 @@ int main(int argc, char **argv, char **envp) bool list_data_dirs = false; char *dir, **dirs; BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); + QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); os_set_line_buffering(); @@ -2934,6 +2936,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_global_opts); qemu_add_opts(&qemu_mon_opts); qemu_add_opts(&qemu_trace_opts); + qemu_plugin_add_opts(); qemu_add_opts(&qemu_option_rom_opts); qemu_add_opts(&qemu_machine_opts); qemu_add_opts(&qemu_accel_opts); @@ -3717,6 +3720,9 @@ int main(int argc, char **argv, char **envp) g_free(trace_file); trace_file = trace_opt_parse(optarg); break; + case QEMU_OPTION_plugin: + qemu_plugin_opt_parse(optarg, &plugin_list); + break; case QEMU_OPTION_readconfig: { int ret = qemu_read_config_file(optarg); @@ -4030,6 +4036,11 @@ int main(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } + /* process plugin before CPUs are created, but once -smp has been parsed */ + if (qemu_plugin_load_list(&plugin_list)) { + exit(1); + } + qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, NULL); qemu_opts_foreach(qemu_find_opts("global"), From patchwork Mon Oct 14 10:49:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176199 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4401088ill; Mon, 14 Oct 2019 04:48:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiPboN5bZXvxKuTKdOvfs6wKaY+kKvHjua5o7q4IPlBIcuhdAdYSWTyYtx7laKY0aD5fuL X-Received: by 2002:ac8:1c34:: with SMTP id a49mr32695368qtk.184.1571053680039; Mon, 14 Oct 2019 04:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053680; cv=none; d=google.com; s=arc-20160816; b=aeb8tznAekDJnwxkV/EVF/daoSQtT/gJ8Q/0NtRBZeU+wLR0i7y3SbZMUeGewva7/4 bhiyhZrEg1qcoxTRjU5PYKFCeI23T9UanBtAi7xpWUnGp8QeyaoADsAmqOp39FbKTR00 NN0y9Wt19e3Z/zDs7v4hgOL/2RZsZHS+d9B72Tc5dhq7E6rxL38rnrq+Q1Pr57vvPorx HTWo/Q/WLShpIWTmrCSFQzlC7dyLkIzvV9abQmIv/G4sPklOIynUvW4hPk1h+8hF9Kty VIQdr/uCEeUkhkhTygAQl9/8wYQrPzkB4bV1dB1y36SRAouvn3ddFi9ChidMQNR+LgdI fJcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=j9VLj7yufnPKaz6aaA2SbuwWsfLmWj3MLD1Awwtmne8=; b=07/kijS0hSmEj24PskyrpvMys/zqlWIlxsXYrXCXp6BOZa4hCvFY6Fqn0N2AqMas6H EWCKTNzwysruT79wzEu26i+N2luveIkSFmeXUIe1nlCyELgOLceZI1mzwhKP26PloqLJ 6AFP6sXgvFOJOTNoNOcib5wxp7WipMuhofEBXof97YQNusyWJKSJzNmx2EHwvIF0CveM sDYcmdKUx5E/SpRgh3vCGq6G+yvs7VrhDfD5a1aitcYTCPxFbHmbq4U0yb1CAXAgY4Si u9YgCnToMhcXItSjYLsNoHWVHrdT44fvZxvlhtAOOJeqEVqT8Kw0B4XEP3UeORLwJ9hc RepQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="oecO6g/3"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l55si18918956qta.288.2019.10.14.04.47.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="oecO6g/3"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJypT-0003KV-Ha for patch@linaro.org; Mon, 14 Oct 2019 07:47:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46862) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCA-000842-CN for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC9-0007gk-2k for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:22 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:37598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC8-0007fZ-Sr for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:21 -0400 Received: by mail-wr1-x444.google.com with SMTP id p14so19204004wro.4 for ; Mon, 14 Oct 2019 04:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j9VLj7yufnPKaz6aaA2SbuwWsfLmWj3MLD1Awwtmne8=; b=oecO6g/3JdU/4TFoiyt63qfh/TjovK1lLUNBurXi88JoRRRNlCJR+waZSAZ6ypma9Y cIMvk/4JZciOdKM4dv9ThBtpNNltPafWLDaoH/OjkZOv8prhs71wseAL1TyDas083Qpw FlADygF/xNXa1g8GzCtjyOuAUwN3ezTyHiC27NhL78W6NbgItdjI8xlHpyrt4zot7y9j lIz9wOD7FbtjKNvxJmn8I6Y4OwQKtbDpqFSTBd7YKChZ4omA/FpG7PI2ruvxmE+mzNZk NWr/RStHsuBFMiwHpH+zChnZY7XFsRAa0jyFgIyvzpwtVZNKv6bHCCDm0FC261RN/c+I Yb4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j9VLj7yufnPKaz6aaA2SbuwWsfLmWj3MLD1Awwtmne8=; b=HHDS2Ljt4bI3v4XCkF1OCgfDczXV4v5YieFDmqwFGhlNUaBTEHc1DXNZFePvJOPKUZ axBoyjvisEdQxCtLWv5jaGGzXjTiPXB3WPFXGwG8muvs1a/jCFoBmiPvDJbX89Nxn6jZ mQUR4N4a2iW1/Al64xRtnkwm0dd+s++IU5kNxtnvJcJky33UtktycEzcix5MzaBai8P2 ICxlCKhRcP7+/CQhDpu2f6ze13UISMzqT6/5almVNH5rc43EAGTjYSgYgPVqh0S8LGo5 K5gwhwEQFWuzMaQvzLIEIVdzq9AhEcpKhGVkRUJs5JBDa4olbbnR0uoY9cR+KKTdhIQ9 APXQ== X-Gm-Message-State: APjAAAXadql5YK3ynerJfIzbvvgM3tpNtSvCGDCjTM2Xa4fRvvgmN+7Y 1t+w22x8H5PUcZQK3g8Fe2yeRA== X-Received: by 2002:adf:f4c2:: with SMTP id h2mr25955533wrp.69.1571051239774; Mon, 14 Oct 2019 04:07:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f18sm16911737wrv.38.2019.10.14.04.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8C54B1FFC7; Mon, 14 Oct 2019 11:49:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 38/55] linux-user: support -plugin option Date: Mon, 14 Oct 2019 11:49:31 +0100 Message-Id: <20191014104948.4291-39-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Riku Voipio , Richard Henderson , Laurent Vivier , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , =?utf-8?q?Llu=C3=ADs_Vilanova?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lluís Vilanova Signed-off-by: Lluís Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- linux-user/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.20.1 diff --git a/linux-user/main.c b/linux-user/main.c index 560d053f72..6ff7851e86 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -34,6 +34,7 @@ #include "qemu/error-report.h" #include "qemu/help_option.h" #include "qemu/module.h" +#include "qemu/plugin.h" #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" @@ -398,6 +399,15 @@ static void handle_arg_abi_call0(const char *arg) } #endif +static QemuPluginList plugins = QTAILQ_HEAD_INITIALIZER(plugins); + +#ifdef CONFIG_PLUGIN +static void handle_arg_plugin(const char *arg) +{ + qemu_plugin_opt_parse(arg, &plugins); +} +#endif + struct qemu_argument { const char *argv; const char *env; @@ -449,6 +459,10 @@ static const struct qemu_argument arg_table[] = { "", "Seed for pseudo-random number generator"}, {"trace", "QEMU_TRACE", true, handle_arg_trace, "", "[[enable=]][,events=][,file=]"}, +#ifdef CONFIG_PLUGIN + {"plugin", "QEMU_PLUGIN", true, handle_arg_plugin, + "", "[file=][,arg=]"}, +#endif {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, #if defined(TARGET_XTENSA) @@ -643,6 +657,7 @@ int main(int argc, char **argv, char **envp) cpu_model = NULL; qemu_add_opts(&qemu_trace_opts); + qemu_plugin_add_opts(); optind = parse_args(argc, argv); @@ -650,6 +665,9 @@ int main(int argc, char **argv, char **envp) exit(1); } trace_init_file(trace_file); + if (qemu_plugin_load_list(&plugins)) { + exit(1); + } /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); From patchwork Mon Oct 14 10:49:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176198 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4400167ill; Mon, 14 Oct 2019 04:47:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfXxXVst6ad0xfXiSwmBUhNG980d0RTsOjavCXThi7idgtXbp7jdnH+dqqVYqzWR5BGVsm X-Received: by 2002:a0c:b057:: with SMTP id l23mr30634758qvc.216.1571053621996; Mon, 14 Oct 2019 04:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053621; cv=none; d=google.com; s=arc-20160816; b=nv7G+pxdKaTJ2WtMMWWvPYXieugknmoO55NFQkUlY9bFNYxcXX+eLXnCl+hSmuI88e DQTHq8bZGP4Sop7cRgduD65cThpBi0LzGSK9lIm+DhKWrzf2mjbUSezzIRTL4oUYOxN8 +u/n4SwNKAMQmXGAxl/EOeciWlPYi4w7Zb/WqnuYhPfb866n4MKRvIP/2OIswRObsgmf JJzU32HePkk2IhvEhtAYJGmwS+KmQXJcJCjrBbMaKUyx73xTVJir3adh3q4LjsxOKt1P hnBneajQzOQ6CFfjut9mjz0iW8624m1VX7pXZ1Qu4NZfF7EdifJsMYZ2aGtsc5/gR6/g phPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jb94Z+Gp/SEto0c7c9pjyGvoGowBStIfIYtnSg1TGYw=; b=PRR3Ig32/QHCounpwWbIB6x7HEG65zQDEAO6TrTN5fuI3UKcPTmFh/vIA6kZ0hbZ7X 5cjUBia3RTGe/qMh/AZMi9c3OBLmL0C60mg7wkCy1P+ZHsniXXCxfkMQcQY4vCgXa03m OmSsyQqqFTQJwJOyhjprYFmh/0nFzpDtArm5Bdps/iKypxJrFQ+IQpVBqhFiXpK5OV8+ HoSgUUA/HB0IM7dTvEwUokg25lQ3cbaKN2CT0lakqPD4HCv8IBsQQ68cYqbUsIiEc+6y fWPRWUFH69bJ3TMBG+CElIuIJhZG47knmbW2APDFxrJatO6/qDFrx94SRQfDM9wgVsDs UvwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZTxPVhnl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j62si16795931qtd.367.2019.10.14.04.47.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZTxPVhnl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyoX-0001pX-CK for patch@linaro.org; Mon, 14 Oct 2019 07:47:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46909) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCF-0008C8-7A for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyCD-0007mQ-H8 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:27 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:41285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyCD-0007lU-AA for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:25 -0400 Received: by mail-wr1-x441.google.com with SMTP id p4so3326796wrm.8 for ; Mon, 14 Oct 2019 04:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jb94Z+Gp/SEto0c7c9pjyGvoGowBStIfIYtnSg1TGYw=; b=ZTxPVhnlh6IJ0i9/HS02KCIiEi452j/wOypJG/2pzNwQM0y55fz2G6P+8xE1OdzHRW 5NwTdR70fOms4try8kfS76K5rlAhyJX7qvxyK7vH9kuLEwTmGtLoyyvCeZ4pWpCBJid0 iNk8WARfSjA9N7g3EDTvdHZOKHBhicbmfrM4rvrx69f+KYaVH2YZvJFYyJirw+kbUqDN 17k33wRfEncHSllzRMpz5jfP3poJiqICCdf3nsXxc5kQE56tPfJf47uNld/wgp0zPdXd MzGh3tVLq5o8GTTxdkdxrImEwkSGrjJwH49Lw8opIOFJIqmy9e/mBpZv95Khl7yz+dLh WhfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jb94Z+Gp/SEto0c7c9pjyGvoGowBStIfIYtnSg1TGYw=; b=rRoTFY7nyFF0+IUhRcrxcq8QI7MGBf5ed4o6rWKBWaF5lzik3CICpjkQeVijZ7V713 s7bFLPiP7iUSksIPLWXw/XtYEi/q5ETtGm1OTqITijRemK2LLzc4Zv2io87Vw0N0o9Vz JDGeMFNWZPFjuWAebvae9Z88BbgOKrT8BsYUGoSoVcXSj7/lk/nqZrJPhtRj+QcWOk+H 7FlPkl0hZVzOw6d9N6RlkpWGX0ce+z2sv+B3hJORSzpAV8LbhU0YOgRmDZmp26uEa+1p wdkZHsvfvGKHMYCW1ANNRt84Rv3kFCcrOSDBXbvZ0ZI/pRpUon0Wjs6393UMq1DKY219 pX0g== X-Gm-Message-State: APjAAAX3hI7HMiM6e3rPHuzh7b28kSmiRDnUFU7I0ajv1WU4RMb/atFl NC80UyOirlr45WRQ7M13iSAExg== X-Received: by 2002:adf:f188:: with SMTP id h8mr25028454wro.38.1571051244216; Mon, 14 Oct 2019 04:07:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f8sm19894304wmb.37.2019.10.14.04.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C01971FFC9; Mon, 14 Oct 2019 11:49:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 39/55] tests/plugin: add sample plugins Date: Mon, 14 Oct 2019 11:49:32 +0100 Message-Id: <20191014104948.4291-40-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Pass arguments with -plugin=libfoo.so,arg=bar,arg=baz Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée --- v4 - tweaks for hwaddr API --- configure | 1 + tests/plugin/Makefile | 28 +++++++++++++ tests/plugin/bb.c | 65 +++++++++++++++++++++++++++++ tests/plugin/empty.c | 29 +++++++++++++ tests/plugin/insn.c | 62 ++++++++++++++++++++++++++++ tests/plugin/mem.c | 96 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 281 insertions(+) create mode 100644 tests/plugin/Makefile create mode 100644 tests/plugin/bb.c create mode 100644 tests/plugin/empty.c create mode 100644 tests/plugin/insn.c create mode 100644 tests/plugin/mem.c -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/configure b/configure index 75632b1df1..d5527a9f15 100755 --- a/configure +++ b/configure @@ -7887,6 +7887,7 @@ DIRS="$DIRS roms/seabios roms/vgabios" LINKS="Makefile" LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile" LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile" +LINKS="$LINKS tests/plugin/Makefile" LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps" LINKS="$LINKS pc-bios/s390-ccw/Makefile" LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile" diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile new file mode 100644 index 0000000000..f9a3546ea3 --- /dev/null +++ b/tests/plugin/Makefile @@ -0,0 +1,28 @@ +BUILD_DIR := $(CURDIR)/../.. + +include $(BUILD_DIR)/config-host.mak +include $(SRC_PATH)/rules.mak + +$(call set-vpath, $(SRC_PATH)/tests/plugin) + +NAMES := +NAMES += bb +NAMES += empty +NAMES += insn +NAMES += mem + +SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) + +QEMU_CFLAGS += -fPIC +QEMU_CFLAGS += -I$(SRC_PATH)/include/qemu + +all: $(SONAMES) + +lib%.so: %.o + $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS) + +clean: + rm -f *.o *.so *.d + rm -Rf .libs + +.PHONY: all clean diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c new file mode 100644 index 0000000000..93d25de363 --- /dev/null +++ b/tests/plugin/bb.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t bb_count; +static uint64_t insn_count; +static int stdout_fd; +static bool do_inline; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "bb's: %" PRIu64", insns: %" PRIu64 "\n", + bb_count, insn_count); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + unsigned long n_insns = (unsigned long)udata; + + insn_count += n_insns; + bb_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + unsigned long n_insns = qemu_plugin_tb_n_insns(tb); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &insn_count, n_insns); + } else { + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, + (void *)n_insns); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c new file mode 100644 index 0000000000..b141ddd0df --- /dev/null +++ b/tests/plugin/empty.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +/* + * Empty TB translation callback. + * This allows us to measure the overhead of injecting and then + * removing empty instrumentation. + */ +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ } + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + return 0; +} diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c new file mode 100644 index 0000000000..3000ab4b73 --- /dev/null +++ b/tests/plugin/insn.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static int stdout_fd; +static uint64_t insn_count; +static bool do_inline; + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + insn_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1); + } else { + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL); + } + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && !strcmp(argv[0], "inline")) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c new file mode 100644 index 0000000000..e5490f4a99 --- /dev/null +++ b/tests/plugin/mem.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t mem_count; +static uint64_t io_count; +static int stdout_fd; +static bool do_inline; +static bool do_haddr; +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "mem accesses: %" PRIu64 "\n", mem_count); + if (do_haddr) { + dprintf(stdout_fd, "io accesses: %" PRIu64 "\n", mem_count); + } +} + +static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + if (do_haddr) { + struct qemu_plugin_hwaddr *hwaddr; + hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr); + if (qemu_plugin_hwaddr_is_io(hwaddr)) { + io_count++; + } else { + mem_count++; + } + } else { + mem_count++; + } +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_mem_inline(insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + &mem_count, 1); + } else { + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc) { + if (argc >= 3) { + if (!strcmp(argv[2], "haddr")) { + do_haddr = true; + } + } + if (argc >= 2) { + const char *str = argv[1]; + + if (!strcmp(str, "r")) { + rw = QEMU_PLUGIN_MEM_R; + } else if (!strcmp(str, "w")) { + rw = QEMU_PLUGIN_MEM_W; + } + } + if (!strcmp(argv[0], "inline")) { + do_inline = true; + } + } + /* plugin_exit might write to stdout after stdout has been closed */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Mon Oct 14 10:49:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176156 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4353279ill; Mon, 14 Oct 2019 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlrPK2AfyJU/opdzpft2hRUpySGdcL4ya9nuarrrBiWAdzwtjmyZlPJmVQRE9AM20T8MO+ X-Received: by 2002:ac8:3476:: with SMTP id v51mr31589929qtb.285.1571051070254; Mon, 14 Oct 2019 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051070; cv=none; d=google.com; s=arc-20160816; b=hWXIuoOEfEsxPiTeaxmdcs5dwZltHoPkNhTiq/7oHf3B3jmNmWwLydqAQ+2u8BCxsY QY7EW8gq2ModmAVUTXhGVPoKLqFwkylUXp4m+zOp4+DbKP9yA3syoTf1zbammvb9s6fi I+q8qj7iy/IP/Es7V/K+at1Jyp5MR3KQxbSoXnu6uRbAJS0LCainAH/Qf5D7XUybRk0F j2GxYnFL8x6BH/Ii4v+xPv/H1HQOY5YS9HuFjDRoaksLG9mNjnA/9BsMMkytEz7MXgRA If+PPC1ozw5bHzNtdJHq01d8sz6KRKh32WXRRaOD+PokuCg34e0QPjbBMh50HDGqOC7f NWBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7e3kGGDhCCeDmaWnT5E6lm7XvO8I2yKVtKu9Sla1anI=; b=W3SZaOASVW2/5a0d+3Tn/ytVaxpPiOuLBhH8DbECT7rckVx5j8NSqbEbKAgiYQTkC1 GdUCsB3tood9PvJcm4bz2ryy0YbqFjjaQC2o6k1WdcUCwjCrFZnzFn5/dC4nAKcum5el CgZbZBMLKTrBcS5OQTK4RzuVQ+vKrX08M4LSN8k6pNaK+7F0StasIuPWI7Cufj/FC3Tq Ur5hDCeWpbh5KThQY+DaSsa9zg6UX+ZpBEinVWpjIHzApiasBp3NDGlQTzfdZddVc49v 74adY3YnYI8HWOMKaEFrrwHhaGO8ww0Ig1tUBfg4gRFOPL8Ryv7YPczMDRcBN4n5kkJq 8dxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ArQdQWmu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a21si16794817qkn.60.2019.10.14.04.04.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ArQdQWmu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy9N-0003ki-9j for patch@linaro.org; Mon, 14 Oct 2019 07:04:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44712) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvV-0007YP-1n for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvU-0006Ih-0r for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39495) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvT-0006HN-RA for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:07 -0400 Received: by mail-wm1-x344.google.com with SMTP id v17so16247258wml.4 for ; Mon, 14 Oct 2019 03:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7e3kGGDhCCeDmaWnT5E6lm7XvO8I2yKVtKu9Sla1anI=; b=ArQdQWmumjGXoXSIKblyHPxWNGkITe3vRfYdLJ+A/tNTNMEa+c3phhEvaFnPx1D6ms vnrhQlQxyLv3mG95GwVs6M9GYruXb6MBCGiOzIUIRVQj1M7bpgDjcJpZFi8ljpRFe0GV Qrtwprlmz6II+yrvPcYWEjy08Xh22gR6qTAnlnwIv4tQ9pn4DY3iHapo73owHSmPbZBv y2psxOMymqZ3Sdujw5kWVP6zEvc1AV8oOzMS1qzKwO9OA1C5eaNGrjgtB8cK7VomlzGp HeMyFKnUZiPfDIBmpAN7ANqGIV1V+GtUCOJC+WzrKnK75eJY1MQWO5GQG3O+B+0cj+Mu tCVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7e3kGGDhCCeDmaWnT5E6lm7XvO8I2yKVtKu9Sla1anI=; b=Y/SzURMsIfGw7sXNcdjKlRZxobll5Plb0ihIXru2SMJk/an8uD47FhV+M7j6OdOylQ nf+PgntBvKwbj8dgB6jU8MA2mMupN4kOQLQM4TCRwvfw/JC9biGcC8F72uhL/kKQg0lG MbSZrUdJjzV95ztVNaHIaEBeTnTydSFPOQhd1PUHYgKThTFUT0QIpgGfBqhZTsg5lJgL DoEbHZwuSAHEqh/0ls5RDG9RA2xJJo6vFoEhvDJO733BtEZIxe80w78iFcM8IolD3g8i Lj4GWMc2SXeTcPXB+vo/zqjhTGJSZSj/bBxHQ9NrlNhfOLRu/xzGDV46T6AX+ynPW1No 3Snw== X-Gm-Message-State: APjAAAUtMZW6LSmuXG48knJ6+2Fpb+s9Y5fj7NA8EmK4RzdQ1uw8lBcy +MSSzx5fUdldfJMb5OmrqdRicHmP3uY= X-Received: by 2002:a1c:6389:: with SMTP id x131mr14155783wmb.77.1571050206744; Mon, 14 Oct 2019 03:50:06 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p85sm24611469wme.23.2019.10.14.03.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E67A41FF98; Mon, 14 Oct 2019 11:49:57 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 40/55] tests/tcg/Makefile.target: fix path to config-host.mak Date: Mon, 14 Oct 2019 11:49:33 +0100 Message-Id: <20191014104948.4291-41-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since moving where the tests are run the path to config-host.mak has been wrong. This doesn't affect much but things like the time fallback for CONFIG_DEBUG_TCG and will also get in the way of checking for PLUGINS support. Fixes: fc76c56d3f4 Signed-off-by: Alex Bennée --- tests/tcg/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 5a9a6faba4..84abbd24f3 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -30,7 +30,7 @@ # all: --include ../../config-host.mak +-include ../../../config-host.mak -include ../config-$(TARGET).mak # for including , in command strings From patchwork Mon Oct 14 10:49:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176192 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4391801ill; Mon, 14 Oct 2019 04:38:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4qAtZWAjY/68WoEL/3gVAFA8MfugF3tUo2MtMpTuMOduKU/S3bQJfpZ2aKlryMtgtcrLs X-Received: by 2002:aa7:ca52:: with SMTP id j18mr27584620edt.299.1571053113604; Mon, 14 Oct 2019 04:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053113; cv=none; d=google.com; s=arc-20160816; b=ovr61Ouc7DrnIVXHZIzin/+RzNGu2EomJh+c/HysepvxjCUV83Ql1FDKCDXgYtLyCB XljeKx3g+soxzR+BW2P3Sfpc87UITMUfuVt6PUA2ODVOccZea5GsKPs2+2Z7ToWROp5j nZBzYDsoo6L3cbBcURlu/2nB0tMc1e03VubThtj04/oknupo1R5DrvdQI8cAOw9ImYw+ KpthhtmLKWuTjuIYlJbPte4pwwIOA2r2w+kSN5+D33Q/K4uE+q5PBSkdAGC1A8UWWLi+ NDYEidZMbDP6ZryWvEmUUOCvfEfV0Q66K6MKiRRHaEls+AnNBcj7AdPDi5nGMywonmlY CgIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+LPt3b3VuC6svudCo6yMH9K5JcQPfzp2HiF31OZ0ieU=; b=T7kYfxyeJcUbCDTxhaEPTWv14grhIFsPLV9ivEfHt33VHc9wm7gV1duPVO48CYXeWR yPWK8mTewe8JtPsNGoA3xeTtv3O8naqJNj2roLSsjZUIS1bUfXcI6Z+srF1F7/tKcEQI o+jPNBJrtfQmxRzzSLxWi+L8aiMYFy+OTQcabC58q8qCtpfrUrASyj5OTJxz0SGiAZDX NuhkpUkQQezs1NtnVMyaqw1r05DDJmgyIdLKiQJM1VHR7/sWx0KtXZU5gSEubRiHIRTG nlhFuzq4PU7LrUKQoLJH71fl2lop+0kkkqkhpPcYB55LlEHC6GivNDKU+9MhZcZeSwRn TE6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WzQLbqoq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u12si11433646ejt.21.2019.10.14.04.38.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WzQLbqoq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJygK-0000N6-9E for patch@linaro.org; Mon, 14 Oct 2019 07:38:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCF-0008C9-77 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyCA-0007ii-DP for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:27 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyCA-0007he-6W for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:22 -0400 Received: by mail-wr1-x441.google.com with SMTP id p14so19204081wro.4 for ; Mon, 14 Oct 2019 04:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+LPt3b3VuC6svudCo6yMH9K5JcQPfzp2HiF31OZ0ieU=; b=WzQLbqoqArxZufhYS7ArUwASH2OjhurVWNddGvFoApijftex9JZ/IwH0swe9EPc2jg Hq+3Uah+3jpZAuCN2x72IrYzt1nbq5czI4F/deGu7szXye7QNd47Q00/vQvkNVsPlarc OzGaYG9jSDe7cSXcr07bsKgt4mrS6M2OXfED97MHlfzgpz+gYWgsS1DwcjQtU8Obtk7G hyyLS9DmiyTWg9bHJLlcQYRqv4zC+ObFRVj8GKVViqfb6T9Ya7x0o/TJZJrt7u5Cdupy PHjnBhwcIOxIQ00ZJlm++we0UpvGoTIVP/tsNK6sIl/N9WoCp4dSG/CTLFImDDps1Z3J AqTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+LPt3b3VuC6svudCo6yMH9K5JcQPfzp2HiF31OZ0ieU=; b=lUWHdREO8d4LEdKm6B/CUAnHUpAnc0vMYoAgGg29WdZAr+IN9WLXlYeUMFg0EYidWM 87aQZvz8GkAsz9yc62/2MKqUPot9y1pHUuZXmSwkBLBuNSrOrRhMkTlJbQxSi7TPBzd0 u4eqdTZ2JOpVqP+MvtIm3oiktKYnP7QEb7aV81mL0QAJsfskJBeLMuCtegvBVISGmqZo Zbne4mlVVBU4YI9bgnGLFdL4+qWTNAvHR1bvNB1Sovhm2ubVmxFq0Rf5mLoEk00VaYdH vR83NrR9JoASa1Y85DrGPuDUcBx6yItVsL5THcxeHFz/MyJw+lPqZdLO8jGWDXkhclOz 1tig== X-Gm-Message-State: APjAAAWeP6gMBIIBjHJnB3o8fMlDyEaYHP+Q/jiQYXjFonj80IteLA1l aPETpAP4ZxSsEz/gj0Z8PceBv8+5kcU= X-Received: by 2002:a5d:4bc4:: with SMTP id l4mr26150521wrt.146.1571051241137; Mon, 14 Oct 2019 04:07:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o18sm46201598wrw.90.2019.10.14.04.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 27AE21FFCB; Mon, 14 Oct 2019 11:49:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 41/55] tests/tcg: set QEMU_OPTS for all cris runs Date: Mon, 14 Oct 2019 11:49:34 +0100 Message-Id: <20191014104948.4291-42-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, "Edgar E. Iglesias" , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will important for ensuring the plugin test variants will also work. Signed-off-by: Alex Bennée --- tests/tcg/cris/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/tcg/cris/Makefile.target b/tests/tcg/cris/Makefile.target index c1173ead42..24c7f2e761 100644 --- a/tests/tcg/cris/Makefile.target +++ b/tests/tcg/cris/Makefile.target @@ -47,7 +47,7 @@ CRT_FILES = crt.o sys.o $(CC) $(ASFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT_FILES) # The default CPU breaks (possibly as it's max?) so force crisv17 -$(CRIS_RUNS): QEMU_OPTS=-cpu crisv17 +QEMU_OPTS=-cpu crisv17 # Additional runners to run under GNU SIM CRIS_RUNS_ON_SIM=$(patsubst %, %-on-sim, $(CRIS_RUNS)) From patchwork Mon Oct 14 10:49:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176171 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4370497ill; Mon, 14 Oct 2019 04:18:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzfWibtl57fulDF8QGrrZFneyt7dssB3Vc4CpAg4spwOi7jcgjzt02hiYHdbd61a9G9OjQ X-Received: by 2002:a0c:d851:: with SMTP id i17mr31109013qvj.61.1571051919398; Mon, 14 Oct 2019 04:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051919; cv=none; d=google.com; s=arc-20160816; b=xwzxTYd3biSQgSp6eH5uMHJalcpVPP53QCLYAm+M83x7O3h1aHNUdZu9fy5+fexsmT d6Ru6qlWd6Us/ih1KX+Fw8KRdUQlqHSWW1IHM94L04nHzLoAwZ7vHjE3l34IuSQYv2GJ iZGXInnHsplwPrslP+M9yOUu80RPvxiVL6UzW8nB3hzm4a2gCpb7ONfvPVbyTeHGxpS0 YlfY7bLa4htOzG4I3orzpnPoGiyGhSDJbPAYM0OR13N71zbE9u5nxl5ouA7pIED3jjU5 uefJ/jiODV9HdbpOt4gF3t/93a90brYWbj+k7pJwsicHXaBuF9/d08Yvy2sk6HnD/Lzi vk5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zgKKogRe87ORjvkyL8Bd5r+4c7iR9meeLjhfDNvmOGE=; b=aWyBkJ40gQgjU7bItIoF0T7DMSD+CrqbpeLZoc2lqjTIsNcv7I7tbvfT35vV9Ifjas HIGIIVXhqUuvSAY1eTHWz1HotOWIEI6pnGhJyBb5tvQx+GfMWpt0pf1TrClE+ujCkALP 5JQ/mEQ5lpfErZkcHl9UN58ysRVF0LnGDwlh2NJmFdjAZS/3tEiRbvC2MARikvsTi8bE fTQXE6ZmmIUDaROjy8Mf+vmQVXhedGt8rwnAXSe6KQtpkbrwMj7NqPRY+g4gb77XWTMc zQECJa915qarWD8rroB/DL2uz8lS0bQM2OcetO8Ld2Og2sxbRUooX9d9mDMScX2TwdzM HGVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qbH0faCQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 4si17923080qty.378.2019.10.14.04.18.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:18:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qbH0faCQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyN4-0002aS-IQ for patch@linaro.org; Mon, 14 Oct 2019 07:18:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45416) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy27-0006Xc-RZ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy26-00055g-K1 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:59 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:40117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy25-00051X-SF for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:58 -0400 Received: by mail-wr1-x42d.google.com with SMTP id h4so19187452wrv.7 for ; Mon, 14 Oct 2019 03:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zgKKogRe87ORjvkyL8Bd5r+4c7iR9meeLjhfDNvmOGE=; b=qbH0faCQ9jnCEhBUCQH8pnoqojlDLD76S7SiqWpvEaayl5WitjxGq4a5IWWZXSNUsg o5c43sqNe1Q3HmhTFV+gI37XrZUUt+VmJpHnX4kOekMezW38L0l6kQVWnbbPB0X6Sqaj Jh2myrRobttOkn3MwbWuT7GsWA2KQuVfzwRoGXxIOIWWq4vKwTXFyrK6LG5/qxJm/iHn DQ3EBl6K6OVCtKCsP08cVcyZmYKbxq0sFbHP1CboEPdebRu4J0j7k0U2q334mEel0l07 ifNAqt2zw3cTWlmsGkjOk4A7nDpp/nh9Ffq1iiXJxbdunXcWvSMDXTLRY9Y6ujEz7yFL WDNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zgKKogRe87ORjvkyL8Bd5r+4c7iR9meeLjhfDNvmOGE=; b=AMX9A8kPL0jBNE7BVs4KIt4Qrf9yhQ9yVkspZ/8L2KXtIp3uVgVNEfRdmNH6CXmQlf r9kxq1xw1FC50LY3npv8ZFjAwxQlj5uXsp9bWuaBQS0iLiGQMand6urMxwUtJAv+BNI+ lz6RdT2tE7e39LkaL8FaxyeQ9wNPSBdELb7bdcNhQh4jAZC6i7OeJgBL01Xtr65nMruJ uAiYtjwdqj68ydsLA7r1YQ00SWFHEw1yxA6rkA2bsF2zsqCBEYUu5ApCWHYvzZTX5LnX 6mUrLiY3YTwKzkTMlc9FE98f93LMV6sriL7qk3tyVt7qYc2e77FtDrKGbqKYNiwylHqd MBlA== X-Gm-Message-State: APjAAAUuABgF86sqEM/XL+0wE1Hb8QDjJXppBSfhVnW6E4oZLwkdjnUs TPwp3e2X3DqCiNKlSiygiVO/+Q== X-Received: by 2002:adf:e40a:: with SMTP id g10mr15807002wrm.395.1571050614791; Mon, 14 Oct 2019 03:56:54 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x129sm34203080wmg.8.2019.10.14.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 57AEF1FF96; Mon, 14 Oct 2019 11:49:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 42/55] tests/tcg: move "virtual" tests to EXTRA_TESTS Date: Mon, 14 Oct 2019 11:49:35 +0100 Message-Id: <20191014104948.4291-43-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, "open list:ARM TCG CPUs" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Otherwise clever expanders like the plugins test get unstuck. Signed-off-by: Alex Bennée --- tests/tcg/Makefile.target | 4 +++- tests/tcg/aarch64/Makefile.softmmu-target | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 84abbd24f3..9664613002 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -66,6 +66,8 @@ conditional-diff-out = \ # Tests we are building TESTS= +# additional tests which may re-use existing binaries +EXTRA_TESTS= # Start with a blank slate, the build targets get to add stuff first CFLAGS= @@ -109,7 +111,7 @@ else endif -all: $(TESTS) +all: $(TESTS) $(EXTRA_TESTS) # # Test Runners diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target index b4b3957963..950dbb4bac 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -52,4 +52,4 @@ run-memory-replay: memory-replay run-memory-record $(QEMU_OPTS) memory, \ "$< on $(TARGET_NAME)") -TESTS+=memory-record memory-replay +EXTRA_TESTS+=memory-record memory-replay From patchwork Mon Oct 14 10:49:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176170 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4367743ill; Mon, 14 Oct 2019 04:16:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy6tmjzw4KExXFl5YtROA6Q1XPgXENAN/UNq5H/VPTBoOnVe2G9ZGOxO9/WN45BSOBXI2c X-Received: by 2002:a37:4f4d:: with SMTP id d74mr29471072qkb.51.1571051781725; Mon, 14 Oct 2019 04:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051781; cv=none; d=google.com; s=arc-20160816; b=ErwXTbEte3N5vpP0G1GQwTo87xDJqxQbjsw4ew856Zs8IIrQlz1JXmWi9PMmfh6k8w uhLCPiGa3QbQk10rzP5/SU/hAYppqW+cOILjSQ7kD59hZJg1PNVor6Ccp3ddRs7Zb+Id HZZZzKAjFkW3rKhqmt/Oq+u3HCnftJtnEoViskYc9f7XQabg3ypiFdL8V9kRRLjafnGJ r32dYIoeAIZeywISlyRT1lJB/5NkzJg8ROyjVPrBcbgceZ3wU9680O9WfdNtXiKD28Xf CirzFQQpF+rdo6JIKhnaDluxzE9xT/+B79w7PwO+meew+ZEPQT/q9kYULfRbyizCtRfE rsaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7/acujaq0f8VIuYkCq8x2pbN5arCr0y/77PvQd1T9zw=; b=BX+5lEHm0FIY5s8kk3hfUNdtu/uIPcnL5oym73l7EusPCKuhKIPYO2tgx3xp4BHvFa Gu62jkPU5960ufp7403Su7yN/1bf15LP36Yl1+Y9cbDE6rOQtsF23D+RBuUKJIK/KwoI oT5rSpKN7zRNogdCGzY9sRiLdr3yMUapyRU/e89dKJcCMJeUzIYt0dlabWoGy36ZLB02 /KnqG2IkKVaIkHlyzGoPBUWFkb7o8Bu4M0zXE/PqpvCdyOXfNNYo/N4v3fBE77SbmEz/ ZyBmf8i4opl/Iiffy640dWz+qPQ3ueedvy7NIyk1SsOAzxBtdRxmkW29oGyWmd7ERvgo vjNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xCi5jrcc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d135si16899703qke.176.2019.10.14.04.16.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:16:21 -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=fail header.i=@linaro.org header.s=google header.b=xCi5jrcc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyKq-00080j-TL for patch@linaro.org; Mon, 14 Oct 2019 07:16:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44727) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvV-0007ZK-JC for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvU-0006JN-Fi for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:50316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvU-0006IC-9u for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: by mail-wm1-x344.google.com with SMTP id 5so16761870wmg.0 for ; Mon, 14 Oct 2019 03:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7/acujaq0f8VIuYkCq8x2pbN5arCr0y/77PvQd1T9zw=; b=xCi5jrcctHYt6cJ8cWOqCxcCYDafzYCmO/vdDUoHooCaZraUHYgKJgmSvRchLli1XI C1ZrilPAq9oeh6Mu6RjWZomMJwbyrT+gz97iB9MT6NZD++9bXvhc9HjRHtSZNtF63cEZ PkFGKZuqS2Dp52Q9LecVVB6j+YoYxIH+2zQHFW0c/RpQxNUZWUbjvqukwwBYE0y9ajC8 3j/yNDm1ZxX2RomVlRywlJ5Phn+zkN+YE3WnKzi+yvikloGCiTizL8ZW7kZb9XDqZO6m FmII10g+MpCSOukglXD57XQiEvaFlbs7q/QcWcqpX4URxqQ0Acm2o7U+Hf2gsfK+ZJZh tzfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7/acujaq0f8VIuYkCq8x2pbN5arCr0y/77PvQd1T9zw=; b=DCOGh7b1wsntMNsxLNcOO3W9NwwS3wGD/b06Dw60CQWC17iKl2DarXNabHn2zJvwSu /N45Yg/KeZe0gH7nZX+2cFEiLza9YhN0ZOmGjHFAQ9ihKIcbSmhdT4VKCe1SbkX/MQ1r CWUa3dxXLyUYs690tanQoNPvgpI2CWGrkOgxqxakSOn73ZZ3dvaTeR2BRX2rsP7yS6Pk VuRZyWpUv2kCI8w8xYMyk/Hc1rLxTyhfEqmnOst/czT69KCLLSlNO02eRwn2nzkHBWT7 4fowLP3mT1KnMAfEPkbTAoIgJKXnLlJJ8jtHlarssFYjvXRc7EDHHSveTV0jTjDaHymn 64cQ== X-Gm-Message-State: APjAAAXemIQFyg9PfbdeZfu+JDKCHcETdoAuRb538/bpcD2fIcvpYlHb DwIiokx08nIhlxJ0u+Mo05LU0g== X-Received: by 2002:a1c:4e15:: with SMTP id g21mr13486037wmh.148.1571050207289; Mon, 14 Oct 2019 03:50:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y186sm37048985wmd.26.2019.10.14.03.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8AB501FFCD; Mon, 14 Oct 2019 11:49:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 43/55] tests/tcg: drop test-i386-fprem from TESTS when not SLOW Date: Mon, 14 Oct 2019 11:49:36 +0100 Message-Id: <20191014104948.4291-44-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a very slow running test which we only enable explicitly. However having it in the TESTS lists would confuse additional tests like the plugins test which want to run on all currently enabled tests. Signed-off-by: Alex Bennée --- tests/tcg/i386/Makefile.target | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index 08c5736a4d..43ee2e181e 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -7,10 +7,8 @@ VPATH += $(I386_SRC) I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c)) ALL_X86_TESTS=$(I386_SRCS:.c=) -I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS)) +SKIP_I386_TESTS=test-i386-ssse3 X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) -# Update TESTS -TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) # # hello-i386 is a barebones app @@ -36,9 +34,12 @@ run-test-i386-fprem: test-i386-fprem test-i386-fprem.ref $(call run-test,test-i386-fprem, $(QEMU) $<,"$< on $(TARGET_NAME)") $(call diff-out,test-i386-fprem, test-i386-fprem.ref) else -run-test-i386-fprem: test-i386-fprem - $(call skip-test, $<, "SLOW") +SKIP_I386_TESTS+=test-i386-fprem endif +# Update TESTS +I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) +TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) + # On i386 and x86_64 Linux only supports 4k pages (large pages are a different hack) EXTRA_RUNS+=run-test-mmap-4096 From patchwork Mon Oct 14 10:49:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176200 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4402238ill; Mon, 14 Oct 2019 04:49:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDDM+QUSuwlcEkHzW9Qzt1KDrWxG/Hnb+28fhGUHQv4mLjlirb2wdE/6kzXUUOfc/nGxE3 X-Received: by 2002:a37:9907:: with SMTP id b7mr30197966qke.452.1571053755619; Mon, 14 Oct 2019 04:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053755; cv=none; d=google.com; s=arc-20160816; b=Oj2yktcS5M1FxYJXO6hSElHcrbAXsd2r6tIOHbTitBnd7r/45S0cW10YMm2F3Kb6Gk tWGKawuOAYIDU1w7wJVz8XaM2A5S3upGLz05v0AuiGMi8HSDIVBtf6XjBjo8EHSkJTj6 D6gfKGHGTiGFLEZAHd/GrVkqCsVjLAcMdDgyDcUK9cXOYlHzw+IJ3nocikhYkgBxLqB9 X3SlnFBk6sUSDJ0j9yx0eNVxqQ+WFUVCwB/l0ES6Kee2rc8ZckGeaJX4BrsLy07U4VFZ l3UU99+c3EgF3ScE0M98QxuT71owJbtIrf+leFgxo7iuz+jt4nJDh8/4TqZtxKXutWcu y9cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KpM3SyJDkKhcUHIVLFnItn5R6+AXIYS7UFfmeyEbac8=; b=pENCIPNaRUlRdredLFSNEBxETi3J4PE+h/ldG21E2TbfUKTx1bq7F9974pvmZF8cIn ds6nR7fqU5PxJkZ9CNhD7ovk5P+Xkx01H1Vdu8FmK+M8iOWUglnuhGeBu5kEyWjs2t6e sCOoSyvrAaT0JkboagTABfw8H2EFRgaTjPqoS0yBGWUBsgJEvuvn8MWWk5G8LxbF/91b RZDAl7DSXRTUv5+J+NOHm1H3kBjxNf4FTOEJB1O9FDlGZAG+lDl9+J6kVh4K4xFH+Rlw v2SCc3/JabFcU8CzrDXuc/q4Whs/KuKp4/UWSVR7JHngNObuk3ksUg0Sd6K7y4t2EmmN dIzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FwSIXiWv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q8si16427013qtn.164.2019.10.14.04.49.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:49:15 -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=fail header.i=@linaro.org header.s=google header.b=FwSIXiWv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyqh-0004eT-4e for patch@linaro.org; Mon, 14 Oct 2019 07:49:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46935) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCH-0008FD-CZ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyCF-0007od-QZ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:29 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:36614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyCF-0007ne-JY for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:27 -0400 Received: by mail-wr1-x433.google.com with SMTP id y19so19225909wrd.3 for ; Mon, 14 Oct 2019 04:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KpM3SyJDkKhcUHIVLFnItn5R6+AXIYS7UFfmeyEbac8=; b=FwSIXiWvVyQXV3tamVT+RpTc7tE0bBsHri7uBVqqmLoCewIeqP+Ou7C4gwYIjnTS8M liPqcIHDajnEfNa+9vQ0PsyFM/OyckztfqB4DfbxEXMurPy8TIfwNUimu35RzYWGlPtJ BkdSGx3Z3beXamcCCYwWiKbCwc0fVxKBCtBMdWNT90mNbsPGRpieuxh/tmym24ttcqBk osJnT/HHFA1azlp0kzmDRL7hRciGvHokgUADRExU1aRrbneFUF+Bm0VrhnNPxEm6TsBY Rl/S3G9Fg3iZ8tqPnur29k74iG0l60N2OODczgMP30szumALwbjO6zlcS0PUCuwTolJH /I0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KpM3SyJDkKhcUHIVLFnItn5R6+AXIYS7UFfmeyEbac8=; b=fyhIuM42O8cT6+Z9nUsE2b1G4nTh6P9Ej+mOUw2X+S/PAGQyjp11SGTuRL472kTYdM +hBtATzek+rEmmWRXbj2l4B3/8EvwrvlHozDdDOoFaTHRfBrGq1W21skaFT0aTofzQUk 5iqss3rFvjt9MDtnF6uvZzCsDnzBDwkhECVA7OFiKhfboQ3OOZpQ7ljXv/0LOAYSuDng agdxgZ59+dEKGPDPtWBx+nHb2MaXpevDL0N6eNQBo5J7fJezOdUfdmIPVy2/H+X7Mt5s 5wor2/zVKnW1tlXH6HEeADK3B2Lgb858g753r8j8NbSuSb7LGBpEYGkZRV7OUXomKO6T 68yw== X-Gm-Message-State: APjAAAUE6MSa3zCg20bgOThZ8sjsdzzcYvTXMCVhZ8GpI0Wq9cMqthYO 9Lv0bbfY26czRhs222aYQSIIgQ== X-Received: by 2002:adf:ee4f:: with SMTP id w15mr6582038wro.378.1571051246196; Mon, 14 Oct 2019 04:07:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r27sm52393613wrc.55.2019.10.14.04.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C50081FFCF; Mon, 14 Oct 2019 11:49:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 44/55] tests/tcg: enable plugin testing Date: Mon, 14 Oct 2019 11:49:37 +0100 Message-Id: <20191014104948.4291-45-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, "open list:ARM TCG CPUs" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If CONFIG_PLUGINS is enabled then lets enable testing for all our TCG targets. This is a simple smoke test that ensure we don't crash or otherwise barf out by running each plugin against each test. There is a minor knock on effect for additional runners which need specialised QEMU_OPTS which will also need to declare a plugin version of the runner. If this gets onerous we might need to add another helper. Checking the results of the plugins is left for a later exercise. Signed-off-by: Alex Bennée --- v5 - fix for the latest changes to check-tcg - extend timeout for plugin tests - add special runner for semihosting with plugin - fix naming of test in call output - add special plugin aware runners for semihosting --- tests/Makefile.include | 11 ++++++++- tests/tcg/Makefile.target | 35 +++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 6 +++++ tests/tcg/arm/Makefile.softmmu-target | 1 + tests/tcg/arm/Makefile.target | 6 +++++ 5 files changed, 58 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/Makefile.include b/tests/Makefile.include index 3543451ed3..646a704e65 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -1052,6 +1052,15 @@ check-softfloat: "SKIPPED for non-TCG builds") endif +# Plugins +ifeq ($(CONFIG_PLUGIN),y) +.PHONY: plugins +plugins: + $(call quiet-command,\ + $(MAKE) $(SUBDIR_MAKEFLAGS) -C tests/plugin V="$(V)", \ + "BUILD", "plugins") +endif + # Per guest TCG tests BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS)) @@ -1062,7 +1071,7 @@ RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS)) $(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs)) -build-tcg-tests-%: +build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins) $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ SRC_PATH=$(SRC_PATH) \ diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 9664613002..d25fc64300 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -123,11 +123,38 @@ all: $(TESTS) $(EXTRA_TESTS) # RUN_TESTS=$(patsubst %,run-%, $(TESTS)) + +# If plugins exist also include those in the tests +ifeq ($(CONFIG_PLUGIN),y) +PLUGIN_DIR=../../plugin +VPATH+=$(PLUGIN_DIR) +PLUGINS=$(notdir $(wildcard $(PLUGIN_DIR)/*.so)) + +# We need to ensure expand the run-plugin-TEST-with-PLUGIN +# pre-requistes manually here as we can't use stems to handle it. We +# also add some special helpers the run-plugin- rules can use bellow. + +$(foreach p,$(PLUGINS), \ + $(foreach t,$(TESTS),\ + $(eval run-plugin-$(t)-with-$(p): $t $p) \ + $(eval run-plugin-$(t)-with-$(p): TIMEOUT=30) \ + $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p)))) +endif + +strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1)) +extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1)) + RUN_TESTS+=$(EXTRA_RUNS) ifdef CONFIG_USER_ONLY run-%: % $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<), \ + "$* on $(TARGET_NAME)") else run-%: % $(call run-test, $<, \ @@ -135,6 +162,14 @@ run-%: % -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ $(QEMU_OPTS) $<, \ "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=$@.out$(COMMA)id=output \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(QEMU_OPTS) $(call strip-plugin,$<), \ + "$* on $(TARGET_NAME)") endif gdb-%: % diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 509f1afa93..96d2321045 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -26,4 +26,10 @@ AARCH64_TESTS += semihosting run-semihosting: semihosting $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") +run-plugin-semihosting-with-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<) 2> $<.err, \ + "$< on $(TARGET_NAME) with $*") + TESTS += $(AARCH64_TESTS) diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target index 231e9a57b4..3fe237ba39 100644 --- a/tests/tcg/arm/Makefile.softmmu-target +++ b/tests/tcg/arm/Makefile.softmmu-target @@ -23,3 +23,4 @@ LDFLAGS+=-nostdlib -N -static test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel +run-plugin-test-armv6m-undef-%: QEMU_OPTS+=-semihosting -M microbit -kernel diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 3ddff85240..0765f37ff0 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -34,6 +34,12 @@ ARM_TESTS += semihosting run-semihosting: semihosting $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") +run-plugin-semihosting-with-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<) 2> $<.err, \ + "$< on $(TARGET_NAME) with $*") + TESTS += $(ARM_TESTS) # On ARM Linux only supports 4k pages From patchwork Mon Oct 14 10:49:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176179 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4379063ill; Mon, 14 Oct 2019 04:26:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFldrp0hwU5J91Bul60xFkFdnvi0w/7UnUNq0WaHKMM+Bao9Avt7AIBzjrN6fLtm9+gavV X-Received: by 2002:a37:67d6:: with SMTP id b205mr29550366qkc.183.1571052407129; Mon, 14 Oct 2019 04:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052407; cv=none; d=google.com; s=arc-20160816; b=EU+4Jej2AYjbARHRtNPZdW6znU95YPr5INS3AulfPR2fTe1EYn8T1didcJ9QjWE+zG kfMct5veLlcxC0Hn9ZWo3o3+e+f9KQGoeoVTgIu6gn8Q86oJwo10BWMvqEn8E0MDa5wU iQwGwP8yiH68bClwauHTM33lI4q8H4xJvQcy/YBNAOYpvwLNQxW6lBRzmahVSpRGz1xf UpqLcHozBK6UwzvGvXshRIlqkOH6gYkqHb1Yu8N4A4dr5gDaTTZbS+SfHGLW3hxduxYN XHgMjhWUWuxyNuIsCzmflgohwOiPGxqzI60RmYt4yIvkE1+//CASCxzTCmCl0zsrP1Cv 6IFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ouNEnxImoHWm/wNyLGaSm67QiP36d/93Hs/vzEx9qe0=; b=Xnyh4DIud74NaU4Bd86HcMG922dqjuPIL+16m2AB3+5QQ3kkvGLAex+adUuWHJ0VhU fE7IRyioDTdi6hcxo94mM9zJ0YET/tos3zcTnAUPek84yBqtjagh/gohel1aItrudZRk u4/lWW8Z0q3K4xNJMtIR6k8gsGtinPqGoHem3c0yaoWho6H1+Kx2lfxJReQ3D4SEkE/Y sJemf/T31nCnMbnUJKH8XNJP2uRa8ToUTmgIjBL/fsaX6jzIqJAKuF7+cqwh0hqn8Bt7 v+pYg/wqgZG5Wr5nqoYw/VbYp3xzm4nvyexYxLfKvHwC9x9s9jiU5pc19RPKYjIcCM3v 0kBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SKHSn+DL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2si17557029qkj.366.2019.10.14.04.26.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SKHSn+DL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyUw-0005Zw-4i for patch@linaro.org; Mon, 14 Oct 2019 07:26:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45503) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2B-0006fH-Ec for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy29-0005Aj-QG for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:34513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy29-00058x-Hr for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: by mail-wm1-x341.google.com with SMTP id y135so14227108wmc.1 for ; Mon, 14 Oct 2019 03:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ouNEnxImoHWm/wNyLGaSm67QiP36d/93Hs/vzEx9qe0=; b=SKHSn+DL+ng4qlmoynBsiGbH9Azsi1Xdh+ct127aWpKhh+BQb3kZ1asd6U24F5Naxl NhItxw4YbYFwKJK3BYhtJz1k2cfMdyJHyif519PJaaf6/Gjuw9XTJNYi55PORgR7yqDD +TskcI3Mro0hkR8deZEPJx3i/AIQxSadcadb2QWaePDjNAQfmU/bUtbLW7cxsYmgPtbo ytg6a/CZtqjwEdUhnaWn+hcVIgICihpniZIZf2b/sdCZlO4lvhsdQMYUnlAs2ynuE3t6 Kfbs6by66Gb7L0ysf1WbAF3u+Wo3ijKMS0WEH7B3cwalhBM80tt4YnTvSoR8S9BWY7CT V1Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ouNEnxImoHWm/wNyLGaSm67QiP36d/93Hs/vzEx9qe0=; b=BFMVqYROXTd0NNC4Iluor45Yn1v/eQn53jNS45lvkJU40N0Ka/h0ra9ss4X7iY/joZ bCv+d3SBWocxHOdrVlSc4iVT0gffpTzu5otAbM9wmm9ijr52EsCdJu+uKF1z3/9oKywD pIk1927Lmb5LX8W2wzDVQxP0rJYKuH8FBpaAqRtUqlzdqkC5IKJiSPfKnVdUVcZEnHLb n2m2MfZFDomtL3kdI9cDh/7VXQ+l2CoZzDTh7oiQ5IxpxIMF32cRY6yLVzP0BLoWKl4/ xTJL4AvhYeFqCPDTTgYrdKkdJjZxfaGMQlFm3SkEmsR7pI9ktYoymL+0mI7Okgr7/unx n8PA== X-Gm-Message-State: APjAAAV9ZiGusI3eBuEOBj2dUmQ1u7qq8+FwhkVyuigfUwo5SQtEsiqs WW6l8efxUAyz1B5NJq9jMz8IDA== X-Received: by 2002:a7b:c206:: with SMTP id x6mr7007965wmi.147.1571050620018; Mon, 14 Oct 2019 03:57:00 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f9sm21400754wre.74.2019.10.14.03.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0D94C1FF99; Mon, 14 Oct 2019 11:49:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 45/55] tests/plugin: add a hotblocks plugin Date: Mon, 14 Oct 2019 11:49:38 +0100 Message-Id: <20191014104948.4291-46-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a simple plugin to track which translation blocks are call most often. As we don't have a view of the internals of TCG we can only work by the address of the start of the block so we also need to tracks how often the address is translated. As there will be multiple blocks starting at the same address. We can try and work around this by futzing the value to feed to the hash with the insn count. Signed-off-by: Alex Bennée --- v5 - handle 0 length report --- tests/plugin/Makefile | 1 + tests/plugin/hotblocks.c | 148 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 tests/plugin/hotblocks.c -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index f9a3546ea3..e74940eaac 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -10,6 +10,7 @@ NAMES += bb NAMES += empty NAMES += insn NAMES += mem +NAMES += hotblocks SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) diff --git a/tests/plugin/hotblocks.c b/tests/plugin/hotblocks.c new file mode 100644 index 0000000000..a150179a5c --- /dev/null +++ b/tests/plugin/hotblocks.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2019, Alex Bennée + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static bool do_inline; +static int stdout_fd; + +/* Plugins need to take care of their own locking */ +static GMutex lock; +static GHashTable *hotblocks; +static guint64 limit = 20; + +/* + * Counting Structure + * + * The internals of the TCG are not exposed to plugins so we can only + * get the starting PC for each block. We cheat this slightly by + * xor'ing the number of instructions to the hash to help + * differentiate. + */ +typedef struct { + uint64_t start_addr; + uint64_t exec_count; + int trans_count; + unsigned long insns; +} ExecCount; + +static gint cmp_exec_count(gconstpointer a, gconstpointer b) +{ + ExecCount *ea = (ExecCount *) a; + ExecCount *eb = (ExecCount *) b; + return ea->exec_count > eb->exec_count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("collected "); + GList *counts, *it; + int i; + + g_mutex_lock(&lock); + g_string_append_printf(report, "%d entries in the hash table\n", + g_hash_table_size(hotblocks)); + counts = g_hash_table_get_values(hotblocks); + it = g_list_sort(counts, cmp_exec_count); + + if (it) { + g_string_append_printf(report, "pc, tcount, icount, ecount\n"); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + ExecCount *rec = (ExecCount *) it->data; + g_string_append_printf(report, "%#016"PRIx64", %d, %ld, %"PRId64"\n", + rec->start_addr, rec->trans_count, + rec->insns, rec->exec_count); + } + + g_list_free(it); + g_mutex_unlock(&lock); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + hotblocks = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + ExecCount *cnt; + uint64_t hash = (uint64_t) udata; + + g_mutex_lock(&lock); + cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash); + /* should always succeed */ + g_assert(cnt); + cnt->exec_count++; + g_mutex_unlock(&lock); +} + +/* + * When do_inline we ask the plugin to increment the counter for us. + * Otherwise a helper is inserted which calls the vcpu_tb_exec + * callback. + */ +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + ExecCount *cnt; + uint64_t pc = qemu_plugin_tb_vaddr(tb); + unsigned long insns = qemu_plugin_tb_n_insns(tb); + uint64_t hash = pc ^ insns; + + g_mutex_lock(&lock); + cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash); + if (cnt) { + cnt->trans_count++; + } else { + cnt = g_new0(ExecCount, 1); + cnt->start_addr = pc; + cnt->trans_count = 1; + cnt->insns = insns; + g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); + } + + g_mutex_unlock(&lock); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &cnt->exec_count, 1); + } else { + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, + (void *)hash); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Mon Oct 14 10:49:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176173 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4372549ill; Mon, 14 Oct 2019 04:20:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1hqKD3dxDDFkxLVFrMoZ5VbxCa7hIcTKvp5NrfaD62+dCg8aHpTrGEXCnCciG4JxbMG0b X-Received: by 2002:a05:620a:140c:: with SMTP id d12mr28354668qkj.419.1571052031642; Mon, 14 Oct 2019 04:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052031; cv=none; d=google.com; s=arc-20160816; b=B/5N1aeHlvwGY6NALAoN5fdK4g1b3tP9wmqxlr+nOUlMnpmsBndqQxH6j0UMVImrnF IY9RQ5gYVBtwvX44dGOu85KbysiiTxIYqcyB9z3bB/5+228cbNyCaxBm3djNUMKORo6k 8I0IbnQlNQj4AAlJ4s9KOJ0Ub7EP9rVL/io5mSV9ZPQVBPXXvnNoce+jFIQ+BqIMtNGc I0H03e1woVcPIciE4NvD8+btwlHyPzjsYeuszUelPVodbVcauOidh810AT8V13vBALPT zie5kMmPs4m5C9VGxp99qEjYw2eo8X+PZscoVdulvOO0l5xW808Ynd+Y58eP/lkFuZVu cj1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=j/zM8w2UQVs1nwStRjcaLSLZ/8bKSPRTKMusEwFjutc=; b=jhq3g/fgOosg2CYQ9aOSzz/Cw7SP4YywXQ3gwJRH7fIxp15Te5sCUSgJxRkIOLCtx9 ipSVVwBtpy1oudEBdVeQB/8Y+qNDjRw6XQ0MiTpUYGrbIJfxZaYue1rH1xyk7COdRF4A gBru0sd0g5re2a+VynOLfGO0zhwEpOm5LevEgXaRTsAHWMbzovcNhnlgyFaMVvbzfbBj QJgy9eHIkrVEi9E8HmniP3VMkDBN488uJ5+//KF4NsnOHyetccqRHTpWcmxvX97/w60Y DZltcf1gD7DqOrmavLMJh6S+b/Fj7eUZXIYw1MkYCp74K9yaI3ZkLukl0mvdIFLJeZaT N9pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Dej9oXWW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s9si17621964qtj.335.2019.10.14.04.20.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:20:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Dej9oXWW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyOs-0005tL-HO for patch@linaro.org; Mon, 14 Oct 2019 07:20:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy25-0006Uz-TZ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy22-000516-Td for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:57 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy22-00050B-Mx for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:54 -0400 Received: by mail-wm1-x341.google.com with SMTP id 5so16783210wmg.0 for ; Mon, 14 Oct 2019 03:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j/zM8w2UQVs1nwStRjcaLSLZ/8bKSPRTKMusEwFjutc=; b=Dej9oXWW14KR5gGGkav99r/Wmz4AauPLq9M20BH1yuz+s0xopUT9eT14R4P+WtVkJ4 jkhxwWLIavpqaO1CG3hrAp45KpqN4vrxWa+8ZZuQhGdXBBG0TSWvU/5AJMPpbKbtS1Ye +kK2o9A5hTq20e3V7isXfbN79POE95Y0hDl3s0T0uz6pwtPiP1klI6mFtTEW7QJ/Ix99 XYsZTIPJbRg6uP//fse7TU66GJFj6b5iGuEpswr/Iy0kge9pM0kXt6jobYhcmXPF+h1m Siau/ACWzmrBOwahnLMICFD6TtxJMDClVOAESaf804NmD0/IND8PMUpXv6LSZ/C2P+VH bUKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j/zM8w2UQVs1nwStRjcaLSLZ/8bKSPRTKMusEwFjutc=; b=nvMlr3Uc6mGF9jGSWXMscFUR1dxET57nyO2sjlL3sLjgUXPnyNJq6nq22xUJ+dEqXz dP3+yGYKqHcaTHdHlSkY1Ktw7cI5laDHsm/CdRN5rtS1UUT54rHxFIuT1QPUlzSK7QHg ClY6NFVf8UETLv7UUouo6bMQW7n+ZEjSrjplKmT4aiPErpr5dgSNwvhTEHk+0CkdI+9t Gi8vUcd/qCpC0qHBxklmoqnRZvvHIV5b/F8ZQfFgbopiSoaiZspYBD/FZXHfwsUHJHmQ a+Y3xc94nS2XQFe079Of6wPrKrzCLagU7d5qCYv56GJneJ4XgTPfnuqQ2bqxqRPCjlFP /hXg== X-Gm-Message-State: APjAAAXQUQIIiJ1mSvXgkfFRs2mR2LWl9XoCeEjbrOdyMqQtdrDcF+ZY BcuBYu325uXH+fTggJvYaXVMemHGhLk= X-Received: by 2002:a1c:9d4a:: with SMTP id g71mr15229671wme.26.1571050613553; Mon, 14 Oct 2019 03:56:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o9sm25681893wrh.46.2019.10.14.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5A1BE1FFD1; Mon, 14 Oct 2019 11:49:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 46/55] plugin: add qemu_plugin_insn_disas helper Date: Mon, 14 Oct 2019 11:49:39 +0100 Message-Id: <20191014104948.4291-47-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Give the plugins access to the QEMU dissasembler so they don't have to re-invent the wheel. We generate a warning when there are spare bytes in the decode buffer. This is usually due to the front end loading in more bytes than decoded. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v5 - fix plugin_printf to use vprintf with va - use __thread storage for string - only decode single instruction for bfd case - don't assert, warn_report when we have spare bytes in insn buffer --- disas.c | 110 +++++++++++++++++++++++++++++++++++ include/disas/disas.h | 2 + include/qemu/qemu-plugin.h | 9 +++ plugins/api.c | 7 +++ plugins/qemu-plugins.symbols | 1 + 5 files changed, 129 insertions(+) -- 2.20.1 diff --git a/disas.c b/disas.c index 3e2bfa572b..02f68e92ab 100644 --- a/disas.c +++ b/disas.c @@ -418,6 +418,7 @@ static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) # define cap_disas_target(i, p, s) false # define cap_disas_host(i, p, s) false # define cap_disas_monitor(i, p, c) false +# define cap_disas_plugin(i, p, c) false #endif /* CONFIG_CAPSTONE */ /* Disassemble this for me please... (debugging). */ @@ -475,6 +476,115 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } } +static __thread GString plugin_disas_output; + +static int plugin_printf(FILE *stream, const char *fmt, ...) +{ + va_list va; + GString *s = &plugin_disas_output; + int initial_len = s->len; + + va_start(va, fmt); + g_string_append_vprintf(s, fmt, va); + va_end(va); + + return s->len - initial_len; +} + +static void plugin_print_address(bfd_vma addr, struct disassemble_info *info) +{ + /* does nothing */ +} + + +#ifdef CONFIG_CAPSTONE +/* Disassemble a single instruction directly into plugin output */ +static +bool cap_disas_plugin(disassemble_info *info, uint64_t pc, size_t size) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize = 0; + int count; + GString *s = &plugin_disas_output; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + size_t tsize = MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf = cap_buf; + target_read_memory(pc, cap_buf, tsize, info); + + count = cs_disasm(handle, cbuf, size, 0, 1, &insn); + + if (count) { + g_string_printf(s, "%s %s", insn->mnemonic, insn->op_str); + } else { + g_string_printf(s, "cs_disasm failed"); + } + + cs_close(&handle); + return true; +} +#endif + +/* + * We should only be dissembling one instruction at a time here. If + * there is left over it usually indicates the front end has read more + * bytes than it needed. + */ +char * plugin_disas(CPUState *cpu, uint64_t addr, size_t size) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + int count; + CPUDebug s; + GString *ds = g_string_set_size(&plugin_disas_output, 0); + + g_assert(ds == &plugin_disas_output); + + INIT_DISASSEMBLE_INFO(s.info, NULL, plugin_printf); + + s.cpu = cpu; + s.info.read_memory_func = target_read_memory; + s.info.buffer_vma = addr; + s.info.buffer_length = size; + s.info.print_address_func = plugin_print_address; + s.info.cap_arch = -1; + s.info.cap_mode = 0; + s.info.cap_insn_unit = 4; + s.info.cap_insn_split = 4; + +#ifdef TARGET_WORDS_BIGENDIAN + s.info.endian = BFD_ENDIAN_BIG; +#else + s.info.endian = BFD_ENDIAN_LITTLE; +#endif + + if (cc->disas_set_info) { + cc->disas_set_info(cpu, &s.info); + } + + if (s.info.cap_arch >= 0 && cap_disas_plugin(&s.info, addr, size)) { + return g_strdup(ds->str); + } + + if (s.info.print_insn == NULL) { + s.info.print_insn = print_insn_od_target; + } + + count = s.info.print_insn(addr, &s.info); + + /* The decoder probably read more than it needed it's not critical */ + if (count < size) { + warn_report("%s: %zu bytes left over\n", __func__, size - count); + } + + return g_strdup(ds->str); +} + /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size) { diff --git a/include/disas/disas.h b/include/disas/disas.h index ba47e9197c..8481d4a8b3 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -14,6 +14,8 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, void monitor_disas(Monitor *mon, CPUState *cpu, target_ulong pc, int nb_insn, int is_physical); +char * plugin_disas(CPUState *cpu, uint64_t addr, size_t size); + /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(target_ulong orig_addr); #endif diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index d9c1ca3b4c..8b403dd615 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -324,6 +324,15 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_ret_cb_t cb); +/** + * qemu_plugin_insn_disas() - return disassembly string for instruction + * @insn: instruction reference + * + * Returns an allocated string containing the disassembly + */ + +char * qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn); + /** * qemu_plugin_vcpu_for_each() - iterate over the existing vCPU * @id: plugin ID diff --git a/plugins/api.c b/plugins/api.c index fbacd78df6..a9fa229369 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -40,6 +40,7 @@ #include "sysemu/sysemu.h" #include "tcg/tcg.h" #include "exec/exec-all.h" +#include "disas/disas.h" #include "plugin.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h" @@ -211,6 +212,12 @@ void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn) return insn->haddr; } +char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn) +{ + CPUState *cpu = current_cpu; + return plugin_disas(cpu, insn->vaddr, insn->data->len); +} + /* * The memory queries allow the plugin to query information about a * memory access. diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 40c0d1abd2..267ec381b4 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -25,6 +25,7 @@ qemu_plugin_insn_size; qemu_plugin_insn_vaddr; qemu_plugin_insn_haddr; + qemu_plugin_insn_disas; qemu_plugin_mem_size_shift; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_big_endian; From patchwork Mon Oct 14 10:49:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176195 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4395564ill; Mon, 14 Oct 2019 04:42:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqEqQLXDn/Hrh2dT3bx0W5Gq18+PzKzPcfIl1hmi8mFGJeoYieg26t9VQ/jUpIjVRVHaIC X-Received: by 2002:ac8:b42:: with SMTP id m2mr31812004qti.174.1571053340221; Mon, 14 Oct 2019 04:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053340; cv=none; d=google.com; s=arc-20160816; b=FRBnyLpgHf/rX1MYA1kuhCf3NGvEtvt9ZShagZV4u7UYbz2cleSLRo5pKi3AyekAhJ EnDlVdRaS7+wqJu/kAI9jLXde/Pesvr35sewchlDskSp+A+JcgvkdaadiqkBlYJcmbDj JvK/tm0LB5BUgjib5DAGg7m1nHqTGab34rhfZFF7dJ5QcR6NM8vZt+HQLf+GoZnJ5/cZ /Ygx6ncaN1DweSYRzE3Nx1uAMb68J+rhvZHPDWSYipbSLS8s1uAgbFtUR8YPk1IY1TLa JEnvGb1sZLxD7pBu1qDrYfQt7l1mljISqILkUhWAQV0KgjDOrxzN7kFBVRx4/0y0UPmo pq0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NcM2OW8hOZLGEmTgGaT1ah5hV9uWmpQOgbN08Bz7RB0=; b=Vinu75Dr697co0BAgS8ZjHJGqtxWSqibF55C+ezOaNUGok5dKiqOZjPSl/6wGsjz/V ZuIUz2eHciM3Sa4JZimUWf0eLgT7tjipWG/6o1hsR9okDCGGfy9i/TCjc7HF60ci7zMb sNNV+P81mJXBM261RK+1KJBhNdg7k4kJ0j4o2xVtXtXimUv468zh70g37qPAds1H7zdK mPfnfAdLXbHJOV+zgUoSmtDrJTVwtRIis4M3OxX6U9sTmLCWJ/KxnYE7J36upLpWthkY Uwtbmu3PtBgUzKSeNwM3JAV4J48UqFWDG5QAaAQiJfY7sG7QZyiFvHLVtahYoLy1Js9C 1mFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Rg5GYxxq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p184si17833187qkd.119.2019.10.14.04.42.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:42: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=fail header.i=@linaro.org header.s=google header.b=Rg5GYxxq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyjz-0007V5-Kp for patch@linaro.org; Mon, 14 Oct 2019 07:42:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46887) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCC-00087A-5q for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC9-0007hu-QU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:24 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:44288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC9-0007gW-Jf for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:21 -0400 Received: by mail-wr1-x42b.google.com with SMTP id z9so19189819wrl.11 for ; Mon, 14 Oct 2019 04:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NcM2OW8hOZLGEmTgGaT1ah5hV9uWmpQOgbN08Bz7RB0=; b=Rg5GYxxqSGji7CEHQVpbwf7H3UlExM6gUkQqFW3zFtORmZLLNYzx/s2WBKDPLD3y44 RdTmXK9UjafVaRYzdFNWG35avRoJQj5mbzswOTj+BZ4HHOo2pQ4hZlfxsO/SKcwDmfKT 411x7KNfLXL+PAkfomCj+dINSaHybW1A+U5b1S0tx6KjP0Q1Nz1DRwap0NpeTUcmiIr1 hZMQgaSPPsJVdnZrYD0b/dI5Jj54KI8pOJhAhOeHsdU5KWwgeKx0/c4EtoQzIXyCCfmt l6dYLgh75yZJ8V191V6lvaYhiSjB+P/Q7Tall6/a6yBuS7FqXRHWaHZ9Ie4bnH2TTfRj LMYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NcM2OW8hOZLGEmTgGaT1ah5hV9uWmpQOgbN08Bz7RB0=; b=Rp2CdLhXgFg/VzfyR7TDUgLCRMb5ZdM+dO0R6YXs83Y8FbR4PqTVwn+Y64CsVelLm4 xYmAj6FsrGqUIg0GFw+SL3UpwpERj25j0YwnNIo31iUVqaTFX8W2reQwQZwlzM2b7+xL do6RQQ+tYi4n0U4RQSd9WgWJ7MnJbLqLeuvLYhp3fxxUKy5jyVj75HB9vNjoxpbXilw4 dJqsBDCwzicq2ctkBhuiCk9OsSr403gUyJOdcj27LMTu5biM4HaU8pZDN37ywN1MsOrl 3Z0i7FHx9b2mHTWvOnV2f+6RuSbLeKT+NlIQzJmTF8p89vR1y1rY9gqttBd30EIvvDXw s4pg== X-Gm-Message-State: APjAAAWPOrDnF4nXcoIrsZB1ymtM9NmcfhQNHyQwsCxNbnIY3QNB/ijT je2Kvgpi3obhAZmggq9tOUm6kTrIBhs= X-Received: by 2002:adf:e401:: with SMTP id g1mr23688737wrm.211.1571051240373; Mon, 14 Oct 2019 04:07:20 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q22sm15585251wmj.5.2019.10.14.04.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 89A2E1FFD2; Mon, 14 Oct 2019 11:49:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 47/55] tests/plugin: add instruction execution breakdown Date: Mon, 14 Oct 2019 11:49:40 +0100 Message-Id: <20191014104948.4291-48-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This gives a break down of instruction classes and individual instruction types. Signed-off-by: Alex Bennée --- v5 - add a bitmap guide to the comment ;-) --- tests/plugin/Makefile | 1 + tests/plugin/howvec.c | 303 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 304 insertions(+) create mode 100644 tests/plugin/howvec.c -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index e74940eaac..3656429d46 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -11,6 +11,7 @@ NAMES += empty NAMES += insn NAMES += mem NAMES += hotblocks +NAMES += howvec SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c new file mode 100644 index 0000000000..b435c6b64d --- /dev/null +++ b/tests/plugin/howvec.c @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2019, Alex Bennée + * + * How vectorised is this code? + * + * Attempt to measure the amount of vectorisation that has been done + * on some code by counting classes of instruction. This is very much + * ARM specific. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +typedef enum { + COUNT_CLASS, + COUNT_INDIVIDUAL, + COUNT_NONE +} CountType; + +static int limit = 50; +static int stdout_fd; +static bool do_inline; +static bool verbose; + +static GMutex lock; +static GHashTable *insns; + +typedef struct { + const char *class; + const char *opt; + uint32_t mask; + uint32_t pattern; + CountType what; + uint64_t count; +} InsnClassExecCount; + +typedef struct { + char *insn; + uint32_t opcode; + uint64_t count; + InsnClassExecCount *class; +} InsnExecCount; + +/* + * Matchers for classes of instructions, order is important. + * + * Your most precise match must be before looser matches. If no match + * is found in the table we can create an individual entry. + * + * 31..28 27..24 23..20 19..16 15..12 11..8 7..4 3..0 + */ +InsnClassExecCount insn_classes[] = { + /* "Reserved"" */ + { " UDEF", "udef", 0xffff0000, 0x00000000, COUNT_NONE}, + { " SVE", "sve", 0x1e000000, 0x04000000, COUNT_CLASS}, + { "Reserved", "res", 0x1e000000, 0x00000000, COUNT_CLASS}, + /* Data Processing Immediate */ + { " PCrel addr", "pcrel", 0x1f000000, 0x10000000, COUNT_CLASS}, + { " Add/Sub (imm,tags)","asit", 0x1f800000, 0x11800000, COUNT_CLASS}, + { " Add/Sub (imm)", "asi", 0x1f000000, 0x11000000, COUNT_CLASS}, + { " Logical (imm)", "logi", 0x1f800000, 0x12000000, COUNT_CLASS}, + { " Move Wide (imm)", "movwi", 0x1f800000, 0x12800000, COUNT_CLASS}, + { " Bitfield", "bitf", 0x1f800000, 0x13000000, COUNT_CLASS}, + { " Extract", "extr", 0x1f800000, 0x13800000, COUNT_CLASS}, + { "Data Proc Imm", "dpri", 0x1c000000, 0x10000000, COUNT_CLASS}, + /* Branches */ + { " Cond Branch (imm)", "cndb", 0xfe000000, 0x54000000, COUNT_CLASS}, + { " Exception Gen", "excp", 0xff000000, 0xd4000000, COUNT_CLASS}, + { " NOP", "nop", 0xffffffff, 0xd503201f, COUNT_NONE}, + { " Hints", "hint", 0xfffff000, 0xd5032000, COUNT_CLASS}, + { " Barriers", "barr", 0xfffff000, 0xd5033000, COUNT_CLASS}, + { " PSTATE", "psta", 0xfff8f000, 0xd5004000, COUNT_CLASS}, + { " System Insn", "sins", 0xffd80000, 0xd5080000, COUNT_CLASS}, + { " System Reg", "sreg", 0xffd00000, 0xd5100000, COUNT_CLASS}, + { " Branch (reg)", "breg", 0xfe000000, 0xd6000000, COUNT_CLASS}, + { " Branch (imm)", "bimm", 0x7c000000, 0x14000000, COUNT_CLASS}, + { " Cmp & Branch", "cmpb", 0x7e000000, 0x34000000, COUNT_CLASS}, + { " Tst & Branch", "tstb", 0x7e000000, 0x36000000, COUNT_CLASS}, + { "Branches", "branch", 0x1c000000, 0x14000000, COUNT_CLASS}, + /* Loads and Stores */ + { " AdvSimd ldstmult", "advlsm", 0xbfbf0000, 0x0c000000, COUNT_CLASS}, + { " AdvSimd ldstmult++","advlsmp",0xbfb00000, 0x0c800000, COUNT_CLASS}, + { " AdvSimd ldst", "advlss", 0xbf9f0000, 0x0d000000, COUNT_CLASS}, + { " AdvSimd ldst++", "advlssp",0xbf800000, 0x0d800000, COUNT_CLASS}, + { " ldst excl", "ldstx", 0x3f000000, 0x08000000, COUNT_CLASS}, + { " Prefetch", "prfm", 0xff000000, 0xd8000000, COUNT_CLASS}, + { " Load Reg (lit)", "ldlit", 0x1b000000, 0x18000000, COUNT_CLASS}, + { " ldst noalloc pair", "ldstnap",0x3b800000, 0x28000000, COUNT_CLASS}, + { " ldst pair", "ldstp", 0x38000000, 0x28000000, COUNT_CLASS}, + { " ldst reg", "ldstr", 0x3b200000, 0x38000000, COUNT_CLASS}, + { " Atomic ldst", "atomic", 0x3b200c00, 0x38200000, COUNT_CLASS}, + { " ldst reg (reg off)","ldstro", 0x3b200b00, 0x38200800, COUNT_CLASS}, + { " ldst reg (pac)", "ldstpa", 0x3b200200, 0x38200800, COUNT_CLASS}, + { " ldst reg (imm)", "ldsti", 0x3b000000, 0x39000000, COUNT_CLASS}, + { "Loads & Stores", "ldst", 0x0a000000, 0x08000000, COUNT_CLASS}, + /* Data Processing Register */ + { "Data Proc Reg", "dprr", 0x0e000000, 0x0a000000, COUNT_CLASS}, + /* Scalar FP */ + { "Scalar FP ", "fpsimd", 0x0e000000, 0x0e000000, COUNT_CLASS}, + /* Unclassified */ + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_CLASS} +}; + +static gint cmp_exec_count(gconstpointer a, gconstpointer b) +{ + InsnExecCount *ea = (InsnExecCount *) a; + InsnExecCount *eb = (InsnExecCount *) b; + return ea->count > eb->count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("Instruction Classes:\n"); + int i; + GList *counts; + + for (i = 0; i < ARRAY_SIZE(insn_classes); i++) { + switch (insn_classes[i].what) { + case COUNT_CLASS: + if (insn_classes[i].count || verbose) { + g_string_append_printf(report, "Class: %-24s\t(%ld hits)\n", + insn_classes[i].class, + insn_classes[i].count); + } + break; + case COUNT_INDIVIDUAL: + g_string_append_printf(report, "Class: %-24s\tcounted individually\n", + insn_classes[i].class); + break; + case COUNT_NONE: + g_string_append_printf(report, "Class: %-24s\tnot counted\n", + insn_classes[i].class); + break; + default: + break; + } + } + + counts = g_hash_table_get_values(insns); + if (counts && g_list_next(counts)) { + GList *it; + + g_string_append_printf(report,"Individual Instructions:\n"); + + it = g_list_sort(counts, cmp_exec_count); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + InsnExecCount *rec = (InsnExecCount *) it->data; + g_string_append_printf(report, "Instr: %-24s\t(%ld hits)\t(op=%#08x/%s)\n", + rec->insn, + rec->count, + rec->opcode, + rec->class ? + rec->class->class : "un-categorised"); + } + g_list_free(it); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + insns = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + uint64_t *count = (uint64_t *) udata; + (*count)++; +} + +static uint64_t * find_counter(struct qemu_plugin_insn *insn) +{ + int i; + uint64_t *cnt = NULL; + uint32_t opcode; + InsnClassExecCount *class = NULL; + + /* we expect all instructions to by 32 bits for ARM */ + g_assert(qemu_plugin_insn_size(insn) == 4); + opcode = *((uint32_t *)qemu_plugin_insn_data(insn)); + + for (i = 0; !cnt && i < ARRAY_SIZE(insn_classes); i++) { + uint32_t masked_bits = opcode & insn_classes[i].mask; + if (masked_bits == insn_classes[i].pattern) { + class = &insn_classes[i]; + break; + } + } + + g_assert(class); + + switch (class->what) { + case COUNT_NONE: + return NULL; + case COUNT_CLASS: + return &class->count; + case COUNT_INDIVIDUAL: + { + InsnExecCount *icount; + + g_mutex_lock(&lock); + icount = (InsnExecCount *) g_hash_table_lookup(insns, + GUINT_TO_POINTER(opcode)); + + if (!icount) { + icount = g_new0(InsnExecCount, 1); + icount->opcode = opcode; + icount->insn = qemu_plugin_insn_disas(insn); + icount->class = class; + + if (verbose) { + dprintf(stdout_fd, "adding for %s (%#08x @ %#20lx from %s)\n", + icount->insn, opcode, qemu_plugin_insn_vaddr(insn), + class->class); + } + g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), + (gpointer) icount); + } + g_mutex_unlock(&lock); + + return &icount->count; + } + default: + g_assert_not_reached(); + } + + return NULL; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + uint64_t *cnt; + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + cnt = find_counter(insn); + + if (cnt) { + if (do_inline) { + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + } else { + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, cnt); + } + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + int i; + + for (i = 0; i < argc; i++) { + char *p = argv[i]; + if (strcmp(p, "inline") == 0) { + do_inline = true; + } else if (strcmp(p, "verbose") == 0) { + verbose = true; + } else { + int j; + CountType type = COUNT_INDIVIDUAL; + if (*p == '!') { + type = COUNT_NONE; + p++; + } + for (j = 0; j < ARRAY_SIZE(insn_classes); j++) { + if (strcmp(p, insn_classes[j].opt) == 0) { + insn_classes[j].what = type; + break; + } + } + } + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Mon Oct 14 10:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176188 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4388715ill; Mon, 14 Oct 2019 04:35:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxQvZs9sBpXMjY3Sf8Gx7vss1zKP8u29dbidWmNxmge1VjA+y4MMR32MHuHgKnnj5groio X-Received: by 2002:ae9:eb11:: with SMTP id b17mr29341297qkg.25.1571052937178; Mon, 14 Oct 2019 04:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052937; cv=none; d=google.com; s=arc-20160816; b=HJkdYUd2bLUgD2MbrhvGwjmlZCNTBQNoHghYK4JHl4lYxBlLwtUce0HrHODSdCfTpb ZZYTgIKLV9EiqH3ocH2NgouOPRguPJnjBKvCQjEQQtI1SM+pxwxN5mF00eGWo3e1xoXr X6uATyuIvpUErMMuhWw9+0wlsCRU+A95ep5jpqft5E5zkOkG5kJKiz+RZAwEQY9zzLw9 JMtbhvNFCaKhtI/mE0H8HH2h/S74sPQ8m1B9U5h/+XUErRdaQ83TQ4D9nm6sC8m8DPy4 1TuH6boC7gHvEQbbnu4tWVFn3r9Ovo45+JxiiYljRBZyLnBPxtw4+Q89nmALQyCshexF +UNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ye+x/1nnHia5cN2gZpTEgLE2DtA5hK08gljlzreXCM8=; b=tWiuo0KBNxVxTm/fU+aZ1fpTzpPxQI10pLt4fJdzwnEVi/FsMTbk7p73MV1vFnvcPZ pCxgenos4KM8VX0QTmWY+ot2UWxXY9e7q2KEuxECGGyVMrAj5H1kNT91dQzMD7jmai77 lNxhIm2najkgxcGDXD3YmQ/ONYPbVTrOkXJ4hUuoBcTQ6t1z/9QT7gA2bQwgEl1EKsZZ 5uLAZY/DxK7vu1M4IhI0QJsKpKbh7WW3Lvn21M0IuWlRozIpSmsQbDZb5MMgvpiEGPXQ cVlYz/HTU53LDIyyQZv1SGDW4Y21KqO0eB0E2p0QU13iGYkC8Dlo7tiPF6JVxfqzbHav oJHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lns6ajTc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j91si18825232qtd.248.2019.10.14.04.35.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:35:37 -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=fail header.i=@linaro.org header.s=google header.b=Lns6ajTc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJydU-0006jQ-GV for patch@linaro.org; Mon, 14 Oct 2019 07:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy2E-0006n1-Rb for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy2D-0005FB-EU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:06 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43070) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy2C-0005DK-SV for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:05 -0400 Received: by mail-wr1-x441.google.com with SMTP id j18so19147263wrq.10 for ; Mon, 14 Oct 2019 03:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ye+x/1nnHia5cN2gZpTEgLE2DtA5hK08gljlzreXCM8=; b=Lns6ajTccNlQWQJkH+x1Ht04T+FIXEVgxdMYSH7Wbuc8WU56z/9PAWkFtK3Pto6FDv YYmiPeIZ5Z5qv9/P6bAiBpzT2YEf1jAYSLRu7PL/0B2mt3DoJhc0Yu6mcV74QdERKQF5 Y91EHWMnLv6AKRtbUIsQuy8lbSaovC//fdq9D0VBQGUAvjxqo7eyxA/Okq/QxuH9McPD 0KerWVd7JKmCzsX2XmfW5bHtLrKPJNTomxzMBjcEvOMF8pBE5braLPdI0KJU0LDEu/pr +fGbmog8T8XS58Wcq1Q4amABYazSBNQRm7OEKSdb6GB/ss9TakdvOFgJuambHy64W3SE 7X8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ye+x/1nnHia5cN2gZpTEgLE2DtA5hK08gljlzreXCM8=; b=Hbo/LZkZZ5EpaygYAim2ZWpeJeJKgV5OqzTkx3dpzjXsovMuEeF+cZKWrL7iCp90fx japHUaIs2gGOQh36l02ne3jhJtRSuOA0Rv4uYk4egTtHTnryOPab2VWUn0o0+9+l9UnD +EzudjnUWQOBeYHzsbqkdkEZ+HC9CYrCs+355/owspmn808VgFMDnfs8b8FyIIMxMJyM PthZZsYUjvAfv3QmSmb6yQ2mFL/aAupNu8HMNRd1yHRAmum04OkQN/kFZBz/8qyuNOOR oucUXgkE+D3AqYJ99+TQb+zSavMx0vpZwtXr9Fep91hQcCc7K3gzJe9QLYvEhpPEZ79c SIlw== X-Gm-Message-State: APjAAAXaJpuVNxtbI8PdP2M+/QWBXEKD9JsZKVic/om2TbtnvAxNgKOX 4JPLNJ7mzLafebfD4Dx8i6SbjzaiCL0= X-Received: by 2002:a5d:43c1:: with SMTP id v1mr25996208wrr.91.1571050623389; Mon, 14 Oct 2019 03:57:03 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c21sm13133247wmb.46.2019.10.14.03.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:57:01 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B7E301FFD3; Mon, 14 Oct 2019 11:49:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 48/55] tests/plugin: add hotpages plugin to breakdown memory access patterns Date: Mon, 14 Oct 2019 11:49:41 +0100 Message-Id: <20191014104948.4291-49-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This plugin gives a break down of access patterns grouped into pages. Signed-off-by: Alex Bennée --- v4 - tweaks for new hwaddr api - add sorting and pagesize selection args --- tests/plugin/Makefile | 1 + tests/plugin/hotpages.c | 179 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 tests/plugin/hotpages.c -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index 3656429d46..75467b6db8 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -12,6 +12,7 @@ NAMES += insn NAMES += mem NAMES += hotblocks NAMES += howvec +NAMES += hotpages SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) diff --git a/tests/plugin/hotpages.c b/tests/plugin/hotpages.c new file mode 100644 index 0000000000..13ce8ffeb8 --- /dev/null +++ b/tests/plugin/hotpages.c @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2019, Alex Bennée + * + * Hot Pages - show which pages saw the most memory accesses. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +static uint64_t page_size = 4096; +static uint64_t page_mask; +static int stdout_fd; +static int limit = 50; +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; + +enum sort_type { + SORT_RW = 0, + SORT_R, + SORT_W +}; + +static int sort_by = SORT_RW; + +typedef struct { + uint64_t page_address; + int cpu_read; + int cpu_write; + uint64_t reads; + uint64_t writes; +} PageCounters; + +static GMutex lock; +static GHashTable *pages; + +static gint cmp_access_count(gconstpointer a, gconstpointer b) +{ + PageCounters *ea = (PageCounters *) a; + PageCounters *eb = (PageCounters *) b; + int r; + switch (sort_by) { + case SORT_RW: + r = (ea->reads + ea->writes) > (eb->reads + eb->writes) ? -1 : 1; + break; + case SORT_R: + r = ea->reads > eb->reads ? -1 : 1; + break; + case SORT_W: + r = ea->writes > eb->writes ? -1 : 1; + break; + default: + g_assert_not_reached(); + } + return r; +} + + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("Addr, RCPUs, Reads, WCPUs, Writes\n"); + int i; + GList *counts; + + counts = g_hash_table_get_values(pages); + if (counts && g_list_next(counts)) { + GList *it; + + it = g_list_sort(counts, cmp_access_count); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + PageCounters *rec = (PageCounters *) it->data; + g_string_append_printf(report, + "%#016"PRIx64", 0x%04x, %"PRId64 + ", 0x%04x, %"PRId64"\n", + rec->page_address, + rec->cpu_read, rec->reads, + rec->cpu_write, rec->writes); + } + g_list_free(it); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + page_mask = (page_size - 1); + pages = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + struct qemu_plugin_hwaddr *hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr); + uint64_t page; + PageCounters *count; + + /* We only get a hwaddr for system emulation */ + if (hwaddr) { + page = (uint64_t) qemu_plugin_hwaddr_to_raddr(hwaddr); + } else { + page = vaddr; + } + page &= ~page_mask; + + g_mutex_lock(&lock); + count = (PageCounters *) g_hash_table_lookup(pages, GUINT_TO_POINTER(page)); + + if (!count) { + count = g_new0(PageCounters, 1); + count->page_address = page; + g_hash_table_insert(pages, GUINT_TO_POINTER(page), (gpointer) count); + } + if (qemu_plugin_mem_is_store(meminfo)) { + count->writes++; + count->cpu_write |= (1 << cpu_index); + } else { + count->reads++; + count->cpu_read |= (1 << cpu_index); + } + + g_mutex_unlock(&lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + int i; + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + for (i = 0; i < argc; i++) { + char *opt = argv[i]; + if (g_strcmp0(opt, "reads") == 0) { + sort_by = SORT_R; + } else if (g_strcmp0(opt, "writes") == 0) { + sort_by = SORT_W; + } else if (g_str_has_prefix(opt, "pagesize=")) { + page_size = g_ascii_strtoull(opt + 9, NULL, 10); + } else { + dprintf(stdout_fd, "option parsing failed: %s\n", opt); + return -1; + } + } + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Mon Oct 14 10:49:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176172 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4371943ill; Mon, 14 Oct 2019 04:19:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyW4uyhJaTwUlcnG8YUPSvU0cMi/xCISEUXpkRyDHZ/kB5uOn+1E3O/wKKre8RjvSAC0PuD X-Received: by 2002:a17:906:1690:: with SMTP id s16mr28081254ejd.294.1571051997879; Mon, 14 Oct 2019 04:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051997; cv=none; d=google.com; s=arc-20160816; b=pv61xvbbazQ+wB9p8/W+eX9AgmS2e7j4LzM8Y0Vkvxq6hBPQDrZUYVYwaLkjCe6G7x Dtx4jOn/suuLDslAHtgVrvAxfbdov0D9eAbQPmjhurd9HYTjg1xOYLWNBwLgn0D9dldv ySqpIeaDKBhiGHxjjvJQ60Bu+mR9xnOeJrMFKgEb6YQetzd1V7vlDrBxNswxZer2j5B6 F0NMVgibYP5YcflfZtvG1vEpHbOW/HB+St2RKz/pBVAJd/FxeVjLsLcmtJ7I7Zv/TfUI hQ4NT5eQv6rOH4ca2KTLjeonHvlmI3qmxlH9QaGOWvbAw+l8VVmlLLEdjpNmKXDfo/RQ KpfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=AQnBIoxWJcGF7VxKdA+3Fs3YaFpJDSvvaPPi8ZLzb54=; b=vtD1TCS54YVrD7fI6tEpBTZgviwR186CmbvNII9Apvwl3K2ph7s/y0EM1FBfMddxzP ShUmI/oAh4sdzC1b08pdCHfbFpZ2SZlxaK1dS456slyA0OLwp1BDBGOHCT4RXd2RFLJW GAr+xTf86tXrYW6sBYHnfwa9lTq0aK5gIOKg6Hi8AV2GTU6F4lOug2N5LEK3L/ZqK4f4 l+fpnizHE3y8oiTYN7jnJH72/aIfmVAw47+4JbpbvTV9ZxYuw99X0KEtba8HNoiCptMl ITgosO1fm2yH3cTut2FRVo5C1yxcUlRZxnVSEI6EydSQ67EegF9vltgKT8O/n+i9olqZ D66A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TlF03HDF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g29si12164774edb.13.2019.10.14.04.19.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:19:57 -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=fail header.i=@linaro.org header.s=google header.b=TlF03HDF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyOK-000465-Mr for patch@linaro.org; Mon, 14 Oct 2019 07:19:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44751) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvW-0007as-JJ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvV-0006L0-GU for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:10 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvV-0006Jg-A6 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: by mail-wr1-x441.google.com with SMTP id v8so19151684wrt.2 for ; Mon, 14 Oct 2019 03:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AQnBIoxWJcGF7VxKdA+3Fs3YaFpJDSvvaPPi8ZLzb54=; b=TlF03HDFOj2n6QqbryaZSM7qOLJY8m/vg6xIzE2uNwk0xaUG/i78iswMP8JLNXSIWz b6QyK/OtmBGTFDM7UppTa0KBsnf+S9kJSus5cufQyI2Q0lmow/3ZgskgBTb1Y4rg4bQx sv+u4FL8gxfw1/Z6N8WwDy8hT8bms0W0RgX9EX50W/0DX10+stiRFYeIBhFHUPwoSLSM XkLuUIOW5lkE98XoUkal37Kt3Bs6IQNS0q2pQBnSqT4OdFvjcspFnlFKCTw2g+T1H5Sx MiOh5C16C0Y76BNDt15gNM+K6JwkX/MviBNLl5jf+JmodFXtpkMqknbvbgRTR5oMuOVa 4FYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AQnBIoxWJcGF7VxKdA+3Fs3YaFpJDSvvaPPi8ZLzb54=; b=p5if6eiRJYbZDxUqf9OXrUlYQb31eleF+FInZd3skEUt5e05/QbYevTm6EjsqrGeE7 SQ2L0HsglfCyR1/crcJ1/Aa4Zh6Nf1oNbZ0ytsy8l2GKq0AEWkgr/pmwMZoECGhbesgW vH75J0MP4abRxow1xhAK4G0Lli4vML6uUcSLIkvKrIcaPw/kj8ww2XZp6C4pchDF4jv7 nFVnDCinPQXOCw+7zcjBwYUM+K1KdNbwRNLE7MQi9mhfOCVSMXVScX3MWNf0zY6NYWfX LG7b0gs9XsMvaoZG//OTuJDEWP7uYnmgYuMPD6VQiZ153R41HqEpyOBMc5Ubspf+tBSW 1Twg== X-Gm-Message-State: APjAAAWnu7m2tMfeC5FGHfsf5lcPaDoTlS3rXBda6wufiCmxIeT6QEkv P1ixEkuMcpPLesD3c0Lc1v7gsw== X-Received: by 2002:a5d:5228:: with SMTP id i8mr19531464wra.191.1571050208199; Mon, 14 Oct 2019 03:50:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s1sm25625137wrg.80.2019.10.14.03.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E66B41FFD4; Mon, 14 Oct 2019 11:49:59 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 49/55] accel/stubs: reduce headers from tcg-stub Date: Mon, 14 Oct 2019 11:49:42 +0100 Message-Id: <20191014104948.4291-50-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We don't need much for these. However I do wonder why these aren't just null inlines in exec-all.h Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/stubs/tcg-stub.c | 1 - 1 file changed, 1 deletion(-) -- 2.20.1 diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index e2d23edafe..677191a69c 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -11,7 +11,6 @@ */ #include "qemu/osdep.h" -#include "qemu-common.h" #include "cpu.h" #include "tcg/tcg.h" #include "exec/exec-all.h" From patchwork Mon Oct 14 10:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176163 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4361779ill; Mon, 14 Oct 2019 04:11:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1Fm0A7nnd7VlOP+4XSaXf5wmJew5DxC/5fq0OzYPsJmGulwuYcVQNU8U8qILIx8DX9BcB X-Received: by 2002:ac8:363c:: with SMTP id m57mr31768417qtb.290.1571051480391; Mon, 14 Oct 2019 04:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051480; cv=none; d=google.com; s=arc-20160816; b=iFdyuub4GflGzckbdCc8qAlf6xYLkRm6ev1phNacJ5R+4tnsZw67er28oyJ7tZUziQ 8pEzLat3LzlXfIJ+pdDbYy6GnqZjVxlBA11qQ2CkZibbChRZ3CEfbZpJvPJar5aU/Fsh iVkFtuN6QqaZueO43XzfJAKnhj8LZrPVpUs8p2EiJbu/uCxpXmhoLc+YZnE3Uc/pDfC5 ajkfrlBuy0wjbiPL1GVjCbWs+IHD9lPQEvCXVUqQaZrj9FS2Yz4X/LnvrEVNe36PetnS PC4P+cv7TgJzpf+vUkl9cMWDhSnTApy+K/kPGidQhYeH0ULhe4tRxBeTWfQ+bmhyUOVE MIUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bN4XmGTG9/FatEh/7FtZa/B9CvFqCRZ6R/2X2ZutnFU=; b=uhrcF05D0jaZQU8ZLlqO+HIV8eRw88peP9w8xK/d8xwrNQnD/y13FAqxG/JWxPWPUr 0dtgejA1KZkhIxBZIUpV3bNSu9m/pmRtaNHhhzGocZ/EPmP+kqWZ8+e9QMVnhEcD4OYo QSo8DzId9BtEl+nS8cEgQQ+zmLs+GZ0o9itqRD4YWZHZ9suM67FOqzildSChdFzOKfGM MNrEfJrqKj/lctEsMGbM+OpZUAmjQDUE1y1p92pv6VRiMrKHC4+wtqPAVigyrVx3SrFD 3udMxk2vm88H95LGGfRJz8DG5bl9i8ybzLtj84dTadCgxdJj+MxpcdfcyQE9p+F+5HQA p+0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bjm7HNau; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v37si17226927qvc.178.2019.10.14.04.11.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bjm7HNau; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyFz-00044d-Bx for patch@linaro.org; Mon, 14 Oct 2019 07:11:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44694) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvU-0007XH-MH for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvT-0006Hm-E5 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:08 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:50315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvT-0006GK-7v for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:07 -0400 Received: by mail-wm1-x343.google.com with SMTP id 5so16761805wmg.0 for ; Mon, 14 Oct 2019 03:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bN4XmGTG9/FatEh/7FtZa/B9CvFqCRZ6R/2X2ZutnFU=; b=bjm7HNaujfIiQwunUt3Oir/dBUL78Uo1Fh7DuPuLOMBoUNax9PKvxw0PU/STqGvvaI gjct/iBy2Z8XQ63InA2K+iYUOk4jiVf46oC4mxEDgP7u4vnp89GJ4VrIyqWaLVwgSVk5 UOvXb6gRJfQPAU/H9a9RHsCsDenU0jA2kSqCDbvycij+ek/PMYgaIFk+ebkI6diLe6xL 9aOighsAaFOBGWtnWPjPGMTs4+T/xVBGCeajQVIvg+xDpavrSe/B23gMMumjAmr1LzgZ AetesW3SU3XbUSgwNSZLo2BPScPx7CIuuyYYLQm6HBZLTGIwzqTy4vwsxeYmEIYhIhag oD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bN4XmGTG9/FatEh/7FtZa/B9CvFqCRZ6R/2X2ZutnFU=; b=eA+k5U3m51UfonygSCHeRQ49IdCqhnjnom4AlvUfkKhtzTCUTn5yR26NBOUPDbw5ow Tbailo0kzEp7NcX0Jv9fzh/RzCi65Ry8blMhNq/k9C0tEtVczUaXUG/y8oE2WCde3d7a BjEoeDqmmU5Lc4n66Rrnn0FEOrFITlq+KU9Chd+CzgPOX7IiSbwx01DqtQXcq3cQbDE9 lhUS5Hhf2QCjQ/LXencIs5QGM4Y8frG8NclyBuEAPSRjf9ofq0wV5e776tDCq0NjRNyH pAZzHlx7fkgCcDMaoAHahePMEUBFAAE8xwKw4V9oHNhRqeoyNhETxujHJUqrGc9OPzLf CeSg== X-Gm-Message-State: APjAAAVw+/pdHzLgmTVTSrrVwOGhiIUvuCcMZZS5hXAs/qI9xTrkp97P 2BZVP6kLDKq2PbS4jrqDNORJnSFGP/o= X-Received: by 2002:a1c:5f09:: with SMTP id t9mr15395842wmb.124.1571050206167; Mon, 14 Oct 2019 03:50:06 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b7sm19111097wrx.56.2019.10.14.03.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1BCA91FFD6; Mon, 14 Oct 2019 11:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 50/55] include/exec: wrap cpu_ldst.h in CONFIG_TCG Date: Mon, 14 Oct 2019 11:49:43 +0100 Message-Id: <20191014104948.4291-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This gets around a build problem with --disable-tcg. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/exec-all.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 47a071fee0..e74cf980e9 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -22,7 +22,9 @@ #include "cpu.h" #include "exec/tb-context.h" +#ifdef CONFIG_TCG #include "exec/cpu_ldst.h" +#endif #include "sysemu/cpus.h" /* allow to see translation results - the slowdown should be negligible, so we leave it */ From patchwork Mon Oct 14 10:49:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176197 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4397083ill; Mon, 14 Oct 2019 04:43:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXkhzM9JAHypdxM6XlkIH96mX4xq3xrfACU9luAfFQLmJl8hiHHgQAl/bW8qHAMDv0+sJP X-Received: by 2002:a17:906:80cd:: with SMTP id a13mr28527924ejx.12.1571053435689; Mon, 14 Oct 2019 04:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053435; cv=none; d=google.com; s=arc-20160816; b=SqoWr86DYVuegSadfJdICKHOE1eG/BvDRG3wx0Kw0t8Vza0hfih/RgRRx65WGZKnc5 gkIY+pKla6OSec+h03cV9TPZ6woC7PuE9caNtA2DA/6+kL9nDcy2mz2aN7bvOYYm02dY /KmNI5CgyA8ggGxyZJ9RCXkLPmQOks8MLnHcJltWqb+DyEQlmhcA1Ro2UdxpFUXIMWui jlzijT4avzUd9tOpTHB5rgc+YOO79Rrb97Xa5x6p75npmaEUXn9l3inL6B7V4y76oBwO 0FKwLpH6OdSVAspXFtSophe9pfYHBheC30a+Dzh+dTlDe231h1H5y36aBmTH1W2grRsU xwvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3DpqzaOrNntDkFAtLNgfVGSPKEwLzzpzG6mkI3f5/AE=; b=ZqsLhefj6MtRXcBCgLM/UDn3TcKJ1o0/XqLCeIStSsqSNB6F8BrX+6Z7XlPA2WIygj VLaGmdJE3dDif3k0Az59vQv4Rq+ye9IDT+G0GTLol8j3meBRaIP/LJTy7iGsn476KCvO Ygfa3mfYZ7cn16raXNT36+FxIcEPAWr4Q04u3k3nJqfnQXFPpSavBOS5Kzc28rC5TnZY o+WuNROjswOMZbusHRELnqj/lnI0l9VXmMnLiAYMfVOBS3DVtK0VeeLzr7RmUOLW7QNI UbbXW4GuMOqzZvEevMVrkDCXY1Cnd4QVKYaZmmB4yNPXZgSPxA9IJL3GFRYXInyE3wMt 8w6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ImaDVd7L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a3si13795769edc.75.2019.10.14.04.43.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:43:55 -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=fail header.i=@linaro.org header.s=google header.b=ImaDVd7L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJylW-0008N6-CD for patch@linaro.org; Mon, 14 Oct 2019 07:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46830) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyC8-00081p-WB for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC7-0007eJ-0w for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:20 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC6-0007dM-Q4 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:18 -0400 Received: by mail-wr1-x441.google.com with SMTP id v8so19217095wrt.2 for ; Mon, 14 Oct 2019 04:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3DpqzaOrNntDkFAtLNgfVGSPKEwLzzpzG6mkI3f5/AE=; b=ImaDVd7LxXydpl7pcYiPgZ1vdyAVAgbO8Q7HnjywLiP1LCYREfdymKJKMBmr9msY+c sRDEuYHTtX18uefWeBvbQuD69iy9bP15FsASA+XryJLC6jkj1J6FYr5HVNOytqTcMzkQ 5viDbwswTo2RbXye7hWN/Xuz95LEOfkETPAri+iSoxW9JNkt021K3C6uVWgHzqqUBjRu ySkxJXtU2CbGa4AjV74Jt+KRSRdicnT+1Rpxz8J42j87clXXX2ilDPgy0aWz2L81WjTv +9rxZmBX1BmgMIAm4dRAaIqi63dM3oPA/6D876ELkiH8p05Vp3/mvAWVVN/bWkAR9awR WAeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3DpqzaOrNntDkFAtLNgfVGSPKEwLzzpzG6mkI3f5/AE=; b=G9ZjyZDL1NPtVeGhveG4fGKgFvFUZvFPJg+iyOYIfyFu4oPimfY9Ug7gXBhDa7dFoV Fj6n88nSbS/Ge9QmgOdTlnTBu3lfsJH5qkTDmBagNTjQoan6dZCoZgjzxW19QkT5zoy2 i0/NiOuVwCaTl2b6eV5iAd5mYETibdYCZVYZnM6OiFbDln4KWHCMtC5bIZrTMF2zVAZV OXO9JxcCraCRtVyEZGBIz4WBzXgBi1miDkE3f5AZrAQTQ8QVCOE/SK6+NVNeunJfavEZ R1mfIgU0DDbSM/gSkO6UWG7vcyXJM4urlpbXMOYxcVsghzX9rWkGwy/eq2b9i+vXM0c9 KflQ== X-Gm-Message-State: APjAAAVxuLsWwo6YD8J+4hb5ahaBYoHru+w1R7NK60nMxOdJE8Okhw22 wuQW0z3ocrAIgGfpNVswXHt3+g== X-Received: by 2002:adf:ba12:: with SMTP id o18mr15204429wrg.147.1571051237648; Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h63sm31448934wmf.15.2019.10.14.04.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 741E51FFAC; Mon, 14 Oct 2019 11:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 51/55] plugins: expand the plugin_init function to include an info block Date: Mon, 14 Oct 2019 11:49:44 +0100 Message-Id: <20191014104948.4291-52-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This provides a limited amount of info to plugins about the guest system that will allow them to make some additional decisions on setup. Signed-off-by: Alex Bennée --- include/qemu/qemu-plugin.h | 26 ++++++++++++++++++++++++-- plugins/loader.c | 22 ++++++++++++++++++---- tests/plugin/bb.c | 5 +++-- tests/plugin/empty.c | 5 +++-- tests/plugin/hotblocks.c | 5 +++-- tests/plugin/hotpages.c | 5 +++-- tests/plugin/howvec.c | 5 +++-- tests/plugin/insn.c | 5 +++-- tests/plugin/mem.c | 5 +++-- 9 files changed, 63 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 8b403dd615..719d7054a1 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -38,9 +38,27 @@ typedef uint64_t qemu_plugin_id_t; +typedef struct { + /* string describing architecture */ + const char *target_name; + /* is this a full system emulation? */ + bool system_emulation; + union { + /* + * smp_vcpus may change if vCPUs can be hot-plugged, max_vcpus + * is the system-wide limit. + */ + struct { + int smp_vcpus; + int max_vcpus; + } system; + }; +} qemu_info_t; + /** * qemu_plugin_install() - Install a plugin * @id: this plugin's opaque ID + * @info: a block describing some details about the guest * @argc: number of arguments * @argv: array of arguments (@argc elements) * @@ -49,10 +67,14 @@ typedef uint64_t qemu_plugin_id_t; * Note: Calling qemu_plugin_uninstall() from this function is a bug. To raise * an error during install, return !0. * + * Note: @info is only live during the call. Copy any information we + * want to keep. + * * Note: @argv remains valid throughout the lifetime of the loaded plugin. */ -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv); +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv); /* * Prototypes for the various callback styles we will be registering diff --git a/plugins/loader.c b/plugins/loader.c index 5de5cff8e3..a136a71d35 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -29,6 +29,9 @@ #include "hw/core/cpu.h" #include "cpu.h" #include "exec/exec-all.h" +#ifndef CONFIG_USER_ONLY +#include "hw/boards.h" +#endif #include "plugin.h" @@ -60,7 +63,7 @@ QemuOptsList qemu_plugin_opts = { }, }; -typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **); +typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, const qemu_info_t *, int, char **); extern struct qemu_plugin_state plugin; @@ -147,7 +150,7 @@ static uint64_t xorshift64star(uint64_t x) return x * UINT64_C(2685821657736338717); } -static int plugin_load(struct qemu_plugin_desc *desc) +static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info) { qemu_plugin_install_func_t install; struct qemu_plugin_ctx *ctx; @@ -198,7 +201,7 @@ static int plugin_load(struct qemu_plugin_desc *desc) } QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); ctx->installing = true; - rc = install(ctx->id, desc->argc, desc->argv); + rc = install(ctx->id, info, desc->argc, desc->argv); ctx->installing = false; if (rc) { error_report("%s: qemu_plugin_install returned error code %d", @@ -249,11 +252,22 @@ static void plugin_desc_free(struct qemu_plugin_desc *desc) int qemu_plugin_load_list(QemuPluginList *head) { struct qemu_plugin_desc *desc, *next; + g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1); + + info->target_name = TARGET_NAME; +#ifndef CONFIG_USER_ONLY + MachineState * ms = MACHINE(qdev_get_machine()); + info->system_emulation = true; + info->system.smp_vcpus = ms->smp.cpus; + info->system.max_vcpus = ms->smp.max_cpus; +#else + info->system_emulation = false; +#endif QTAILQ_FOREACH_SAFE(desc, head, entry, next) { int err; - err = plugin_load(desc); + err = plugin_load(desc, info); if (err) { return err; } diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index 93d25de363..4a6d6ca0bc 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -48,8 +48,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) { if (argc && strcmp(argv[0], "inline") == 0) { do_inline = true; diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c index b141ddd0df..3f60f69027 100644 --- a/tests/plugin/empty.c +++ b/tests/plugin/empty.c @@ -21,8 +21,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) { qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); return 0; diff --git a/tests/plugin/hotblocks.c b/tests/plugin/hotblocks.c index a150179a5c..57bea765b3 100644 --- a/tests/plugin/hotblocks.c +++ b/tests/plugin/hotblocks.c @@ -129,8 +129,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) { if (argc && strcmp(argv[0], "inline") == 0) { do_inline = true; diff --git a/tests/plugin/hotpages.c b/tests/plugin/hotpages.c index 13ce8ffeb8..99bb4be07c 100644 --- a/tests/plugin/hotpages.c +++ b/tests/plugin/hotpages.c @@ -148,8 +148,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) { int i; diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c index b435c6b64d..3b1d177ef3 100644 --- a/tests/plugin/howvec.c +++ b/tests/plugin/howvec.c @@ -264,8 +264,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) { int i; diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 3000ab4b73..9cfa7d0e53 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -45,8 +45,9 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count); } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) { if (argc && !strcmp(argv[0], "inline")) { do_inline = true; diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index e5490f4a99..fdf4347c5e 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -64,8 +64,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } } -QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, - char **argv) +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) { if (argc) { if (argc >= 3) { From patchwork Mon Oct 14 10:49:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176168 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4366287ill; Mon, 14 Oct 2019 04:15:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhmGPy90Ad7bNsLhiOZyDizuKx26Pb8Aby8x4Zr5MrHZzjM3z2DlJRWiABMlJ1dxBV0OLu X-Received: by 2002:ad4:5345:: with SMTP id v5mr30432786qvs.217.1571051711004; Mon, 14 Oct 2019 04:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051711; cv=none; d=google.com; s=arc-20160816; b=vEtdWw9tGNegiut7P48VuUHsMHuvZC27jnfYzhUdAZJA9ifQI80IP2OI5ukpA6u4rH v2lk6S3gmcCypIW7dZV7rHT7p45TZH7G9MIDic5brT2SHyZYBLXbttjweniLs5Z1Z0nB HQiLOncHVH7ihJYN69S2GhOWAmLC/418ZcUFuELnDTkUvtsE1JOxfoZ8XylUL7Va9xGN YlMkJhchHD2NEQadKjkr59ydK6/y+HTu8OBYSB/+eg2uUy2j32fWmLNtL66My52bOuLd ihPg0vh5bYJYO0pewr6cFNuDh4ltYgGW76plgc3ThKFt+iT3O5RxY0KUuw7r2pECrnYg MLHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QSezH/dLGIYf9I3MKQlHUWilPU0vUTftD3XFAejcu6Q=; b=xB0ycunV5EsnD1iD49v19vFG51lh2vsreTOKwLudHXHPgFRr8zL7SBniQVan20Mfz4 3tRAPal7zZWX7KQwob/oKsf4wKvLrFl07d8nHaOPo4hB9oytjcc7rSm00/CyUNgTQ06W E+cEqFae4l3bPiYv+uy3EV84XglIVDQQLASNDxNfV0nXlRhN5gqwhmws3InEClsbvZHj jMHe8Hwj9j0YskoJoeTTqKWgjNuVKNHgqiGD5WiRFJ9YPoqN1MLGjzphXJo72CHNMJDP 655bYNFIhoFjBIMJXsbmqDpx1grsMZnrXIYYJQZiFJSPdhmkcTWrDnXZ+vg43jPCllIE GPcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ZuCqw/To"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t58si16912152qta.337.2019.10.14.04.15.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:15: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=fail header.i=@linaro.org header.s=google header.b="ZuCqw/To"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyJh-00073U-Th for patch@linaro.org; Mon, 14 Oct 2019 07:15:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45424) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy28-0006YI-1i for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy26-00055Z-Jo for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:59 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy25-000533-SR for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:58 -0400 Received: by mail-wm1-x341.google.com with SMTP id i16so16758710wmd.3 for ; Mon, 14 Oct 2019 03:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QSezH/dLGIYf9I3MKQlHUWilPU0vUTftD3XFAejcu6Q=; b=ZuCqw/ToHQqiBrH2Jr7laqx6Z1ZC/NWGvgaMXrNrFR+oKqrshk8S89iseJkzXH85kc oKvIwC+P7HJsGlxCuPMED6wKHkjei3PpkOQEH42y3zgNTX/TYkc3o8+Mohdk7ga0Fshk e27Qq4od8WI2ig8ZDjcERiF64/2a/mjiGmsXF2nxkObvg1mz4uOB2usrhjP4O9ixiGYM /KwJ5MaIEJHZIylo/owwyTlds8tMsm+2G5nrX/vlgfFEzKYAnqyWmVFGFJnaQSz8MbUG B6rYXy3OoLEsqrsuoEKOCCtZAj8kIAgspvKx2J/cfVQ6XdFM07apLvpjPbbDr++VAOOe SzlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QSezH/dLGIYf9I3MKQlHUWilPU0vUTftD3XFAejcu6Q=; b=qpS0HHcyS3cCsVhjo4fBqg8sJbMs3czQIHvYVAPN2DX55aba8/+SkCxilxisz3S1ty NUZbhGeCqsl2ByuZwXtdw/PjHXRuufLYPzjzS7w/M7BfisvFFqTawUDf2KwhZqS99PIj M/mZ3pt9wTdVGe89U8Yu8swrVpGINmH6wJY0sW40m5OLD/eLNWfWpJPS2dlZqhbebWPo Z61WV7le0fKj+29NgDIISGdEU78RvT2sIwmgr9/BFS/XiZIIEHT7ofoMmBQG/W8KlKPd 4Rnx0ViFlGg8ZUKXxGcKRO17DPrODN1AI9aBlliXMvr47qU8veey60aBT2W3P8F/NZ+p ON1Q== X-Gm-Message-State: APjAAAVParRPRxYfepc/nbiDiK42ZkDRur+/immRzUJzhTFCqaGtFamJ 92ojJksJtQUYL5OrPPHT/IrbGA== X-Received: by 2002:a7b:c387:: with SMTP id s7mr13605669wmj.22.1571050615867; Mon, 14 Oct 2019 03:56:55 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r12sm19450722wrq.88.2019.10.14.03.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 99C661FFD8; Mon, 14 Oct 2019 11:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 52/55] plugins: make howvec plugin more generic Date: Mon, 14 Oct 2019 11:49:45 +0100 Message-Id: <20191014104948.4291-53-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now the plugins interface indicates what guest architecture we are running we can attempt to select the instruction classification based on it. For now we still only classify aarch64 instructions and fall back to decoding individual instructions. We also wave our hands about irregular instruction encoding. Signed-off-by: Alex Bennée --- tests/plugin/howvec.c | 76 +++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c index 3b1d177ef3..5f7c740833 100644 --- a/tests/plugin/howvec.c +++ b/tests/plugin/howvec.c @@ -4,8 +4,7 @@ * How vectorised is this code? * * Attempt to measure the amount of vectorisation that has been done - * on some code by counting classes of instruction. This is very much - * ARM specific. + * on some code by counting classes of instruction. * * License: GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -61,7 +60,7 @@ typedef struct { * * 31..28 27..24 23..20 19..16 15..12 11..8 7..4 3..0 */ -InsnClassExecCount insn_classes[] = { +InsnClassExecCount aarch64_insn_classes[] = { /* "Reserved"" */ { " UDEF", "udef", 0xffff0000, 0x00000000, COUNT_NONE}, { " SVE", "sve", 0x1e000000, 0x04000000, COUNT_CLASS}, @@ -110,9 +109,29 @@ InsnClassExecCount insn_classes[] = { /* Scalar FP */ { "Scalar FP ", "fpsimd", 0x0e000000, 0x0e000000, COUNT_CLASS}, /* Unclassified */ - { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_CLASS} + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_CLASS}, }; +/* Default matcher for currently unclassified architectures */ +InsnClassExecCount default_insn_classes[] = { + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_INDIVIDUAL}, +}; + +typedef struct { + const char *qemu_target; + InsnClassExecCount *table; + int table_sz; +} ClassSelector; + +ClassSelector class_tables[] = +{ + { "aarch64", aarch64_insn_classes, ARRAY_SIZE(aarch64_insn_classes) }, + { NULL, default_insn_classes, ARRAY_SIZE(default_insn_classes) }, +}; + +static InsnClassExecCount *class_table; +static int class_table_sz; + static gint cmp_exec_count(gconstpointer a, gconstpointer b) { InsnExecCount *ea = (InsnExecCount *) a; @@ -125,23 +144,25 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) GString *report = g_string_new("Instruction Classes:\n"); int i; GList *counts; + InsnClassExecCount *class = NULL; - for (i = 0; i < ARRAY_SIZE(insn_classes); i++) { - switch (insn_classes[i].what) { + for (i = 0; i < class_table_sz; i++) { + class = &class_table[i]; + switch (class->what) { case COUNT_CLASS: - if (insn_classes[i].count || verbose) { + if (class->count || verbose) { g_string_append_printf(report, "Class: %-24s\t(%ld hits)\n", - insn_classes[i].class, - insn_classes[i].count); + class->class, + class->count); } break; case COUNT_INDIVIDUAL: g_string_append_printf(report, "Class: %-24s\tcounted individually\n", - insn_classes[i].class); + class->class); break; case COUNT_NONE: g_string_append_printf(report, "Class: %-24s\tnot counted\n", - insn_classes[i].class); + class->class); break; default: break; @@ -190,14 +211,18 @@ static uint64_t * find_counter(struct qemu_plugin_insn *insn) uint32_t opcode; InsnClassExecCount *class = NULL; - /* we expect all instructions to by 32 bits for ARM */ - g_assert(qemu_plugin_insn_size(insn) == 4); + /* + * We only match the first 32 bits of the instruction which is + * fine for most RISCs but a bit limiting for CISC architectures. + * They would probably benefit from a more tailored plugin. + * However we can fall back to individual instruction counting. + */ opcode = *((uint32_t *)qemu_plugin_insn_data(insn)); - for (i = 0; !cnt && i < ARRAY_SIZE(insn_classes); i++) { - uint32_t masked_bits = opcode & insn_classes[i].mask; - if (masked_bits == insn_classes[i].pattern) { - class = &insn_classes[i]; + for (i = 0; !cnt && i < class_table_sz; i++) { + class = &class_table[i]; + uint32_t masked_bits = opcode & class->mask; + if (masked_bits == class->pattern) { break; } } @@ -270,6 +295,17 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, { int i; + /* Select a class table appropriate to the guest architecture */ + for (i = 0; i < ARRAY_SIZE(class_tables); i++) { + ClassSelector *entry = &class_tables[i]; + if (!entry->qemu_target || + strcmp(entry->qemu_target, info->target_name) == 0) { + class_table = entry->table; + class_table_sz = entry->table_sz; + break; + } + } + for (i = 0; i < argc; i++) { char *p = argv[i]; if (strcmp(p, "inline") == 0) { @@ -283,9 +319,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, type = COUNT_NONE; p++; } - for (j = 0; j < ARRAY_SIZE(insn_classes); j++) { - if (strcmp(p, insn_classes[j].opt) == 0) { - insn_classes[j].what = type; + for (j = 0; j < class_table_sz; j++) { + if (strcmp(p, class_table[j].opt) == 0) { + class_table[j].what = type; break; } } From patchwork Mon Oct 14 10:49:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176185 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4386144ill; Mon, 14 Oct 2019 04:33:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWesiYv9yuSR4pTzJHd5MU5fjKk7NrOmIVKg35xnnqnzExmNEoSYIssieM3v/2lYZIXMuj X-Received: by 2002:a05:620a:2191:: with SMTP id g17mr5450730qka.418.1571052804433; Mon, 14 Oct 2019 04:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052804; cv=none; d=google.com; s=arc-20160816; b=fr62zilO5kQW+esg6a3zKi095rGGyx2mZLUODT1wix67sXAFlbTYz3nDAukHMNmfS4 fTraKM+4ku9zx/T9Im2Vx7QklL72xxpBor9TJRgPFN/Oc65VG33CbRCWKz8cayfuC+yg tqIIJUasWtfIqJ+CTRIoLuqUxOqlZb3GLOtWCbcmMtpa8uBz4xf1qqU/ifKa7CQUqmOc b0/IiLgJU39CFIGyz4QtYf5asN2nTjkQ8nXXofSsj9RNW8KzKEDETwviyizZaUkNrAjx nlNW0ueD8jnl3pJtzEdBnQKNbW/fFegpF9OkcsHoNk9G44C4UFBsMHSwYQidFUd+zbgJ UTbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FKYCRxM54+fFieoPbxriSyiRx4DZwuJ1T6+6ndzyCSc=; b=oc+HgpaLCNnRYN6o9Me4dwRTN62TWetRyHTvqiecyG3UCyAyzfHoyKJVdTGNAB+nMO rEnU4A5j99NnbQE6Yp8zkWxdQmLFW/Fn13n0x7ym51O6p1cEqjNAZkWQIr0UTpvos7AY l516RADmoyHL7hWtm37Wl+8XnX2Dy6RTiMw4V+kfoiVtsXL8/yIHxWa1F4P/UAkaUzBb 9UKk0k6ahItP0havJuNJ0CvlYgm5fx1LXjKoBdpFs2uWwKUn6nVHfWpuwBPLIGSlGY3e 4soHQSptMosoydND+6TkMXKw6TzGCby31RGtkggA6ZrnGCn6tYmM2yfm2alAG+pZNb5C WwQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tsEjXFXD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l16si16756506qve.62.2019.10.14.04.33.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:33:24 -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=fail header.i=@linaro.org header.s=google header.b=tsEjXFXD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJybL-0003Ci-N2 for patch@linaro.org; Mon, 14 Oct 2019 07:33:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46829) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyC8-00081n-VD for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC6-0007eB-WD for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:20 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:37211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC6-0007cy-Pd for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:18 -0400 Received: by mail-wm1-x332.google.com with SMTP id f22so16306178wmc.2 for ; Mon, 14 Oct 2019 04:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FKYCRxM54+fFieoPbxriSyiRx4DZwuJ1T6+6ndzyCSc=; b=tsEjXFXDWa9AFkxcomh08i3oHIYhxMC8mpxDWsszOIooj8mrSGrIs1KW6eprejRHaJ BrEptceNGBulQEcfvL0P9F2/KhrUUJo87JHbsiiHggO9nbs9si0IVPY9YiqNsrfm3WYa tzjYHp0Hew9tjd1gCwBgpZVr4QdQjifCc6xTxR9upbjkVOuHOMtelWfFQdkg8KnIPgsf 4Im1r9jUDRN/2syi5ynj0X9nBxb9JEvdKBN6/Nzdhpo1xEEZ23WqQhNpCbGE7B26a8a7 pX1vdhMj/jTczoQyi2zliOr1AirROrekidKjNrC/MJzR8sbzeMm/NmggTGK6a1B3Eh42 VdiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FKYCRxM54+fFieoPbxriSyiRx4DZwuJ1T6+6ndzyCSc=; b=D6N3ObiAxYyTWBjC6QIb+XQCvwAIknuSF5M5s6mGxqsPgD2eBZi4s02HkLgpQkylXV ND5JD3sm0BW1EQ+N8yb/choS8ZTt0LVZv0OHWR3wgKPoA7l04m9xNf9V4GryX/mekO1n zrf0UxzKzmYT1McXbAn0Q19f2XaOgWnzLZ9mdKAGV4mYWWZr+oeLDzMVNdzaFR3um8E7 fUlhb02g9bKiz443D4+d+TIeuIY4OgOYQcBxwj08WAVyYr4MggFxpEIeJQAl19VSPImM UZTkcE30DiMzJFFINMkwo6MWR+f5pWY7cnqFBa29uwHWI2MekAx8JnzPDlsjLaGFPWHs TFEA== X-Gm-Message-State: APjAAAWLKwjGOiUC8p/uyo8HNsYwvtJd0cMkxNgDQckP8oGmgFkRn67u J8EpWAoK/2cdeUkp4Y2l2qAcPw== X-Received: by 2002:a1c:1bc5:: with SMTP id b188mr14875814wmb.164.1571051237154; Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m7sm19094537wrv.40.2019.10.14.04.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CD6A51FFD9; Mon, 14 Oct 2019 11:50:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 53/55] plugins: add sparc64 instruction classification table Date: Mon, 14 Oct 2019 11:49:46 +0100 Message-Id: <20191014104948.4291-54-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , robert.foley@futurewei.com, peter.puhov@futurewei.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As an example of another set of instructions. Signed-off-by: Alex Bennée --- tests/plugin/howvec.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.20.1 diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c index 5f7c740833..9ec0d25e3b 100644 --- a/tests/plugin/howvec.c +++ b/tests/plugin/howvec.c @@ -112,6 +112,27 @@ InsnClassExecCount aarch64_insn_classes[] = { { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_CLASS}, }; +InsnClassExecCount sparc32_insn_classes[] = { + { "Call", "call", 0xc0000000, 0x40000000, COUNT_CLASS}, + { "Branch ICond", "bcc", 0xc1c00000, 0x00800000, COUNT_CLASS}, + { "Branch Fcond", "fbcc", 0xc1c00000, 0x01800000, COUNT_CLASS}, + { "SetHi", "sethi", 0xc1c00000, 0x01000000, COUNT_CLASS}, + { "FPU ALU", "fpu", 0xc1f00000, 0x81a00000, COUNT_CLASS}, + { "ALU", "alu", 0xc0000000, 0x80000000, COUNT_CLASS}, + { "Load/Store", "ldst", 0xc0000000, 0xc0000000, COUNT_CLASS}, + /* Unclassified */ + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_INDIVIDUAL}, +}; + +InsnClassExecCount sparc64_insn_classes[] = { + { "SetHi & Branches", "op0", 0xc0000000, 0x00000000, COUNT_CLASS}, + { "Call", "op1", 0xc0000000, 0x40000000, COUNT_CLASS}, + { "Arith/Logical/Move", "op2", 0xc0000000, 0x80000000, COUNT_CLASS}, + { "Arith/Logical/Move", "op3", 0xc0000000, 0xc0000000, COUNT_CLASS}, + /* Unclassified */ + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_INDIVIDUAL}, +}; + /* Default matcher for currently unclassified architectures */ InsnClassExecCount default_insn_classes[] = { { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_INDIVIDUAL}, @@ -126,6 +147,7 @@ typedef struct { ClassSelector class_tables[] = { { "aarch64", aarch64_insn_classes, ARRAY_SIZE(aarch64_insn_classes) }, + { "sparc64", sparc64_insn_classes, ARRAY_SIZE(sparc64_insn_classes) }, { NULL, default_insn_classes, ARRAY_SIZE(default_insn_classes) }, }; From patchwork Mon Oct 14 10:49:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176169 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4366314ill; Mon, 14 Oct 2019 04:15:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfTsxV2J6Jcc0FKwoaGfADzvL4upuEkgKsFErqIt95qChdcsJgMsi0IWVV2qSlmoxEnPx5 X-Received: by 2002:a05:620a:12d8:: with SMTP id e24mr28805166qkl.273.1571051712635; Mon, 14 Oct 2019 04:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571051712; cv=none; d=google.com; s=arc-20160816; b=Z4EOMWdscvwpNu6hIhboLwkaG9ulfXDB9oK1gO5FH2uKuUgBq5F7KFP7efPlRDaszz W65ZcWPDXgUqj9DjGsWXkzHq3ckdiFe8tXMdxFcppWRsbsDEb5tlZYh1r32ZdQvQ8FyV iAYfBaQSOa2SlFnTm0W9MRmyJJQQ/dFOfKUWB1hZkV6+2w4Db4gXiw1fPkF384coWRi0 NKMYBdPJOPKVzRF4Gm4ywyAoJmz3xAD9RZhHmoM917mWtu29NdBa+/kSI7625VjYhfym zWbbHQePRHsmG4tvXFBO49fU5mgeCs7PS7cGNrqMhxBeWBG9/H4LOVhe/0XLBY1lNGme DWUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wSPReI6vXrdAyz5OkGAAu64UwO/gQv+p6h6aCIL3M10=; b=GSGS+JcNsk8b898DUehpk6fewNgRaRFT8pWKCiRVkNvUVw3Uh9Q1M8Qe4KM/nGx3AU Vk6NaKfHQ69v4VvetZe2Z7BLL+SC2H6MWw006IO/3YUwGLHhmq/+c0Y354P0VVW6Oe2x KNWKD5uFX5PoG2XVh+cCwF2g6mtjiGCw9oS8aMMyq9yCH0oUV1RgZYwM7NyysYRgZQN8 L8pimQTn+56cb/lP31162XyzzTbdPkXcMKstSF9ArUB9RuCzY+XIJAUFU915x8kf7lU8 GO744yx52hOyntRrfUUC3+gK2rJIpkA2NnnXWSKJcl1YXNFMzQ523ZP2z4Hd8sgWsgoI Uhag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MKDcZtTd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y34si16945207qtd.270.2019.10.14.04.15.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MKDcZtTd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyJj-00075H-Ab for patch@linaro.org; Mon, 14 Oct 2019 07:15:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44772) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJxvY-0007da-2s for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJxvW-0006Lk-3Y for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:11 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJxvV-0006Ke-Sq for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:50:10 -0400 Received: by mail-wr1-x443.google.com with SMTP id y18so9677718wrn.5 for ; Mon, 14 Oct 2019 03:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wSPReI6vXrdAyz5OkGAAu64UwO/gQv+p6h6aCIL3M10=; b=MKDcZtTdkkkqtJ8gwELlV+iKjy4Li0rE87TSFvvoMi5VatV4fXd50X3tHK0t2ulBza ShCBh1GeJ27x+WCJlrYa6mTDrk2LMfzLS6K8qr3B/Pj0+kU5h4PxE77EpWWuShJT27hn Oc+eCcB1JjZ7HACxueflHk/ZFQ7pwx4bedGo1slvBMrG+RGBAt31kNNvIFEpONpC4wGz EchA/IJ9132dgy8/1ru+BKTmAn8P+9baCGbl1MyPlGydXQczFn/nY967bDEqo4LGyJIa WIf3p8HTHJoKwwt+oYIiBVkfk3BYUUBZnWAl91Ge6CC41ND2nWY48Lh3Xd7crNt5640s kgTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wSPReI6vXrdAyz5OkGAAu64UwO/gQv+p6h6aCIL3M10=; b=UXs3abIk9vhxBElO/BPoNmIJc/HmFhf1pAd6s4BG8CUi7OjhCtGeQxt1xb2vBrEhCJ 7FE8IM39cI6pVcV/zwpKyb8yh6D7mzM3CSdNQlccp+zHfaQw5BWKHf/7S7dAp+D/V/j9 bVSsscuTU63eR1rw0spjK8vqnUAedjv8AuI26hP273/7m0EdCFqzLgILBgMkhLNIul01 yu76u9873GYFOLNox4oyaYEr1W3gwYP7V44SJDgzdXVB79hKrzBCMVKExaG7zbnmgZis pqaD8Sq+MddrSYP2kTEoOffP0Dfw6N6t5e5qVPJw1aNsf9z+YIsJyTPkQoYTW+0fhH7N 1Syw== X-Gm-Message-State: APjAAAUZvkM9195vsHvugpU+Kz624AdqUYlV8JcX24SA1cPwL+Rhhk6a YEb8AkNQ5+LSr2LWytzWGB0/BA== X-Received: by 2002:adf:fac2:: with SMTP id a2mr24059544wrs.290.1571050208772; Mon, 14 Oct 2019 03:50:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a2sm19750943wrp.11.2019.10.14.03.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:50:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4EFBB1FFDC; Mon, 14 Oct 2019 11:50:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 54/55] plugins: add qemu_plugin_outs and use it Date: Mon, 14 Oct 2019 11:49:47 +0100 Message-Id: <20191014104948.4291-55-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , robert.foley@futurewei.com, peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Having the plugins grab stdout and spew stuff there is a bit ugly and certainly makes the tests look ugly. Provide a hook back into QEMU which can be redirected as needed. For the newer plugins that use GString already this falls out pretty naturally. For the older printf style plugins we convert to g_strdup_printf and pass that. While we are at it we can use g_autoptr/g_autofree to let the compiler worry about freeing things. Signed-off-by: Alex Bennée --- include/qemu/log.h | 1 + include/qemu/qemu-plugin.h | 6 ++++++ plugins/api.c | 8 ++++++++ plugins/qemu-plugins.symbols | 1 + tests/plugin/bb.c | 12 +++++------- tests/plugin/hotblocks.c | 10 ++-------- tests/plugin/hotpages.c | 12 +++--------- tests/plugin/howvec.c | 15 ++------------- tests/plugin/insn.c | 10 ++++------ tests/plugin/mem.c | 12 ++++++------ tests/tcg/Makefile.target | 2 ++ util/log.c | 3 +++ 12 files changed, 43 insertions(+), 49 deletions(-) -- 2.20.1 diff --git a/include/qemu/log.h b/include/qemu/log.h index b097a6cae1..a91105b2ad 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ #define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_FPU (1 << 17) +#define CPU_LOG_PLUGIN (1 << 18) /* Lock output for a series of related logs. Since this is not needed * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 719d7054a1..060e253b74 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -379,4 +379,10 @@ int qemu_plugin_n_vcpus(void); /* returns -1 in user-mode */ int qemu_plugin_n_max_vcpus(void); +/** + * qemu_plugin_outs() - output string via QEMU's logging system + * @string: a string + */ +void qemu_plugin_outs(const char *string); + #endif /* QEMU_PLUGIN_API_H */ diff --git a/plugins/api.c b/plugins/api.c index a9fa229369..701c232668 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -324,3 +324,11 @@ int qemu_plugin_n_max_vcpus(void) return get_ms()->smp.max_cpus; #endif } + +/* + * Plugin output + */ +void qemu_plugin_outs(const char *string) +{ + qemu_log_mask(CPU_LOG_PLUGIN, "%s", string); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 267ec381b4..4bdb381f48 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -36,4 +36,5 @@ qemu_plugin_vcpu_for_each; qemu_plugin_n_vcpus; qemu_plugin_n_max_vcpus; + qemu_plugin_outs; }; diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index 4a6d6ca0bc..45e1de5bd6 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -10,18 +10,20 @@ #include #include #include +#include #include static uint64_t bb_count; static uint64_t insn_count; -static int stdout_fd; static bool do_inline; static void plugin_exit(qemu_plugin_id_t id, void *p) { - dprintf(stdout_fd, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - bb_count, insn_count); + g_autofree gchar *out; + out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n", + bb_count, insn_count); + qemu_plugin_outs(out); } static void vcpu_tb_exec(unsigned int cpu_index, void *udata) @@ -56,10 +58,6 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, do_inline = true; } - /* to be used when in the exit hook */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); - qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; diff --git a/tests/plugin/hotblocks.c b/tests/plugin/hotblocks.c index 57bea765b3..1bd183849a 100644 --- a/tests/plugin/hotblocks.c +++ b/tests/plugin/hotblocks.c @@ -16,7 +16,6 @@ #include static bool do_inline; -static int stdout_fd; /* Plugins need to take care of their own locking */ static GMutex lock; @@ -47,7 +46,7 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) static void plugin_exit(qemu_plugin_id_t id, void *p) { - GString *report = g_string_new("collected "); + g_autoptr(GString) report = g_string_new("collected "); GList *counts, *it; int i; @@ -71,8 +70,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_mutex_unlock(&lock); } - dprintf(stdout_fd, "%s", report->str); - g_string_free(report, true); + qemu_plugin_outs(report->str); } static void plugin_init(void) @@ -137,10 +135,6 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, do_inline = true; } - /* to be used when in the exit hook */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); - plugin_init(); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); diff --git a/tests/plugin/hotpages.c b/tests/plugin/hotpages.c index 99bb4be07c..70917ea174 100644 --- a/tests/plugin/hotpages.c +++ b/tests/plugin/hotpages.c @@ -22,7 +22,6 @@ static uint64_t page_size = 4096; static uint64_t page_mask; -static int stdout_fd; static int limit = 50; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; @@ -69,7 +68,7 @@ static gint cmp_access_count(gconstpointer a, gconstpointer b) static void plugin_exit(qemu_plugin_id_t id, void *p) { - GString *report = g_string_new("Addr, RCPUs, Reads, WCPUs, Writes\n"); + g_autoptr(GString) report = g_string_new("Addr, RCPUs, Reads, WCPUs, Writes\n"); int i; GList *counts; @@ -91,8 +90,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_list_free(it); } - dprintf(stdout_fd, "%s", report->str); - g_string_free(report, true); + qemu_plugin_outs(report->str); } static void plugin_init(void) @@ -154,10 +152,6 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, { int i; - /* to be used when in the exit hook */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); - for (i = 0; i < argc; i++) { char *opt = argv[i]; if (g_strcmp0(opt, "reads") == 0) { @@ -167,7 +161,7 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, } else if (g_str_has_prefix(opt, "pagesize=")) { page_size = g_ascii_strtoull(opt + 9, NULL, 10); } else { - dprintf(stdout_fd, "option parsing failed: %s\n", opt); + fprintf(stderr, "option parsing failed: %s\n", opt); return -1; } } diff --git a/tests/plugin/howvec.c b/tests/plugin/howvec.c index 9ec0d25e3b..96db546b4d 100644 --- a/tests/plugin/howvec.c +++ b/tests/plugin/howvec.c @@ -29,7 +29,6 @@ typedef enum { } CountType; static int limit = 50; -static int stdout_fd; static bool do_inline; static bool verbose; @@ -163,7 +162,7 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b) static void plugin_exit(qemu_plugin_id_t id, void *p) { - GString *report = g_string_new("Instruction Classes:\n"); + g_autoptr(GString) report = g_string_new("Instruction Classes:\n"); int i; GList *counts; InsnClassExecCount *class = NULL; @@ -211,8 +210,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_list_free(it); } - dprintf(stdout_fd, "%s", report->str); - g_string_free(report, true); + qemu_plugin_outs(report->str); } static void plugin_init(void) @@ -270,11 +268,6 @@ static uint64_t * find_counter(struct qemu_plugin_insn *insn) icount->insn = qemu_plugin_insn_disas(insn); icount->class = class; - if (verbose) { - dprintf(stdout_fd, "adding for %s (%#08x @ %#20lx from %s)\n", - icount->insn, opcode, qemu_plugin_insn_vaddr(insn), - class->class); - } g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } @@ -350,10 +343,6 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, } } - /* to be used when in the exit hook */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); - plugin_init(); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 9cfa7d0e53..e5fd07fb64 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -10,10 +10,10 @@ #include #include #include +#include #include -static int stdout_fd; static uint64_t insn_count; static bool do_inline; @@ -42,7 +42,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) static void plugin_exit(qemu_plugin_id_t id, void *p) { - dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count); + g_autofree gchar *out; + out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count); + qemu_plugin_outs(out); } QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, @@ -53,10 +55,6 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, do_inline = true; } - /* to be used when in the exit hook */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); - qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index fdf4347c5e..d967388989 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -10,22 +10,25 @@ #include #include #include +#include #include static uint64_t mem_count; static uint64_t io_count; -static int stdout_fd; static bool do_inline; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; static void plugin_exit(qemu_plugin_id_t id, void *p) { - dprintf(stdout_fd, "mem accesses: %" PRIu64 "\n", mem_count); + g_autoptr(GString) out = g_string_new(""); + + g_string_printf(out, "mem accesses: %" PRIu64 "\n", mem_count); if (do_haddr) { - dprintf(stdout_fd, "io accesses: %" PRIu64 "\n", mem_count); + g_string_append_printf(out, "io accesses: %" PRIu64 "\n", mem_count); } + qemu_plugin_outs(out->str); } static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -87,9 +90,6 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, do_inline = true; } } - /* plugin_exit might write to stdout after stdout has been closed */ - stdout_fd = dup(STDOUT_FILENO); - assert(stdout_fd); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index d25fc64300..3c7421a356 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -153,6 +153,7 @@ run-%: % run-plugin-%: $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + -d plugin -D $*.pout \ $(call strip-plugin,$<), \ "$* on $(TARGET_NAME)") else @@ -168,6 +169,7 @@ run-plugin-%: $(QEMU) -monitor none -display none \ -chardev file$(COMMA)path=$@.out$(COMMA)id=output \ -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + -d plugin -D $*.pout \ $(QEMU_OPTS) $(call strip-plugin,$<), \ "$* on $(TARGET_NAME)") endif diff --git a/util/log.c b/util/log.c index 1d1b33f7d9..1ca13059ee 100644 --- a/util/log.c +++ b/util/log.c @@ -273,6 +273,9 @@ const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, +#ifdef CONFIG_PLUGIN + { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"}, +#endif { 0, NULL, NULL }, }; From patchwork Mon Oct 14 10:49:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 176193 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4393276ill; Mon, 14 Oct 2019 04:40:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh/Y5f7+6q3ZWpuyPyuIaVKTmCd+p6IH/UqfYpjsyta/ziYEmqUTT39OTOfkeLmeJcASQK X-Received: by 2002:a0c:d787:: with SMTP id z7mr29296483qvi.152.1571053203214; Mon, 14 Oct 2019 04:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571053203; cv=none; d=google.com; s=arc-20160816; b=biSmsbxXaFeD/kL9izhw1eBC/7bruZjLSa0tIkqtQ4Pc/XyGpsXRqRbMqnntEj4vpc w7bscIyMcFf/b3Tc2XwyD5pn+DqXwv+D8PxKiGot59ogJB+tY6ivNQ2TfVLC8rqco1DO J8P3L7cKbmBJSYwvmJACMt5UfpWvdqry3J4AsreBiFibzr6CU0+aM9UBKFMv49CemOin mWw4m+Mxy1AmM7Ior9HM+tU+0XN/IPTAlKWInjqWLjjyJjczIs/IOUJCIoLP1ZDYd+Q+ G6iB+W5ZfwNdissMJ0IILFZR453TIskp0lypqpaoTn1l5iqfB5AOtxQDTopN0iglSgz2 kQ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cgnURW7On79/62ZfWFlo3wt05KKxTsvmAfQT2MMGb8A=; b=FO6g/8RDZUdR6JPin4togm8pkLLoZwahMNkmK2ghWv70WuVqZ92WkLEixGGhxcNALq Bp/y2gcG5QFRD1ZDfpn6arz62RO0UOWw+LHS81YNmqInmaiPu06dD0p0OaZHWWxLy49O l3YDEq8lBjNDVpWKwFOVHfxByhmnrr1SbyPDpnSssSMZd1a6syk+nTvCpZxOvjzi4DqN kol3JzVJoYntIrifywahgEk+Z+Duu4sNhGk7HnRbk8fT+drdfKcyCFln8T+DEydy0k03 kszYfr0oGJfdxwyT5suQ9SfDAck8DnJZ+4eYbwB10Z2kIOhNZv8xoVutpQVOX0Iy182A tjyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Dck61wv7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 79si17146793qke.223.2019.10.14.04.40.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:40:03 -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=fail header.i=@linaro.org header.s=google header.b=Dck61wv7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyhm-0004HS-JW for patch@linaro.org; Mon, 14 Oct 2019 07:40:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46859) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyCA-00083v-5h for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJyC9-0007gu-3P for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:22 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJyC8-0007f9-TE for qemu-devel@nongnu.org; Mon, 14 Oct 2019 07:07:21 -0400 Received: by mail-wm1-x342.google.com with SMTP id m18so16323032wmc.1 for ; Mon, 14 Oct 2019 04:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cgnURW7On79/62ZfWFlo3wt05KKxTsvmAfQT2MMGb8A=; b=Dck61wv71VwOMiZLUxd0YHY7tTYvalyf3JAyksmOOjIUgLRsClbtcGX342W/8PDYV7 OsoBHzJwDnw8cpuYgukbVUiOQPXquqo38Z63FnbcZI/+Z3MkCnQM1cIwOxUbKO/lNuqs x1VJt9HUJvV6Ytnd8OwibfOx91IQFTlgtSzgO1UCoIE+s8uqxYd5UB2zOSwzJEpYDC8q srmk3pH9Q0lyAGugQITSRLpQiUITSbs+6zSNfqjLwVh7IbMhCt6cvST6csFIkUBcZ/cq Njg6aZFt7W2hHY0GajCsY10EQW2hFzhPZy1236vfXA8G90v9+zyCY5H0de3zlJj3nXx+ 7wHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cgnURW7On79/62ZfWFlo3wt05KKxTsvmAfQT2MMGb8A=; b=IXxhpwh1kWVrKINg3iq2lwvMy/0gFuWhHHIC0k0PK27bwHDoWt+6c1gk/xshXysFnq ksMRr/H0avzY5wksjSN9YjEEy9UD1XVojB+SC6HdOwLCcaZUsBn8pBM4vO32DhMkHhre OmcgfMRoXUTgy4cxbz3zp12k6O8tfBcGI/aVFye2hoCB3yn0ihJ9CRzwORx0CCYmQKi3 JIMHmsNsLSFrZhwCZz+HxvkJx1nCNZhSDGwuojobIyagyTFLtGxgCnUFr+XOxaF74pEO pM68Pe4sqc07zcNnz9EN6WKy+Hyfxu2+I2CSpkPibXFc971iXdelklS+D0w8TJLGYXy4 Sp6A== X-Gm-Message-State: APjAAAU5vDlXI65W0IJwhSryw0AUs8Cce6jGwpZOm9Zgyc6sX0fwm2yK DY9Mcg/iiuyE6+jKWV2/d/KISw== X-Received: by 2002:a7b:cd19:: with SMTP id f25mr15120161wmj.154.1571051239230; Mon, 14 Oct 2019 04:07:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q19sm36321550wra.89.2019.10.14.04.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 04:07:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 816461FFDE; Mon, 14 Oct 2019 11:50:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 55/55] .travis.yml: add --enable-plugins tests Date: Mon, 14 Oct 2019 11:49:48 +0100 Message-Id: <20191014104948.4291-56-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" check-tcg will automatically run the plugins against most TCG tests if it is enabled in the build. We exclude sparc64-linux-user for now as there are pending patches that need to be merged fixing it's fork implementation. Signed-off-by: Alex Bennée Cc: Richard Henderson --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/.travis.yml b/.travis.yml index d0b9e099b9..37bca1ca1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -334,8 +334,23 @@ matrix: - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default" + # Run check-tcg against linux-user (with plugins) + # we skip sparc64-linux-user until it has been fixed somewhat + - env: + - CONFIG="--disable-system --enable-plugins --target-list-exclude=sparc64-linux-user" + - TEST_CMD="make -j3 check-tcg V=1" + - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default" + + # Run check-tcg against softmmu targets - env: - CONFIG="--target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu" - TEST_CMD="make -j3 check-tcg V=1" - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default" + + + # Run check-tcg against softmmu targets (with plugins) + - env: + - CONFIG="--enable-plugins --target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu" + - TEST_CMD="make -j3 check-tcg V=1" + - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-default"