From patchwork Thu Oct 17 13:15: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: 176607 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp924070ill; Thu, 17 Oct 2019 06:25:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAd5cAnMeqaQjPxRQGKPQ8lQ98hz0oo2ezo2sqGZSry9v17eLdhzRkMheOIWtXo4GJgHVZ X-Received: by 2002:ac8:356e:: with SMTP id z43mr3793615qtb.88.1571318740501; Thu, 17 Oct 2019 06:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318740; cv=none; d=google.com; s=arc-20160816; b=K9wEfAR/+ZDGHI4shu2KGQHJQeMWcf1iYl6XeKiHHJlcVN/dw56eOKNh0C2NRmSddf xXD5KIwThSaNsytmEcKOrBE9BBukGMtz2sHZT2H5ZUY7YBbagReE19ZeHA4d/FpGtZxU S+0OZZEjKPv5zt6RKst9KRwA3Aj19/EAFnQ+lcDVL8C7S5uYbnQ1yPVGxgpMCg3r/fur 9hvoPOoFkoNthCf/3oLY6wq58mzHUUVQyeqheb5sOXE68RCpmXefDkty/25IcJ3Xc6Mo hk6sTlbAGQnVCqUZgeMawHBbEZQ4lgObOAuOHnzua6hI1tBe/IzPFgO8pXgQGHGpcSqZ Z5/A== 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=f0tAv2/jAUxDhCTtiuArN1X2HmDUT/iHPyZZjUW76EY=; b=GQ+4DnHDUE1+PCcTiUTJ6RMm5ymcl6yFlDddouHO/8MDIDTTcCWx1XWyahncrEWp2C xBb/oJCPxZFDkP5N3o1xofgfQZqR3+idXOeE5srluFxdBhZXdxuaErX/8mGdL6Wx/q5Y FAPvQZ8OIPR5bLBM943MGRQy1sbYbn8Yz67LTYqoF6/wY54q+vRa3lziKQkUiwTS5KgE nnmHJuQIFvF7bJxAnxSOVybJd1kivV2q5nwVIWXGNRWaFzv7txBIhjDwif0Hamb587Ru pMYZVkarKg67A43gwCJ+6SjIJGEUuhnCuV/2GTi4WpyrhyDAZDCi+FCQgP2RS+5c279R ISPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="H0+q/acx"; 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 e14si2041209qkn.179.2019.10.17.06.25.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:25: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="H0+q/acx"; 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]:47448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5md-0001vT-P9 for patch@linaro.org; Thu, 17 Oct 2019 09:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33797) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dd-0007xN-MJ for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5da-0005IP-CU for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:19 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5da-0005Ht-4c for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:18 -0400 Received: by mail-wr1-x444.google.com with SMTP id p4so2306748wrm.8 for ; Thu, 17 Oct 2019 06:16: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=f0tAv2/jAUxDhCTtiuArN1X2HmDUT/iHPyZZjUW76EY=; b=H0+q/acxPeEnQ8wg781ymQLeWxa7rvcDeY+edi4NMNvkxH84v9GwHiI+WEMCWMDYZw 9E679+XkAt2DmAfUszo5QYlWbhruBpOxFUbACGVC4Fqy9N99U5eJ2+e8Fpph+tCjfw+P O5enLwn3S/Hzq8iudNCas1ADGuerfkrYw99BdNL200ifdAtxJrGzjevXKKMrcw94Plr4 QyLUXxnYrHcdpA4W2lDeWeBZvAojbpAebJCE7Mh4rHC6cfto2ToCGr2VO916RM1q1EEq X+2WqJQfdnkN6GOTrQCICT8us9D0JmeZoFmWOVavf0QD6MFJlUbeyQmX5G1J3yMJqcfo rxJw== 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=f0tAv2/jAUxDhCTtiuArN1X2HmDUT/iHPyZZjUW76EY=; b=chdTWARIqTxEE4d2cMGst9jrQ393vyV4lM8O3lbSvEUqz5c8+ZBnJL3LV5mM+IUC38 01jIjTr8kNI4k0Tim5Sm5fdmz6Mv1HIMYEjE8AFUD9AqkEQvAgNSTxjPXS2UG1FqBz6c jrnjukJs6Wd+TWUwrcm7f9ZcU4F6E1QuUK9pCgOYPTQeNszKXLDQdkF9Oycor067c1Cw khM+I07/MCGLH5m9ahZj0VtSgA2ig5zpyXzJ1KZFpZm3SVH0/ZoBNpX/BZXAcY9FBsLx FT3rNIiVPB68nvxx+ZVk5QmwKtwZySsaPhYyG29phchjFBPZqKTbBuTaQGMdXlGEsHNE lhLg== X-Gm-Message-State: APjAAAXNNg1qLO4lEqAnbI0NQDIRApqBIx55Q3jcm1XeC8IMQhCLgPOm 20++vSo762u3PEFulLlLaIGWaA== X-Received: by 2002:adf:f0cc:: with SMTP id x12mr3037271wro.326.1571318176949; Thu, 17 Oct 2019 06:16:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g11sm2180583wmh.45.2019.10.17.06.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D4DBC1FF8C; Thu, 17 Oct 2019 14:16:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 01/54] trace: expand mem_info:size_shift to 4 bits Date: Thu, 17 Oct 2019 14:15:22 +0100 Message-Id: <20191017131615.19660-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Reviewed-by: Richard Henderson --- 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 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 Thu Oct 17 13:15: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: 176609 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp925385ill; Thu, 17 Oct 2019 06:26:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzkSlD7CXbyTARC+MmCgJZWS/Hv8ZfbQCoJ6G/afPoQOQfUTqos15DTKim6omXJkStY1Vv X-Received: by 2002:aed:29e7:: with SMTP id o94mr3717897qtd.161.1571318804190; Thu, 17 Oct 2019 06:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318804; cv=none; d=google.com; s=arc-20160816; b=sitwBAAPO72jQgSGKX/C0uR6Rz8Gu2+vNqnIq4aVOxgI6tVxw1FdOFh0WAmU37fmoJ yybVdgnCyKUY5Gfn8y3aXM1z+rtP567gaCge1ciGLLm16XFbF+2kRYFO60indvhDGHaO v+fnACFWAa5qjrU92BWdpabtUstRiVvrcDmaPPny4xO6+K2Giin8aN9IdEdTmiaAElT8 3hmKXKMIwWU7TRegPFNrbJ7khwg19Qffc2zZ3cX3kC6CvCTXCV/lqh0nQUi90yb+W3qx cZng3EWCwbciF1ZmtFn0x6x571rhp5x68lADGWmbqHpCel2SkWz/u9aqUNaVZib71LGL DZVg== 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=sqU+kuQqhqED0Clb/Ojiqrbv6162Tbysj/zW0ZTKNHA=; b=X5TE7ZbFZuSmgr6tdwmIyknI0Ir5YJjiGwpHAFaintQnK4G2UL6geCz0UMFQslqaE9 YspmBdEJiAFo2FOikkvEPlxVgvjw57DaQA2aCIWIrK3b9DGU38fUXWVjGWTipHp4aKlf PysK9i4n57AFr2S07lAlen+BPS9qw/XOPmx6uGTse+XHXWwSGWG/odWUiKd0LEYlYtJZ STv41DXq3It3YU/0Qn0R7xqd5Ch7wbPq12czwMAlQllz3lkSFpNWlmN47//xQ07WTAqf t7jfZFPkBVSMP6s9G5aBWotoBBQ/GF5afGe6WUcHyyfvkJRORUHDM7LMD2KECjsOLoR7 Znzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O3DEV2li; 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 c27si2014946qkl.133.2019.10.17.06.26.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:26:44 -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=O3DEV2li; 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]:47566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5nb-0003BA-T5 for patch@linaro.org; Thu, 17 Oct 2019 09:26:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5df-00080K-Sv for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dd-0005Md-Mm for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:23 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5db-0005Ik-Op for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:21 -0400 Received: by mail-wr1-x441.google.com with SMTP id o28so2307502wro.7 for ; Thu, 17 Oct 2019 06:16: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=sqU+kuQqhqED0Clb/Ojiqrbv6162Tbysj/zW0ZTKNHA=; b=O3DEV2liK0BzOBJ9Jr0SQBYTrkyKpw90YzCAyLXXQV8E900yNbcqBm1oFLmqH07uBl t1oM6ZgzBFkOHMxfdoC2bPHIXVP5rSck7JmMI++Fl6w7AOuZ04j5CDRiy8l5El2/+r71 iFbMY/tuSf2tHkQBdrhZRm1vjtBHbpG7czSfxHMzg9t+xSGPtRWcmVy6UGy7DHTegOTW BnA1SqgRKWaeINj06u8tsHU5CLHHP61VI7eDS9FQULG7VLdibAYhNwkB6f8mWVi+vk7j iCs5qCcNWjN98nB2CcIAf/MRGB2DZhhDhIy5VhhoFW/tLRWTVQNOEvNyGdqKS7bnhou1 lm0g== 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=sqU+kuQqhqED0Clb/Ojiqrbv6162Tbysj/zW0ZTKNHA=; b=OKgFS2fYkO9KhCEZ/7p+zxWBjBXlrX95m638IMwfasZpoU/iWZ7qvDkJZpd93WVhz8 VKC4MGO3jajfRGA9KOY5MAt+yWiUvQTv9rkWrQTzBn/pvVR5Dj6ghWKEvJSrfL55Zcqo qA2mzXpS6snPJYRRvVB7meDdvwtu5zeppEHipM/zXBV4dMB1fS6X9t/014c0BEhqa3Kr ZROem7kQUe5Voman8d/q8uAsQeGwotARUQ72baCNQuj4AVCtTim+CKBMgoNRWxgcsFe2 OHOz0LwFALGS9noSeVffJiI6h+UxXGMToBYWUYo3H678b69HRTRw8p9oe5nBBZe2Q6uW zlfw== X-Gm-Message-State: APjAAAV1+BUHgYuPYSTf9umZWId0ESwXEc6WfISQzkumZkwRRWQi+j71 75WWlyRfLaaHHw4kZdnn4XqarA== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr2924076wrs.158.1571318178369; Thu, 17 Oct 2019 06:16:18 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y186sm3273750wmd.26.2019.10.17.06.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0399D1FF8F; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 02/54] trace: add mmu_index to mem_info Date: Thu, 17 Oct 2019 14:15:23 +0100 Message-Id: <20191017131615.19660-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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. Signed-off-by: Alex Bennée --- v5 - fix up shifts v6 - use get_mmuidx(oi) for ATOMIC_MMU_IDX - use MMU_USER_IDX for user templates instead of 0 - fix line wrapping on ATOMIC wrappers and re-justify --- accel/tcg/atomic_template.h | 21 ++++++++------- 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, 59 insertions(+), 39 deletions(-) -- 2.20.1 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 287433d809..473d7e5a94 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -60,23 +60,26 @@ #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, \ + 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 { \ - 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, info); \ } while (0) -# define ATOMIC_TRACE_ST do { \ - uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); \ - \ - trace_guest_mem_before_exec(env_cpu(env), addr, info); \ +#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 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index defc8d5929..a8f9069582 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 get_mmuidx(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..8d315a6587 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 MMU_USER_IDX #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..93ad532f94 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, MMU_USER_IDX)); 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, MMU_USER_IDX)); 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, MMU_USER_IDX)); 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 Thu Oct 17 13:15: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: 176604 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp917048ill; Thu, 17 Oct 2019 06:20:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO6AtO8NP7H4UdlckU5tDodkW1BS+ZlWKor47/Ou0AjfqtfaeabYs5hqOshk4r4qe8mya6 X-Received: by 2002:a05:620a:2185:: with SMTP id g5mr3271645qka.401.1571318430043; Thu, 17 Oct 2019 06:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318430; cv=none; d=google.com; s=arc-20160816; b=Zqzlfl5YH6Ek37EnIMeMJToCb9Qsz9GBp6fHoYQ1I/a+zxoGnAdLi7g6YG+8Xyanyi 0ffhXlEwH7Cab5mvwm/Gurk1uccWapHQrmNo1/yTqoGfYxljZEXyGOuR9QykyLC1UCLS DdtG9ck2QnRBMzxf/0HhSjkU5TiHP1ZJn+m+T61odljfb/mPz/kEDqgTnY9suvO4ZpPj 9kso+n2xghl4ZY/iifGJ7JEOIDjKUj4MKEvg1rTCuj9wsKxrgciJjLcGaKj2oBcPtGWh 95NODZ6mBcaAM4p2zPekeE/nakmeNb6CI5uS9RZIIUeGJ3y7aX8YkRV4Srqhh/OK88CV nPlA== 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=rbXL1fLlbklrDVwyoWdTozQcU/Hu7SOnWR5N/e8FoN+tNqu+PULtwwMmUNJ9IC7sCZ QNFA/WLje/pw75m5HBK/UXAY7u8fG6Pq09kXm7w6uORkBCSCFDeugYq1IUSfLrSWzEop 2PTZSJXjdfpdPsjckiyUbrF7njieuQ4R2xO8SixkGqJrCbkX6s2TT5sKXIOxIywiaCy0 0qP7X6SYRWJudDehnWyWGQKt8dera9TBrOmNvD1AfJVfh7QbmSFhWdg2GnUjEtqZ2AT0 6Qo3D8yxMLkWhswL42GcElU7yieheh4I1/6ePkOwYy/zMMJnc1a0N0gHCopMwJsbDtc7 I4xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jcFk3PJ1; 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 o23si1957478qto.30.2019.10.17.06.20.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:20: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=jcFk3PJ1; 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]:47184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5hc-0003TX-Se for patch@linaro.org; Thu, 17 Oct 2019 09:20:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33855) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5df-0007zh-HC for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dd-0005NM-Te for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:23 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dd-0005KN-N4 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:21 -0400 Received: by mail-wm1-x341.google.com with SMTP id b24so2488461wmj.5 for ; Thu, 17 Oct 2019 06:16: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=xbXPv2RF3r3lJivkBr9kmxKqq17UhIjfz0xNCVqHlWU=; b=jcFk3PJ1/CmGz5/lRGB9iRGqb2UCbLBsEPlbcZ6hafLKzrw54R2liKw+Zwanewpctz caID7vLt/62jUHV0W2nZnwwjw5iqSPElxJoBCf060dyQaj57y1B8Dsv7YBeqqisE27RB pMTq6GkXnRQNtbZDNwi5RjYlm+0xCbCzhF2dLF+qBYOdoEReb8ZOvbrcozb+1nXayDq1 MD3VryDAdo5DunefZRbOkh71yhGygnibbcXDtHesPfK86joxJDx9d7YgPj8zgK0yECSi kjJNiV9cdU6Qk0ABfVp0CuRk+x09ShZ8UwV1xtn4f+I6KogxATa7EL2RH7AzS6zVUlff JFLw== 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=rGfY4SW9zm3ZAL+78VRu0L/Grt92YMUE74kPri69fs98ldWOBUAPNA1ErZSKmzGs4z d6CPoq9jQigZgHIZqQ6Ah1kR/4rsbpZ+/P6x+UcGUCQL8a4A/NyH9BFgizbgShWeBG8O z7ZNhrBaG5VEseRNdZtxzTzbCkZd9gdHI4yqoplTd+6YeH+OXSrnWz69kYRtX3jD8hL0 pCz++vRs8DpS+Ygvr4Uqzj4LiGSI1wYZJ/SjVhKYU12b4J7Hyl8vWz3javGk0QxBQP0q +WWIBPeOyFUrEUXAsO/Hi6BH0WxBsOkLGOshFwjNgpBfor3/P9+QujfgoL7hlPu4JQhB ysjA== X-Gm-Message-State: APjAAAVSCJpxTzQnvF//ocZzvEL8Q3l6+L6zr9O9eVUNyIetcae2KXul BdJ3oWcSH+nUr6J4AXVwfCxInA== X-Received: by 2002:a05:600c:2908:: with SMTP id i8mr2793009wmd.20.1571318179859; Thu, 17 Oct 2019 06:16:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s13sm2015416wmc.28.2019.10.17.06.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1AEE51FF90; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 03/54] cpu: introduce cpu_in_exclusive_context() Date: Thu, 17 Oct 2019 14:15:24 +0100 Message-Id: <20191017131615.19660-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Thu Oct 17 13:15: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: 176605 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp917888ill; Thu, 17 Oct 2019 06:21:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqymO2w9qJ5QxQO2LHQpt6L7xiUVRqR4asUQ8VTBCdbrV/bSL2RjtXpvbnIzUJYj6TIMyRL6 X-Received: by 2002:aed:30c6:: with SMTP id 64mr3619751qtf.91.1571318464099; Thu, 17 Oct 2019 06:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318464; cv=none; d=google.com; s=arc-20160816; b=e/t0MUIaxlc0kFy++oOJJ9+oHegUE4uhvzY5xDCoZ6T8OvqzoNPEakzMU9zJixd8g0 V2z3Y/7vbwYjc1HWNP/O5MxRldwlAp1D06b9RkBC8mS7tmKawLwzswWjpKFjW8Vyh6kn lKf9o7GMgUZKXRhGftAYzOPOMk0cE0kyDkrSGHHD5IfHD3QpNSEPOeZ85IZ/X3qUrT7Z 8HmB5rGYsFH3kHDiQGZw5YICigYFBu05x5br76xbNJduCJHCzBq9r07e+9xa0cr8wl2D RqD9eXOctNmHn1vfaf5CxxX69Y8ra+NbO6lOTv2rmHSdWA1H5eq2T3FoH5uTCDhvs+HA mwBQ== 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=jl7CYODQt8OnuvIgp2XTk2g8rCG4V8KuyWDrLSftFD95KucSR5Qps1aPs50sRre/v5 6K2mq/FoSblKHpi8Fg2gJEIBSqwFVLECBZR1ehP6krkwURGnEmzYaHPqaE44NxrLeoss FrD8q3j+J6X3+WQeQ2fZZHhkXnflSXnFMCCy0hyr6e8FMHZ1VlLsWSk/jHQspbvqT9Of iRt3HohNEznZAwnzZCSJJIE61EHTAqlkSd60JUSoX3Z0OUEvBK6uYsFaoijm+8fiif1b hYE9Gl8k8sSkRiWauxC2Hs55F2v9K/oBlhhP1b+eQ15FzOZ5ySOJRtj2QndCc/3OkSjx P+sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YzbmAveP; 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 p20si2000770qtu.245.2019.10.17.06.21.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:21: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=YzbmAveP; 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]:47216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5iB-0003hH-1n for patch@linaro.org; Thu, 17 Oct 2019 09:21:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5df-0007zL-1P for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dd-0005Mv-Qc for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:22 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:45312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dd-0005J0-KX for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:21 -0400 Received: by mail-wr1-x443.google.com with SMTP id r5so2287223wrm.12 for ; Thu, 17 Oct 2019 06:16: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=TcDnMTCbqc+SMPI8ZRIhg2t2SAwRlKS9dBsRR316T8M=; b=YzbmAveP3kH7nfi1Fd1MCw5P8sEtLkh9oaa0FdIsIlgTJpxxai+H+uusU5scFJbqVJ IuO2sBK3Q3/T1zq+kSSJ+nnxHcQvZHv7GSO1dNcv3MLIDqFe9zbIWTzAMT+FQIBn4WCR mu7CgkOxp8KQmK/pBhq3rirs1AEtQ87YUFhWg+cQM4LdCkAUrpsS7qe1AxkKHWQnr46s YHBSP4r0jlmDndyRHHjvu+Co7eFTuStk79rHh7wwdbYB80c/zDTsVN0URPuszI7exnWy B+MQU9Tdv3AGcfn8m9t165hNc3G7UYdFvWg5vRh/GYoDdT4UlInoJD3TBbWEVvxtYgA0 wuIg== 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=WvyPJh/LCi7wBjZl8zoE6Ye7aSZjwSy5TdmWX0sf67bZisUlT7E0+7SdTZv3r99SnC aVUY/skNtqMF5KXnOcOxekBV+x+vR9SFL3ioERnVI3DaaOT8/QdkQQ6DbluBG0ZFv9AV +95JiV6qv8LlHroAOisb8zWd0CHIHB/fTJn9D2tMY3UeqVc71kzT6y83yTaFumLBsaNl Cgo35fBiOb8UtVOhIK/8eCDNJRWw7P8vHRzNx8HhRQZGynhptQcGBJwW1Onw6cqiVKEK LtURgUHKSLTI6Z7pz+1iU9jZ0CQEdxyJRANDQRFd2QUqhFSMXtTf0RaZ48tctFR1KEIZ 5Nzw== X-Gm-Message-State: APjAAAWK0pzFn8qrca7Q/sFGwdXINnrIQXUqXf0eY2532kEve88sJU6J 38jZBcZW4JrK9bJzsJSjiy8w2Q== X-Received: by 2002:adf:e74b:: with SMTP id c11mr2905615wrn.250.1571318179027; Thu, 17 Oct 2019 06:16:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r65sm2215123wmr.9.2019.10.17.06.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2F0BA1FF91; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 04/54] translate-all: use cpu_in_exclusive_work_context() in tb_flush Date: Thu, 17 Oct 2019 14:15:25 +0100 Message-Id: <20191017131615.19660-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Thu Oct 17 13:15: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: 176606 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp922461ill; Thu, 17 Oct 2019 06:24:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGNFZRVarl6fIxl8PsnLYtI4fzP/q6B7FhF1mt+tQ38sALqnXSL3Xb32b50Er7htPkZVoe X-Received: by 2002:ac8:72d4:: with SMTP id o20mr3797435qtp.366.1571318674425; Thu, 17 Oct 2019 06:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318674; cv=none; d=google.com; s=arc-20160816; b=jJTRW3EUv2uQEvztm7wrFOE3Ykx+3NMV7LZxRUUv92gAQauEE9UzxwJhcaZ0amiScK W2FvDz9PjCuivqLpZqhggmXRUPur6K7Vy9H8omnpOfoBn22sJZT7BTvi+aIW1hB222yJ a/VvWa/3IJWgM4KVTd+VhQd6GZlb8uOwfys2QyowW3DhDAr8UGRMKCNnt7uT9kBKBmNK 4f6+TZ0zR00+fjLRPgcZaoEhp2VyiL3mogwKYMqTr8tlk0SmUKDcCnnNrEDox7zJZcO9 cYMqykT+dvVuSyxErgnSB/SBMGFS5MWPwPl07tZx+2/ez6p/H5+omc+Ra4p9eV4vpXj3 Tk7A== 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=PpIshHFLTGwEjHqf7SVWRmKF+B79qXhz6YDgYCo/3s1Pe7Ar8QTlXyz07LDbaQbwZ6 p+zB5LdEpA3P1lD8Uu/MmSkg7RXE7A1hqQ29xCm+kmjCKspY0hkvrJQSbLU2NTeV4q+v i53G8nZ5QQ2WaoYG4YbhZYthPIRctpolnRZRgqIF5DZFVVmuJOCWecr4I9/1nSHyu5K+ O7MK458AKj9lUa6Hbj0Rkchf9QSXTg2Rpy2tYOd+sYqESUyFmwuZ+MQ1d+h7k7dfdCdc 6R0w1F4FeZuzIqzbM+HFP3G2xMYg4tLhHNqdLFLoJ5WpwSiH1StwFNP4kKWEm/0dJ1kA md0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UZXsKnWt; 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 i24si2091834qkh.127.2019.10.17.06.24.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:24:34 -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=UZXsKnWt; 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]:47388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5lZ-0000SB-Eg for patch@linaro.org; Thu, 17 Oct 2019 09:24:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33896) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dg-000810-BO for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5de-0005PN-Qr for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:44362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5de-0005NW-JO for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:22 -0400 Received: by mail-wr1-x436.google.com with SMTP id z9so2295602wrl.11 for ; Thu, 17 Oct 2019 06:16: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=Yb3UF5h0z67h7aWNI1Qg9AnW+g8R23U+pnxlZeqlysw=; b=UZXsKnWtcnkNTzA1iCHj+upMFdVXTtiZOC2PSNjGo8I5no2Z2JLdRnGek9wlxkUWsg MMxhFXe0cVNy2I0tN8hQnAgB29MNGWaWXJUKVgLpF/GnmHQ2d96RkJPYymJXA+B+yL26 uLG6aZJwgZ34TQz9fBEoG+2aVxwLBRa4VrgGhXQogjgZKg5xJhse5wT0bS+eK5zbah98 Isbra3+hjm/pK+n4NNKoEYes5ptttifIMgeFW1b3ru/EagW4DXcQNFRD1XT2kcXdkmSl jxSRMwOxhahETAnMB/QZ7KSDlAFwZERgvvvmRscnzCqHBONKVvp5ECwtCHUOqKPVD74M KYpw== 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=HcDV5NhJuS8OZAXz13+dXL+ZtuGkTJNxGKY5EHlQOA94s8vDGPFOqVPgRU4Ci126fH R2GVQNwfIcvP2XXaSOa9t8uRYf0IctRxSz01OYmiK6y0jYX5j8vOjQfcoLDDRGwHarle BC4G63xZGDW73ZOTN6MG4OEIW5yq/Q4tEvsFGGbNjS341Ljd+9TklaN7TRLlzP4w5whJ dBkO4YkUDUoG4ZbEK7CvA2Go1eVZXTGv/tSUTtq4V9fIe+T460t7fss0LQ3RHOMJeJyf ECbmMc13/rza5Fo3L4IJECvFNppMr1w1bbM0hfKEfD6oXr+oYJfU7ucggoIrZMbvBsjX M40Q== X-Gm-Message-State: APjAAAUIkX5iWPbLb22q9T6nHQaRULXYHZDj6uWJPJzhx68UefN4e5aZ q3b+DR+MQ4lFWrVimZtXpet5Vg== X-Received: by 2002:a5d:4302:: with SMTP id h2mr3152122wrq.35.1571318181295; Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f3sm2016346wrq.53.2019.10.17.06.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 45C371FF92; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 05/54] docs/devel: add plugins.rst design document Date: Thu, 17 Oct 2019 14:15:26 +0100 Message-Id: <20191017131615.19660-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::436 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 Thu Oct 17 13:15: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: 176612 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp932347ill; Thu, 17 Oct 2019 06:31:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8NCuzWMHj3Ae+lWnmH/emkXfhjESAnuqyehG47QlnkRMuox1NJehhRBEPvMS0kmWQs+bc X-Received: by 2002:ac8:4749:: with SMTP id k9mr3754517qtp.257.1571319107636; Thu, 17 Oct 2019 06:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319107; cv=none; d=google.com; s=arc-20160816; b=iRvA67a596hiTBBvcaXskMtrcNlM+w+bIT0wNXTODiTmA6J/NwwH5k/dBOjlkFP6o5 6d9yQStC5hKUYED96pt8w745LfTL3B6hlmb51tgKhToCW9fmT8Tc7mD+o1p6NunVvzim t5UKVM12okDNr34mGqOi2C/oZZriGiNlkC7GWn9P1IT949cNkTBbhVi4gOn9F0iThg7c bY4GeLbUiCwE9V0nWB4W6xF3TldC6gRhyRreC5PgNIrMKN0MSlwtM7pree2plOCCY8y/ LmbhdN3RWE0ClgtuCrtJ87KsoYYgGP953sdKvPyQMiYiPAy4bBaoNiRAJLEeXAa2kgYH nLqg== 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=Na/LzVev5nwIdOWvwUR3N08HwQSA8Gfwy4+1yYXMCI+mfJmxDEg3Qi7uTU88eT7ylZ TWZ1cbC5vpIQsHIQPBvHdT05O8IIrPjBBTQOdqoF2JOzrUoQmMYPG5UExFKBDfaX9/j8 /OLe8+ZmzoJBqhHiQkCb2/cvicL46CRDKNqiDGgmXnzQVp+RELBt+CYOsNChQlHb5CeF 2fZazElpixXE0OyF2ATWFfmYx2I+6uQp6JW98vobrAi6fKl5Z8iDliIe+86GFj30mbI1 fkOEjIJCMTWQuDUr9D8wQvPNvQIbmpy24MdxvLqBa8VoiJMZh3rTttEeQ7LQO0JJpxX5 veZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iMdfdwj8; 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 i17si2251322qti.113.2019.10.17.06.31.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:31: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=iMdfdwj8; 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]:47722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5sY-00018f-Pm for patch@linaro.org; Thu, 17 Oct 2019 09:31:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33893) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dg-00080w-AA for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5de-0005Nk-0Q for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dd-0005La-Od for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:21 -0400 Received: by mail-wr1-x441.google.com with SMTP id r3so2319014wrj.6 for ; Thu, 17 Oct 2019 06:16: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=jxSf2lbuW5KJiixqzN79rCXNmB+////wViO7YEre93M=; b=iMdfdwj8gkyW/+HononaJbEEZ844boMUIfSaBU0o+Hs6IpV/1Qw5AQtjb+RHxL2Mwp 6JUpKc2d49MaO3iG2DZ2FbWmyfZr5AoiTinDEe3Dh/NzdynaO8rs5RtbZs3dLni9Vrzl GTKHGKAl31nHY4NtzKK6qQmmC4hfVQyYbE5MHfY071NC8F3TQ61qRX7/au4BWG0iXMTR 6GA5uRPXgHi3gFrASmpSRf/EEApTR4tYi/MixBbVeUAGXv++mShBd8G+/5GUs4w+Fy6m JfQluUT8CWgeXpX2xlP6ojx/xzdlndYQRi2doEMpTxhbQJ0jnv/7IOcanQE2Iu9Wfn0M eUVw== 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=AiKNsuNoNoKcwNw9oa2y0xccJQVoOJ+BUHN+O24YDrKbvipmFoza5VNqcYZxau7wFP WklAxH6C0llMpVLh+O3ABm5DZC8jxSrvcPJx+jsXJ+D5tl/RHHBXRrU/jGZieJVfZ/WQ BP43LG2PCuWW0XViDGH/2ZG1qgnBi93QC98wPxLZeUwiwUFpjDi9JLZQPUYwyOnHTXAT IAcfGAcBhGluPboZYUUhHadV3rZfyY/VmDBUyhUlfK1QmArsxXcxrKip69ZdRz9akMVE tFvRpw8IfDwHxVdaIBA6DtnrtETr06AiNCmyhlV/lP/FjHAWPYXhZowZdiUh1QKvEmPJ SG9Q== X-Gm-Message-State: APjAAAVsA7RbOTtHsSETSKeG8/i1sho9EKqL184IAizchLRCyT9vSwM5 pSDlR5IWjf/JTgyFV2S4h8hBB1BjzMQ= X-Received: by 2002:a5d:50c9:: with SMTP id f9mr2925736wrt.36.1571318180439; Thu, 17 Oct 2019 06:16:20 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g17sm2158196wrq.58.2019.10.17.06.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5A9EA1FF93; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 06/54] plugin: add user-facing API Date: Thu, 17 Oct 2019 14:15:27 +0100 Message-Id: <20191017131615.19660-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= 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 Thu Oct 17 13:15: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: 176618 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp939825ill; Thu, 17 Oct 2019 06:37:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGDPI4jkKGezBLXlDQL8BXi6TarlKYz4Y7TSmUtvvzGdndeW6PHxDDaQZ9y6aTUrw8I83f X-Received: by 2002:a50:8e53:: with SMTP id 19mr3835749edx.134.1571319445266; Thu, 17 Oct 2019 06:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319445; cv=none; d=google.com; s=arc-20160816; b=d9zkQla7wZXWVNkBeXaVL1BwLkWcRs9VQ9z/beVH+BM1YdcIVzkQiAl0BCjY6GK74t RDwKACJkuUDoXCjn4434gGwHarLPtub3E42BdMdVdZATPJACZRdbEO6eiLVM8S83xpMU qEt+K5XYciKWu5Mysw0kBeN8Qw8Em8GMoNs1qgQvFcoBAEBKb5ce2+fCMnJZhEPL+r5h iwHRf3gMdMtF5c0DXrTVf03bgn2DXXCHMKwFdyW+fnF09ZKglBwwsT0IM1NTPvVZJnet ecT3NYhWEUPj5mnMqBEhcSFM861tz+dfmWRz3umbB8SYkd8unmzw6Og/S/Xcvqm17WRT AcMQ== 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=yuKYDVURJsoh7ltrhZ/rRppynX6rAlAjmrHW/gLUgw0=; b=R7xnLzk57v67pxkN/KltieQlcKIFI60bVnym46Gd+C5EFrdHxYggHPOIU1Gw93Jufk PFt14FOEkHHfuSUSVp3EyI+qsApI7hIlYl6dKWBamcjFmJfpKlzZAxdQ0rxB+3lYz/AK ZFBJOZwmHrwWBkMkfealNPsKeyTeQU8bPea0s0cXwT408tIs7tuXSEN/0vddeppUn81q fJZbA9BNTv2Nu4zpZlUYNShpaXoTsv0Tyz6wpH9jmeLtExHgSORpU/kSAFjihjEcPhkS WfXjPO2vS6WCnA+jPKTvK4DyH+OlCfUMd+yWa7vkCBbSKO1Hq0pDXQfLfnoHtwVb3HTr h0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rqIwv0ZJ; 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 v5si1662691edm.313.2019.10.17.06.37.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:37: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=rqIwv0ZJ; 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]:48058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5xz-0007vJ-Kp for patch@linaro.org; Thu, 17 Oct 2019 09:37:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33981) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dl-00088C-L1 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dh-0005Sv-HQ for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:29 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39879) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dh-0005Rc-54 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: by mail-wm1-x341.google.com with SMTP id v17so2488920wml.4 for ; Thu, 17 Oct 2019 06:16: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=yuKYDVURJsoh7ltrhZ/rRppynX6rAlAjmrHW/gLUgw0=; b=rqIwv0ZJe7hxzbAYcjlIIle1SwMdlPVtOM+l383xFe7bUkxF3NqOJPGiE0KQg9guwi SbHKjiRtbMRk6M4bW+QLa+Eql/XoD/tQRwJ8zI2nN0G9Bdkv/NIZ8kqEUZcWCUVU5nVl m5KGGQJ4ZEPtpBj5ASlO0LpsE8hCMjuCPuVqxOmmGKbUISuv+AVAwECy5d8CjnPMXhY9 H5jxxG+jI4VynHYb/a1Hajw4mWnwcN5mLWwi92JvWdUXNqfcWlP/949L/bwqBYkbuUpK 71cXawBxd/jjBUDT0G+lXhh1TtNdnbERktJCJ12YrRvM6LqW0wTU2T73Qezq46lvxA6e 14MA== 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=yuKYDVURJsoh7ltrhZ/rRppynX6rAlAjmrHW/gLUgw0=; b=MJBTNv4bory8AteK00Pspmb6iK3+sujLscyvWyLRVraXML4SAWwvsQ6GE+br0K/kNQ WeUsJjYK7RK+SD5IRtHx8lNeIqGKUWybexJJX3zMKl2MqeCMnVlKt4mvIkWZjefl2mH8 TTVObgJybBtUuapHF2Mv1tqC2l/vMLEq6zP7fDDgWJ7PUasyNipH9E4DG0lILUyp4DiI t1/KfTZGSLDaPXPgweTndG/3n+eC3m/nWUmsUuzReVm6Z4N2URHAnaRly86Uu1UAcV4Q cxD0Yy8M6ZvsYsoX5PZBd46ZNXhzU2k7SliaZ0hv9fT23ixn93akks9tYbvT1PmmOSMY H1JA== X-Gm-Message-State: APjAAAVaJRfS3mMGN4t9JhVkixVnQlK0HfHdMs0eJKUeshZNzVXhBJkJ 4RRE0cVW5PR2FSW+3+azd9zUxQ== X-Received: by 2002:a1c:f709:: with SMTP id v9mr3037833wmh.62.1571318183174; Thu, 17 Oct 2019 06:16:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o22sm2469933wra.96.2019.10.17.06.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 80EA21FF96; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 07/54] plugin: add core code Date: Thu, 17 Oct 2019 14:15:28 +0100 Message-Id: <20191017131615.19660-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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 v6 - call plugin_reset_uninstall directly instead of API function - fix up some checkpatch warnings - remove unused QLIST_HEAD that checkpatch warned about - use gmodule for .so load and link operations --- Makefile | 9 +- Makefile.target | 2 + configure | 3 + include/hw/core/cpu.h | 6 + include/qemu/plugin.h | 255 +++++++++++++++++++++ plugins/Makefile.objs | 6 + plugins/core.c | 502 ++++++++++++++++++++++++++++++++++++++++++ plugins/loader.c | 362 ++++++++++++++++++++++++++++++ plugins/plugin.h | 97 ++++++++ 9 files changed, 1241 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/configure b/configure index 08ca4bcb46..412b1e13af 100755 --- a/configure +++ b/configure @@ -3607,6 +3607,9 @@ glib_modules=gthread-2.0 if test "$modules" = yes; then glib_modules="$glib_modules gmodule-export-2.0" fi +if test "$plugins" = yes; then + glib_modules="$glib_modules gmodule-2.0" +fi # This workaround is required due to a bug in pkg-config file for glib as it # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 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..11687e8cdc --- /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..9e1b9e7a91 --- /dev/null +++ b/plugins/core.c @@ -0,0 +1,502 @@ +/* + * 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 "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; +}; + +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..eaedff577c --- /dev/null +++ b/plugins/loader.c @@ -0,0 +1,362 @@ +/* + * 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 "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; + gpointer sym; + int rc; + + ctx = qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); + ctx->desc = desc; + + ctx->handle = g_module_open(desc->path, G_MODULE_BIND_LOCAL); + if (ctx->handle == NULL) { + error_report("%s: %s", __func__, g_module_error()); + goto err_dlopen; + } + + if (!g_module_symbol(ctx->handle, "qemu_plugin_install", &sym)) { + error_report("%s: %s", __func__, g_module_error()); + goto err_symbol; + } + install = (qemu_plugin_install_func_t) sym; + /* 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) { + plugin_reset_uninstall(ctx->id, NULL, false); + } + } + + qemu_rec_mutex_unlock(&plugin.lock); + return rc; + + err_symbol: + 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 (!g_module_close(ctx->handle)) { + warn_report("%s: %s", __func__, g_module_error()); + } + 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..5482168d79 --- /dev/null +++ b/plugins/plugin.h @@ -0,0 +1,97 @@ +/* + * 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_ + +#include + +/* 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 { + GModule *handle; + 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 Thu Oct 17 13:15: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: 176613 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp932903ill; Thu, 17 Oct 2019 06:32:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEFH4KubsqlBZ4KlqCFT+ma2R3MFzw2E55W67sKwYIVHXe59dU2zDRvAMf64EUBZNyleAR X-Received: by 2002:ac8:550d:: with SMTP id j13mr3754424qtq.37.1571319131479; Thu, 17 Oct 2019 06:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319131; cv=none; d=google.com; s=arc-20160816; b=O5rvVtvnhVStXOLfRT2SPOyDln05+Ijd+EGOsXykaShFoBMhP4frO3VmVeaiQhHW9x vL3QBKxTI0sl/fYNHAfm7kTte8ARQonfzJoALKAmiAqa2GQpScrn1CKNoBbWkfsLzB3c tJVHVcmGpRWrJcEdJhAGP2LXaR4DgUMREXKdPxIr88O95CVZuPwnTFMz1LcNyzI9QXhg MJCM6PXPgOmbFBJw6XnW/nOZ1H84BOVv5GaaJOWSkmnEgD9hxgDdFOWVY8vKaNuGnEWb N0U7P//WXjvvDBgMkHCY7oBLTs9hRtDLE1YcOxMbHEuSc6eov83fx0XX/qC5HN46yJYc vXHA== 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=1K5R87gH+RKq1gBcfzruUhBEbc4LEOKl5E0k+gGHnl8=; b=pCrzI+Upuvo098NZRnUs3tkDnbh73Jb/94ATSAjJKzEb+ClKW2fKEG9RXdn1EKJ7G1 ltOPSiFN0D8o4j4+Ac5MUgJDMXsxj5TvM2GTk/+W6rJzlPVTxgaMuupivtA601PxoIqK ee931c1Z91agVhVobsVq//Jof4CSJ28LJFohuePu48Je3GA2Dl310Ybb0RAa1AliVqyA kiREeYolDZSWGjl0io9E/ZyR4Wk3hAaV4PlFf8iPfCVROt2Kvw5sLD8hsRko1nXu26Mx hM3JEC3OQkJIOKFQszkapP6QsMXZAp0HIzr42uuZ2mMCwDSJrzfdMwlf9YMXpFZADRSC 0Mag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Efwjq8f0; 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 i20si2291818qvh.194.2019.10.17.06.32.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Efwjq8f0; 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]:47772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5sw-00022a-4S for patch@linaro.org; Thu, 17 Oct 2019 09:32:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dh-00082b-Gt for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5df-0005Px-JD for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5df-0005P6-9r for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:23 -0400 Received: by mail-wr1-x444.google.com with SMTP id j18so2299754wrq.10 for ; Thu, 17 Oct 2019 06:16:23 -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=1K5R87gH+RKq1gBcfzruUhBEbc4LEOKl5E0k+gGHnl8=; b=Efwjq8f0c2DIJJXvD72ATIyCNpaWymKuB1m7wRUfG2rucjej40Et1QRYm5HdJTR7Nl lnWmTn3qs0EyWFnhrk1HYigdvKZDmT/zHwuFMGWhJo6RZuETwXZXrK9MHTaEmIH/AkWv HOGBjrdEnyLFoCVlxuTggIzVzQunC5zKoJmZ9Q2C+m1bfh86hNazOTbKb27mzfClb6k0 UDr/QGPXGfc3tB/ZTIK+Ysa8RdvFcyVgkvz0fI46m7KEu6c5heEPolzPZtyjCnxV4B9s mL9rJhkaiE0BJuuhOrttjMNfTSb6mfAsEg8ksrsWusQZ5Mp3iP0gMpjqTWOR6eufbrZ1 Fepw== 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=1K5R87gH+RKq1gBcfzruUhBEbc4LEOKl5E0k+gGHnl8=; b=BPymHttejEBmnEczK3op6MdiHlKR1yrpEjEvJua8zYVIucE/X6hlSYxpvFuJXXqmYS +qYhR5Pb8mwYHygdUUMXakkzX0BSzVeQtqpbnxzmRtwAG8EZhsWPP15Wlqxvi0csDzfX S9Bv95RzZN98dw6Rqx0I5Xe7iLSidlNWWSZHZTZ6TL1odcMeVxrJ1FHTMP+ifqGgryw7 isXeRQvIKwOqkblclkc9UALtQYKRHrlQqiIBVuSsZOc+WtONglWbNwtpusuyr2Z2dRSo 2hUa3m2+6mNQbAJhOxoErQ3Xtv4SFKp/euIHhw8RnxjJ25exGUXdskw/04mUD7IVLQZv K0sA== X-Gm-Message-State: APjAAAVWLRBGFfTm5+JNIsRv3ZH9mLPxs8AWl6srgJPor1cHk/by/dlS o5xvlOrckkxpGvvdlsx3WgZ67Q== X-Received: by 2002:adf:ee81:: with SMTP id b1mr2770255wro.58.1571318182052; Thu, 17 Oct 2019 06:16:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c4sm2063264wru.31.2019.10.17.06.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:19 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9948A1FF98; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 08/54] plugin: add implementation of the api Date: Thu, 17 Oct 2019 14:15:29 +0100 Message-Id: <20191017131615.19660-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" [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 v6 - drop hwaddr queries from initial api (in later patch) --- include/qemu/qemu-plugin.h | 3 - plugins/Makefile.objs | 1 + plugins/api.c | 277 +++++++++++++++++++++++++++++++++++++ 3 files changed, 278 insertions(+), 3 deletions(-) create mode 100644 plugins/api.c -- 2.20.1 diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index d9c1ca3b4c..b9a4a4b684 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -285,9 +285,6 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); 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, 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..facf2a132d --- /dev/null +++ b/plugins/api.c @@ -0,0 +1,277 @@ +/* + * 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; +} + +/* + * 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 Thu Oct 17 13:15: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: 176617 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp937857ill; Thu, 17 Oct 2019 06:35:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzg4P3TeN2R/4vZ13KtaZRIqTSe/+Sa5yUBZ2g26JW7/+PLj3EKjaMYlU7QA/PE/+y55kIZ X-Received: by 2002:a50:8d8a:: with SMTP id r10mr3827474edh.302.1571319356877; Thu, 17 Oct 2019 06:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319356; cv=none; d=google.com; s=arc-20160816; b=0NcigoqtpYAx6npKe4dw5VfRencHyFHgtY32GnlCX8CkbiHeDCjvA4/3pWebRYUKHv SiVnZTkyFvTc+avsisuRlW/3LYJRGtFvpynh+gh3arjYPLfyh4Zb/zOnGweaYmVyjrsn zUg1VkBxBHHaZd29l4Q+S1iB7zUB3e+w22INj90irtvKeVKGuSgHsJZR5x4936hwjEdx kqHaUKlLidWaOscU7F1cT1yW/bStw+k5blvx/jMOffP4Abad7kVxdHX6PDKfRjDwaaKU rBHgYZRban+zYoj8FX4D/0BnYO5pZkzt306AwFNEF6Rk7xfXSp2s2PZr2Niu04PL+oj6 0nWA== 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=D8Sg+MuUYvHsCOLKRCM3XKO3UjNb0enMfi4iq+zsrLQf67tOhN6z6CJ++165mwX7KF 37uBsk/KPfTK1SfW9Oa5g51VruGKlMfwwBCNN1fG2naJDnYPuqtJO8ja6G1u3I2GwQOc DQSD3zxTGebMvrXAiVwCq3mDnUCmJ2l2KaGOZ42Ze4m1aNzI9LoFi4o7b596YxlERDXd jTuPnbDDLTd+GfLc6OqsNAgiYe7hgFKZ8wuOmk/0sZooInE3a7AJFPh857krqngmgZI/ /d2mfnhzGeQHVutsrkwElpx54xySc6xgBTHH2ENgLMGXN4Ina2AusybYhcc50NuJ6NY9 LD/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ANtwZlKj; 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 y47si1604446edd.236.2019.10.17.06.35.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:35: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=ANtwZlKj; 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]:48032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wZ-0006MP-4e for patch@linaro.org; Thu, 17 Oct 2019 09:35:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dj-00084v-9v for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5di-0005TI-1M for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:26 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dh-0005Sg-RS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: by mail-wr1-x433.google.com with SMTP id z9so2295786wrl.11 for ; Thu, 17 Oct 2019 06:16: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=4u0DAyRPQyWfOOgltou2F/pxj6T1sopcMhD6CsKad8c=; b=ANtwZlKjptqrzZntw/imIkxEzMzWSUisY7EV1BEnF/0uwTl3dTLWAGKKv6osJnjR9p xqmMvanFuHpDEwIOatSLKhsrSljVKFvXy0a2g5SWOtLIvfTVUpwkQceNVcPnoMO5OE2t h6grn74EVcYUcMwwqWrKj7LtjMCrADy0huaTdlrcq2ycir9rL2r5fGyDgGqSVaKe5VsX YdQqwRQkOeocY/mngB6BcE7LhPCEzaExQm+OGJndQlj39VWLyxXpCsXjZXs5b2styBTn 02/zEvKa7EWMTiRM+WjUnJ2X9QlS1IZG1HQX0ZVUlh9/I+WECQB8k62DZf3q9loCvfa2 ZQ5Q== 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=srIFb4Nzck6x3RMMLO0jDUkiKt76a8Dc+2ZNhWq9XwnFU0U+gdJrbrruYV+ai6w+aO tueyoojdhNL2JyuSkarYV1J+4vdHvaxxIb1Jf2Ooz5aU1WgouDrhJhKo0kXnKduxHY2+ 00zFQv5m8iLbGAhQ1qTRdtUZfVvEEajoA4Txwoy6jNxy+V/tVlmTco0K2j2fsbhRkI7c sLKGlP4w+xml1H2q0FcFffhT8mVSAIT+xKO1doUtgDg2k26vqCyoq5THHe4zC61yI8Yp ErZX1P+JyElZxvinaLuwiCOT6fjXWQ9cL1+qkvHvT21MKFpzjq5vPJcRQ3fbqJ/BuYKD pXDg== X-Gm-Message-State: APjAAAW99f/qTzuFDmpr85z8sClBBde385FkYVMfqfBew6pRMzSXwGO2 YYB/Rg7pNqJvSyhzmDDxvSrWzA== X-Received: by 2002:adf:da4a:: with SMTP id r10mr3131057wrl.356.1571318184632; Thu, 17 Oct 2019 06:16:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a13sm2245583wrf.73.2019.10.17.06.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD7061FF99; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 09/54] queue: add QTAILQ_REMOVE_SEVERAL Date: Thu, 17 Oct 2019 14:15:30 +0100 Message-Id: <20191017131615.19660-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 Thu Oct 17 13:15: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: 176619 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp941849ill; Thu, 17 Oct 2019 06:38:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRKglSQjhgcsKCGcx0GsyWI8BJaVbPoInsdjUShp+Ib2xzKf/E5qU1w6171p/BUIEcUI53 X-Received: by 2002:a05:620a:1211:: with SMTP id u17mr3313410qkj.310.1571319539671; Thu, 17 Oct 2019 06:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319539; cv=none; d=google.com; s=arc-20160816; b=spUaEx9vHgeyG8OHYTpLJyjBDX7UkcEaTnq+DZXdEVFnud4A06Q7zpBOHavVmof9Ep tsCrdqeDNOjhRDnPALy9yqaEFsjpmkgpIfwcEVUnd+PGZ+nHFYiEG5SrqIvLtLqrJK+7 aQV7v80B8t/3oePtdXyiP086IUJIbSGgWDNEiP/4OIB9KHR9NIm9z8i6y9SmZDKaRLZ3 p7zm01MMp0aTrt8C0GMTvPy8PQtpze1xnj21NcySUG+oR25OBftOEeA48TaE+iBNgZPT zQ1NBsM3s8j9vsql1r1B7nnOw+YpaB4aOHLSzS+YCElFx2FPNz9TcCAR1kiM7zF+pQiF +d5A== 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=K+1mXE6c26sJ05xL/OiaWYUlLkihUxvX+Cms6fDNZy0=; b=cbtSn1ffXPZcrboZ4Co2YGt3RmUhXAsGsLRaHA4OqQUhdEhWzqLPkiINTpCCu+UvQK RGwK48FoSokfeGenkubwM3DOk4A0+LekhsE00hgVTqzvTN5tKcFfUlTkHEGAclymkDWD isiz8auV+G8AP/quIP0OwkGIdxq8tMbDxhYX6QslGp7leUijCeWP2YeiKAidQyXSfEd2 864XpNaqT1QVoO+fJO/q+qhsq6LmB6tDx0aoY+ki17NIuG+mYW1s3OIl/xDw0dKq3Yck Vqk9LvqwsTlt9zsNa8PQImaKgxcnwm/dvQ7UZkHR/HklPWdj3QKjWWZ6UC2wcobX2+eW aHMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=skQ4kprB; 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 m190si2208791qkc.320.2019.10.17.06.38.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:38: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=skQ4kprB; 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]:48112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5zW-0001bo-Tr for patch@linaro.org; Thu, 17 Oct 2019 09:38:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33952) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dj-000864-U6 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5di-0005TT-KS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:27 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5di-0005T8-Dp for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:26 -0400 Received: by mail-wm1-x342.google.com with SMTP id p7so2527895wmp.4 for ; Thu, 17 Oct 2019 06:16:26 -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=K+1mXE6c26sJ05xL/OiaWYUlLkihUxvX+Cms6fDNZy0=; b=skQ4kprBFAkH6oRF0+0aDe5wxPbSBlRhVDQnJ4CzGC3oW6HSeOiMVPpC8nm24LTfR3 sbLuQRbOsNSMVF7leDmgObEZvCNoYQx/EMfsWS8k4UguHuLbZe5sNVH9187uYMd9y7Tg yB79vjBUa4jIwfsCLDtUPa//vYzI3Ec1axACdQMe+w82KVElgBWyPljirDvYjqF4dIxK H88uEPHQu+xi9h9Q1z8RXum+YvSHDD0FWoSm5hfSsaJvhtwYXL9pKmLI5Zop5n9rbH5b srfwn2aBbfUzmG5E8mjLUK0L354M93sPId/SIOvIvlK0ghWUF7yK8BGkwkud57/rftqd TQAQ== 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=K+1mXE6c26sJ05xL/OiaWYUlLkihUxvX+Cms6fDNZy0=; b=F9+6GWWAs9D4ayNL8x/SCj9EeDKLEt58SH9bwj4hJg9ZRi9ZwB/bhpebD8a3r/Y47X CUxmciX48ycRG2nDjraYhrm95Pk/JS2kIezkkNSDPLx3Fcts5qcEtbZmiKxfgh8YpFBz punspXyeGDi1xGTDFqQAweWsNeN6ggqNvew8s+d+UvnzUjTvyGdd/cTJxqJv7l+0NjIF 3H/aCQg6tk1TzYajybV59o4Ky49Up8lTb8HuTzyRTDehP90Mqu10UN4lF4OrHtm/29d/ ZL8bZeiczWwWBd7sIQOSZ29Cfcr6MJdq23bg/Ze05ivF3BzKEZiEdbL7fEc5relVBndE 5Rew== X-Gm-Message-State: APjAAAWHVO5U/99WipeMrmU5XtuJck8/9obROnT5qZbZLfozdFI9/5u3 l1NeZ75mE9HlLtKsTcSk91Gsuw== X-Received: by 2002:a05:600c:29a:: with SMTP id 26mr3060695wmk.127.1571318185259; Thu, 17 Oct 2019 06:16:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u26sm2387029wrd.87.2019.10.17.06.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C2A261FF9A; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 10/54] cputlb: document get_page_addr_code Date: Thu, 17 Oct 2019 14:15:31 +0100 Message-Id: <20191017131615.19660-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 04795c49bf..e4206cb173 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -504,7 +504,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; } @@ -512,8 +520,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 Thu Oct 17 13:15: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: 176615 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp935090ill; Thu, 17 Oct 2019 06:33:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw55eSqr8t538DKd8A/ySYEk+esrXGr5I06Fzy3oC7OMbm1tWrag/fdtXKssOrugtRjO+mY X-Received: by 2002:a50:b083:: with SMTP id j3mr3763005edd.15.1571319231223; Thu, 17 Oct 2019 06:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319231; cv=none; d=google.com; s=arc-20160816; b=v417DlU3wlZjRHM9I/oPr658YfsdNNK47sCj4m+NgCL3hg8PMuw2p1S6j9KhrT/mdQ SGnc6a8hZAnqNBp5vhlSKvG8IRG8pxvbjxKGB1u7XohqPUZx3/qmyE5CVW7kPOkN8A/1 +Fa7X4jbMtnucz8z22XqXH0a36LBZnyDkj9pYQ6iP4DdJiQaGFp8nEQvdiycegTI68GM tII79ip6duQh6vAtVSZUTs45KPg2HRvkdLAcfQ6R/yMzPIywK498Gsq7ww8lLHU14jP7 p1Lg4PcWZ9FYquzEaqKLisls+2R4UxAggzzAmMG/R5S3x422mJT9/kO3nzC3THJS9MrE g3FA== 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=lLM+xKKxPEW7VAxcx9ZcpQ8DuflKLaTBtk33YYXEM9o=; b=RLMCzSwX8Ifj47oQMeI6kY+1NIjSZ9n2lF++UqJDEIeelcfRnuM0lidzuyglv4svlr bOmwkhms2F9UYLQHzBWhDpPfgDW4dEIxtWl0v90Ybd1lLYWhY1i1LbuKb7pU6fKOxKSz F05aYUloWy0+tFZeb46DeormHe7psxFQ2aXnVd2staHKqxN/PR/akAhBY3BfIBDc2jrw +lsmFRGeGbKhI6Oqc0St9Uc2m8HEcnZJ0MTQ+3NYsa9d1aX+FDrZcAYmq0mFmstN5a7m 5R5rfC5jMaFvGW/Q3O+0KA2Gu4wDsBbRVM9Ufx6u6DQKCGnypWY1xLRXDhrOjg8dE94R SopA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h5jx0zyI; 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 y54si1732450edb.217.2019.10.17.06.33.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:33:51 -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=h5jx0zyI; 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]:47908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5uX-0003aZ-7d for patch@linaro.org; Thu, 17 Oct 2019 09:33:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33903) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dg-00081M-Jt for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5de-0005PT-SZ for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:42411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5de-0005Nq-MA for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:22 -0400 Received: by mail-wr1-x442.google.com with SMTP id n14so2302635wrw.9 for ; Thu, 17 Oct 2019 06:16: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=lLM+xKKxPEW7VAxcx9ZcpQ8DuflKLaTBtk33YYXEM9o=; b=h5jx0zyIIhYP5HfBCpDxUm8pyJ3IONYuZjTk4ZJM7NQLrtWlWf4FU5AsIVuB4McQzF n3ZhLCAUgrcttQMc04m7ydpcNhT4LNjFXSYGXZXUoN9c8E3MHjI0yBhjAI03CN77101N oYiIx+c95oMT+I1ExVZQ4woT/l8Z5CeqdQ+r+gI56r5kK/I8q22RVjHPDRNbQrRQ8L5n 8nT1q/wCq0WG8PIP+IMa7budCnHuoM90oeibe76Oriqv7ZZMt9jNZbjAM1DZpBeaQGud YvvtBUGknanoWmZhGAJbiHo5FgEXtJ8SuLq/UWctsHLw9MhMOOMeoPnFjlC00a1tY0b6 1cCw== 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=lLM+xKKxPEW7VAxcx9ZcpQ8DuflKLaTBtk33YYXEM9o=; b=qudc9jkBWt876yeJml8VZVurEkMCAwxwd3g9jU0r3KvXN+zKh3HpWXpfbxToqZGNKU FTbAZoMKFIto/BSCrFvjhf9nP1EhdaibUrPDCsj/2Sw5ntLTIBG8a44+zURv6Pm/ij7o 7p3auvSFS4CyLcqEvZb0QfwsZmhhzkvXCedTgWu+hS5AIvD5S9z43kgztGGsXmQ+U6ln /Rm3tck9ygBGdZlZUeGp7Bq5GvijcF1E40C0Ro76uMqsxGMzYK5okLWN4g8lEtkpXCTA 4jMNRkpEz0PJeUxLVCIJLuZte1oHj2qnOOjUQ3/v8Bk8nGwVpiCCtcrV5SpHqfwTyNl4 LcgA== X-Gm-Message-State: APjAAAUTSmlilrexoJBxtaxPgzNqcZOxPNxCUhQBCYGSnV813HDMABy7 yTxvwBgOa3zzY1KIGMdE2nDTkw== X-Received: by 2002:a5d:544b:: with SMTP id w11mr1444015wrv.205.1571318181510; Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z6sm2419443wro.16.2019.10.17.06.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DB3F41FF9B; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 11/54] cputlb: introduce get_page_addr_code_hostp Date: Thu, 17 Oct 2019 14:15:32 +0100 Message-Id: <20191017131615.19660-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" 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 a8f9069582..82a5783a2b 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 e4206cb173..eadcf29d0c 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 */ @@ -516,6 +517,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) {} @@ -533,6 +554,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 Thu Oct 17 13:15: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: 176608 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp924821ill; Thu, 17 Oct 2019 06:26:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqz716ZdkZ2UG1vZfVVIq4l7MgbrFUSi2EIwr8nnn0zHKePVbidt9P2MjqXtqaYF4V4ngmey X-Received: by 2002:a17:906:60c2:: with SMTP id f2mr3439886ejk.21.1571318778879; Thu, 17 Oct 2019 06:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571318778; cv=none; d=google.com; s=arc-20160816; b=B9St8S4xIGnox7rfCbW2usa+Cjbn5fDY/Mt5+PPMa25QuuHRb6O40jFwwb5ToW/FCW +1IzCyru6z0xO1wdgEAOtSlEELQ6+jAjNUKwjVgxN3nq7n51jkrGx6nCiaR1rHxj9PJb dvfeWqV6GMyROhLSSP5POir+Pr/XlKl0GAAhLAOFYQYIh7lKtamBXsK2lZcS5NpWf3v/ kiIxW9+wniwH75g+Y7aiDr235dHs7T4vS7I2LwwPEBzIOl/Hrd1whoxW8ImXUtajEg2j BTzYBseacjvucw7wdn01Rn1EKcnuXCe6+Xp0DYald3+UFNWW76lneET2axU+Te3KZR6T 5kLQ== 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=yTJNj/ajpR0KRTy+XV89mpb6vbahmwLIMBG+tLT9XatYjFTGkZD2A/2FUeERJyixEB i2RpG9+KLdxaT7mMEH+zcqbYZ9wc8IyrBpPcFO0fS1jslbYgavlvFWAYqZXtkl3kHAqH wqcOnprrtst8caXwLANM5lo7Gai4JNAeUuqhagHhvjv/vNvxS26juwHQHLvkgcR3si0t YVndiMRw0Z0+2q5ep6N6ETNVs8FLCiOREKs4/wTo/aWhVND6xix/BhtdsRPjXICS+bC8 miZD6BgT9Fk3rRJv8BXjNXFcNIPpqg3Pya0ghur3OmrxkvVrW+yj5V1vKW9Ueuyk96j0 2ERw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v5xN3Jku; 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 ox5si1279162ejb.252.2019.10.17.06.26.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:26:18 -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=v5xN3Jku; 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]:47562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5nF-0002xd-Ai for patch@linaro.org; Thu, 17 Oct 2019 09:26:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33877) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5df-00080P-SU for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5de-0005PC-OX for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:23 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:35617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5de-0005NS-Ij for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:22 -0400 Received: by mail-wr1-x431.google.com with SMTP id l10so1903837wrb.2 for ; Thu, 17 Oct 2019 06:16: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=eKrMpcgiWZC+DVZc7vkQy9WeCAb7Sz4gQtueyAwrb/8=; b=v5xN3JkuIt3wd6wuymwE0JqYIExwsxOuaFlP8UbfenSQRQlq7nm5pKzNCAWfSHg0iP P5f6UOXqVGD0f6/3mx5gVKJ8HzKoDQ7xTIj2WInqLRug/7jM9c2mfhcFedT8X72G9nEj XhfinKMtEc4aQlfS7J49ZpV6N+c3vg4Qez+p60LTzFp+2up3pUqBePdWzp9AAhHGGirQ lpLS8tC+wij/+qbgoi7RlIJ2Ut3zABqgRAfEMCgSaJG37ZVXBQCpXwjJgrUz2+W4WGO9 wXrxCeyX186iYd5IkreeA/oQ+AuUe+ERqLYf+KZ2bqvdcfdTNPtWWHYJrBQUzeuFQ5wG WNzA== 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=SsZ8awDeqWOLC14HfnctaEuMkA+Z6eBc4I8dK8DOnpg/H9zDCYAr3oPlUIw6cZc3Sv GBDtlKoS1rFLEcvEvP1Vvlo8lkIgfSGOFwql/1qtFvX5Mxpp9XdNOPJteDGoUgi8bBfx rv3qyQ16gHn4Wjfb5aTxXVVbQQv+PdOGlVrWsAJ81vvVO42QqZHiafwKEOnC7iOrJQCi 2re9MafutsXfdBns1u3tXVyHilPYww0pUWJE+HZtk/TZn134C5ReKVRGTUCCioyabylm Os+zayNjZg2QRfZ3UuSa5eV7NuLCuEy85SGqi542Aq5i3jsDfyoQf46VcpKUCz+lLfon wU4A== X-Gm-Message-State: APjAAAWeU+3mQvUX3siPEnk+yXIyI8T8F1skTzqzbQ5zKAayt5wpOCWX iZvbKVSfkB0IWpF/pQsVzXJ0fyFx+sc= X-Received: by 2002:adf:ef0f:: with SMTP id e15mr3146256wro.312.1571318181446; Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q14sm2681495wre.27.2019.10.17.06.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EEDD81FF9C; Thu, 17 Oct 2019 14:16:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 12/54] tcg: add tcg_gen_st_ptr Date: Thu, 17 Oct 2019 14:15:33 +0100 Message-Id: <20191017131615.19660-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::431 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 Thu Oct 17 13:15: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: 176628 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp949742ill; Thu, 17 Oct 2019 06:45:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7I98PPuuQwOCqLS36wAzTEbAjoWQVrOUtTjxkjD3A+CbmnoBIg4m/IOTIheZYJOrfk3Hr X-Received: by 2002:ac8:1732:: with SMTP id w47mr3979969qtj.167.1571319919861; Thu, 17 Oct 2019 06:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319919; cv=none; d=google.com; s=arc-20160816; b=gFj+RduIy9lIwJcQaULzMgQfaHjpN/apFnymOX/oqg75nqwX02FV+8ZZ+IalVhBdvt ts64nJy/ZyXZigI3Alh6QTXXR6G0dh2XEN5/MTvWutll4zScX5lbhDwzWr9JIJ7JjICj hK1QTpEBJGWksmPjf+QxmYcvDztxR8bEWBXS0v4zgJwD3LygNS8/nQiJqz+1pdRq6Fqg FxzSHuVqT22DlJGrhN4KnUoASUfe6of5/ADIqMmq7Y1oMJAhrpnrcQuFGZ+hPgYYly8h DiYbt/adjSiwf54AIoHKdvHGREiWexMq9GGbYzKPMLPNwCeiDZm4vPQA8jxwT8UqbfiM +O0Q== 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=X4ubSfXf9LMCz4CmM78ihd0dpybaxxssEegRSSDgJVw=; b=xgT00KiJXylud8FK73zuvWiXV7VrpnOyIOE7MBni32/U+PGCpqLyVDFdMhCKd3gx8a I7hKnJjQ6KrL25YHS/KrZ/uwtzKHyiUjhTZ4ycwdsMEUplJEcxLBIMk4mlENbiDHl6zu pstxte8JlD2OmWZRL+d5liTR2BdzSGWIS9wjeH80yXXWpq3nwk4gcsjxCfg/jXLBPnj4 FIFzm77HfYIDMkff5TpSEcNaBTlS0gYD6zA4mSgwSMyzQd31tjQ8MZc4xboH7sSAIKJ+ tmw3zvOx4aHk0vsoNSDQnwFoc6AH29NFAe4U49K6vNx11LUDxWqZ8v8Zp94O4ru/2C1D O6gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EXd4lAa8; 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 28si2170004qkr.140.2019.10.17.06.45.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:45:19 -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=EXd4lAa8; 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]:48248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL65e-0000pa-KO for patch@linaro.org; Thu, 17 Oct 2019 09:45:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34049) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5do-0008Bo-G2 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dk-0005US-A4 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:32 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:41855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dj-0005U2-UY for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:28 -0400 Received: by mail-wr1-x435.google.com with SMTP id p4so2307396wrm.8 for ; Thu, 17 Oct 2019 06:16: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=X4ubSfXf9LMCz4CmM78ihd0dpybaxxssEegRSSDgJVw=; b=EXd4lAa8fVHbwnSIaDxjase+KRLULdExAr8RvgVJ4tC09h2eYsXcUmFkv7nkenxRoA BbADLrZnSI61qoJWrZ8ciehzufNMt/C1MjqsTL5cCUSiZSOem/9bZHyUBOoey5S3w5E1 jOgXBWleYrKM9zM0Z9mdr9ExmPR7j2xFXhSZXjDkS2Ar1VXamoVK5ayu4sMdonWWJdw+ 0+Eh2r/41gJFMjGRNYSIrQjoGMAYtUwS3TFADrM99k+M4hRgNa4w5dy7ha6HUqqVZ4Ht taESuk2uEj16rztHHH6JmZZEbEZgJNOHTPr/TqQGxoR5bhjM6m8LQymLyhJdtR54023p iQVw== 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=X4ubSfXf9LMCz4CmM78ihd0dpybaxxssEegRSSDgJVw=; b=lMg3aeDkNhYsCUkb29gJA/ZOHWfkEZNS9b6crQIcgKDrqFZgN5ISeXtFysj9wwvy3A /+ejULA1xdpRQudUbh/wIBRe6LJr94sQuGlGtzrI305CI4VIBlW86v2YdZtz+5AFCUwf x0ijv/f9XFMKJ5z8g7sLy+pFQUg4GYf8XTqB0NAgZiJrEode2xKhQY1xg7E6phdu0cLn vnJ7FoWZQCjzKAuS9BGGtvvzRmlen1JM2zT8aVex7PoEKIsGP9Y0DkrHx8OkkSbz22jf 5lbIdglSmsH8D0u6N4IwGHhoc12HEK0bB07oXr2uGs8GZGCPANjQjl6k6U+SEpVZTfAG 1xtA== X-Gm-Message-State: APjAAAVEbNSvz+NzJ9fAb1EFaDeeVdEcMPbRb/t+3HJdn4+HbDkCnvH4 Cn5GY68RqYaTh2B18nsILAhqFA== X-Received: by 2002:a5d:4010:: with SMTP id n16mr2963591wrp.152.1571318186130; Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h17sm1945052wmb.33.2019.10.17.06.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 222361FF8C; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 13/54] plugin-gen: add module for TCG-related code Date: Thu, 17 Oct 2019 14:15:34 +0100 Message-Id: <20191017131615.19660-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::435 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 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 Reviewed-by: Richard Henderson --- 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 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 Thu Oct 17 13:15: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: 176658 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp989188ill; Thu, 17 Oct 2019 07:14:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZxjdaNDwgSGdO0njke+h16Zem1Hp8M9TfoV6EfEBikevjl1AcNm8FRmMhXHkrY4vFGZ0z X-Received: by 2002:a05:6214:154c:: with SMTP id t12mr4085866qvw.127.1571321683190; Thu, 17 Oct 2019 07:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571321683; cv=none; d=google.com; s=arc-20160816; b=OtBTCzZHncK1Tc+jSf8MLPXCQlAGmEmxro3Dgni79AP9xjCrCahEXcxPBi29Y6ZkDW FudXbdIas9tggyji9Umb1r8NiD3+azMXgpDYKQ5By+Swwit8OFoJBFRre+a6wowNNOGM TXNNyuCTa2LvpmRRa6SdGE0CYKKw8sbsXrW65paMeG33q7J4gvHqSs0Tu379btm/u+y3 vXI4W40olhZb135i1AA5RqHXrzY6yMSX2vwPHHaqun3vU4CwSozY3Y9qEsaCVwZz0PI0 fmhoeLwFKMtWTm8ew33sKyGf3aKZwi4pjILiMUTPsy5bTe8wnax7jbWojLIagXQaA002 6ngQ== 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=FkyqsSZiNzh6QFniSMV2nSfJU4ChEgQxUDVAYQOrs1k=; b=sDDMQbLGne32ULqKxwaSVt4w7HBgYO/YRRUIMXEvGfa0a2OuFOLIDL1BNohkn82H4j tCBSzzRSxkYAgF7IIfezWWIci5NYHA7rYhCGFmFXZWFM+vVU7r/ETTTBLuFjExX84nIF 1q749aeqpp3LENZ0Q1OGsG+s6/VZOztGxXbHCpX5fSqzsX1dmmqb49grwE1VhBtJCNGE bSNceBmQKoVW4FYqs+Pfb5CZLNFOIXIpPG595uNG6BYPQ/kGt68KsOv4s74dJ73opo4L Y3nNc/L3b3aSDgRBKmgJxwxMb3ozePe7SXClrpEP/pRY2zQ9qxdamFkCV2EToABZiZCw ym1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=agVWFdb6; 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 h14si1985811qtr.22.2019.10.17.07.14.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:14: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=agVWFdb6; 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]:48976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Y6-0001tw-9T for patch@linaro.org; Thu, 17 Oct 2019 10:14:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mX-0002LQ-IX for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mV-0001IU-H9 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:33 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:36726) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mV-0001I7-99 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:31 -0400 Received: by mail-wr1-x42d.google.com with SMTP id w18so1790808wrt.3 for ; Thu, 17 Oct 2019 06:25:31 -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=FkyqsSZiNzh6QFniSMV2nSfJU4ChEgQxUDVAYQOrs1k=; b=agVWFdb6xR9jTKnFeitq2vdLHIBqXzOTbfYjacaIBKmrTZdJbF7G4lyXlYU3tqkCGi Svwm0mY/kj7EYTcRMAt0vQpYYCdgmqgCWoOjg/uXBzYdXs9qvTTjtL3kN8OCQuyDlIOK T3O+XVzlaZK1MU0XCdFf+TOsF+LArOEu7t2g8vtCE7apNSs7lRHiRILdr6SLe+vNLVBm qNaF6uJgfdZuTBmIdeNTkuqdp5gEmWsq7o9njwILR79GlUcw0Vg3dirF2+Qikkyx3TPG 741NqBHbOCcUodVpmXnC2EcAanm7gFsbMyU7YVoieBraMiKBom4zCI36k5VG4+Kermbo qVIg== 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=FkyqsSZiNzh6QFniSMV2nSfJU4ChEgQxUDVAYQOrs1k=; b=O2X8uSkVlPaVHotFrTH4DFWNWVfKXKJGPskZgbME2KBSl6D6pqaJ7N3uIcHudrv7wS PxDMUJK1Xt5VkSbQh2PrFekhIRkZ0DrHt608YwiC/eTZmAAPp8C0ItLrRPaHdWT5ip2b SLmsm/qPjNdTZCtoXSvEG5wEaIno7jo+z1v71wfVIbWsKlCuJ3UDooaGICbA2uqAoHEv X+dU/cLYg34punnMt69GmgDSa8d4CR7VWiectH0vDRLEeAiJe65MduGva/b5oW6DxGpY hM6hzXwZLpqSEy0D4guNpK+vbuiet3gqgrEZGlYDS9ZeaI6iELoGqLPu4IHNmLZcofV+ oiSw== X-Gm-Message-State: APjAAAWuiVUqp8Gw6/O1lb15UsV4h6TPcMYvCPZrRX+k6tiUvQK3fCEt FUFz8T0zBUjmQ/UfFBoSADV0Xw== X-Received: by 2002:a5d:4a87:: with SMTP id o7mr762789wrq.374.1571318730049; Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r2sm3115786wma.1.2019.10.17.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3C0501FF9D; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 14/54] atomic_template: add inline trace/plugin helpers Date: Thu, 17 Oct 2019 14:15:35 +0100 Message-Id: <20191017131615.19660-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 v6 - rebase fixes --- accel/tcg/atomic_common.inc.c | 50 ++++++++++++++++++ accel/tcg/atomic_template.h | 96 +++++++++++++++++++++-------------- accel/tcg/cputlb.c | 2 + accel/tcg/user-exec.c | 2 + 4 files changed, 111 insertions(+), 39 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 473d7e5a94..84d3370bf0 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -59,29 +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 @@ -101,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; } @@ -118,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; } @@ -130,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 @@ -143,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; } @@ -157,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; \ } @@ -189,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 { \ @@ -198,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; \ } @@ -235,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); } @@ -252,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); } @@ -264,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 @@ -278,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); } @@ -292,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); \ } @@ -322,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 { \ @@ -331,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; \ } @@ -358,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 82a5783a2b..82282d30d9 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 get_mmuidx(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 8d315a6587..b09f7a1577 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 Thu Oct 17 13:15: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: 176648 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp968281ill; Thu, 17 Oct 2019 07:00:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWHIB0MCsNIAFQLwfo2D/VDpjQdEK31LxbBKwHk+/H5Xmd7VSpOM4tW9CP0FKa04O8XfeD X-Received: by 2002:a37:ad19:: with SMTP id f25mr3381519qkm.361.1571320832051; Thu, 17 Oct 2019 07:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320832; cv=none; d=google.com; s=arc-20160816; b=ayCTn1Kb+dzCmn0SEdXx9bleJuNKOewqUozOWDxpsr2Re6aFDXjknbtvPNFqeriGRk K9N7/jtvxrZGorlrUUtW8BXZJw4M0iL16YacZEQB5J4NNIzMUTagpj8oJlGMhc4P7OQd Vb6YXUiMZAfJWqtACDlqsMxmwm8BYVLZRnn4DduPETWZt6JyFLrUsborJDMcNDIoqNe5 yToXXg1PrvGRZpA8YGW8S3uY4LW4qkE+zT3UIw6/aDXW60gwImaP+QSbklih0mT+NuGX /kN/vjB/Eh21JEb0VUHJIu6+aHyWvJu18eVcSOkgCQ+GzRrX47uIMITzPiC1aOpU18qV 67SQ== 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=IfES+584HSyI7NbR1r5tJmwd02109CyXfgI+SsGXGhc=; b=QJ5XBmhjqB7QuXdWdLKJuCnOdvxEtMaKAFFVFu0MmqkIoxcp8Xu0nt17zgxQvMThJS E3sKqzksV2paz+IHOpQAOOUweTfpOJb3moTyAiwvMrRIpdGEvEDOJTPoABJN6AxTN4EN jz+ID/QQ9VNboL+yk4eLWnpTCnJbjZeq9fDh8CRHid1tOV6tfeCI0ROaAvBD4FDhBuGs onlXIDa0KOO/YVHunfku1EjdbZfm8XQAa4Kbj5+TxuixZqlwjS9KocdfGY0aq7F+6AB6 U2JruQlmtv4qW7hItro2Mvzhc+plCGA7YE5eX11xJVkXW/XfWnWJZRglni57vLqbGb5C ALyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vyaNr3yQ; 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 j5si2324388qti.159.2019.10.17.07.00.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:00: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=vyaNr3yQ; 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]:48652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6KN-0002zD-1j for patch@linaro.org; Thu, 17 Oct 2019 10:00:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mW-0002J6-9l for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mP-0001Fd-Ux for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:32 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34797) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mP-0001FJ-Mo for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:25 -0400 Received: by mail-wr1-x443.google.com with SMTP id j11so2375673wrp.1 for ; Thu, 17 Oct 2019 06:25: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=IfES+584HSyI7NbR1r5tJmwd02109CyXfgI+SsGXGhc=; b=vyaNr3yQP4ooj5XdVY81Nf7pb/xuoVgXX942jDRppY3mka31Jijgvd5c5e3WqSd2dX ZeNo9r3nc+tIY2PPaJdjl34fcJ06nyaG4i9hw05ax+qftC6Zs+kTaBCJlMJVXGAWUIbt 6Og06dvUcyDQvqKcVswJXEmRBY6gRLegm+XDQj6hqP9mhlGiliFazI3NgQ4ueRhWGiIY GAxJqrFxLheZ5YNFtpwB5kGxZQwGxkehvk2HYoEm/+cqc0Kl/c2S0chffkTZXJq/xkkS BVRH2RSv492KNaRsBuzALWpyXG4M6jZGHAA2dH5NU/vWgEhTWwJeBYASsBUGYfnrVfQ/ iMsw== 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=IfES+584HSyI7NbR1r5tJmwd02109CyXfgI+SsGXGhc=; b=Vw5UHzcW+3txEB7LR2oKDHIH6uZ966Q3plP+fZiy5o5+Bpfp+f0LDEgdTVGZRDq+7z 1NEe35kM5G5BTe+WUsuuQcIaMd5WZOB2U1QCVWGyK/psopMQL98PQR93O/ExpI3dQB0/ AMvxY34GMtzoPW8NuO31UKcihVEg/KZcYlCZsNPr1NmCfZS1gbM9uAzwApY/LhUC/3wf vsuhV6OapXQIfrIaqgeo18UlRUWpIeO85xC5YTTTOoZx3H3yw20nPrROheDw5Gwdqmyj noaaahRl0VrzXokoM4pesJTP5A/9eczT5ZxWkHFBQsTe1P2J6QTJltQpLb+leJ91UC0N Q4nQ== X-Gm-Message-State: APjAAAXc8nUG7udxRiJ1thECozZV/GJESP7ewWjSthclSDiqe0fI1NGp 6Q6hWoaXN/OCnUXKXfI3dQb49g== X-Received: by 2002:adf:f686:: with SMTP id v6mr3277174wrp.141.1571318724380; Thu, 17 Oct 2019 06:25:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v6sm2860197wma.24.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5B9AC1FF9E; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 15/54] tcg: let plugins instrument virtual memory accesses Date: Thu, 17 Oct 2019 14:15:36 +0100 Message-Id: <20191017131615.19660-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 v6 - rebase fixes --- 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 | 32 +++++++++--------- tcg/tcg-op.c | 40 ++++++++++++++++++----- tcg/tcg.h | 1 + 8 files changed, 74 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 93ad532f94..dbdc7a845d 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -64,18 +64,18 @@ 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, MMU_USER_IDX)); - return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false, + MMU_USER_IDX); + 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 +96,19 @@ 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, MMU_USER_IDX)); - return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + uint16_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false, + MMU_USER_IDX); + 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 +131,11 @@ 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, MMU_USER_IDX)); + uint16_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true, + MMU_USER_IDX); + 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 Thu Oct 17 13:15: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: 176673 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1036113ill; Thu, 17 Oct 2019 07:49:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8o0T3xKquf+UmjKhsIpzE6fJvuEtbh2gg/24pLpMU4FxyIl/ZBuvSpy+E6Ls0bV/tzgZS X-Received: by 2002:a17:906:6847:: with SMTP id a7mr3866208ejs.261.1571323741543; Thu, 17 Oct 2019 07:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323741; cv=none; d=google.com; s=arc-20160816; b=YIBI8KX6MuMV5zn//vAonHluC9jTT0UET4geFkmi9P0m73OTKLId1QH/jEUZDY3yiA CnYj5hJifTf0E8jjo9q41dX9hm2wva0TjUmuky4O3tp13zHeymzrHl5rkpnrOEcd3UaN 4ffEmNojIJ5uuN/P+k+AXWteQGyxzWPzxNSvUS0gmweYeAkEcyFsXfFS5w3vQUiEuTvN skoFPC0TdVbfqx9Gt/5oHFRvW1pTWONPe5hr9ougRZ+5QrdjOYGsmziSkSDFFAx3K0Pc cVd13wmcA3C2MSgy+OaJj5CXtiaDx8ddgGMslF0f1XYbcTqP64xp656dhdrSsnKyBKNR ovXQ== 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=ciNF6SAJRuOiY+C5HOxCQCLrm7QppdZGV2meoQ3PBRA=; b=LIRLziUISnE4TdkqAgSPuayAR83fwqZ/vFuf/KA+NciFftviPOL/HRK7SFdkyLEHSa RZBHU8DDRckZex3ZGGrcnSvOXPKZX4kZgZfM7Qj4w0ZGcBjOo3AJOERGwpuFUv1aZnTu i3lQXQPdfuAYvR+cgE1Jx9LJMGp/7sS5b1RYfKNfGhzWIYrVib89CbNa37kyuvSthvor aju2zlajyJpe/e5HMPIx978w9G814UeKgCQicRBwGKBej+0nntl97GRjqNQ32oT+FaAV oPGpIrTX2F8Ocy/4R0qdqJDVDOS1+qmJpCMFOT8S4ew90NfCk3F0YPkgNaVTkpXFswuj E49A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DnAvsztg; 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 l15si1517900ejz.74.2019.10.17.07.49.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:49: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=DnAvsztg; 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]:49700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL75H-0002he-PZ for patch@linaro.org; Thu, 17 Oct 2019 10:48:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wH-00064Y-62 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wF-0004ZU-3t for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:37 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wD-0004WI-5C for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:35 -0400 Received: by mail-wm1-x344.google.com with SMTP id a6so2585675wma.5 for ; Thu, 17 Oct 2019 06:35:33 -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=ciNF6SAJRuOiY+C5HOxCQCLrm7QppdZGV2meoQ3PBRA=; b=DnAvsztgNa1vT56WhOo9VNDKcAc/61/H8LUvYRGeiuJ3Yo1lQHhrVOytHJxH0Dgq5Y zC2d/Pz0p7a1naUu9vtoFP0HCmxJK7pULWMKA8I5ZNTtHKxV9/e+NlvaauyuRGyVQwTX z0epBWsRkGpLA6FE8H++4qSx1Gh1Ae7vlKM4FEwassjZARu0BXj9iLbQIYQXSCK3z4U9 CrOAK95H/gcyCT1qY596LtrcFPl2NEFkZ4X3RwIVeA3KlVdwTozd5gd8nQIqo9uiTx7e auBfAA9vT5BU+xGs9dE3ZbfPxnduVb/7GPSWIAmm7CWZ8Q3zwQf0VyIEUdpeEYMWTxc8 wxxQ== 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=ciNF6SAJRuOiY+C5HOxCQCLrm7QppdZGV2meoQ3PBRA=; b=bpSK7A/m6zNzclnCkavXLLEUxh9L52vRhU32oosRx9lqVRtOXSjvE9J7C6kljGXyzx FT7x6H1HG9f1QLGSOCi4rMTwjFuRwOeNPzY+wh3TyHhZh0dNK3/a/orQCqNrnNqGmMQ+ cD+8BMY4XTYjJj4rq0QOZwHUBIgGbjv2Jl/TEEL0HXcstFW/dit7217rLdMsSPqAxFly uPaPdEUORYmHQ6lKVZ9l/XBCDOYIliKl4Tj24a6LFT9d0PsGNfUWYohqv9CYoPofPHFK 2tlujyzj0uN6wLsqBonUPzY82HNvSn+fP9F2w01a8egil6FWknaZO61b7lkQcpAh/kyd XXXg== X-Gm-Message-State: APjAAAWTmMj0SaU2bqiEJj266O5x++B7qezB/h1IEkuD8h+TpQ/bPfHJ kTitw33WXi8S7oBFtDD9HlOvuQ== X-Received: by 2002:a05:600c:2196:: with SMTP id e22mr201555wme.79.1571319331868; Thu, 17 Oct 2019 06:35:31 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q19sm2908150wra.89.2019.10.17.06.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 74C831FF9F; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 16/54] plugins: implement helpers for resolving hwaddr Date: Thu, 17 Oct 2019 14:15:37 +0100 Message-Id: <20191017131615.19660-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 need to keep a local per-cpu copy of the data as other threads may be running. Currently we can provide insight as to if the access was IO or not and give the offset into a given device (usually the main RAMBlock). We store enough information to get details such as the MemoryRegion which might be useful in later expansions to the API. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v5 - use TLS instead of racy GArray - add more commentary regarding success - error_report if we fail v6 - rename api to qemu_plugin_hwaddr_device_offset - also save iotlb details for IO accesses. - keep memory api header details in separate header --- accel/tcg/cputlb.c | 42 +++++++++++++++++++++++++++++++ include/qemu/plugin-memory.h | 40 +++++++++++++++++++++++++++++ include/qemu/qemu-plugin.h | 8 ++++++ plugins/api.c | 49 ++++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 include/qemu/plugin-memory.h -- 2.20.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 82282d30d9..2c06b57272 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -34,6 +34,9 @@ #include "qemu/atomic.h" #include "qemu/atomic128.h" #include "translate-all.h" +#ifdef CONFIG_PLUGIN +#include "qemu/plugin-memory.h" +#endif /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -1247,6 +1250,45 @@ 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); + uintptr_t index = tlb_index(env, mmu_idx, addr); + target_ulong tlb_addr = is_store ? tlb_addr_write(tlbe) : tlbe->addr_read; + + if (likely(tlb_hit(tlb_addr, addr))) { + /* We must have an iotlb entry for MMIO */ + if (tlb_addr & TLB_MMIO) { + CPUIOTLBEntry *iotlbentry; + iotlbentry = &env_tlb(env)->d[mmu_idx].iotlb[index]; + data->is_io = true; + data->v.io.section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); + data->v.io.offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; + } else { + data->is_io = false; + data->v.ram.hostaddr = addr + tlbe->addend; + } + 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/qemu/plugin-memory.h b/include/qemu/plugin-memory.h new file mode 100644 index 0000000000..fbbe99474b --- /dev/null +++ b/include/qemu/plugin-memory.h @@ -0,0 +1,40 @@ +/* + * Plugin Memory API + * + * Copyright (c) 2019 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _PLUGIN_MEMORY_H_ +#define _PLUGIN_MEMORY_H_ + +struct qemu_plugin_hwaddr { + bool is_io; + bool is_store; + union { + struct { + MemoryRegionSection *section; + hwaddr offset; + } io; + struct { + uint64_t hostaddr; + } ram; + } v; +}; + +/** + * 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); + +#endif /* _PLUGIN_MEMORY_H_ */ diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index b9a4a4b684..c213d1dd19 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -285,6 +285,14 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, uint64_t vaddr); +/* + * The following additional queries can be run on the hwaddr structure + * to return information about it. For non-IO accesses the device + * offset will be into the appropriate block of RAM. + */ +bool qemu_plugin_hwaddr_is_io(struct qemu_plugin_hwaddr *hwaddr); +uint64_t qemu_plugin_hwaddr_device_offset(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, diff --git a/plugins/api.c b/plugins/api.c index facf2a132d..33dac8e790 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -42,6 +42,7 @@ #include "trace/mem-internal.h" /* mem_info macros */ #include "plugin.h" #ifndef CONFIG_USER_ONLY +#include "qemu/plugin-memory.h" #include "hw/boards.h" #endif @@ -240,11 +241,59 @@ 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; + hwaddr_info.is_store = info & TRACE_MEM_ST; + + 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) +{ +#ifdef CONFIG_SOFTMMU + return hwaddr->is_io; +#else + return false; +#endif +} + +uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr) +{ +#ifdef CONFIG_SOFTMMU + if (haddr) { + if (!haddr->is_io) { + ram_addr_t ram_addr = qemu_ram_addr_from_host((void *) haddr->v.ram.hostaddr); + if (ram_addr == RAM_ADDR_INVALID) { + error_report("Bad ram pointer %"PRIx64"", haddr->v.ram.hostaddr); + abort(); + } + return ram_addr; + } else { + return haddr->v.io.offset; + } + } +#endif + return 0; +} /* * Queries to the number and potential maximum number of vCPUs there From patchwork Thu Oct 17 13:15: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: 176671 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1035403ill; Thu, 17 Oct 2019 07:48:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+Qq6MyOoul5HzZTRXOjMj7vmNcL8MNHZP4aGR2Qegu11qtb9hF59pg2kwihRG6gKUQrGL X-Received: by 2002:a17:906:5388:: with SMTP id g8mr3857042ejo.278.1571323707090; Thu, 17 Oct 2019 07:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323707; cv=none; d=google.com; s=arc-20160816; b=Cj6RBF+JwLpB4nFpOACUimBXJuXcGFiInH1m+KEiJlsMshsRBre0GW6IQyheZOcQvW ZAImVB2YbAij+1eLPWlA5DzNbETj822filt8OkZPwrfZxNE8BwpAX0DU7ndd6AJ/VBvB 8IXluz5wDeoKyfagydEguTy53MNQfLMMgh1nRO4n/j0uRb3HIAdukb/EbMXODTQgUjMW 4BZ41dbx/2no5uq3qIi8Ca29JBe25eJcN2sZIMIKU2aUGlFOKVii0pp20r6YXT+g+E+S zBa4xGTQfP5xIUm/9VuMYNmcjwoB6olCqDCFRwGj66rYcI/6qWOI+6/XYBt0EXGYn5vq YeMQ== 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=epQRWe/kA8NglzzvvjsAgKTkBg0efmmNVhvoEjHQJySnJmOfCmCO4PvYcnUgRBKbRG xZLLTQy7kArB6X6en+k/ocb+HgmRmd+vx3l+1VbmBA+zKogSfMn9+4WTx0qG15oKqHcv WA9C67jOigzp155ZQfcBHfqzECCpxPMEL08geWJpy/qz1k4/zp9t/ECs8IPEKk9CnFkK GmAWCpFRz89pS8Cs7bAzCcIfpJnlooe8e44YaSBYBxw6tzcFT77Fei5WF/zqC4+7z5CO E2IR/e722xnijjEMKs2sDKDKHEpWMRwOehwAdgC8dsyBFfuwKMkpBj8vbnySC0N7Elpj umDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oAEcbGqY; 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 i17si1455690ejc.233.2019.10.17.07.48.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:48:27 -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=oAEcbGqY; 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]:49690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL74j-000218-J1 for patch@linaro.org; Thu, 17 Oct 2019 10:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37686) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wJ-00064d-5e for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wH-0004aR-3L for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:39 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:34366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wF-0004XW-1G for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:36 -0400 Received: by mail-wm1-x342.google.com with SMTP id y135so7060148wmc.1 for ; Thu, 17 Oct 2019 06:35:33 -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=oAEcbGqYG6oxYP68i32TzoR4Erhb3LaCyXOWnKK8XBW94sX+eHcY87oFcYUCMyxQaP Dj2i58Do/ZsjlK7YGyR/H7/PX72sMA5VFIgxiA/S+H+Ja+vuEPj4G3MeTlzShIRfLo2c bhbCYObE9qYIQfpLcetLgHEv8pzN6PrBzP1AGTYXWtwU3G2qM5yNvfAmepEp+GjSpQ55 BDbnwU4/7wL2LLtExcT1jwsStlKSo2rzjwKpvwGiri2KJsLmFJcQSXZYxeFSedxRdVPI B/7mk7O45r+wIKgXfGiDMDmad4fx9kStYpgztef8OGhgRpbCxCp24Hs0ePEtFgkvlahI dTTw== 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=s5xCHCZ0uRzJfFHADehy9lZhRPpYwM5SdmCdgEPWaimbES48MQZCCGL3rb2DqKwckL hvxsXGNntIHEGGZ+HHLp/SgyOHWQmR/IrD3dhVqRRRoBtsINSN/ekPb7jIfFT2n+CXwB RDuOCw9Lh1uF2QTdJA9Szni6KdfJt6cuQwA5cX0OVrMtHcjQP9/FWsGrXW1aZnL08tox Wptv91K51agFbM9AWsWHRkUTYenx6l8iG2QpZJKsRFe+4ZcLlRhxn6rj1iQu64R5QWmm Tl35PqXwYfjpmvgDwDsNOQVHRa1A14COdIUYnU49wox06ghPoFRUSxFyuWgyfVKya44V 5cSA== X-Gm-Message-State: APjAAAVdhs357W7C0qB6GHFfUDq1FLU8oop1pyVQmCTqWhL6P1C27tYU UU9wMwK0DBYFRQ4gC9dKiDcRCg== X-Received: by 2002:a1c:7401:: with SMTP id p1mr2843267wmc.144.1571319332534; Thu, 17 Oct 2019 06:35:32 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t13sm2573167wra.70.2019.10.17.06.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:31 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8AA251FFA3; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 17/54] translate-all: notify plugin code of tb_flush Date: Thu, 17 Oct 2019 14:15:38 +0100 Message-Id: <20191017131615.19660-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Thu Oct 17 13:15: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: 176641 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp964030ill; Thu, 17 Oct 2019 06:57:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFkJuWlSSg8JAZfvbrMw6SgeITIMPgNVfnfY2y0B+6eqOcUkEKGON9hT/Hg5+yRELTaEcQ X-Received: by 2002:ae9:f204:: with SMTP id m4mr3446811qkg.376.1571320626022; Thu, 17 Oct 2019 06:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320626; cv=none; d=google.com; s=arc-20160816; b=L7u1X1GU2GVFI8US7j/W3NglYauSm0nr9oFww8V+nIKeygiM35bhxMetmcfikd0edc wf5pK0iDxw0/Jo4IUfkVHT1FyNO0QCN0XGJ68d4ktd6RP6V795rLKstdXHvki0GBlS2t ZYrzxZsV0x07vXgQczdKMXEkaGISMUKPTLicN7j8uXucYvgUvMKJMtJW2jy4i/bs3ivo d0G0uTUakZcojNI7A3fI6nkva88oIEczVU0JjzgzR3UL0l6dKRMwOmQ1fnBTD6Ia9bZu VhvpcDMMF/fa+U3Jn8bdESYJeLXU5zxJe3TM7v5Z4bDIhNolaGd4qngyFDrQEZLRDtAg ujDg== 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=UV0gubbdhZEEsA92MKkxsFKKW1wjjWtpC0hXyHovvW7bBV/gZQpzmer04lTXI9E9bI YYp4dtwMmQRU7+dTS5Cjahqask/UDU2c8vrRmLk0xtFooWT59fFAFA2/FPK87xUwNJz9 VhF9GKQh1mERqX0I3CtoYT3oR99BT4LxHgZJ9w2S4RNvGQwhjx8t5ZWPU3WM3qOFxfCE 8Hng32DO5/jbs716l0AYiOF9rBGjY26myPLvs2n892rbb/5jWNGP9qZ7ju7T1uSzpkUA beoKWAym/SLNgPHxiXwBAT/afAj0X9Aucv8pA6htzAgRRq7xaHUMdUnokRgPt1M76jK1 5V5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QYTzuTqT; 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 f15si2145196qtg.373.2019.10.17.06.57.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:57: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=QYTzuTqT; 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]:48584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6H3-0006U4-0Q for patch@linaro.org; Thu, 17 Oct 2019 09:57:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5ma-0002QH-Tc for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mY-0001K6-SS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:36 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mY-0001Jj-Lt for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:34 -0400 Received: by mail-wm1-x342.google.com with SMTP id v17so2523603wml.4 for ; Thu, 17 Oct 2019 06:25:34 -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=QYTzuTqTRv9k4dwikGibJ6BTRaMcJ9Z22ScLexM4hESE2I1l0JLdiL8/deaPzVKLHb oqkNgssyVemThpqxv96DQcyx8jSVEkOVJIhUH5KTOQ3qQ7WTGa0pl3/KjJSHMOzRyJfo tSxML33moo9itmA69RYwIOFfdbqc9cMFdarvQryfG7tFfIiQyUGIUWfxg64scuedhWfE d8yNqGmPoJzAuN1d6mfGKK6q/Xfk7CsvrDkY8YKxrb4xMa+1lrJRzOzjihxl83+0I7Zv 9nWcdmf3807axu1kAF6yqBJDbzTr1nfv+pYFSPn780U9eaQyCOOQ0rNu1izpTuCRGfuT 8ElQ== 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=htUXtyME6fRbDISY8GCiF0ZxVGDVwv0bfofO0cVgOFJz4kj0auU0HdlIqsReoNicfU 9gEome7elAe4AyEHwo42MMEzOzgZOMtw5v2VwQuKEpL493MSe7TDBB8ItR8qxNPAJe44 ieNG4WNnT8RKaPCsRiS+Orif9PrKQV706TbHvAKOPPdKNsmFh7bN1+NS3simuFBqr/cU rsLfw7KuCbusX9mvsH5VqlumI4e3Q7tnWJHj9+yAIU69VBuVf+KqLM26/6A6P/SaonjQ s3owmwNUgC+aJ+b+f3DWGJojV+XylnpbFoQxJ/QKZ3NO7BdTsEitUlMfQzRJ/rfJ8cu5 U3CQ== X-Gm-Message-State: APjAAAV7yWOWGpUkf2Vo5JZSeR4KRPfyWGswstwQsAH6/YkSJ+NNW7Qj 4WwcJAKRrzrPm47WwJDq+JxKgA== X-Received: by 2002:a1c:dcd6:: with SMTP id t205mr2950572wmg.10.1571318733514; Thu, 17 Oct 2019 06:25:33 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k24sm10131817wmi.1.2019.10.17.06.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A22671FF87; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 18/54] *-user: notify plugin of exit Date: Thu, 17 Oct 2019 14:15:39 +0100 Message-Id: <20191017131615.19660-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" 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 Thu Oct 17 13:15: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: 176616 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp937115ill; Thu, 17 Oct 2019 06:35:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2OQGyY8KqmctiwYpJtFQFFc/T+n5QoIc8AEp2Red3M7OPX1XFcd9TrXeCX46UN/1NHYSg X-Received: by 2002:a17:907:429d:: with SMTP id ny21mr3627906ejb.176.1571319318813; Thu, 17 Oct 2019 06:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319318; cv=none; d=google.com; s=arc-20160816; b=w7xzeB35hP/i2iwzGkqfKMVVffzjEgzZR7DRr5wehTZSGRsOKVZmau7voNwV+9Muwy xRu2UPXM9UPj9ItWwJ7on/Zy3Da96prWwRXb6RiGi/Z1bDSNHkAYoTBEYpXUhZNtWp5B mkop1+cCIpVOdydUfhphYTWtDqTuuoG2FbK/Wq0YJyvs3CjPYmBYFgybBcFt8Oba5eCC R+cRV9Pq+KoD0LLs6+XdbfgVIKHgnZj4AwfPVaYjID+IAMOVpZOEmEGlSgZ2kdAZfIRo otYKoFy255UH4JVykD+Ki/9+RUQJrm2gJrGSQLUeFeaef2o9TfIa45fRk7u4Eg5SBJIP w1Ww== 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=Zh74vUOPTp0gxSs7A8PYljuKuP1xzpygb/d2J7Y2vUI6MpbJLXYH0N9nNP1NYXsGMq ryr24VfWZSQwJY74oepuXMSXewW6hwNhWZJcligjR+uXu3NPs08fukCksF1H1LxiWRhQ h1I+OJd/+drl4sIoEmKrPcFHStDTYkyAtIGw0UdSFUw+DHRxs6zJlDZWyKQfDgy1L2Jo 5c7kQX5fNxp3XW+AKM6RhHOV+GfIP3NSbhF8hqoKbnkTLvINmhODQU7rgjm4OoKoKpoM mbotBowGCbgtQZFdF9oM/dKAWL0F1lIB0wPz6Q186bLPy5pvqMe7JW9OogXBUS9Bxw/l wFPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="dSi9RR/F"; 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 dc10si1347833ejb.81.2019.10.17.06.35.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:35:18 -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="dSi9RR/F"; 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]:47932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5vw-0005BB-Uq for patch@linaro.org; Thu, 17 Oct 2019 09:35:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34012) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dm-00089i-PD for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dl-0005Ux-AL for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:30 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dk-0005UM-MC for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:29 -0400 Received: by mail-wr1-x444.google.com with SMTP id r3so2319449wrj.6 for ; Thu, 17 Oct 2019 06:16:28 -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=dSi9RR/FAGfahfUx6d4zyjw8bGdRDSXq3te/ysoRb208aIloKC9qhn98xhhuTPVYgi RGedQoImgYAVvdFeTtGCE/tKLCHQCkTmZuAV0RMxg3Bcu0Qff4aUSBmePb2EC2F9HR9E 1Ei5VLvKMifhV3xzkjU6Kx5hAcXl4i+cnp0eOAAfsCAMu2Z2UwsUgpp6KfDBcrQr6Lf2 QCJeQBUk1BRKo22B0IdFY4otpsCY9tuQAj3E3A3z2C03M81S8OsyzCitZNdvZqOfZzvj Q0V88vkrv5zNKELfrGYBn0lIapNCmx0IisKMeRJ7cag3Q0mfiPqndRB2OAxksLCRFpxB zerg== 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=rsVcXhrEjsFnrTJGL7QxlBxXRh/IiUuz/yAokWNGy5jIE7JSnewu3/eqz9iv03vagu k6x94Ksb5zFdNAkRIbuhrNiw5HTRSoz8uL3ZlcrfilZzHIYjIGtM3rKwQym+tDzoL1VV +GTMBO6Q/JBPmBsXyZxI4XjlCXiCwQltWk5IRI7XpuCokXXNJg4gsBIAI9Ya1JZg9hNa ihco3c+WfIgqNp3Ha9hN7d9jZB/LxRQM3ruxid+/T9QuTpW/mYplbfDTg/iHtdraLR2b h1nE30tJVxP09ORIfYmPO58nqE3z9wdM6g4i+JRrawrs43rdYiUlAJpuGFBK5cA25R9/ RiMA== X-Gm-Message-State: APjAAAWhsyu64r1eN52/hjXA1otVUF5DfYNOx2Zar9DF/YkbWmfLrHg5 GXIz05cvuXDY240fkTtPwhSJtw== X-Received: by 2002:a05:6000:11c5:: with SMTP id i5mr2956100wrx.303.1571318187541; Thu, 17 Oct 2019 06:16:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v11sm1984454wml.30.2019.10.17.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BB24B1FFA5; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 19/54] *-user: plugin syscalls Date: Thu, 17 Oct 2019 14:15:40 +0100 Message-Id: <20191017131615.19660-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" 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 Thu Oct 17 13:15: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: 176663 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1019867ill; Thu, 17 Oct 2019 07:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKJ3AVaVAgyHEnotWNISZyhIE4FsH8KVriBD01DXJog0dS8fZECEVqsfFn93u4ocz7kxEP X-Received: by 2002:a0c:e7ce:: with SMTP id c14mr4131438qvo.187.1571322973026; Thu, 17 Oct 2019 07:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322973; cv=none; d=google.com; s=arc-20160816; b=OewQCEEmtJuJw+Cz9OiK6RSghhn0UcJ99eqxoo8TGQZddqG3cdDCKGRzl46KO07aC1 rpeh7VRy4jnzOgZe94Yp3ifOlJak1Ot3LkBUZ7mup+FIWV5OuZsbPVIKrtOPFw2gY+it PS6oTFM7FhF8sLCTzG+3J4zEd9Tr282Ugu6IXZ8jHKTW7BB4uJlf9ccSd5+i1I8VbHXM UeX29n+mQQufC77tgMro8YPEGAZr3R11CoUwJNgbrFj38ZQCQW2h/fi5cpL17dBz82D6 YPC1rOkAwkBDMJY9T7nijwcAw8BDDwo+ON9DQSQMmdhbYKhhghAawxbWp5xM/T32LT8G aM1w== 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=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=COG6imXkx3xq9QMybcdxOVzT/lXIsLFsfSo2jYcJFvfXE5ZTgjtSTGuKZIfFbS9pBy uAjSYlb4FYnxgIVcF8e/SygRjgKwM6gXtl9lyY/W0vviPspUKQoxZZSoa6OcD5yv+tjV O2Maa94hOPuQZfcJJG5uC4uR7EPcSlnmnEB1gxSx/b2MFXhJmJ2aE0rXxlpoTOVWOSqQ fWS0iTHGD4+YcPJHI0zh+p8A1t7DiUuaF7U193YBJfVLh5bVy/86uaQ772uff2Udyf4q Bhr8Es3aqcqMNuSyoDcdZ3lgq34gGlHd4bDFW6TLXBoFRpT6qMwp9o34CIBHC7QvxG/d SKqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SdiZc4vS; 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 f35si2045875qtb.181.2019.10.17.07.36.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:36: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=SdiZc4vS; 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]:49436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6su-0003sL-Fb for patch@linaro.org; Thu, 17 Oct 2019 10:36:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37501) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5w7-0005xj-5c for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w5-0004Qj-B0 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:27 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w5-0004Pw-4e for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id z9so2373666wrl.11 for ; Thu, 17 Oct 2019 06:35:24 -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=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=SdiZc4vSEfjoFdfXfkIQyfSdh7Ivxp2mD6QH58PL2jNUPKnFotm64MxgX+9lpWDl3H La5X6Z3dSrchs0lvo47nwJBynLwkuqglXyHIIFvMvCiBXmDAhkNA+ipGO7V3CKlEemQ/ txQS0Ksxzpa4ZwiLJcyI3FQOmQYUTOhlZfBX1MBAVqG1/1xS6f0k6E01Wk+G0kJ+AhAK 9eoJgoIkird8XuMXUgFEFwQFoDV1zE4aU7wSFqB7nIFhrAaHCdBw4/oZnY+9z6QSecVi i58+Kh8gmakXVFMjQtlHuSv9YQBiCvCBVanGU+1Q+BRHWgLWD+b74sLW5YIkSzdb+MCL cQcw== 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=G6i8iHuwznpz+U1YFqKClWDlEDl0r8YmQ0dBefcdrI8=; b=iObofW0oLaExZWuoiRV6OAP2nNslDVkzUiQWl8nV9VE46ziHqqTE5mg/r5C1Qoc8gE 1vuxGquu8Gd9Xe8yz7oW18/mSysl2R3MFVtvK1WKpUwMq9pBGoQthDlX9FXYCkMGYYuX rDdsBT4jrpi2c5QmP9fJ9DMlQLQR4fg5A8CnE3aoxXOXLoLUMKWdxSipQxHKmihqqo26 uDibNpRfWYMc3dj0OmCUjdR018Y0wFt0X9+ICmCEE7RaGmH4+IpnxrqpE/UsnyuyhUUR yLjyPsVGUOSbzdARn0YeKQrtA2hAU2Bxk8CmFtSKdERr95ujioNRd3rvLC5qoxesCTI8 uQUA== X-Gm-Message-State: APjAAAW8gzm0nFenbhKbRsY6VWzV+WVjjhzrgQJY3RwGM6El35ypD33y 9NqjonCQ4Ly26wavAjpHqhRSng== X-Received: by 2002:a05:6000:1190:: with SMTP id g16mr3038816wrx.133.1571319322805; Thu, 17 Oct 2019 06:35:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o19sm2622802wmh.27.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D41C11FFA6; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 20/54] cpu: hook plugin vcpu events Date: Thu, 17 Oct 2019 14:15:41 +0100 Message-Id: <20191017131615.19660-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" 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 367f0657c5..cdd2798c0a 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" @@ -1254,9 +1255,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 fb0943cfed..1feda0ca76 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 Thu Oct 17 13:15: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: 176610 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp929932ill; Thu, 17 Oct 2019 06:30:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIcd4rSRB+Els7nywEamoPc5OHwi1Mctwey4TGNtSUAOuq5Ss4sxBXHsxEU59yisrx6OoV X-Received: by 2002:a0c:ee49:: with SMTP id m9mr3880251qvs.118.1571319012001; Thu, 17 Oct 2019 06:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319011; cv=none; d=google.com; s=arc-20160816; b=l77GqfzxOpK8/1OpaovfT8wZMVd/KxeqOQrpTrxGVsSCjQ1sJiibygru2FcguEvQ5V Ull+BuR6m9ml3WIxIlM/P5x93xIqQ4TE3hH69gLJYOxtw+EmUApRs44YjLSccF0A+YAh 4XzRGECf2E1BFAlHgy0qZzG9a89NUi6wrTjUYCFwpacCrT45JrQmfrWaKs0/ydnXYTKd EyfRLd8u+ANx87KA7LqioFv7StU941pzUEnDvhp1QURCZwkqHLzpsMTTEDo/k8j1Z8eh u+OpDQ9fDrvWaz1SClvjpLpaH0llnPtTzbgqlo4MqBX+tKwsjuXNeoc0uDlJRmBmfYe4 Ed3g== 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=nIZpYRyrlqeUhKVYX4qlN82UJTTJWWcX27Pw7yB+eepR7HlLF68RAKi8NbDnxot/ox pWj9BKHm23iN6JSP15e6V3P42rbWGo/yN6Hq3xbBHcs4EwLdadl4QowFF/ivdD6hxJoW +497cxlmiTA/KnwZeY1zwLFlDUR9QlHctg+JjG+TWHhnfhhWAPol0t96f7qeExcIepO/ B3MQwa38ZYlPkcFfj3V/ghCQ5Sn1rrRZntf/l7UjEBnBnWOGJRRxY6Ac04pB+EvBJfMQ uhYshgneGG36mW6OdVSqeSwhlMhANhTiBsntgmIJpBnof4IfTbadCcSPIlUYfaRDFqNb 7opw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FNlWDAB+; 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 191si2219833qkm.338.2019.10.17.06.30.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FNlWDAB+; 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]:47704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5r0-00089o-T9 for patch@linaro.org; Thu, 17 Oct 2019 09:30:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34015) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dm-00089n-R7 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dl-0005VP-O6 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:30 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55433) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dl-0005Uo-Hv for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:29 -0400 Received: by mail-wm1-x342.google.com with SMTP id a6so2518117wma.5 for ; Thu, 17 Oct 2019 06:16:29 -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=FNlWDAB+eSG4X+dD6IMQrw4QZ9OrnDkuhOJyxyFk4H1+DT2B6LZSbYBrq/k5E2IW4G mmp2PvfMCRhvL64CX4xqqAvvWYwqXlRToGPrr1skOD2XOURQpVZyK6LZsI6NfDzn0tlZ ruNRp3DWjs2DSmUjE2hZoHBn01YZeYCNK0HdfizIHNY8rJ/brhM+6BSGyUWaXn/lK+FG /qBHCUzkfBY6LzmeiaaMGjJCuODT0vu4u0Z8gXG09Ah0917f00cjsmcFL+9klhiTR0r5 tsfNNS/GGsWUTCdNTfRdLzuQDshFWKBvtkRXhdpdgb/LR+G3UcCpYxvEOoSPYzZibQzi yfzg== 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=BB9QC5w8x+FMR9Pi9KPd/wspJeX1Omr/lsD6bDpKnFW8jVzWs3Lm78+vGcsyfaCRQb uDbJyF2yE/DhDnoYf7JzVTiPD3jnkPiU4T7jdeNP0hlMz2bJ3SFOC9SjCuioCXXEy8qU 7bSb13P+K5woH/Nad/TsHjfupTdox3GJgpOGC3XWO3BSKc1Pb/A0vpYcN1iUy2JlpYh1 J5qjVS2ugDfIZ5KPo1vjRtkmoKeJxJ47EWuw4kcvJkjZ3E1NHNFzW0w0yJ3t0BCJPB4s M7XP052LXLRwKAheN2NnVF88e6Akk3FA+aU67F44PQaJ6Hn9CQkbdgQ0CD3zM0NmKmZr I/HQ== X-Gm-Message-State: APjAAAVq6CvxpbU2e7IVb/XdBBYEqcN4cEbtMJpmOy/zgvQz+yiinrr/ Q1RpQ2SA8bQFZXpTLqEaqKBf0d7b6uM= X-Received: by 2002:a7b:cf28:: with SMTP id m8mr3075893wmg.161.1571318188466; Thu, 17 Oct 2019 06:16:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u1sm2020353wmc.38.2019.10.17.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E802B1FFA9; Thu, 17 Oct 2019 14:16:17 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 21/54] plugin-gen: add plugin_insn_append Date: Thu, 17 Oct 2019 14:15:42 +0100 Message-Id: <20191017131615.19660-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= 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 Thu Oct 17 13:15: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: 176661 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1000887ill; Thu, 17 Oct 2019 07:22:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUn2EaRM2smwMIoMzrKfex3kRugtu7sskmpM8vfG4OZisuu0rUMhTM1jPiZp1bthZj2P3h X-Received: by 2002:a50:c949:: with SMTP id p9mr4009557edh.25.1571322174310; Thu, 17 Oct 2019 07:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322174; cv=none; d=google.com; s=arc-20160816; b=jn06WNQygSMLh9XkaC9wxmf2AXLPdJI/TLmvpSnAgPZNv5aUi1XfqoZWVvOyJ9WNk5 th3BYdEry2sMW4/cY7+5IqcFgqM5uo29alMbFia/VSOW830lF/oN5oTiUKiT6N78+gUH NjKbDLJbRrFyVbmkiRMUBFhqVoOTD5s1e5+LBvmeVqElDl5fRk5UQQMfk7MW5MNQQPNq p3yc+oHlCoZVngqdq964vdMr4yJ4Dz7z5bdcMg2GIHr7mTDtOkXgSRVIKJYtaqVaqrr8 GCSIxfZCLVllDf/GQp0FgeqR1+Q7VgeF7Fecuz+wYO1suT1A+I9q3UIo9g4+CCxMtCW+ M6Hg== 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=ESP6ykQOaykBHMJkZ60Hbuq+EhkqCSyBnm8ZbwocBec=; b=z7MhS33wN5YlYs0k1VBMjaUCInSxZDGeUQSlrqJCXfwDdt7f0AqQIklLmlvaYh+MN6 rNl7PUnCp2Au7rYgBZWNTiHAOdLODDbhpHP/ykDhX7OsaiSGhpQ74nk4u+zdrEczDpmH Zc7dmZbEpEVGMnDq8KfSEzmXmfXW+cAVgxib0arnrwjffXPSernIxt11Jv8JDi2i80ZL BclWw19ZjolWN3+Sl0bmwe2A0FAopym5z6Uw+ijPlbuocfI5plNichmpc8ObJYFHDy77 wIPItz09p1UDVZtSErbG9+OW1TNRt4axEU5TfcEak6cMrfyiTAj0CGAsKlg2xFrfMn4K e/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lep+GBIx; 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 i10si1792703ede.101.2019.10.17.07.22.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:22: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=lep+GBIx; 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]:49180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6g0-00044p-JV for patch@linaro.org; Thu, 17 Oct 2019 10:22:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37519) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5w9-0005ya-3v for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w7-0004RT-2b for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:28 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:55272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w5-0004QI-Eu for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:26 -0400 Received: by mail-wm1-x335.google.com with SMTP id p7so2596395wmp.4 for ; Thu, 17 Oct 2019 06:35: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=ESP6ykQOaykBHMJkZ60Hbuq+EhkqCSyBnm8ZbwocBec=; b=lep+GBIxj8+7UQF/2cwrN4OrMr+pOC3QExg4ODk/n+lupFsdwYmPrYa6+DbeJ01Ib7 zwyPOv+ZBSu+WP9EcMyrt8FUuX2ff/TNQHDLhW9Q0YI3EkPHmJsQOD1w0lib0wikohrU 4cXgHDG3oW880C+ZRQtzo2f2vAyxGPBgzn88sc4W5e5vDjl38mPbwaVY9vO5OsMxtrmf p47tlkZj740/MmWdBqZaDUm9sk2Qs3m75lyZqHtvO04JZf0OY7R2rIxEYWLVHTEEQKVq 0V4JidfMiKQ5g6Ztrq6XWKOEqrqDet8oTJXfuIDkqefpxiTX77Om4U573ojHmlMvVrLt dSJg== 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=ESP6ykQOaykBHMJkZ60Hbuq+EhkqCSyBnm8ZbwocBec=; b=eI/7mUQE6DI04gtG7ONAMoopa+flVGDsPBGmcVz5Xu5ccengnhxjA/HEExvh382DQs paJN7hvlN2kjzHxg6XJASZNIm9qEJL9Rj6zXZid+1K3m2MsHAP/tvlpdQSkCMGT0JhQd vg7FAmlnNPm7oe2t5pmE6gLE4ydF0kbJwHppMIN4ICPXbZS+/6YzVS/lIjufKfvzVm9I h2TWyBmy0hafXywhM1NlopKhv8YCKfhLG+g9qsAt7/iGEqMnOOIDlwSmNMINZW3unbZO I7MQVR211Dc0iY5NMrOb10TjOaqIvy0fPqAevqEnt4j26lUgqXyMDHGNeYX6XIZvt3P9 ZV6A== X-Gm-Message-State: APjAAAWrUw4oXlahAZb3BLJCO1u7uIRqevV0wTKFD6hZDBTLQeaD66pm FEOoHKBbMNO6pu3xsOdUfaTMZw== X-Received: by 2002:a05:600c:20ca:: with SMTP id y10mr3140261wmm.168.1571319324191; Thu, 17 Oct 2019 06:35:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s12sm2188915wra.82.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0C3BC1FFAA; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 22/54] translator: add translator_ld{ub,sw,uw,l,q} Date: Thu, 17 Oct 2019 14:15:43 +0100 Message-Id: <20191017131615.19660-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::335 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 Reviewed-by: Richard Henderson --- 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. v6 - add do {} while (0) - expand name/uname instead of adding aliases to cmmu/ldp - use signed helper for user-mode --- include/exec/cpu_ldst.h | 11 +++++++ include/exec/translator.h | 62 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) -- 2.20.1 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..f65d6b1a95 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,61 @@ 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, uname, shift) \ + do { \ + set_helper_retaddr(1); \ + ret = uname ## _p(g2h(pc)); \ + clear_helper_retaddr(); \ + } while (0) + +#else + +#define DO_LOAD(type, name, uname, shift) \ + do { \ + 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); \ + } while (0) + +#endif + +#define GEN_TRANSLATOR_LD(fullname, name, uname, type, shift, swap_fn) \ + static inline type \ + fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ + { \ + type ret; \ + DO_LOAD(type, name, uname, 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, ldub, uint8_t, 0, /* no swap */ ) +GEN_TRANSLATOR_LD(translator_ldsw, ldw, ldsw, int16_t, 1, bswap16) +GEN_TRANSLATOR_LD(translator_lduw, ldw, lduw, uint16_t, 1, bswap16) +GEN_TRANSLATOR_LD(translator_ldl, ldl, ldl, uint32_t, 2, bswap32) +GEN_TRANSLATOR_LD(translator_ldq, ldq, ldq, uint64_t, 3, bswap64) +#undef GEN_TRANSLATOR_LD + +#endif /* EXEC__TRANSLATOR_H */ From patchwork Thu Oct 17 13:15: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: 176625 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp945518ill; Thu, 17 Oct 2019 06:41:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbRG0uF5cB1Uvfyh7KP4lVOyfYJRKV7c3cxkDS8iYXthXUDJM86E7ynImi0LaBUvvJiPA1 X-Received: by 2002:ac8:363b:: with SMTP id m56mr3931114qtb.22.1571319713541; Thu, 17 Oct 2019 06:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319713; cv=none; d=google.com; s=arc-20160816; b=DayWikMVFf2Y1gz5+fkr3RBTU0anm6KrDktZ0YPljako0Xej0B9HGJL9SGk5T+7lbR 2V8y6qDOvB3LgNX02TfhaI4P21bDSjqxPx8kJkIvuz7OdNUPNsqlS53qPi2YpzH58cuO U6oZUIb5hU9qRRrxA2io8qmzoK0uybhVLo6oJIQHYxVKmLclDJFRvrMd1S7PSjRYLBez xtHgNkqO6PqDAatL/RlsJudjmtHX0tj2PvScd4QV8HZLGg4qzeH6l22nEsMmh4AIdW6L IzlELt51Gwj+MjbdzAqNAo1d7fymBdJdl/Xbp2Qe0sMuojGrKBo9H9kI61oh6kBIqYQj D15A== 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=yS72b19HdIEeUw0g2ykHZ9qRzc5Rbz6SYOP5nsOCPtoH2fkamvNZf9QOxwBdqua3wf ercLsSsVfOuelGOe9fY4kfr9vX03VNvOv3BNd0PKYFDR/mEEiy3/XpgY5ze/L3h6o+Kk vEguDd6bb2fVqQlvKyBA5iF344yYvDKPS7jQ6mPCrxzprXNiKrm5KQHif3zE9PQIcgFU 5xWo91jbJ8YknCkqhcFZyzmMNKNcQ56tAgCAjjxzLiTJuhWU/3n8oy3C9HphQa0mUb2+ Qj0r/5wxkfct3Ara78X27YkxMsERMkiLBASiyqABjr4YyKthhMRIBO1pyEZAUKla9r5e gqUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d7iit7GE; 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 g48si2324106qvd.146.2019.10.17.06.41.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:41: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=d7iit7GE; 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]:48176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL62K-0005JW-FB for patch@linaro.org; Thu, 17 Oct 2019 09:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33982) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5dl-00088E-Su for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dk-0005UY-Eb for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:29 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dk-0005UA-8M for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:28 -0400 Received: by mail-wm1-x343.google.com with SMTP id v17so2489104wml.4 for ; Thu, 17 Oct 2019 06:16:28 -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=d7iit7GETkguplVjVDK03X4AncYDzTUIS06y+tddHAa7DpB0mxXcW95msDS4wuBsW1 tcc8Gorj54E8srltNxdoPb+LFFR31jKTAxyk7Qxigr8eVRgktV3Te2TWy6IG9Zrl7xbY 3HEBezqm4cR6GmSgzzMzeDQzpZ0JOzivxmt6cHosXFrY8aBt6pDm17muDBvdLPk7ojFL /MsIj5gmBU37jH375hw0spuZCcuZnv41jwLjBHOQhi5+EOQ44Jj955XTsE5pm9Fy5/FN dPxsjbJe1g0YKZnmYk0OSbnfNFg7yXgvjb7t5yyrUQDE844LfNFO6k429xX5twsPR6yS XwfQ== 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=Kegx+JXwEzWS8bT3oUducbNjuXzPNz9ivMIlj6U137gv+8Qb41rUEprGpnnNZHsmMl 7QmH3w6kvEKLvR3QSU0/dqcI3UIw0oi8HxRJquD3gnqYFjWDvzkdhgneI8h+SfvlZNnV Sq8q5xYX7R1oxJmoUwUOVu7WSexaivaaAzHjemPL0fXd4LyINqsw6BstJPn1o4VV9qF6 n/tI4dz8e2msI8hbSHiB0jDSwMK3B6eeadekq7Ecfe+b7+GtiS+Ne6/+M9FyGjNpqaUt 71nn4TJqdR/9EtGXE0lpQ+lkMLNGg5aizUOxW/DooNcuXxv5yE4RyMJzGldYasSWFevu +VOA== X-Gm-Message-State: APjAAAVRVf2qKYmhoxFUxQ8yzW/e3dhhfZZ6uOQ0ve906rG9qjGsWcl0 igsHRYNJFSkhUqgtvUAq596KiA== X-Received: by 2002:a1c:6308:: with SMTP id x8mr2901372wmb.140.1571318187069; Thu, 17 Oct 2019 06:16:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u4sm3062810wmg.41.2019.10.17.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 207D01FFAB; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 23/54] target/arm: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:44 +0100 Message-Id: <20191017131615.19660-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 Thu Oct 17 13:15: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: 176623 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp944608ill; Thu, 17 Oct 2019 06:41:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxX37mkdqQorN3H428sxyvUckWs1zaJWhxnBojRshM6SRCI19CkevmxVxVlmSoyd4RI5Lqi X-Received: by 2002:a37:8185:: with SMTP id c127mr3245662qkd.420.1571319670722; Thu, 17 Oct 2019 06:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319670; cv=none; d=google.com; s=arc-20160816; b=qxdebDPSw9ly5C/rYNCl6TpLZWhG6VGFFQW23d1xExwmLi5ngHb/Dpi+XjX4P+MJqM lx1ZICwLi3VAvTbJaLaJWsIyVhqJVimfOZcUHdHrGyoKxgpsxVQpyUR8ftpjKKJWA9fU PuDr8ioTPnOuZoVqm5e+J8qXeMUMYs/z5ZPvI6bd7gZ6wo3/TsUox1e4qtGcvnaSoZfS trMXBTo0u7m8GUnagbEPVszWqSsbeFZSQGWLqIBBd55MVNH8XKeC4Di/3c2nOrOAG8ZP fGjibY+rAYtx4425E6+6l9/IOaWGSa/ilyjQk8UQcZhrTSv5oOmBzEiR5yS4hnFbLFga yjRg== 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=zoJwzSnpNtm/KpOB6AZKLCOOqIvUG4CtS9/wJYNCjCVctJEofoEzqE0KYFPf3rKAWn bl4s8dng/rToyqhiD5WLUiPMfuYVxy343WqAJgiCyw6bLETtYHNi6SHpHh9mHs2t3D4h aqwRySMlEk4VYnyDn/b4XhiajfOp4HjvQngA7XX5EuiZdtFyWT8UkFGI4HHVgoVGA78g /nlMhGRN3HzmlI1Li4ccp6rMfGfEkLsx+zJPGYGCciB07wC+nIRHGb+qp02ft0f5zU9p Mp5frunjo2lu7CtEpjAHlYUuJL35jqJ3g0U2oNNBupEv4a7CKSjvxQtSF+1i0Cp/h6aX o+1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rTa1X6lB; 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 c16si2101687qtb.170.2019.10.17.06.41.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:41: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=rTa1X6lB; 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]:48164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL61d-0004ii-QR for patch@linaro.org; Thu, 17 Oct 2019 09:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34052) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5do-0008Bz-Bh for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dn-0005WO-7Q for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:32 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:36632) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dm-0005Vd-UE for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:31 -0400 Received: by mail-wr1-x434.google.com with SMTP id w18so1754265wrt.3 for ; Thu, 17 Oct 2019 06:16:30 -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=rTa1X6lBDRkyP2/hDTmolWJCZfeklme2HvJmd1b/uTAIMlnWIEGSJ6Q+XgnHyI42Dl hte8dTv9c5T2T/QbbvkHqd1g2LCWJMVoCj+0Xd7AZZsQK/3As9msCyjGqEsVGdfCjrZX 7yrvt0DtP9FxwHquBEMX4vDEuD7iGcvnG1eYf/RkgVcEmecNNv3ZXas3LrahiIVUhhbU J4Xph/E66dWCVJRTgM41PA1WZVPz5uNO+GfFrBIi6hLM7hG/hmcgJmjtQnrfNCraH2J/ pidZElsXp698d8jUWgKxtMc0bTSW486kRDpL0DZi0z53NyDN98ozLY/KYhkTItbEJ7mZ XI+g== 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=j6qArK51oApEAo4p3q31gFGreJOHcM+Ms5HhhUv+2eL8cDXdK5bOOVBlgXYt7phgOZ TvDmYm8NuD58k7EynBCsKJsMMNZxScLdX0/SBYugstdem6gQsD4sCIFKaVMgT+DvJhoG ERSKG18qMvX5l9xkpn85XleQVQy5iRWp3ZeIm7KHXBi17a78CI4af+HIqt3ptdTjvfuk NZa7E7LaFiuK5U+PKvGBlMvOQAzwR52ivh4o2ZwsjzXaCGg094TRhSwI+fUNeDUz5YI4 Z6ksU7yNkehu6VSOwtVQraits7DKQwjEL8klqbbU0RoTLaLWYWWEmtrpLsml6tZxqbKt SKtg== X-Gm-Message-State: APjAAAXvXZKM2IPx/WYCadfqs9IkA0026NAE/EGSYeEwNZeZfSvDN7+0 w1LGA14gIJL8nyxBc4iv3zXDsg== X-Received: by 2002:a5d:56ca:: with SMTP id m10mr2939156wrw.369.1571318189782; Thu, 17 Oct 2019 06:16:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r3sm3243066wre.29.2019.10.17.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3472C1FFAC; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 24/54] target/ppc: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:45 +0100 Message-Id: <20191017131615.19660-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::434 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 Thu Oct 17 13:15: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: 176653 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp979990ill; Thu, 17 Oct 2019 07:08:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXcLlVdWUeg4yemQF7vrd5nUHVZqszbYXrQomc6xlSuiCxhZFVz2u9p8Gv+5OydgCPHfqL X-Received: by 2002:ac8:74c9:: with SMTP id j9mr3985304qtr.126.1571321290579; Thu, 17 Oct 2019 07:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571321290; cv=none; d=google.com; s=arc-20160816; b=cd7UjdL8UpGe7FkUFPptnAV5PCCLY5YOwD2OJFQmOdnHeFz1o0rejzt6ELGyE6It8G p6yCuDfKIdPl9XF+AvI6Q8gtM/mNBltETCKxmGbfJ0PA96D00TZ4KDotL68SRmuL99T5 2nGp1gF1rVe87BU1TmCOeCSJesuMDoLJEcEuW6tN0nKG9lyHdEpCIgNjZ2YbAYK8Xbai UuovCXag0upG2iYUlPya6lYAN9Jkh5YIER7Hl5YzjqycVQbw0v6WAZPfLH5UdQ3cSZbC 4RkFCHVhcuXPiuRJ5L1Scrj8+cUfBvCqMx5C19/2fMEEPEJmm1lf/FV2i6nckRHGEN05 irBQ== 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=udBNqYEiT7pvfe1FOQazFmNabdE+HKaNUIagY7d+I6NYcxSmYNY2M+5zEKSp8Bq0Pw MZUhd9OSPldJloNOtOg9TunINYSPTIC/6ijikHDAib4Xe3gpHMuDEQ/y/tkqSeO+3Nvc yiBoFxtltl3avNNrXrwCSzxjqqNc20cSSJY0Dd6OfSyhGdtrn3Chmm/H/AAOIwVDGcvx jGO7bFEgRk6f53QDJFMsePR9voM0d0AfLNxHbljrCh/bNUIe3IezL98Z8LaoHlwinSPM gJ+dgMuvZqw7pis0KOEx2qkoLY51X0U+hzDb04izmdrOr2M4T6NTjGcW406STGAMWKhJ vuKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=uvwIHcJV; 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 n10si2225562qtl.331.2019.10.17.07.08.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:08: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=uvwIHcJV; 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]:48785 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Rl-0002V0-8e for patch@linaro.org; Thu, 17 Oct 2019 10:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35624) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mY-0002N7-IJ for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mX-0001JI-EF for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:34 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mX-0001Ir-58 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:33 -0400 Received: by mail-wm1-x342.google.com with SMTP id a6so2548808wma.5 for ; Thu, 17 Oct 2019 06:25:33 -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=uvwIHcJVTMPxqYoN2aLnZ1NxqBojTuMg/mGUCpXG86IZunIwoRh+AquVopd4zJF4Qe dcKhCqu9ogf5ehBxPpHFMUOYRLHL4PMW9putiUXq9TfNayI+V+DroIEL+jLI5/iV0ss4 wjl5WHMOR2MIdKuVKgVHQklpcbAnR/rSiKVq6LnPmMG0tGRw9YcfYqHS5z4JNjz8jAWB sZEF9kbJTRrAyx8qV0Fcov7B91pYIc599zbCNVh+fyvdRjzh+8bz3/5t789N1McrNVPy ssRB71E2CxyIanQ6W96540iIKbWuaDaKZKlwBfl7iHKfmeQPNHYdGtPXWS+/+sin1vqu 0fiQ== 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=jeDnOHizWEq1Vq5VU41h/h7LAb3lTs+zFqOQ1VtGdyDspRpn+2bL0dzt9SP1RLrk2C TEvYGxWLiuo33wAwjChkWGvnSWM8GlP//CTjc4VjSNmu/Lk11Ml9oETM7/QOKziX56iw WLuWEe31ollQLma0fv1G5qd676nmT2Y8lcO7Iz7M+TiKvgFeseH+Qn24Q5XtgY4f1lLn kcYxASq64sEvQdPWDi0fRG7EzKX2fRnZQy1olmq647Y17bpRCOS21os0UPfDlH10USwK rjcbFg5enDm7CMbazKt4peo+YAJx43nzcMtd/7idFizdp35oE7OYPxSBklPt22qoZlBW SH5A== X-Gm-Message-State: APjAAAX6atEM6XLe+73Ykx9BIZ+8AyUMXVmy0HP6DZND7R2Sb/CAu19X utWKLTXDOcNyx/H6qsnT/gnFRw== X-Received: by 2002:a7b:caa9:: with SMTP id r9mr2822057wml.58.1571318732081; Thu, 17 Oct 2019 06:25:32 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u1sm2041089wmc.38.2019.10.17.06.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4A0841FFAE; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 25/54] target/sh4: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:46 +0100 Message-Id: <20191017131615.19660-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= , 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 Thu Oct 17 13:15: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: 176656 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp984716ill; Thu, 17 Oct 2019 07:11:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPT0FrhbG5bRvbOyGim7BQybE+oXfdxg9Wkjxd2y0GxqCWV46SzNSIu9/+/NcD7GCRjgv7 X-Received: by 2002:aa7:cfc2:: with SMTP id r2mr3897515edy.229.1571321490712; Thu, 17 Oct 2019 07:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571321490; cv=none; d=google.com; s=arc-20160816; b=bmg8SxNED+oInCFjdmBd73TKfRmjtov/fLHG9B/VueG4x40vDoeN4MbBVGgjmiMrQ+ D71i2mxzHCMF5hvIc4yxmBtjVMXfTgtTdOXb3oHDaegnbMALlUdvWzGKMHaEdE4+WYvn PDE8i0uee4W9gV6MayzipUD7+QngavLBzRSWMS7BtVvTxMxCMFVw7bqbdLxSvYUhOgEN nrdddl/79R/bjZ9O5u+gduRfEX1wIH3fdjrEmhAZ26iKO010rMrHpzmYGWXZGGyhtmZ4 FgSExzc5FC6UwWtApJfzC3WdG1P5P8BIKMSlxy0/VuSToNWjs8P7eizk8ucadH748Mpb 269w== 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=TAlu4eAcFAyDCgZOcvjwygfijSw/BcqNPBTH1OxYfmm7nOQw8M4wKJ0aFHmKlzuNi5 R3tGYpLNg2r1uKUIisJCMga3HSyuqLX6qg6qcEEFe9QytYfQG1glG54gU1os5l1LPf9o jvqYFoxoGatgMLgZzaRildqhX4c4NcEH3JLhfA3QqU/g1z2Lu0+TOWhq3m5sIOCLyKL1 ldvT1BMyiQCQOG93jXvfensScI+fxQu2sN2HdTuK+0UAAiqlmiAOFsA4O0jqhVzW0yMU zgCZp/eR5fNO3R6SnPC5lxDh1IAFSx7zGPZP/0DyPSFtpk6Z76r5GNHZYnWIu0v2NL3H iI2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xS0FBr6W; 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 k23si1446802ejc.51.2019.10.17.07.11.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:11: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=xS0FBr6W; 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]:48852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Uy-0006I4-Uq for patch@linaro.org; Thu, 17 Oct 2019 10:11:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35591) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mX-0002Kb-0o for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mR-0001Gl-Tr for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:32 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42511) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mR-0001GK-Nn for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:27 -0400 Received: by mail-wr1-x443.google.com with SMTP id n14so2340110wrw.9 for ; Thu, 17 Oct 2019 06:25: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=Bu4rKDpgnn8IvteRUio5V7sQbtET4I/Wc2TO4RaQ0LI=; b=xS0FBr6WVWAXfKPrZTybwn6uwFc1uQOgEnOCcU5ItblD3IOLAPKxgR6W/0qDov2+ri E+KJlCX273ZyMeVG47PpLFIJpJfK6lNodhuNIGUMHKyQQZ34JJBqHyUFOmR+DQa/AI9/ syWkjPqRL45V4/JrxE1sXYje0JPF4yOT9HOpp758En8JTVV0Ts7+5MwCAO45cDLBsG3s MDt3vnij7mhQHRif8ZgRH8ktWO5qYjbrEvkRINKqJepgGPZZ2QOOgjoixPOKcJRoKhfD Z1qWHO/8i1qzJV6ABatwGDN8jc07gHwLeUURT+lKCyzojt8Zi/rMEnKW5KpsHsTd1zry JCVw== 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=jPqCMUkRy1ZVxYlBATGY/c2ibblNwrNpR68owvP+1ZLVSs4FdrBZMSyD6Zp4YAo0YQ 2I7XSQ23uRC3fDG1qXPGdbJZVU129d40cQsfwl4muHWOgJr2FB8YrY/tcb3mzDaJKPfp 2gPjwu46ifZGGdHtt6DeiFrjkPeUKu742h4CWnbZllhV2o9UzfHjofDZ0uzPE1lUP8Wu o1Mk9kAS1wqNDdfXFoYAWC5Q5xGAXo4ZV8wfeigvPpBsgCnymzIkPzww00kHd8ZYPJMe jzEZi3ZIhbGWWgaWRYk7PrUE0+4i+2WfV7/jLUSnI3/yC558uEk8y6vNZ1RP8hWFODZc S8zQ== X-Gm-Message-State: APjAAAW8g6WwAosY9rG7zNs5rAnTJFdjSh6u14LSIWYTyrIcBnQBLR4d OGQ+ebLhbeGVkA+Vc08Xb9l5/w== X-Received: by 2002:adf:a48c:: with SMTP id g12mr2887150wrb.212.1571318726654; Thu, 17 Oct 2019 06:25:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y19sm2096038wmi.13.2019.10.17.06.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5E1D31FFAF; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 26/54] target/i386: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:47 +0100 Message-Id: <20191017131615.19660-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 Thu Oct 17 13:15: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: 176678 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1052908ill; Thu, 17 Oct 2019 08:02:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwB3ANGlyD9GGhw6xVfxl4iEmgObP/ba05FBCY1hqQ563j6ozclXAkLtz3vIMNPMYSCpLm9 X-Received: by 2002:a17:907:3301:: with SMTP id ym1mr4019773ejb.106.1571324544729; Thu, 17 Oct 2019 08:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571324544; cv=none; d=google.com; s=arc-20160816; b=H0gtKUEUcdEzM9sCKmTmZV0/KIdwXk7s55JbR+eMt7u8TkymbqgoBYkQE74EUpdFx0 4TCeWdazH7Yh+PA5VuTAS4HF8HDhNn0syJXA5Dd//wGW0jR/ED4EDxiJPCec2PL32TSE d8xMYwidpaSs4zlyDs2Tq2/hH3d65LV12eoUsYJ6/ngLFbniZV4eBz41xf7G6B0ec1qu WyqAcb86HIy/r72uqKc8llpEVcs6Kh7h6JLFh2JoLAr6V6SZCA+WV1ZwlGPnAImufZxD 9lDT2272I0MaHtyIgtnLKuK9Ertip2jpm7D+BRbb6zAIqeXFtBGKY4Lr4iH8m1cko03W pBxA== 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=EPdcZFaKJEKhbAFxpCctHARSaDq3WZZjG3bz0qd1XUrOfx6d6C3aZNeN9b5PvHlnoy pgqjCCE5Ny4ynJM9vjPlhuxECYA00ppBYidPyJgFWVikzhPTNLZvrOJ/kZ69k6k35H7H Pa6Zaa/YDvWBnQ9DYuoR2XWPULW5Do2zMski13mk3Y9cKLeOnh3hlAsxnd7a+T1WcZ01 Zu60STbH8Vi1FEiqp8e3Q6ZjhXYS0MMoTRD9NW1o4NjN5VFuyK9pLRUhowgc/QlelsxI yijF2JZsMecoUgFrSNpWgbyjcllIrl7eaaY2QAr0v4QbULpyfigh5uc9ABpHIrMOG8Js Glcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YAkTgFK8; 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 gh3si1584434ejb.306.2019.10.17.08.02.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 08:02: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=YAkTgFK8; 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]:50184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL7IE-0003Qw-Ui for patch@linaro.org; Thu, 17 Oct 2019 11:02:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FW-0004eQ-58 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004Ew-4p for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:30 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004Dg-Ta for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: by mail-wr1-x444.google.com with SMTP id w18so1909863wrt.3 for ; Thu, 17 Oct 2019 06:55:24 -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=YAkTgFK8cdQ4XRc7ABRysChOsklvrvrjaWLHy2ocyi9fUsZxjmV/S7J9VEa/AVTYXo k1hdzuOj5UC40sXLDJdLbpr9pybP8+1WTKrcYrhcpdT9ZBPHflDILpyL7tWuOq7ALQk8 aQyenGGtQuqjI4I04g3Lo2nUrjfmyJYwY8kns2llX8g6T35NNTyYy1LKUrJ62PI/XKVX G5KceYoOkuWoF/H/Y5QQ2wkR0/91BaTqa5p77HszLxJFqatu8E3/xLCCG+05pgxzVOq2 wE+QzL4KQrnC0XLbnetumR4Hu1SOqGYRmLiWH1UzQIxbAE5iRlHqoPe8Nhhpp6cNDOHe 9ePg== 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=uaE1cTyvQWR5jiFbQrtF8hebGMCoLTDjxoBC+qCVYY77TDUZ8Xq2SCYTzpL1XJ5/MF RnLVHaVf/jmuoZq/KkeEH6nLvfUXqzpQb6lkXF48yMWKh07Yb2UGeq9koh19DYuSkKOg 4Ee7DvJvlMeoFWMqdHpFJSJWB8igC4L2j0XaAk8Relo5On5jwnW0CZ3XbYdlEGjkvow+ ftLzftAYS0tYB9XI0v2cUrYyydiCxuDALKmCzMa8bjIbK/4g+sOKhzR10mYM9lqEIdRe CUoQiHVJp9nA5wkWdrRh97yZ0lQ7DbOddi+NtlxhxKy9466FBM6I8tVVjHOOejFgS6xO +Tfg== X-Gm-Message-State: APjAAAX8ANV8XQ+0tR9jmpX2Vm+FDdlKXVw3Rlly542WwNhrAODrW6Nl WZtBkVcVVEFf7wmRGbbdpIkfig== X-Received: by 2002:a5d:44c5:: with SMTP id z5mr3036840wrr.252.1571320523468; Thu, 17 Oct 2019 06:55:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t203sm2701881wmf.42.2019.10.17.06.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7321E1FF8F; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 27/54] target/hppa: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:48 +0100 Message-Id: <20191017131615.19660-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= , 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 Thu Oct 17 13:15:49 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: 176677 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1049339ill; Thu, 17 Oct 2019 08:00:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXak7MR4LVrFwvcecH/3UBahNau5Ty3nPgGwWLcCg9Cw+j1+/nLLLSOmJsWwPA+chz8n9p X-Received: by 2002:ac8:6c4:: with SMTP id j4mr4278168qth.235.1571324406756; Thu, 17 Oct 2019 08:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571324406; cv=none; d=google.com; s=arc-20160816; b=bLdyoZOTER88gtHFqA1H2ZwzPFvuD8OKbEur/5Kv26+hHHsAwYF52KLFIpkW4T1PUy 5Q8Ra+okT/fGYzeewT/DL+WniNKR+3PyzPLBwGlIrITrUe3Vvqr/hOEk06YdrxvpMDYh Bx8pTFhotoCBsEljQMi/JAihVYaH+9X4VCkiln7IhldrPUXRwe20DvqoOCCXrA/loMtK j/evuV5/jr2lc1mTjXdPwY3PZekKz6EEDaVdmsMAQ2wCmLbzq8arOmAYyvktUZiDep2i 7WxRzccQ6dUQWcadG2y+AJvG0oV6h0/LBeJAL2cP+MhmbzDffFlVHKIxdtiDDTaXMQ3z /jmw== 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=NJVZ10h6YPMN/8nFgRDFymOfzXgdKGh34ILAkDKgrXUO6lufigM9AOW3gtPstTBVar S7JrCbW5X62v8gFVUL4oN2Lzs9oj1IlARB1gPE2sXFlUieb4dwAUqOnFrWl+3UTCdxIT khvnPeXkJ8W1pFnFda7vDNiQ7tTTXL7HswZGFoxiviLw5Wgo3UYuvv5yixhEnJtwFyjU TtDIm/cEVTuUC7CXOssZZ9E7w53cYFXWg6U92OW7GeIQaLUMC/wIcvxsT/SR2CdWkcoD UQuOvfYrRbzgFTCRL6yGtwXfH3lck+wgmN42MSpGieR3gURbz/Qcm1Cs9NmoOULGodQG hkBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=R2XK7l+m; 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 i12si2109302qkm.353.2019.10.17.08.00.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 08:00: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=R2XK7l+m; 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]:50096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL7G1-0000Yq-OZ for patch@linaro.org; Thu, 17 Oct 2019 11:00:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41242) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FW-0004eM-0e for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004Ek-4p for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34097) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004DO-TL for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: by mail-wr1-x444.google.com with SMTP id j11so2495942wrp.1 for ; Thu, 17 Oct 2019 06:55:23 -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=R2XK7l+mPtMzL95A2TVWSs1cW4l2QzKCHOwOxCebxn4hjLFEdrPlry1ckhfJSolyYm l1f5OnIRSANA2KmKZJcV7GPGXwuK4G2awQYLRul3wVpDUYQlNXxIIUzpg/aramXpSb/I 4m400j0TZHyLZ7n2RDMLoklGs6WdZiZS091wnBMoRFn0Rxy3K1Q1YDyuOS/YQCMz3gDb dZ6k/HGkbb+mDnK7TeptVRnxH9Q5SyvQBcxUgb0oujNaxXKbv2mgHvBCnqaud4RwWeDK 1ftuAV+RmD5KSfCWO0Py7MCsXp6IDJD1guIS91HvLyYCAPfV3rxJIUwkDMMebJfhOB+x XeHw== 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=d+w+lSwr3b/Y/MBzP1vG48WqsswTX/7b4nuIZrl0oKkvDVO7HjHKBBwAYKaX0RJOty rJGrls82SoUUngRsG3UXXIVzhyV0g1VSgB5WuqQEYoh4cIBiTMY0RvLOc0+6ZVzlJKZ/ t5OcozLqMMraA1exbCSBgKUTXLC+lhRm5QnNxWZOsF8SUsjYPTh1CuWwoOHhNJR//qXx oUBJ9UC58htXoP4c22cNiSwzslp3h3L+HTai67xCktSkz1pea8uwUIgAqulfDi+aLH95 k6/cUZDGLbhqsTkGmyyaqmbeqE4zntGwbbeKwSR+xFxw5kWM/SS8k5qlaId8Qjh25m4Y uhMg== X-Gm-Message-State: APjAAAVS0a6aBjbCGxGk6kVpLn2jgE/bWmtxHq5QqSgd3PIuLJkWDXDq t4Ol28H3eicDLIvxwJ4RqCHkLg== X-Received: by 2002:adf:f805:: with SMTP id s5mr1541773wrp.329.1571320522323; Thu, 17 Oct 2019 06:55:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u1sm2362922wru.90.2019.10.17.06.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8868A1FFB1; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 28/54] target/m68k: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:49 +0100 Message-Id: <20191017131615.19660-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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 , 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 Thu Oct 17 13:15:50 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: 176639 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp961809ill; Thu, 17 Oct 2019 06:55:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGVwU4SQEKQNrm/as1X1Eg6idgT+p+BBOAwwyN+tgEyJRrZMllO8AkCuT7VAq+iD4xqxps X-Received: by 2002:a37:5d06:: with SMTP id r6mr3377384qkb.16.1571320504816; Thu, 17 Oct 2019 06:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320504; cv=none; d=google.com; s=arc-20160816; b=EZc+8wJopSqfjS4cGmW4cOVFJfikEb1dffXgVmEnMqvW7WFh2CxoF/NlJdpPIIsYq9 E/0WzOdU/rOGX1s8aH8sjYbeBYuMIuX7S1mNVICgJQkkubrOGBLi0H/ZZcyiGuvhrERQ 7u2N+oxBj5+xuKYO0fmTkzcmazEa1u9H0DX/LYtWgypknFYXfA7qo0fjSSHKF/A39wDa EeTESYLLH4BXwstX6GFl2W8VSpco0LNWUXc1TSt3YrmpJCmZkJzvxYzoTD8ucdvFJaaN in/3Y9PdTGfFZWa5O922V0xSxMhGDcEmYG9cXUH3Ehd9JSnM6xd76qPbmXqeluL8/DxP X5/g== 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=Yx95eb6JYKecj7Fo8AZN73E7P8mUzHx9oz2hEf4VJeBWYzA8M9TSPy+qrt5oMtVrT9 3wo3UY12A55flN9Zo7LCJM3IG3LiDWttK6R4/Y08inNKEDBRnjO2RK7Fnfm44Q1uR48n KqN7RhVK1+05nPUsCizllLJ16ILr00XyF4KBqnx13xpIfxmcpeQRTQk2B8gYPQQuh+tp 8uxZwR/FG4kaCUxVyta8vt9CU0ndUliJ/745A39Xo3hsXUk6j7VoXpQrRt/QQGk6N+qN QiFbbkW79rfvRdeFwa6lTPTgcp/dnhzG5RcFl/gvu6pkncAqXJTyIg7GEpR569BJn25H 1IRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=da4H6VrM; 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 42si2099780qtc.145.2019.10.17.06.55.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:55: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=da4H6VrM; 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]:48494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6F6-0003oo-6p for patch@linaro.org; Thu, 17 Oct 2019 09:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35485) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mR-0002BS-HD for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mQ-0001Fx-HD for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:27 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mQ-0001FW-AO for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:26 -0400 Received: by mail-wm1-x341.google.com with SMTP id 5so2580612wmg.0 for ; Thu, 17 Oct 2019 06:25:26 -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=da4H6VrM+xN7VjkwNt7QKqDGy9JU8gzWON4QiqnPqBOJo+PscTol7hjA6i31qgLbg5 lNiPqnvb6EtsjBx3IV3sWnUC06IG4UcmdtxZYJv1Xm9mZvqY6EEOYim7X6jmKBTdovbR cvqxiv/dc+ajU5+VBHDwAdzjk04MFiwJqLCP51b4R5CZNTrmM38/HYdypQbqSaIdiFbe e5ZQOTpD5ix8Yprkj0m2InHw1VrSvUcZiYtyEiNqBkd7ZXvuwP4cCTuAuTGB02AgqNwG +7tB9uPJ6eF7FErNQ6RAgcQvaJR1spkUYlncmx8SHn2ejhky8RISISfsj+sI8zEwGYMY vwvg== 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=brKgvl1ytGV3XHmLTjePVUfQqWUM058Nx32ZN2gY2XWmvxdtwLfkP0QjyCkdgpKj0G 2G4RdXqnh5Xr8IOuWN3E5lWJs6jmUSSEMxmfX6U0Ur34mg+qPctOfUnvFuhVgY96dJq/ Dt3ToO6G4YM4XcGEHuk3ahVahzo3f+tv3PareWlQ27p6LW9KFSiQV0AuYZ3ceWfCDRlD irBcSCIlkK1O9eQQvRbKULYVPdaES+1gu4rTp7uGRgR0Iak3gyROj/oITjyv9jwOGdXL i4qf/Pt3c/sowCdsebvOq5WrJrNHEx1BirMKP9aLfmOX7EdCjuOeIgmEKjAeBiEp+nHF J7gg== X-Gm-Message-State: APjAAAWdCwhrugqOuq+9j/zgvLGmDp4ecnGXdjKsbeLerU8fPNwlm7Sj JjNPu48uLC/65AL56Ffq8DbMTA== X-Received: by 2002:a1c:2e4c:: with SMTP id u73mr2825847wmu.94.1571318725134; Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a9sm2964667wmf.14.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9DEC51FFB3; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 29/54] target/alpha: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:50 +0100 Message-Id: <20191017131615.19660-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= , 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 Thu Oct 17 13:15:51 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: 176662 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1001649ill; Thu, 17 Oct 2019 07:23:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2+VSJbDVmrwSwllrlHr6MuwhlYICY8eDL/xvfWhx+NWO3hIsQA1ndpJaip3/eDN/QNqNx X-Received: by 2002:a05:6402:3c5:: with SMTP id t5mr3948921edw.125.1571322208280; Thu, 17 Oct 2019 07:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322208; cv=none; d=google.com; s=arc-20160816; b=nIkPITFVE84847Oo29C9b5tLSVo2dHlmUIPvJ9JZwXTkUovlncQbiUCmJoPIy2Ev8r oreLjVAFefdcgDFiTf/AOgvhdOinU7/JPRGWtIrobhR4LA8mNOk0yeV/ZWBgTYgfIjSv xfebqL13SZmjZ6tth4FQ3cI8Fc6n8ybWArQcNZflHaM6AeGkd9oYmMBTxLxrFJD2XKdE dMs31M6I/K/o2/dz4JflO5ACcqF1+wZZcEw0HUbvBIpNbqBnsYfSViKVD6lCFZKo0c/K RMfuF/PF7b3/w4w9ss4R5kmhB792B1DOUnbzY5Vp+lemKkgOt9HH0WGb7LinPUApAtm1 wX3w== 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=zINIjrg5CEtICP7WAjfJ/LHNMUKajz/cR/8/N/SNqEo=; b=MNfl9iAL7ljnkYIjWaAwRnhpX2uN7xyRZlrJNd51b7AkpnrZYP2PNlLNahxxyLAkf8 hGs93oF+THsG3EclTer3pG7RohlsfbFxlgscwmJu+XAujgcQ5fIsva/Ke6WHnE1nvyym 4ic2xLh2LyZxXwxPLBlttCVXqe1kdaDgSu7+tEyfmE09QQPTV+ixp5bVvrGxdotpcqzI YYRKYRQZ6LSIJsXQg6aClyv8GQIPRSb0O9AwanR7aqmsRgBV12E+YuF9YOToS+Y7BsMi wuWBu7Wzrd3995p8PDTNh5SK3cJpPMhy4Lr4u/zSpmcpp+DDr4uCqAkc1iSg61kLihOb 4CXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UvRjCgLv; 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 z19si1457972ejr.244.2019.10.17.07.23.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:23: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=UvRjCgLv; 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]:49192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6gY-0004Oa-Nv for patch@linaro.org; Thu, 17 Oct 2019 10:23:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37627) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wF-00063M-5s for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wB-0004TS-2h for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:34 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40011) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w9-0004Rh-5D for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:30 -0400 Received: by mail-wm1-x344.google.com with SMTP id b24so2560743wmj.5 for ; Thu, 17 Oct 2019 06:35: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=zINIjrg5CEtICP7WAjfJ/LHNMUKajz/cR/8/N/SNqEo=; b=UvRjCgLv76Ez7h3mX1zaGutHoDWjvqpwZUin/S2MygvBlEUKForsqAfZ/f2RXEfO0w mF1Icgl9QQjLj6p9NNfs10lAwdah1+P3faAmRwldEKgvsvo0Rr6vKl3mpPA/NgzWtimQ 926cudjLIrirkxuO6Eo/aHibeGUBGgLkEffjBsmzyOJtAm41MQ7ED7BVyQ7FuTRLvKIm t54YtM9D6VU7IuNX+wpK5cEJdSkvPX4NTbHn4JSemv3pqvly1Gw05wNc+nnjMk/dixa6 1tvffZHcsNQlR6u6m7CTCz0V37ByUQq9Vy68kioZ1XDic+M7Q9Aa3xA6jZBiWvL1W4Ou XCrA== 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=zINIjrg5CEtICP7WAjfJ/LHNMUKajz/cR/8/N/SNqEo=; b=kNwczLbmouZpA1rElFL7KsCwuY3igBZlzB5KH8Ll393FtjzGHSAS/5kux1KqvZiHLE wWQUzCxfuZZ+KOdkqQFoxvEDHdz/l+9METQ2kf6kSyzKGpwrPtZoJEAZ8QSLHyrCyq7N 8WeZMtUmNnHfu+VM5BXxQOsV154UKcaK8VnJoYrwK7UYbbYOUKJEU0bNrr+vuumRfHyx wmABMPUu6qEqmFeZrlR5VJ+SvqjiN6dcwgt03G1Fmek14LUplFwtZeD+H8bokvmo6hoh tmycPi6Dx7kxjA8hMatb5uZFo55T5YMp+mvHR6tJ1hXtPGDNTFO6CCQ8WIpM29HV5KJB cDzg== X-Gm-Message-State: APjAAAVJNvHRCyFmkEM71EaSDDQs+QdrQ+ZkSGavC8opjuYTvEJm7XbN EOO9yFpf/dB5x9w0fT+9u0H/Yg== X-Received: by 2002:a1c:740a:: with SMTP id p10mr3035756wmc.130.1571319326697; Thu, 17 Oct 2019 06:35:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g17sm2215623wrq.58.2019.10.17.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B39581FFB4; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 30/54] target/riscv: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:51 +0100 Message-Id: <20191017131615.19660-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: "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 Reviewed-by: Alistair Francis --- target/riscv/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 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 Thu Oct 17 13:15:52 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: 176670 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1034760ill; Thu, 17 Oct 2019 07:47:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqNHc6U8ru2ALu6DxaUSGiIG/XIHqAa69fWzKpMtb7iBswztEMhEWpGWR1LuFMq3AjGQXO X-Received: by 2002:a05:6402:b03:: with SMTP id bm3mr4249673edb.112.1571323678958; Thu, 17 Oct 2019 07:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323678; cv=none; d=google.com; s=arc-20160816; b=hGcfbWUapgej7mBmu2u10XJYE+omKFcvmA/J7kX+8wwdJmUpLpWiRhjmiU6COz35i2 zllYz1sl1/ras16J0lPKmYwarOHyox/YsynxPkQmJxCF3bfdHpzTkCRoos0ws5gn/2Hf W+jKx8T45Fo3/vKLM1kpqiKwlNOuYuyxA6YX93ABkX1bMUxoM4rIU2I2z6I2wMQh/7XC kc4Cg2+O2BUR1IS4TLCDOG6J/3E9/i2MpE21EtlAazDuX4gYX6mEpc6+WSpbi+t5xOoz GsNvqyuWnLAIcHxYB2B9+GAXdtwqBwF7iERe0WR2lKdUbLv/VuphOOtBWV9udFXjsdoD puXg== 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=ATRtPfFnGDoDS59usO+/FCphiYONEmohndcuipxBNZs1a5LLC/bZPC2QERIa9bWM+g G042jiUhri/m0pBzZ84v/ygKOD/rjYpP5Ve5sadhIUtdCjC96AtjTGvnfIS7NJit+AJO 5h87kFdctUIi4Y06sxGC04U/OwTpUyGkvSknAWgan1GDQIZHKGvZR04/tjI8CrKKc5ZL ipuDqdTTKsAUeCr5XLbs+TRqRpJeMN5cLG9889tPnxPNt3F+YhH1MFPYvIeBuhTMRmj3 KyN1ZASVbOXzp7ABJpRbU1TKA0+BYJNj/W2C+3gcApKfRsfjAYxlGmCSP0EYlk5ccgFb +Gcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="F9PAL/5D"; 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 p15si1496306ejx.56.2019.10.17.07.47.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:47:58 -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="F9PAL/5D"; 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]:49682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL74H-0001rx-3d for patch@linaro.org; Thu, 17 Oct 2019 10:47:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37628) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wF-00063N-6X for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wD-0004XC-3T for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:34 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:34366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wB-0004S9-21 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:33 -0400 Received: by mail-wm1-x343.google.com with SMTP id y135so7060002wmc.1 for ; Thu, 17 Oct 2019 06:35:29 -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=F9PAL/5DGoW202thTWt9PWQxH2Va6V+qW3obqzm+cyizfruo8mxHofOSPKLN3O4JVV o2Bhjq1knxePZW2mcPuJB89gxWzQ6ZLINNQh+JfoElCH8yXwzD3IY5mcXrQ7f7QUbUr4 /slst1r/o8Pb9AaAdsJQQUsA7eR3NzbLK4nGa1aYH0uLFxCRSr3soHIsThhDOD+KlfRw +m7BUTOdLO4bRWmrfmwNrV/ksxEpa9g66tLUO+VV8Hn/awtasfu6X7fEQHSllRXGUu8Z TphT5UJzYytFVT3WGEcSO7SpFHIpvkrbI0ES0mWiqs4W4gxypJHEp69L7+2flq+KOphF 7Lcg== 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=irwYclXUVoih2XWc7djLbDyLutTGYup7ZosAmVlcg2Ofq/UE52z2iHM4aZkRa3IT8o PBtJAHob1dU2i+SJc0sUOdg7ouDOdQet5zX4KmJuGzRe8RKhIkbrfKzmP9kyrFMjhmdy Hst3TXjBXHmu3sKGaE0PKtDfIOA7nzVAldBgB4HAnRy9roSC1igfTB114CrGYb5/uYkp rAyZZZXnRfR/vLwsHe4fZYb7/+Vjr4WK8RuVRwj27QUng4gb8ReeIBoBAIKh0abPUhzI 0/OhpUP47wDtsPUcHutiUqp4PhLWqhY2UQx/VO01dD2VcwUmN6Po65qMQQDLbrJEWn3k fEfQ== X-Gm-Message-State: APjAAAVAlGh94/Aut3H/lZ197v209gE7NONZExnhbM+5+LLXBdpra0lW nOyV/pCJAgvvdd/eRPOJzKyw9Q== X-Received: by 2002:a05:600c:305:: with SMTP id q5mr2876832wmd.67.1571319328436; Thu, 17 Oct 2019 06:35:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g185sm2319343wme.10.2019.10.17.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C8E0D1FFB5; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 31/54] target/sparc: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:52 +0100 Message-Id: <20191017131615.19660-32-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 Thu Oct 17 13:15:53 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: 176667 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1026872ill; Thu, 17 Oct 2019 07:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEHDELzA+YIIS1IeWCO1IlaWjHdI/ptUSOO6xRv3EVrXV5t2OevvfsuJu3pLhX8Kzj/0/g X-Received: by 2002:a37:a392:: with SMTP id m140mr1617496qke.383.1571323305681; Thu, 17 Oct 2019 07:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323305; cv=none; d=google.com; s=arc-20160816; b=ujojbzJ+uBD21QiAPDf8izfMX5HGVIR3eBlD7M+FKfhPH4KqO798tG2ZBxXSZFa5sd aDZYB3k/FsGUa5YSojBUbrsJ78pzfv2DiXIipMInnJM26wWBLckGlnj3YwwFShW+uiPu Yd29MB8bySZ7o9yv7UpQYDTTHrCjEkmAnzQ+EZf3mw9KKh13mBOmVLnbhQPR2LcEVQ9v 5WuW7fUD8oy18aGn8EuJXqKzMh6evmV2i94jSvuJramV1y17nADiHNw58zVn0Q7StaYU F/kPdDvjEWtuq6yVKi10UoyKdIJdrsATJg8k8a97PZYbtdb00G2ZXUEV91XzPuzDObaf cdSw== 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=UK19CA70kiSF3cshOE62XM/sETAQsK+nlzEGSyL34etAfZMuoQ/vTcpzx01qMIupgC NgAlaXWMJbul/8s1FsfZszvR4aB+kkbQyKOSNAnh+EhzTJGTsE63xuZoibMSJAsOH+hG oZKTbEXGi5o5pS0RCXUkx9Bmqf1xD9fLkFjsVcA4pg0/BZ3+mTmy49Uo8deMhD9VghKs w04y0Q77VZkM4+NBNNLADsbyKOnkPTc/XW+EuB0pwg717lsGTiSLlFSnB+lYawHUVnxk NGOHZpDdWg7wFWups1PBuaDH6IsbTI50rPPhu5Jf0kGKrAJxTQ2KY1TAzf/6LHZluLmu 3Eqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=q0TJ69hO; 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 y3si2273068qke.17.2019.10.17.07.41.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:41: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=q0TJ69hO; 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]:49546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6yG-00033p-V0 for patch@linaro.org; Thu, 17 Oct 2019 10:41:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37549) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wB-0005zQ-4w for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w9-0004SN-38 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:30 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w7-0004R6-2t for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:29 -0400 Received: by mail-wr1-x443.google.com with SMTP id j18so2377807wrq.10 for ; Thu, 17 Oct 2019 06:35:26 -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=q0TJ69hObxttWqupFwHOTnVy2N6DTQOVgPbIFPnn9/DUoy/XlYFikpJJgzUmeexajR aNXAn/t1t64ia8PrqcL5/y2W1AgCtPmqT4FrmiCrbBNALg/rEox/DG3jJqtXTYyjeOkk fIH06iTqeN3FHMy1EPqXB8tGNQaq7NundRCpnRemzPHT79yvdnq8htHngMFpeM83t4Wv YmsoXGex/hsm3NCATuE3/2PcEA1CggERHcKKx27G61dPYI7KRdEaCHcQX8YMuZT+jpan YXQ71B8OG7LXVac3woAmTv3THwKPYIwNdgm+17veMFCNZc4Too60T3SX1h2UKMg/EXvU Cd3g== 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=gO+MHpfKPSo7IBUXDiDt5K3EEMD6O/KhUQxEh3av6qmgfTLg4zU6nL4KXaswzz297C W76yQQVP1vfonNuwWdoOmk6bR2zJqGfj1l1RrWDm9nN0CvFB5Y89RA15duUPPRAEygGe LbM3mEOQPNR5kiLgmIT+EvZjhmU+tauE6l7UTme+SzhsgwSjlB5nmhxlLZbtSZ1aKVEQ bw6Vbz7bdRqa3fnjaCI0zLU/+5OStCaRlmc72jwikLGnwcHRMPAJYK4s1nWF8/Ucadl7 +IyghzE5Iuxp/MdquZtCPwEse6zICYFRGVgDtygrMWZwuCzhlLrQzUjyv7ugQd5ngBEZ q/RQ== X-Gm-Message-State: APjAAAVMGklZxDt5+AGkA1bfHVZ04o9xnR6F6KwYQKnWDr3g58eZdSJl qm5C1kuDwtZhrzqa/1BYJTXDHA== X-Received: by 2002:adf:e38a:: with SMTP id e10mr3242232wrm.348.1571319325374; Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p5sm2294000wmi.4.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DEAEF1FFB7; Thu, 17 Oct 2019 14:16:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 32/54] target/xtensa: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:53 +0100 Message-Id: <20191017131615.19660-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Thu Oct 17 13:15: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: 176649 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp969123ill; Thu, 17 Oct 2019 07:01:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUa4QUYR27D6a1DhS1lbFXhGFIBdoXSIr4nPIgDX00pVtqlQpOmVnVtIaEQGn8/Qi/tDVP X-Received: by 2002:a0c:fe45:: with SMTP id u5mr4012834qvs.17.1571320866178; Thu, 17 Oct 2019 07:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320866; cv=none; d=google.com; s=arc-20160816; b=kOcOOg5d1Gby1D4DJwNmPXk99pLl2H7CVvM0nOtqqw4QPnvc51uzrbZmt7vVsp+cHt 6M/5NWwwYvfHqp4xxKzpxdq9UTDVjneWiCvAENEzUOwhNHvFuu/8QyYWgy6O8J3mjhoB FamzUA+xClg962SzB+JpsBVT30iNC4vOb/NSkVTU4RKwcwkTxGkI+sMf44vS1kdCP+ao MgZpqX3O80haepDjPq8Nuip8OMoDcECD41ye6OGr4QZ1F18a5nJEBEyBU5F2KG42+Xju BbdCccEkrVjVhae9TDaltnBI5T7nC0AXQJQpXFCFt9+lb0Q+E0GEykeFR+RggLN5SLj+ FsOA== 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=0ZbKbNKtk9B/lZIproQ5CoDTLlcp0n/icRd6AsOTdjZrTJPryJc311oAq7uh5q6b9e noTYsk1VvmIIux470OTWM672Q4lERU3+mqTR1/8o7Q1HZeb/FIsvYiDH/lF0omtd49ff ODychE0JYDWTaNIQA/Qb1lcT4CwKHrWtLtPcEwdVB7DaGgzU/BLbyojbaV2JIHakGdiD ltFd6HDKGCJ3OviK8uP0zWiuGXyJxL2G1hH+1s4FmXYGpV/nSoErvrkFiMez8UpbDEBy wXC9rFu5MdHU2WQp3bzfjFLYLI8ZZnRobE5EL/YeTeO/++2nAevbl12oTIx9mEiG1bdr WL4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="J/r2yhe1"; 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 q136si2219174qke.342.2019.10.17.07.01.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:01: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="J/r2yhe1"; 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]:48660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Kv-0003E5-6U for patch@linaro.org; Thu, 17 Oct 2019 10:01:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35615) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mY-0002MV-73 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mX-0001J1-0h for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:33 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mW-0001Ij-P4 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:32 -0400 Received: by mail-wr1-x441.google.com with SMTP id o18so2319663wrv.13 for ; Thu, 17 Oct 2019 06:25:32 -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=J/r2yhe1NAF0kK5CYJb4JTNNzVIi6nwMJlflK9D2edIuP9dfFnMOdb1UDD1lZrlYwm MRxyCoFan6HIhI16slX497ISWRnEkhYQ08wNmL+m6UkP6eNGLr7UMVTfBp2shVUMI/Vn FkWCiwWxTBDO2sbAH8bGnZZ0yFE4fTkqdosA3+nzdBhagB0jtf5UwwI0FDpIMr8WhsLe KGpETvE8yhRyYoxvoNiWkT4D0yp4uGmrbnzJjsPReba/m+UFDukSGaqla26f1Z6dRWHm fbCIuoDHUZG90kzRWlO7Qf6NLTle0sy24307ofr4NzEN+imU5GrMIPQvigTTV/BytOmy pfyA== 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=Qjvmfa80q/48QBoHG0/QhSiHo6W3rKnWdCWhhYhxFGQsiyGVAgosI4LUF7qnQouuKs uoH9WHSwZI6UHykfMA85oDvWkUo9H/ePNiYSZFr5bCok35EtqiHYjoqVPAf7L6Ai1P/R Se3l1mtAkCxXsvA/CyIRxTuFJ1caCapNKxP7u74oZOpVpcpTi044Z5D7Q6CrytzwbEmU jtM2QPZgdgYOwCGxeW8vSscXD88mwSk0RFuIvmnR/RzPVe0Twr06V3hwD35M2XdjJunC L8hOzWm4pVqscITTS82iHY8AGRiz6ECuLWWT7i7OJxvlylZou+gT6EOXj2LOe2Y9PY1C y0ng== X-Gm-Message-State: APjAAAXVbpzLHHNU8KUWFZJvesiJ7836w91PqkimFXHVb+2krsXLaEz6 LPKG2aR+ZBkNJsTH8rXAXAwSWbsGF8I= X-Received: by 2002:adf:ef4f:: with SMTP id c15mr3120155wrp.296.1571318731706; Thu, 17 Oct 2019 06:25:31 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r2sm2203218wrm.3.2019.10.17.06.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 008D61FFB8; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 33/54] target/openrisc: fetch code with translator_ld Date: Thu, 17 Oct 2019 14:15:54 +0100 Message-Id: <20191017131615.19660-34-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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 Thu Oct 17 13:15: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: 176654 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp984198ill; Thu, 17 Oct 2019 07:11:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5NSiltdHsZezWpq2+m4OhRWufpaEdE5uz0UW82mgTzlL9BiEqYTgccZmV9bBFd8fpwItI X-Received: by 2002:a17:906:46db:: with SMTP id k27mr3664749ejs.308.1571321468093; Thu, 17 Oct 2019 07:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571321468; cv=none; d=google.com; s=arc-20160816; b=rV/ngWLI4Jvd0D9uQbRWrowhuenFVEHe08mKY5mkei9k2Uo3P1Nx4ozeLFgXD/p31Q WcTr3QdxKXxKZkP7mfBHOuNBmQkucKWSX+wBXQoDSOGFp/2rw0IvZTXbn4Mtw+34Av3I Idkk/NreZZq2mvgSJVVJ7rjCQ6fY7adOAWgHFxrquxvvm15PDZrEdwOgrP7Y6B6i1XOW yIZOQUR6LUJ3HDdw2yMW9+NcUqDKQK6LmSbU9CMgwqlOGXrxTSGDK+5xNKV1HkDURJF9 aMHPhy+6+WOVS7wx2uW94oZnUJd8m52/SfxNS9GOyb9rtZuCqNE0DeWkJqveJJALJK3r 0rgg== 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=IPo+YlRUqX+T+H73IM5+P2UqJCMzFGx1cxsdRA9PqCyTwMEhxYm4CtnuP/vVgszsy5 MDKIJfo/OSkCQZJcHX5GBA7vBWyLctul5YkTIp3bsD0Dkc7AP5hrmiyzHFFvuYfv22xy 5KVi6xkqMpAGeSF3P/9zn0jot6ZD5Guq+ikCM9tbbxB6MHPTXss1zOW4UxkJeSe0LjNQ tdcnRH97N1CR7uPvDlXC5Y4Mg1urHHGkZ/c+5U/fMKvsvqp5giBZsC6XMFya/WtXhfxr 3s4igty/ZwLs7ynLeXmZb3A4wjHTM0R65MYWg6IE+zQNXkqXtI3zDYxjETSnzB/tl9Oc Mhsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="gTC/wLzq"; 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 p14si1544231edc.227.2019.10.17.07.11.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:11:08 -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="gTC/wLzq"; 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]:48844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Uc-000688-JY for patch@linaro.org; Thu, 17 Oct 2019 10:11:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35572) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mV-0002Hv-Jk for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mU-0001I3-Ck for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41611) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mU-0001HT-6U for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:30 -0400 Received: by mail-wr1-x444.google.com with SMTP id p4so2344300wrm.8 for ; Thu, 17 Oct 2019 06:25:30 -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=gTC/wLzqjCaPyNsmujQWYX6qTv2sonKaQAn7gL9XcAzvz1lb4UtYLF7etsv3JgiYkr 5Y02mFxVwxpIgC/kYuYBgPo4uRBCvSIrvjGW2VDJSH2H5mCHHIRf/1+tSHpF7INqM8z7 vKhEJccpj3ro3y8cn7VfE9sfpsoAgfmDxuhPnnzfm1Mxekr73cYgBfv4d/FKWsn3uQdf BEynaCYg1qNotyx8zUTGgqozuk9WIua0SQwP/NFN+zQCimozZBJ5GBTrpQS8j4WIq2mA hgTjLcFOxeoYph5C31s5NJotxBpveNT8UNzeZ9oTmuPfBMr0/t5kQ4vXLCgVHzHLGVPT RS/Q== 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=E8m4AdzFk1HgsfWQ+GUAC4Ed6tHQcb6ujT3yHetroXI9fNf76P6tYOlhn5FBTcZz8u T3HWJ3KzVkKysqoxeOajBr/ljQXoojt9MmpoFXC1f0I/JVQvtYh+iBbutuKp6IX7Us7f JLHj7S/lpawln0YER0qeKwVbzm6g4rzJpa4XaAPQ/StqJUgg8mBWUBe6OtmaVOSmnFw3 6PeacVDw3rBNLhunnMBjyKlu+zvApJGPm3Tf3rq+gNlhb4b9u/FvDHu6CHi4WzbFqvE4 FyfiJEFIULe5yHLbEGSEHlnIcHfd88FhZv1aLInsrOrlYruG46DIR83LA0k7Qenk5We/ VRvA== X-Gm-Message-State: APjAAAXIdFZLJ2u7Rwti/Np8pvKCn7rNZRFM09FD5VraFS0TopfgfvRy TH0zmL96zlAoCZiDNGF13a0NuZo6og4= X-Received: by 2002:a5d:544b:: with SMTP id w11mr1484484wrv.205.1571318729110; Thu, 17 Oct 2019 06:25:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z1sm2115475wrn.57.2019.10.17.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 142581FFBA; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 34/54] translator: inject instrumentation from plugins Date: Thu, 17 Oct 2019 14:15:55 +0100 Message-Id: <20191017131615.19660-35-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= , 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 Thu Oct 17 13:15: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: 176664 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1023583ill; Thu, 17 Oct 2019 07:39:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIqJUV14+HYjO925nTeaD4wumEEU9Ih/6rRm2LtjuOUx+VJkRM7gqJE9ilqaDQpfHRHtoJ X-Received: by 2002:a37:68b:: with SMTP id 133mr3494743qkg.315.1571323150801; Thu, 17 Oct 2019 07:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323150; cv=none; d=google.com; s=arc-20160816; b=LepxGvzQAXkabXAn4QyY0pBMU/2SREoedMaX7kJydyyXxlfa65PLrHfVX9vBr1PVhq qXOVW1qNqhNMlcebNsyhL4sS0LxPI9upU+TPwMOQhIpiM57KqJ+9rUO2X2hk6pNgkBF1 tcdqw245fTCHQb8n529baqYewa2+OowSIRpmqXV+VlVAw/3s7F0/IIYxDV3e6EOJQJOE 5ilwmEKVx7DZaYprXEqpsXuua/ls8fy9yC9UNWija0TnbksPpi+fO8hzUAw2cfQRj++C 3ZH017Tv271ENulqvb21hFq/n8EVpHa2E35LHEPG5DNS0eaHdwY4gt7LTtCI7DCF3qVj rQwQ== 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=QzZsouR7Din5HPLemL+hHL1mAITvyQ7Z5IcL4PnrG6E=; b=O3xuWguTlSLy0FMfq0P9/KoVTkI73hrR6ahZS0E06jdbmpwwvjTogR3tHGyfFEgk4Q CMCKg5np+Y6KNbcfsPX6/wDgK0dJc5x2Zi1ll1ZCiM/poJhWM6130NbODM4mXInPjEfO pAzRCLp2whUNbwZbdXqBqWMc0P88146ubsMdG1Eh6l1MrKabmz6sP4wymal/xkUg967E cDEv6Dgx1SYe3kX6//iS+OTLgoq4aqG7CoF7llqvDpv6QDhvNtsyKtKDkcGHRk6xEc0G EctlqfzobEE/IRdbsncCq1Vsm1vR36V15OCb6RckaVsiraac315F8IkUPRovIhDufogZ 6xcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vrniwuoS; 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 m9si2503495qvh.13.2019.10.17.07.39.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:39: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=vrniwuoS; 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]:49480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6vl-0007MB-OS for patch@linaro.org; Thu, 17 Oct 2019 10:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41247) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FW-0004eP-3k for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004Eu-4d for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:30 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:53227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004Dy-TN for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: by mail-wm1-x32d.google.com with SMTP id r19so2681803wmh.2 for ; Thu, 17 Oct 2019 06:55:26 -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=QzZsouR7Din5HPLemL+hHL1mAITvyQ7Z5IcL4PnrG6E=; b=vrniwuoS5TL4OPYX1T0kwBjzLcJO2AKiy6Jm+2WlRhODld79Y4uQJ5I+LAU//tIOw1 /R1TmXSp6Nw8qOEyXu1va6mFN8MT61sJrQ37Bn/IyRN5x4Y6xudlEtPD6MDA/eIcFzEi 3XSagviyLN94Nr5TV2+X7wCu5ZRaWHhSTy9WmQqCWNhGb/IcKWc34VQfIA0cwW4859j0 I+z05wJS4xdBy+wTGQISKTdLpGv59h4Uj3mb9sTm/3cRk09T494+cY5tXKekHrcIHZGD XXK818EAskRQqL6og+Z125aXp5ur++Hi9+cgJ9Qknmy22fqwl9cebYiSvMgN1Z1K/BVB 1OjQ== 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=QzZsouR7Din5HPLemL+hHL1mAITvyQ7Z5IcL4PnrG6E=; b=VHunjzdrged3vuFGJR429jVJXqMhBYL5vn0eRtLtwNmDXAgooy1nhaslP4z3l1D2iD Jo4oGerEdUNNo8cYIA8v/0GVxHMcCOqN85kLu2LLU2j2ji9+lYlGkz+r/3uZ0inrnFAE oHhnY2acxLTG6x3vP6LRgwiEvQGiQPLvhJuvgUujsuG/P1AKR7H6pdOO8e/CY5Wn70xX 4FV4nyxKkEOcj4WdEFoY1/SuYj5zZtc4DODtqS+gzMDaMDyTRH7chKXPP2k+DU/P4oqS HV++vu7KjI9gNblHe+k6zS9r8VXhmPkhPXfNyJL7wbEkRwhW45CUBEnMofsd6kskOG3V 9Pwg== X-Gm-Message-State: APjAAAUqz9SGSpSl9P8N0tmJ0aYlIv2Xl9VGD9xCrtHrm7naP9ced9AY cXs8rUrQ5KV0NtNQuj3iGeXHWQ== X-Received: by 2002:a7b:c387:: with SMTP id s7mr2823247wmj.110.1571320525600; Thu, 17 Oct 2019 06:55:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u2sm1998056wml.44.2019.10.17.06.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:24 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 27DF11FF91; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 35/54] configure: add --enable-plugins Date: Thu, 17 Oct 2019 14:15:56 +0100 Message-Id: <20191017131615.19660-36-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::32d 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. [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 412b1e13af..65cfd6c403 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: @@ -6432,6 +6439,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 @@ -7259,6 +7267,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 Thu Oct 17 13:15: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: 176642 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp964477ill; Thu, 17 Oct 2019 06:57:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzUd4CCn5oh3eKVi9eUgeZhbHSXTR89xf7iCh11+uk3h6y5c8NUnfskMWDBPWyAmJlNOvc X-Received: by 2002:ac8:6956:: with SMTP id n22mr3895419qtr.7.1571320646164; Thu, 17 Oct 2019 06:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320646; cv=none; d=google.com; s=arc-20160816; b=sZQ6fxFQVJDnGdVDmCoOcrVJgpGwE3RH+cLJ6qNtkmPBIarS5Xq8iTaqIniVFCwi4c LSg+LdhDmra+OLDPmS4bRwm19IT/iUPWqmG+irAnDVX177f2Fb+BPWg33LJ5MemhEvF8 wTCQmszMiSob1VxTuZQEWtqiZTULe7mlPTwcdJINtcuRfDe7Qt6aK8b9B8mi94DNxZbs 3upchFSrd843GwgZsNPXT8pUQBCLENbjkuswcYy+jjkgzu+qJMahd+vp8hcPpNLdayOl b80ziehSW09QTZGExHZpGPtsvwFcQHm1Qylq7YpPwnPc6GY902AJBMios5WFKTydF6Bh gE3A== 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=CM8rduArDqqabgd+Q5UUF66iucomwd7DJwe474OgRXM=; b=ewApFZQNHQMD9MnZxfvrykliro7QSK8IWH5+8WhtverYwpV4h12UOrb4FSuCrX+vz+ wMBHSpLzdw1lNYkxDZCG+NQw0K/uJ2KT4gNGyZCG/hHdokeH6GgI15HXPzWaFh4NQTSN mQsO3QwVny00J1jcmKSqFIo5XIfag3Fu+d6aCy/ZSygsUEpA/vBITKqOoWO8WT/3HeDz BrmTxsVr3OgEzbRU1W3EBWvi4CJ4itSGd4imz3tp96HnqHD9RXMskE/sytOTcVyU+r/t vPXrnCL9qjAuyoL2pE1lkxgD2GoEri7lBT3Ku4fZ6iCevi6g0kPK+JkwkBlFYR6jzTO2 hOjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EI1fy+cN; 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 o35si2357194qve.172.2019.10.17.06.57.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:57: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=EI1fy+cN; 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]:48590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6HN-0006do-5f for patch@linaro.org; Thu, 17 Oct 2019 09:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35675) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mb-0002RJ-Gj for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mZ-0001KQ-Lq for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:37 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mZ-0001KA-Ey for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:35 -0400 Received: by mail-wm1-x341.google.com with SMTP id a6so2548970wma.5 for ; Thu, 17 Oct 2019 06:25:35 -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=CM8rduArDqqabgd+Q5UUF66iucomwd7DJwe474OgRXM=; b=EI1fy+cNslWhqY31RZJBm/N1TQKD/yZFrvCP9EcqCWzIblgirdgxhSQRHTrCo505x8 z74xQnLE8y4uw5YmdLU5dwCoi/AHKHf0I00p5eQjwHC/x/YrO1O7LQXhczwk9SpgIMbG PSUiPztKTuoWLxODIhUzFmzFMmj91uINyOGE/vMaBAfqd286Kk6lWsfqikytPxlabwwA aRfgv1EYI7iyPY9+6TsZD24iQ3JVbUtCPf6r2vUDHs4hp8X46c3z1EbhT66Xed4l+Gva FJtZgmjAoF7Gi5R+D7IoXyD6E0ODvwVdxGBHzZ5iKumDRQ7toEYeyWUVy4cfnYJmgz1p xnWw== 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=CM8rduArDqqabgd+Q5UUF66iucomwd7DJwe474OgRXM=; b=riQ7Bi2qF68heFZwv1bQD9oC+ZlTiapbvW19qnSmw4XdJRNGjtvyaVyjxs8lRnUOV6 zSsw5Bu4Lr11iNwuHn2PAWLyISFm4F0Rkac3lCILBGUWj8315oPIYZHc0/HgzLx5bkbM iqgRBy6XdKK/Jev4rISchkq31gHRndxTCN/jK3agew0gRl3uaeYu4fkQFiRuNZhEqGa2 8Zqz1mcnrczYGwNUAeHIXiMdTDQw1Wbue336XVWqvBeA8+Q8qa9tXWao50dEBpUu0H7k RLsAG1Yr/Nbm3/owE7WwQN2QRoe/2Fh5DGKeWgu0CmooHVTb8x1VUA+5nQmSZ75mCnuJ fS9w== X-Gm-Message-State: APjAAAXGqLOX9NGwPH7AHUBIDWkdchd1GjtKpCGIvaZRIvsIvSFVqI4Q GsWbHMRV4HvULVf5D5iX84P5x+Lsng0= X-Received: by 2002:a7b:ca4b:: with SMTP id m11mr2765271wml.129.1571318734262; Thu, 17 Oct 2019 06:25:34 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 26sm2173721wmf.20.2019.10.17.06.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 439E21FFBB; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 36/54] plugin: add API symbols to qemu-plugins.symbols Date: Thu, 17 Oct 2019 14:15:57 +0100 Message-Id: <20191017131615.19660-37-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" Signed-off-by: Emilio G. Cota [AJB: moved into plugins] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- 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 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 65cfd6c403..163eda23b7 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 @@ -5467,6 +5468,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 Thu Oct 17 13:15: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: 176622 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp942506ill; Thu, 17 Oct 2019 06:39:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8X6/0+eKIn1zmvxxP+pj+/EpgKBuPbx0zHhr4rIZiuTpUgB/wJHk6IHPIpSov6TcJHl6x X-Received: by 2002:a05:620a:2111:: with SMTP id l17mr3434732qkl.38.1571319571675; Thu, 17 Oct 2019 06:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319571; cv=none; d=google.com; s=arc-20160816; b=PMISiTz/5UnjgA3RhQENxwUeyt2+qqGXjj7Uk0NLAOGMVy1cE95VZ7bUAwjDHCTBOZ l1r0tYvPYEiF8NrOnS7ZCkoMfDUaY1zHyJO5TLQim1oZ+VywOY6c9Lyk43EjRlVEhbmQ Rbv9Vw3lDfqdD/WhLt/wSCwcOi7K+FWg9wYi/CETUXvffJNpSklxWZPbvGllpNyYSSa/ 3YFM2t+8F//7fta8JLfMJKHwWkLH8cEI/wjtHyx6wujmrEz57RF4Gq51N3BUD17T/N9E +5/j0ywYADorDF3a+nUWRdknNFvKTqHAWKKYK2vxA/644gjRdAT3EjAvDx6uHJirgFJp qPOw== 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=egF3Vw2goo6WaHZI3OIW1Hizhl8BXq2bn64y53glHKg=; b=D3U80lz+J8vMmhI1cGJJx5hDqK7DHon4TUt+2/1vVElnjzoMkE2FVBTYF7t00h3C5K HCaO/J4PSeLyzMCbMhWDJxCWtaAsRsiav6dfmkA4ffOJuhkWTiQ6YwEE5xmIdU+zqtq8 +nXCENleEQ7cgoLqd7u08LV0rTS/5HmmdIlV6Cmg79wcj32JTxp4+TLIH4Ug8El08iO5 oZeRlWW2qS36xQIqKjDLfsJ1dlxcwCPy/fnwH8C/UznodjwQjIbow/U5FpyRd4SZabre RaLRrB1gcu6e1BX3ErX5UE71ixcdcn2ebHOsD5KBdmrSzRZId46NZ7AEIVjg9EP41hlk WQHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=uQx+5Yk6; 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 g91si2199850qtd.265.2019.10.17.06.39.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:39: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=uQx+5Yk6; 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]:48128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL602-000290-Pj for patch@linaro.org; Thu, 17 Oct 2019 09:39:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35539) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mU-0002FP-1o for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mS-0001H1-KF for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:29 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mS-0001Gh-ED for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:28 -0400 Received: by mail-wm1-x342.google.com with SMTP id 7so2584893wme.1 for ; Thu, 17 Oct 2019 06:25:28 -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=egF3Vw2goo6WaHZI3OIW1Hizhl8BXq2bn64y53glHKg=; b=uQx+5Yk6u7tkxbtNEo+L83ysZJDMFfLKDyRd+ZlujWfrz5sp5hF+BAdcbN2v+/Z5O+ 0LoqrxDVpWv1ExC9ATz9iq6Qpx32EIRkK6h2VckKkQORkndDKV88oMwE3wr/LXZis1o4 rKnIL8gngxkTGIFb/EbT+ismDqUuYu+a2/ipMU/Ta8rnOpsFFqXedvWrxsqf2iHGfELr ArVWawPzqXuH6y0dIfv+p+HteunHvCs0t9s5QVbKhD2UBQyLsP96ZbiXrnUaoeXt7+IC 2gilmdFW+xaD6A3nSUq1wJ4QwSSTpJngv/OSxTVICegrzlXPjHvV7W9oucprdiT3l98G prTQ== 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=egF3Vw2goo6WaHZI3OIW1Hizhl8BXq2bn64y53glHKg=; b=rmnndh2PAYAdp9z5eW1wMQlxkSPYEbZUwomK6bQrnGyzoI5mmiM5lm1iY+8Wgw2mPW Ziv8+CYYw/1tsnWXKaAtTIczwwZ5zIIfakh0LFc2MjM1FtmA7+se5oda4OV1x9sQoIqL AhK625bASz8ko8X5A+WkHema9BKjrG/gx0U6CweQVDW8H4Fns+iP5Pf7S8l0PufSKOlJ iImebL8Xm/zMAUB+t2Boe1rDU81oL8YFqOD7nP29ghTNkpd99SVwBa5RChutFWiL5oh3 99yu27D+pQefgp2u4GYXfX6LbPjoVYn4eUmrcLmgfgEIip5a/ylPyWahqeLL3VNgdvgm JoSQ== X-Gm-Message-State: APjAAAWjqqWcQhKQ36G42Wr19kNI1/19HWkZwGcUp/LVWkA8fgaGsFmC at8yxAsnMHzARA2MkLhM+bCe/A== X-Received: by 2002:a05:600c:2318:: with SMTP id 24mr2796054wmo.146.1571318727264; Thu, 17 Oct 2019 06:25:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n22sm1966559wmk.19.2019.10.17.06.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5A2D61FFBC; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 37/54] plugin: expand the plugin_init function to include an info block Date: Thu, 17 Oct 2019 14:15:58 +0100 Message-Id: <20191017131615.19660-38-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 --- v6 - split and move to pre example plugins - checkpatch fixes --- include/qemu/qemu-plugin.h | 26 ++++++++++++++++++++++++-- plugins/loader.c | 23 +++++++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c213d1dd19..784f1dfc3d 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 eaedff577c..ce724ed583 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -28,6 +28,10 @@ #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" /* @@ -58,7 +62,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; @@ -145,7 +149,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; @@ -193,7 +197,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", @@ -241,11 +245,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; } From patchwork Thu Oct 17 13:15: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: 176679 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1058222ill; Thu, 17 Oct 2019 08:05:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYXSNXkXF1K4Fs1G3AeFm0GdoC//En20GbqVyQSe9ilRnxAChvcj88mEeSf1CW8IVNsrVm X-Received: by 2002:ac8:5556:: with SMTP id o22mr4284797qtr.217.1571324749661; Thu, 17 Oct 2019 08:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571324749; cv=none; d=google.com; s=arc-20160816; b=eYgYdDCsj7O+T/rjXbdYNiJNqXD90a8BmooY4sbwxazEWQ+40Iom4vwFcP88nGNkao KjrEheYPykb4qJlzFaPjmfUk4stTDPZ0IFFDUV/0I3Wq9INj157xe3BbZgCbVDp77na1 l9bWmN04BV4Awqi52/yFO8CEarb3ApHLIjWvn1EzkedOg51hL5jRV3Bvt9pKscx5QCUC BL4ZXHk93qAC2DXK3G6e/0OuuIPY1gyn4g3b9QmMyeALfT/0qcLmwv7G6YasviMKpmxN d7824i53oulmPJ+bReg1sKpKAAhgKyASHkR30Gyptf9f/mxbF4bH8FYQS1hpi93PaIy4 s0Fw== 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=IUolK1djo1mG/qeP/V3N37e2P0JzDbNnrEogdbMOcvc=; b=ZedJq14h81qEseuq/dDDdtnapnX0DwtBDamU5q44dQqRfRMbUnHakU3GLRqDkZ2/Yt PPySzYefks57LMizzvPJIvIUG9srKc+rXLgfGpUFowKwcSZymBYQdzuLDA+zh7lpK+cd cKaEj1HoX7b3XJfaXSzKIRy59GEu13v0SzUzAIC0a3DrrRaKqZk5j0Vwopoco1E6sqOV Yay/SzeDjEBzjcXiZ1ziW0a2ycWCZCTWoD71ysRKT4st2Uybfo9U/7COc7fhjRiwbNhJ SuewlRvOuSw7JKdz36HTcXG87WZ+Z23CfgAwmHanQj5PR1k7+L0AKVAExjKegFPIFnsd p3Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="IjE/7y0O"; 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 f52si2253512qtk.208.2019.10.17.08.05.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 08:05:49 -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="IjE/7y0O"; 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]:50282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL7LY-00081Z-FY for patch@linaro.org; Thu, 17 Oct 2019 11:05:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41259) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FW-0004eR-FY for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004ER-0B for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:30 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:41293) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004Dm-8R for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:28 -0400 Received: by mail-wr1-x433.google.com with SMTP id p4so2465158wrm.8 for ; Thu, 17 Oct 2019 06:55: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=IUolK1djo1mG/qeP/V3N37e2P0JzDbNnrEogdbMOcvc=; b=IjE/7y0OXIQ2X3aDICESxenZsSZW9mEVtQskugt3rIxDOMEPFSwNEmuRwJ/UVqIFhq BaDLMmeKK6MEH8KUvSJfbcTr6UtU7ncZjojdpAkXeaYZGfUvdQVsqLN24H+Jfjt5Mfgo IgKgWOzqfDpcNCM+HNEyl/C3fXAQVRUrWmDwC2BNNoW+FkgLYoQasZJjS2Pk6GW6uZ/P aEmSVDaL0s3YkEN45ypPfclXbQYwBJ46YXNE+YmhhWpfhUg9fEYsH2JiZnHucq7eg0r3 z7s+YyoyVcCrCgIa084pqZaHLx3eNgeojEvg+ArjgI065pyDFDrDExjPbSXQnPd3YYAl Fiaw== 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=IUolK1djo1mG/qeP/V3N37e2P0JzDbNnrEogdbMOcvc=; b=aN+c99eizyrUiI8Mnh3/SxPd6JOTEnmVEUdN4G5RMPko7PdBiEoQSmD8xnXc2c8M8L /4iaKjAgxMMsv8/RaS39yUDZLH2K/CyYBAVgAp89lXMYeXHSxb70OoxFq/K1Jv4ifOU+ b6ucMU+EvK5WH+NXUuN8qny3FYxD0XLmXopCWWyrD7PZAOWlpcz/l0X//lGEU3I1mhw0 jD3Q66zPGpkRlOo8ka4QXkiTkc6pje80LORbxWpPhJy+1aXNqED71utD4cbfI0iV6KXS RxydQXVyxn8nGKrCS+4L4Lrkn57Coqv6aYcvYO2gzqqPEzmv7U8K4CZx6CWaeLevUJbg eiHA== X-Gm-Message-State: APjAAAVN93wkcEjSvc+IUw9dX+yi25fqg3G0tmHfcwIHR6i3OeicBr6F Z/dHINEmKW/U5xG38vUFVjWCMA== X-Received: by 2002:a5d:5052:: with SMTP id h18mr3343591wrt.143.1571320524084; Thu, 17 Oct 2019 06:55:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f143sm4398695wme.40.2019.10.17.06.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 74DD31FFBD; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 38/54] plugin: add qemu_plugin_insn_disas helper Date: Thu, 17 Oct 2019 14:15:59 +0100 Message-Id: <20191017131615.19660-39-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 v6 - checkpatch fixes --- disas.c | 110 +++++++++++++++++++++++++++++++++++ include/disas/disas.h | 2 + include/qemu/qemu-plugin.h | 9 +++ plugins/api.c | 9 ++- plugins/qemu-plugins.symbols | 1 + 5 files changed, 130 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/disas.c b/disas.c index 3e2bfa572b..3937da6157 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", __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..36c33f6f19 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 784f1dfc3d..ddf267fbfe 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -351,6 +351,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 33dac8e790..5adc4d25a1 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -39,7 +39,8 @@ #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 "disas/disas.h" #include "plugin.h" #ifndef CONFIG_USER_ONLY #include "qemu/plugin-memory.h" @@ -212,6 +213,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 Thu Oct 17 13:16: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: 176631 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp954367ill; Thu, 17 Oct 2019 06:48:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTwzU8595KUA8fiD78HxWJZfGvxKfE7ClmVb7UYczw5m0JUWRsHc8dR+Z98GKrzqhmPhEu X-Received: by 2002:a5d:43c1:: with SMTP id v1mr3220322wrr.91.1571320139630; Thu, 17 Oct 2019 06:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320139; cv=none; d=google.com; s=arc-20160816; b=v7oN6Q+aDowQeoAB+fVKLFLG64omU5TjhaGSgbQVPacRvulgjJEeHK9iImDJjTNL64 1uKZbQJupfTlxQDdWkLMVQe1vrrzbNrTVrWg55TRdyuu2hsO7NbBMtDjucnMD0s6Sdyx VAyABGF624V/D1kzoN6J6GJt1koxMs4c0xMJ/OG8/4n7HYKlSVyxQgGIfgwwNAX9Nq9N JTAs8ek5694JPmwY/UfIMkHsJ+cqGKaoSQ9pnqHU9RVkHFnsVBkrRdGg310qcupHfLJx QQL+XCdvlr9TdXQEPM5yDbs/RIkyx8NmWj69AYqy5ceeFTmce6Tn1HyTvMATHy4uPVbG p5yg== 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=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=tNOA+opXg4A4h4MQtfvO9iypOYENrceSzqzf11Z1g1pkgr5Td4w3LtNYzGIIaSAeaf KCgITIiur4kbBfdHxkBd63wQsW9kghCBcMRPeenRiVTk2T+O9OtxF3wpIilNog+Kafry iCqTJfYqaRyaX8sqBikPVFQzZu9lssSsDR4ON3oWm/rX0IZUa69rlL0lleyfktonH0d7 S7DPzBSYVplNP82BDywiqypk6N6aEhqUd8PDn/JkRP+49c0JwJm69Y7RBwIlLsiPcoZs R5+XXFLal5e+yaS6bf7fcAtnUxGdTRX/nRO58JRSdgbA0eC6OPzURRaeXaSSKqgVzgXy wV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F0Vb0TwW; 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 x10si2072119wro.30.2019.10.17.06.48.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:48: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=F0Vb0TwW; 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]:48342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL69C-0003cE-44 for patch@linaro.org; Thu, 17 Oct 2019 09:48:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mP-00028b-PS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mO-0001FC-KC for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:25 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:42836) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mO-0001Et-EF for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:24 -0400 Received: by mail-wr1-x436.google.com with SMTP id n14so2339894wrw.9 for ; Thu, 17 Oct 2019 06:25:24 -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=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=F0Vb0TwWW1BUduZbamzC0yB5eWrB/FWr0gz4JEIqQQqbx27l7sDZ3xm+0uNKm/56Ri CAzQMQZAn/QnafbL6Me8wcdtDJx93zD/piEQwvCN+vHbKkIQJQuRo5FxruOL4P9vrCzv p1U6J87gutNnneKMT7t3nsX961zrEwBtaB3I+CblSkDL1AtKUmQ4C6+JsQMIXJO2lwNC cn0lTU/5gUiogWn5tuKRHJMsYIKI4pu6BFNpvUOgo69Kkka6l7d2mabRghZDyrTmpiXd ua/ljXnkT+61npG0+pak6hhuvr3iGgElfPI+tL3KNLxOc/Ivt9oJUqBBIDgdXssbpOBN LqFA== 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=J5h9LF/cBImRwgBymxo6bpvt6wjjRh3DJds8b7bRsjM=; b=XbMg3sVj5Wntqe5qMos0al6bWXGNnjnTQvDcpkC33ZmT23f2xOs+u6rf5M/l3yxHPH ZDSGSV6PNrsOFUIWC/7sMGKw2n53qLmGi0xk1r8cdAJXl4ElbNj5JCm4L5fFuKPcdJNC 7/8AfHjZslO46voPzjk2AJ7IeB+mDddvhMQZMBTlePqCG9flFgFtGjD2U5u+7QjWIomw GrWp7g0tFPMT7JMJspcPbvQv60d7ThSA+9Wb342BOy27y577JPLmUX1G0wn9cWYFueq0 XhJhq6NApU4msSvoeTkF6b2RnJgtX3uja6ccC8hFl7TnTNrSJr9ypwu8d9PIKgcfj0s3 XyNw== X-Gm-Message-State: APjAAAWnOAoUTtqGjoNxeQGc5Faj7FK6UpyhZqsWn+0D9Ua1/7uC1Ppp T2uRO2jsiXP1iO0QhYiy25YKOnrraNs= X-Received: by 2002:a05:6000:1190:: with SMTP id g16mr2997913wrx.133.1571318723103; Thu, 17 Oct 2019 06:25:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x5sm2494190wrt.75.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 921BF1FFBE; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 39/54] plugin: add qemu_plugin_outs helper Date: Thu, 17 Oct 2019 14:16:00 +0100 Message-Id: <20191017131615.19660-40-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::436 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" 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. Signed-off-by: Alex Bennée --- v6 - split and move to pre example plugins --- include/qemu/log.h | 1 + include/qemu/qemu-plugin.h | 6 ++++++ plugins/api.c | 8 ++++++++ plugins/qemu-plugins.symbols | 1 + util/log.c | 3 +++ 5 files changed, 19 insertions(+) -- 2.20.1 Reviewed-by: Aaron Lindsay 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 ddf267fbfe..a00a7deb46 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -384,4 +384,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 5adc4d25a1..fa1d9f276d 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -331,3 +331,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/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 Thu Oct 17 13:16: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: 176668 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1028017ill; Thu, 17 Oct 2019 07:42:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqymFiqgh7ff/0qNohbjBgAK1fR5mmOYs4HqPu7VtJXFa9CZ8XbzOk3UbHfwmA4xI2D0DGfe X-Received: by 2002:aed:2ce7:: with SMTP id g94mr4255778qtd.133.1571323359564; Thu, 17 Oct 2019 07:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323359; cv=none; d=google.com; s=arc-20160816; b=NT0VV/zjDPLh+6rFXuOtnmE/yJqoNs9Br7bNnICLFEaVWB5e4HbluUdE3n2IOBydPW +/gh52JdOxlMRzs2JiEAvMuPiBMNv9q0C8XA6ERnSdw+uJFe5frEZCiCYQypEtk0P88K /LKCtPu+YsRX1eA4CCWrbXTC1DZZ+wg3CIlqADhXSQkztdABy49Grmi7VSzvAZ5422Xw 52Q58aPBSv26Ee4vxNSsgRBC1LqPox2l2YYjYO0fS7KcvN0Mw+iTvHtCmkb7AHdwz3xK uQM7Z3LjQOPZcbjxy4+/HNP1ueZsW8RT0vzdLSag3qF1nMjy6l35Q54nvuLeMwUIXhiQ A8ow== 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=wXzF3UTyYexiGoLPILzFIA+g87jBMrJCBXwgiVbZAdU=; b=GH/4D6f2UWOye/nB72yzK/c71KuLo+IjUifNDaeW4G8g9igP4D53VLwUxTNaCfoYN1 Pk2fl/q7UH03mkcDmf4394r65+kyuB/MQiWbAZWKfX+YyD9AJso0H9ICgqJeK+j6634W vOIjSporJrnIqsmkMBQGAgycBkPXDC22rt6mDErllUlouJbr9aCYTvfpB3wwo7C0q7h7 E2PuLAhUBHg7wbJqmm3uMckvZxvxAXqmOkmGvh+7MbIjVYvL8wOXSTiZ7tI5P7ksVjhh /SRZPeVorxcW9ls+Q5pJFZY61bMkMcOjgFd1P80HYcJEsqHR/DOEW2l+0Z3uMcOmeDs0 hMUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xx9cw4yu; 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 x1si2066248qtq.290.2019.10.17.07.42.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:42: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=Xx9cw4yu; 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]:49551 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6z8-0003ER-J5 for patch@linaro.org; Thu, 17 Oct 2019 10:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37547) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wB-0005zP-4N for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w9-0004SH-2V for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:30 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45501) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w7-0004Qy-2Q for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:28 -0400 Received: by mail-wr1-x441.google.com with SMTP id r5so2365609wrm.12 for ; Thu, 17 Oct 2019 06:35:26 -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=wXzF3UTyYexiGoLPILzFIA+g87jBMrJCBXwgiVbZAdU=; b=Xx9cw4yu1TSSeSMg8VZlvM353VSsXYztlUJMW5eYaIusRFClRVHACQt23jC7UjXfQF OgIVA37dqY8NFY7FcQRUtdRHsil4FZFgOHXrTrM0Fhvfb5CqyYmI86TcWP9PNSDhn+Xv EVZwNxPJQUuo9bSy68nPXw3sr2v0ZuUyYx8hxIjndHXXnmgiO7Vm5d91jEEf26Nvoyov GnhHbGI9K3turwctXPPfmUWvfwAWA0VVuyIwQYF4G12iy4CwMTlHAyazjvoXTt/WjtbN TwqdHTa7ax9ZEtiTL2GI6Vas+nIC3DwjLEWUYrpyCe4Hdyi77JwBe02ota69OGmn03lN mW2w== 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=wXzF3UTyYexiGoLPILzFIA+g87jBMrJCBXwgiVbZAdU=; b=LeaYGGZp4/AHWW2x2q4UsqoN1D0+LCYTbJZuz6Azf3c5suYZozDeq1RNFS5bGT8lgc 5YgftKZcd74yqZKTMbKokB8mJpKeNlU1yQRCPgcIDyR+FXMNX5ndVf7whmWLesg/B7UT NSpf9NhrqqjmwF0HDR+l0v50Zox5dUBFyb3pw93vDtIiOhnY20vXOdqrU4UeB6Hkvwey 3s7r/Pp8/pGlZoxtBQpe2kRWIyTlRCePrihX5XHA6Iz1p6eXoCWyt3dZM071V8USVTaj SYQYcbSwFaH+9rkesuDbH/g2nYbgfJvSlCQv2PV8isw8FpSJ+Cs6Fuh9TBaw7XeO7NpG 5DAA== X-Gm-Message-State: APjAAAXfBYl9/DJmT3Hlso5zON3QjPtt/FHd5mlotLNEGP/DzisveM7S UE4P0435D4x91e5ek0de/vICkw== X-Received: by 2002:a5d:68c7:: with SMTP id p7mr3056653wrw.156.1571319324766; Thu, 17 Oct 2019 06:35:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d11sm2248332wrf.80.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A87761FFBF; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 40/54] vl: support -plugin option Date: Thu, 17 Oct 2019 14:16:01 +0100 Message-Id: <20191017131615.19660-41-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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?= , =?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 793d70ff93..37f13689e7 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4166,6 +4166,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 4489cfb2bb..8b1b4133e4 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" @@ -2854,6 +2855,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(); @@ -2884,6 +2886,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); @@ -3678,6 +3681,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); @@ -3991,6 +3997,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 Thu Oct 17 13:16: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: 176674 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1036588ill; Thu, 17 Oct 2019 07:49:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqztqZx+JR3FHT8nh4FbRfoKgEKgCNPiKDCXFSeAxhNaj11wJHgjKijcRFwT9rvIsgYbILuM X-Received: by 2002:a17:906:a88e:: with SMTP id ha14mr3804757ejb.92.1571323767573; Thu, 17 Oct 2019 07:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323767; cv=none; d=google.com; s=arc-20160816; b=I1OXAgDL3VZqxy5qBRKz3ORezae7xp0r9z+nun4+Z9q7XC+5WkzQNQmF9dKsBNIxZ9 8xjYXaIdJ3bSIFBwUbRbKvtgI3dEIVjszu+KXu8xkCANzNLoluG99lBS65K4NGc3iaoz iKNLR+Mwyb8OIVqwvfxlSU09lFx05UTSusSeWF20yCQQionPt693oet9i5oH1okDPgxf gxaS5ZIqGWZHHvH4kSjZ/r1FQ5iCFQnnfoJS5iXpC7mzBEbw//v6U5l+Cq/aJ6h59YmW r3mf3Q761sniCYVXoH1koKyHsL1p5roZG4eXTbRxIZ7QXVYmOekwx+IOdDzWWbshMvhS K1Eg== 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=NjXhTz9pnC6p+0beCyXekfXGYwoj9Xl9XLtrbq4AxFNupWlwXdFKL5DLlCNqQ524Mu eruJVqe3iPa9sX67hkl521IgFr7Jm3MMEGbehyDm5edSikT1glDWpiIjSbnqKa5hGzqE 7sB1CX9letaN7U4JbmGT/lLTWzRgfHsjtRQY53R8H8KxYK5cfv/ZjjVeB1Op4ETeapzE yuEDntqFxEt7oEaHDWdkS9Yp6Eor61gb+Of9GP7fai4F117mH7Xyxx8yMhMB1elUZICY KGV8Djt9+J8mT79RiU8uChHDjfiKuXCwn8f6HnWVyJ2sTzo7JY2FgObBZ6X7U139Gyj8 uxRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Fd259wrH; 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 m10si1417780ejc.337.2019.10.17.07.49.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:49:27 -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=Fd259wrH; 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]:49710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL75h-0003er-W9 for patch@linaro.org; Thu, 17 Oct 2019 10:49:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37586) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wD-00061s-4V for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wB-0004Tb-3F for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:32 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:36065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w9-0004S2-5n for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:31 -0400 Received: by mail-wm1-x341.google.com with SMTP id m18so2582864wmc.1 for ; Thu, 17 Oct 2019 06:35:28 -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=Fd259wrHctY9DyUwxxGiqpFZD90FvvM4HkUoSRPzNqIJYMxfFJHxhtV+BvjnRKbUff VHJp1fYBxYD9cKEmzyZ35yiDHQ/8kncKyj4C24KTZOIAIeRwt9QL41hqB2HCgkWJZS2S IaUb3K1GFyG0ORtfcDOhy4GzNraq1RAq9PeFwnARrlA3uqCk/Nw8f+qbdork+1FBIaMD NMlFmMTKffTzFKg/1JlCx8mCUwm4Ymtiuphcj3tB/THYh2eXVrTzAyBXXigoLWnGh4wG mALJbUXo2NGSds4XTBbN7fPN6ENxpAr7eEaJWk+d5gUE41JjV/adU6ODRLzsLHmqSYOG 3RnA== 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=DFu7u00ZDd3bNqi1pTp2udYuez0ahxQrrNX5OSyaZ6zIEO9XD8knLz3aKLof09IBZR HUYYG59KMrKifQuP7WqthSeOhWjDalIkKIO3VRF03xRp5ofBAHZKhm0ash8Aa04sIeHW 8bTEy6iIn3qRFCTpcb+/bfeUcIZcUaAwrgdH514h+jmbyNB5DuZaSn/FtBauHA9o6yUI gR9Y7vtnAswpjJSUN64dw43ycjSv4oFEqh2QiRv6ClkBQ8gs3f9iadFX9JoIUeGASjCt THsH8k0A1+g68zWL9DaVrdlUnJz508j/RRkJrZnahhhjbnbq2HRnmpeGb14paJm8Nk/i siqQ== X-Gm-Message-State: APjAAAWbQ2Q2rUp/z7lkUmivQkhK8+4nJV2E/TKpltHvI0LvgzaWyltZ wL8InJicvwemz5zoaIBvZKgXsA== X-Received: by 2002:a1c:9990:: with SMTP id b138mr3040374wme.176.1571319327845; Thu, 17 Oct 2019 06:35:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l18sm3094463wrn.48.2019.10.17.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BD5DA1FFC0; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 41/54] linux-user: support -plugin option Date: Thu, 17 Oct 2019 14:16:02 +0100 Message-Id: <20191017131615.19660-42-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Thu Oct 17 13:16: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: 176624 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp945467ill; Thu, 17 Oct 2019 06:41:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF/sS2MUgDzHgbJyMVrlx7rfvwgF6StDx405TSY+lPMGKOif4zmV9CRC3hS/v/OrasS2H4 X-Received: by 2002:ac8:72d4:: with SMTP id o20mr3887753qtp.366.1571319711831; Thu, 17 Oct 2019 06:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319711; cv=none; d=google.com; s=arc-20160816; b=mAuRkzqJitWX6a+nRNqWXBCKXBlZtbcCVyMLe28Sn1WLqzjhpsq+DCcxZGHtadPT6M Eks2T6cZeZjNxujOVMiCqH1RI/7lk/Nidax4+Bq1Dlq8SFM2e+/Y+Zhy+jpD5/57FYh3 0c966FKlFy49QJQJEOECxXOLWfoCj+uojt02X8jMgfBk5HmuryVzsAvrlPMQOAwKPJ5M 5EWb144lGt264WSfiqHo1/aUemZiWlpaii00Msp/MImbsXjp0APL1VOSQExJ06cVzRqS c5fPCVEWtvkQ0KvcsLHrUORyV4HXLxXo+iAeOX7cAHxhgkaM8aX6KteZhhdOEkZofIgq fxMA== 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=SV7LIVH8inKUDnsFl367qU/UVX1J8Nzuw++QSYd8XdE=; b=yMCYA1vFxIyIDQNSzUoVtFnyLxpQ5e1xYC5sjue68TaJLnBx/1dzPinPK2bg48tjZj atbOf6NRu6KSDEySrofWEVK9DDZQ9bUeU2pFAU9Vmt/JBxu7xHs86JvMq6dB3guysJNg Ox0F5fwsK0Wnar6ji9kICSZu/V1ZGexoDUhCmArEfJUXwefnyOu1yAtTNkiNZHJmaq1D PiawURubYUO5glEKp8mImH2juxSskDicD9zvHrdlYA0/zBjlaVb8HMyJiD11ITdDoOTw xKw6PMbISoQydYgoXYb53NHO4xAxLqnwHfSSZdNJU0Mn3Mtqq38MImFeDjd+ur8wof+E zBZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H7B6CHxT; 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 m32si2123074qtf.85.2019.10.17.06.41.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:41:51 -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=H7B6CHxT; 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]:48168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL62I-0004sE-Mx for patch@linaro.org; Thu, 17 Oct 2019 09:41:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34051) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5do-0008By-CR for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5dm-0005Vm-GN for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:32 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5dm-0005VH-8d for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:16:30 -0400 Received: by mail-wr1-x429.google.com with SMTP id n14so2303117wrw.9 for ; Thu, 17 Oct 2019 06:16:30 -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=SV7LIVH8inKUDnsFl367qU/UVX1J8Nzuw++QSYd8XdE=; b=H7B6CHxTfNKKQk3kgKUvZZ2wZmPNlRtPkDpiMwBHJEheYDGRW6cMNI2nbgFzO53/SF pNBKvUUo2E+pBYYRnBlJSDDzU+mfUubeTcORC4Ut76X1nXGeYGC/BHXNlgDfPG2dRyuD 3sQm3BeQNuhgw2D1s9b6kfx5awHn+X5m53NKb6xn9J+LHrRPePHDiJjT0sRVtFcj6+C0 MYxTVlfm4BGD6bOnqu2gFS0NsEYVNP620ZQHFCeQkXi0pknXUA7A4uxLBoMuuvA2uMOL 0yufnh+MzFd+VRqyEoTHoPgMRXMj9GD6yF+T7oLW1KcuZxeBuLPXgJfF9rGxiQXpCh+N nWrQ== 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=SV7LIVH8inKUDnsFl367qU/UVX1J8Nzuw++QSYd8XdE=; b=nOFhqyG5MGjO2Pab0mHwiRbAosR278LBSoHk9yebM6ycGl6ztN9kwJR4TczJEde+6U Sb3IbwFdos02Fkov+/raiGcRI5K8cBGiY3j+tQogPYjSigciAN6fiDh/9hv+fNizufJv F2jiTpHHqOTcv2PF0Lg74zJe0OHPWNPudTyAbMbIQJiVlkIlXDqqWNboe47gUk4WKEZP fQwlD9qt+aCT+lN8ZgQpmZgF1B68khaOvMqdvb7k3UJCq9AXezEtXwXWlUBq7FUOQWO+ IPROLFSND83U2jYXV2mIzgELUZjI7xG2tC/bqQP4/iVOAlaV9DNtizFnvTJ/mIpYLPgI aiyQ== X-Gm-Message-State: APjAAAV7qI2ZAbSNPmGQyS8m8CzeVAwdqiJgVll2e4xmNv7A3fSMdUO+ TXgZZjgdAwGGqMfiyK0XW5WMTA== X-Received: by 2002:a5d:5444:: with SMTP id w4mr2932358wrv.18.1571318189026; Thu, 17 Oct 2019 06:16:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z15sm2412542wrr.19.2019.10.17.06.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:16:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D99521FFC1; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 42/54] tests/plugin: add sample plugins Date: Thu, 17 Oct 2019 14:16:03 +0100 Message-Id: <20191017131615.19660-43-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::429 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" Pass arguments with -plugin=libfoo.so,arg=bar,arg=baz Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - tweaks for hwaddr API v6 - init/outs api updates --- configure | 1 + tests/plugin/Makefile | 28 +++++++++++++ tests/plugin/bb.c | 64 ++++++++++++++++++++++++++++ tests/plugin/empty.c | 30 +++++++++++++ tests/plugin/insn.c | 61 +++++++++++++++++++++++++++ tests/plugin/mem.c | 97 +++++++++++++++++++++++++++++++++++++++++++ 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 diff --git a/configure b/configure index 163eda23b7..63c9569aa0 100755 --- a/configure +++ b/configure @@ -7890,6 +7890,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..45e1de5bd6 --- /dev/null +++ b/tests/plugin/bb.c @@ -0,0 +1,64 @@ +/* + * 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 + +#include + +static uint64_t bb_count; +static uint64_t insn_count; +static bool do_inline; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + 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) +{ + 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, + const qemu_info_t *info, + int argc, char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + 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..3f60f69027 --- /dev/null +++ b/tests/plugin/empty.c @@ -0,0 +1,30 @@ +/* + * 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, + 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/insn.c b/tests/plugin/insn.c new file mode 100644 index 0000000000..e5fd07fb64 --- /dev/null +++ b/tests/plugin/insn.c @@ -0,0 +1,61 @@ +/* + * 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 + +#include + +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) +{ + 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, + const qemu_info_t *info, + int argc, char **argv) +{ + if (argc && !strcmp(argv[0], "inline")) { + do_inline = true; + } + + 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..d967388989 --- /dev/null +++ b/tests/plugin/mem.c @@ -0,0 +1,97 @@ +/* + * 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 + +#include + +static uint64_t mem_count; +static uint64_t io_count; +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) +{ + g_autoptr(GString) out = g_string_new(""); + + g_string_printf(out, "mem accesses: %" PRIu64 "\n", mem_count); + if (do_haddr) { + 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, + 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, + const qemu_info_t *info, + 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; + } + } + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Thu Oct 17 13:16: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: 176665 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1026314ill; Thu, 17 Oct 2019 07:41:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHMQjKWG6BeRvIQO/fGmqcGy5m+WS3F4D42aVjynWhRUuX+3AL9AzJo78arvAv7uMkwZQm X-Received: by 2002:a37:8244:: with SMTP id e65mr3574336qkd.233.1571323281396; Thu, 17 Oct 2019 07:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323281; cv=none; d=google.com; s=arc-20160816; b=M4Kkzm3MFt/X4ZY/nOvcDLZCCm5h/jCEnd/ZeRslLlPw+wI5oJKlujXIKLmBmP+Mcp uNTqE4gQthq4HcGN9Jm8REv4xQK5hOdTHM509vxSmxmUE5bQFffh1/wK594D16AxUObV PtjD8LCjrJ+9UwfUjKJODn5qsXT/GO10Pw8t1f+w2eacjHkZQzSH71BGJ9EWEk+1RF6c VcZnH50/usf2juHI94gszvkbkIheLRV5D6lK8UTCz5lcAybpdJTIgZiNRwmIhW0+mUMB yaFM/vRKeP9Ei1gOt5MjuAfxD8q5JowfvipdZqlOy+vufOrNcVhc3q6S/9T4MgUg+x7N 5lrQ== 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=YEs/lUjotuLdLq3mW4zXQsTPxT1HP2QzsnSAtyXeLV8=; b=bTgG8hh0goEGRLOFQrITDB4zDly2zqIkA+gEXTiqaQ4+PsI6XC9RssFyd++0rSnwje W5nb6s6P8M8AUlf9Rj1rYyB5vczE1e0/eVAjwmFIfH3gq7xJwvp84LZDiC6GnveTb3Np dMdQKDJu6zL/cEMpjLuCS1kwnng+LpWTTMtw9KBVjR4Fcp3EkXfeCVja2CXsryG44JD1 xpQpKUL4TJp3OQP3WmuYMzHRWvhpZrebznDo/UXo5zfdElNx8raZwQNWLsRpegQ2hy4F C5Ps+BbO8MOX2sPGGw5Mzb4CKEUCdlF2x1UZRQgL6h/hM4gnJiwoDh1CtlbtDw11YBns /V4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BN3O3PNR; 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 w141si2002961qkb.88.2019.10.17.07.41.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:41: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=BN3O3PNR; 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]:49520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6xs-0002TW-2t for patch@linaro.org; Thu, 17 Oct 2019 10:41:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37629) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wF-00063O-6v for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wD-0004XE-3M for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:34 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wB-0004Sv-2P for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:33 -0400 Received: by mail-wr1-x442.google.com with SMTP id p14so2399356wro.4 for ; Thu, 17 Oct 2019 06:35:30 -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=YEs/lUjotuLdLq3mW4zXQsTPxT1HP2QzsnSAtyXeLV8=; b=BN3O3PNRfTbP7VzwYNVf+Wt4Cym5m1AIFi436ViEZok/Ywx/tC9gQNTc0Ln1Ak4QnE 3OMim7SEtOoMNFWnT+bkeGrDPpbi0hSkqWVQpKfaRhGD1YOGc/+vmKHMj/JvzlKeFKk7 XcE4d54nw2blW5jGEB0Je5gRnUFuSZ0wXc5d3F3wXR/8OF8jNVKbEy4nlTCGR06wElRA 5pygMBY1yUmwl9fR8ul+GhIP31h+1ZPlfVtM3rWctO16nbQ8qdWqQpUeBiQbKrRBn83H +Bo26eqgCyZALf6pVoKrrvZk2qWK9rM/+dqV/KfKJiCJQINuVN6CIlgMlyQha9sDs7a1 plpQ== 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=YEs/lUjotuLdLq3mW4zXQsTPxT1HP2QzsnSAtyXeLV8=; b=LJEf0jipDpiHWjHjoGscMTWOsEKtgOZ2gRm8C5PJPXjwUuG/Xd2qBtBTyVis0NPGVF 7fhHR03jQTg46hB1sG6beVg7T4T1DB0hfIv1Sou+UBBBMDb7RSAdCah9X25nGh80aiFI OwjKO9Y49Gf4203UTsHH6S9Z0tFCTkDrLsxy+F5Kr98OgqovlD2Yp+sydAR2dfTR48t4 v9Fr55ajDk/oF9YjnlirJNecgHbXkjr0f2GouJJv3vO4ZHsGDA4yhhIbTS+pCoIo8IOB 1MkYAKWikTYiczGsuFBucBZF6BKo7z5GHlbELvWvsEVlE5GrPuAXEzGtEwZWQ7FA55oR gA+A== X-Gm-Message-State: APjAAAUFfZXPPYN8HeqAa10yQ4/L6eRx7DPUVD73/nhx2YIUzsg9cT01 WY2G1CVTRGtwSKEfGJLyBWzneQ== X-Received: by 2002:a5d:4285:: with SMTP id k5mr3047023wrq.344.1571319329956; Thu, 17 Oct 2019 06:35:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u4sm3122531wmg.41.2019.10.17.06.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id ED5451FF90; Thu, 17 Oct 2019 14:16:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 43/54] tests/tcg/Makefile.target: fix path to config-host.mak Date: Thu, 17 Oct 2019 14:16:04 +0100 Message-Id: <20191017131615.19660-44-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: =?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" 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 Reviewed-by: Richard Henderson --- tests/tcg/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 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 Thu Oct 17 13:16: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: 176669 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1028958ill; Thu, 17 Oct 2019 07:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxo5boov0m85Wv56WMp22b/P4SdTqNaL7i9rFuB2HubssB8ejCZEwTaI7BOLVz4OegiiaKh X-Received: by 2002:aed:22c8:: with SMTP id q8mr4438082qtc.0.1571323408221; Thu, 17 Oct 2019 07:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323408; cv=none; d=google.com; s=arc-20160816; b=r2bmYygIBy+ZX4jV48EdupMSwzHhAXvrUHAj3Ok8k1BQ6RWBWslWi2JUF2kIObWQ0p I3sWco4ZXjgR+vdxEz7JZpd7VlnsTnwBFVKADGZ2izHBhD7tFSuGWSPY1eFHYqXmahC0 hbsIsUC4KtKp0Svc8gd4ZKzEIlYIP1Cj9X0i/D79Bvv1pgVTbUkT1dUrefVHdmETXzMU WLs8k9TlQgifmGsPGJmrfpbJ3e7ddMfurctUtYjDC6qAB24gN242uYSk+Fo/tFrSRVb6 uk5jrbg0Cgi3MfuFxYgzpfcifPNwRwHRMLdGKHO71j+ttrHiyWktWThZtI214kT/kmyF RrhA== 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=hhz5NftkB3QXUXFUzOn5HECwSeZUD2c0OTNQIOBv7F0=; b=LihtaYsD7cYQ2KppwDDXH0tsQ07yIgyTfMBO4OfQpcnal/Pwnn12CW3a9xmcab2xmB lk07tiHbLMwk1ANWyHWmOAllM3rrAXhA/6pkbJATZz5gcamj3nxqIm51BAoza9jwwLMO p0HJjLl3b/FTnvdr3IHUzYuYzyR+mIft8RR8FAgZh43kQ5lPMviyXS/c3t0oLEspNnD4 6RkZ9GtkKtBonF/V4NDxuV6/YwW1mc9UipI3pus0aGxyxb/2CDKth/wJ/Vp7OhDb/fN3 BJF5b8PzjOi6FVDV2mGLWF709MYweQrHDQT2uWyG80oyP78cv5aLNskps7nJirumyGWi Aryg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EwI6lzif; 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 d27si2192686qta.195.2019.10.17.07.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:43: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=EwI6lzif; 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]:49578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6zv-0004iJ-JC for patch@linaro.org; Thu, 17 Oct 2019 10:43:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37499) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5w7-0005xg-5k for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5w5-0004Qq-BX for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:27 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38609) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w5-0004Q3-5D for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:25 -0400 Received: by mail-wr1-x442.google.com with SMTP id o15so1964205wru.5 for ; Thu, 17 Oct 2019 06:35:24 -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=hhz5NftkB3QXUXFUzOn5HECwSeZUD2c0OTNQIOBv7F0=; b=EwI6lzifCVniPD8blopg09XF/jzqzCD7V2veVErVmbQdwtfebm33xskuPIJyGeNwS/ pym/yiabwK5B7osi4kC8XpbclpNxDZLFt2ZtoTRQNkRmKFBi2+mVxJZM89qrlbkZZVfW xIG6J+Aua2vxLNbuSf1fJ3irZQ7HXJBGrl0sLCUNmxiJE78RiBIezIeb8SkNnJLmMxqJ Vzbb5hzTuskMYJxLhY7Ir2g4gRcS7b+Do2MGrVoULemsN/cD2C8WztnLVblC6Ckhg/Wo 8/7lUYT4x3uOHODMhHjbh0iTn30xPRcVNQUqg5QM+8W/q11NGd6tEAkJ7wc21mKDfFq9 UoGQ== 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=hhz5NftkB3QXUXFUzOn5HECwSeZUD2c0OTNQIOBv7F0=; b=ViKv23nnHX+GPRJReHea2CTpQ+2y0/d4aLVg6UIgP8AN8zM/cXXkUXRN+ogqNNk8ht t0lqmOU7iQt66E0s4zIjiPtCjIH90P6eZNMCt3QvUuXI3zpro50LwhC1dFgBX2qyxZNo Q+vHmEemWdhJ/Agj4T/GfnxvhjgllY0JDl50RKH3ZbCc2piP6XBRB4hcqv3lKTgWgHmw SksK1UdNPOiIpng5tNvykH/6bL80eTmBFRzLrjud1UXt2ffi+A7OfY7XmYb0rwnvEtSQ yYwoxOh3KhfhcaQkd6PvDfEMHLU2z3QxZENOzwHGKJ+kpA3ADC15HIoJh8hCgayNYb7p ABig== X-Gm-Message-State: APjAAAUw/fuesCh/JAjuZ4VBVt592yPyJU/gTjfYt9622ig9NuevHmHC XxfQtXcZV5+xThbUyCnivZynOg== X-Received: by 2002:a05:6000:1051:: with SMTP id c17mr3020255wrx.124.1571319323302; Thu, 17 Oct 2019 06:35:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c132sm2187935wme.27.2019.10.17.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0F0C81FFC2; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 44/54] tests/tcg: set QEMU_OPTS for all cris runs Date: Thu, 17 Oct 2019 14:16:05 +0100 Message-Id: <20191017131615.19660-45-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, "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 Reviewed-by: Richard Henderson --- tests/tcg/cris/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 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 Thu Oct 17 13:16: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: 176676 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1048563ill; Thu, 17 Oct 2019 07:59:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqx29iPWiRVvUL/OS+4febHdu+UCmV9i3K3Nwd533Sm6fyT3nUVBZpBm+K4nM/2IPKWO4aiV X-Received: by 2002:ac8:740b:: with SMTP id p11mr4159346qtq.75.1571324368688; Thu, 17 Oct 2019 07:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571324368; cv=none; d=google.com; s=arc-20160816; b=OJXqbHDqq9++k3ykUdfO25lcyKP0njzTJd56fpKobHONU0+qsNC558V4qFH6mTZBYa u12k85MCdVB3Tar9AS8jsp03lztscjU/35xdUYfDZXuZrsmOvBJUBLLpoXlxjDQsRw8G 5/KH0H97eXwPXoN1dvZYgfPs/gypmt6MQhp0g/eD/MTJ10C6oAIn9uj+GjtFnrQUgzQO NWTc8A6k041odGUXe821SRk8J43NbjTYNtjbQaDOH2WFrd5NInG/x16eplU5oxMkJJS7 yIXXSQWfqm8Gf5P82dY3Xnkj0aFADWjN89FubqWYPDXaV7nv543P6u/f3HItAfX5PCYY mdXA== 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=3fGY4DwdRI3LBI7/7yBxn4Qiw9VPVjBHI4jv3b7spHY=; b=OFbCcmuodJQIq6sa5S6CI13SVUCvFmCYIrR/zSW6GRzbPkIgfancvdTyuVCmE22lFV S8I7wk86CjLLa4sP+DozXtID42jnXabtVQbx/7A475WaPgxPfbwvkzEyB86zfKEUGzMP m3E+kN4xV69uThhCeJDEqMm9U75LtmgsoW63L+X1DQ+HnqO0lwR9k6//TwUeeqLvE60b byAR8gQMk9V75hHkHoCjLCZgY63t+vBq3pFBKZi9+KlUORysPhzLxTKaI3ZAAiOSBjcc iaU/3e+Z0g7yMDEWwuKOdLHL0qIAwlB8izOUWdl+L9ITh3jAWZoAVx44Ec533qQ9Kz7K yr4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sg38O9ix; 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 b5si2691560qtg.47.2019.10.17.07.59.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:59: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=sg38O9ix; 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]:50064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL7FP-0000An-PH for patch@linaro.org; Thu, 17 Oct 2019 10:59:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41245) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FW-0004eO-39 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004Em-4H for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:30 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:51107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004DY-Tc for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5so2687069wmg.0 for ; Thu, 17 Oct 2019 06:55:23 -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=3fGY4DwdRI3LBI7/7yBxn4Qiw9VPVjBHI4jv3b7spHY=; b=sg38O9ixtMuSo4XEVoTNhBDbTkrgd+K3+vxNRpbnnNRtjbPWayuV4QzDOrDcGyz/pR 6ccxmqpQbb34kLpavxZiTE6gm9iieAJP4qPIeK4BtQUnNzzL3hAgsRMWv3bLLRLEwis1 m21BhqeufBkvxm0Y5l5fd6ll/wSuLk27gFbONI5DA6tfJ4KQ2utumf6RLx+lcpzqhA6c pJMQHMHFxnVRig22tAl0hBtl/7lGd0YqdCbyOnz0RWkhOmuNFIaTvfJGe4DvYpkB2VkS 3YtPZ1ly/vA3c+2FNbyaf15tjWAQcUTZgI+iRVKd3YQzjVKxJGvRmwBySnnPsUAF6C39 YAdw== 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=3fGY4DwdRI3LBI7/7yBxn4Qiw9VPVjBHI4jv3b7spHY=; b=a8rVMaK2PV8YtU0XbngkzBUwhBrcQqO7JIrsvPvTUs9on8CMmlN/Xt4gpuxrqwEBL9 5t4ErQldru/iJMik/7kObKgG75afKUdHnYJJAXw8P3B+5JtiD7SHvi2ucYFBBTZwYlQ2 w79x5Pv6L4aJ/+iBdUy/4Oy4FU5X0kDBd3DnHk1NfVqblou7/Eos7zCxiUtxd7HmFSKi f6zMKQcbiAvtnhW2xi+SrTGj9FEU0hHbALVdWCPJ+jiZZD7SErb6+0+KGdP9q9VTA1Sl 2RvgiTA34gx9O7RL4JwPv66raI8F2Nje6bZ4B4IpssK+hxijXsnWmKERC8D1UgiXGzmI EhGg== X-Gm-Message-State: APjAAAX5x4FTkQ0/x6fXbzlFFyJobqsM/HF+bJ6FqVDLFUp3iVbVS3lk dQLi1rzJFW8mncgMMCC8Sn3w9w== X-Received: by 2002:a1c:990a:: with SMTP id b10mr2965757wme.39.1571320522855; Thu, 17 Oct 2019 06:55:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r140sm2710271wme.47.2019.10.17.06.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 25B4A1FFC3; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 45/54] tests/tcg: move "virtual" tests to EXTRA_TESTS Date: Thu, 17 Oct 2019 14:16:06 +0100 Message-Id: <20191017131615.19660-46-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::336 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?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , 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?= =?utf-8?b?w6ll?= 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 Reviewed-by: Richard Henderson --- tests/tcg/Makefile.target | 4 +++- tests/tcg/aarch64/Makefile.softmmu-target | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 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 Thu Oct 17 13:16: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: 176651 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp976193ill; Thu, 17 Oct 2019 07:05:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9AU6honZyRIfrMvVsJTjGOw7Ee71YK90HjoMHcHo8TTpQbkodlY6n26cMEs1A8VQQMCAY X-Received: by 2002:a17:906:684:: with SMTP id u4mr3492762ejb.155.1571321130578; Thu, 17 Oct 2019 07:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571321130; cv=none; d=google.com; s=arc-20160816; b=eC5haEUUDO4MSanbNqeckNnNnJ9DqKvFYwknMXGqx3dY7LFXytWnFn3jMel+U4+PBT u3GRiE4bZiMZQSy3xzo4xxK8ZcGPeHKhas6ajSer3X9t+TZAo7KvfsGYs2vEmoBZkcn8 UbhziFM+JHxM8/LekeZfvqH//iiMyCrrxIVsuaZc8UqRr/DbW1iH+C06IL6uDdPhcxSe AeEw1w/3xBIxDeh+pQcCoQar5pjHVVzz6TMq30hqkCFQ0BF2CrOS/yqJqNZCeCKHMJXi fjVVm8vM0js+3E0hliH/EY7MUc9JGYxOo89ngUHaAkhoycNXf3UGFEag999S7j5jhvk+ 7Dew== 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=/83Mz82BQKC2u+/lvppbKDVj/7fy2xgMuJWt2PPj2Lg=; b=mvGoDnpf4+xAAVnpQmLqsNOWQdOWwTM73C44l3JoUe+PG3ZOkxo8kgul5FRSO+kdlR wTCmbvnpTHkNPcIiBvi7QcwEr6yyaMjyWX0Wg9JRDRLOgvh0jypYwhl2wqiRVjVBD2sH dVjFOcnvV8fL/w+7gbIyhlA9zQh8QogFphraUdpHd9FKzk4SUeNeTw6nHpqApOernv9C LY9CofAw44/vYN12fQgs2hpJU5wSRgd24wcH6lZ+CnGY/Qzm5pLX645JwHGOO0EfQhSS 60EZHjkdCiW2WAwpC0Mrs6nEgmpnQ9LRgXIiEyRYZIR5+ze15le5tcdZ4FXABI+j6CAu tZ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KSEEGCeo; 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 e11si1437849ejb.48.2019.10.17.07.05.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:05: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=KSEEGCeo; 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]:48734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6PA-00071z-MZ for patch@linaro.org; Thu, 17 Oct 2019 10:05:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35542) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mU-0002Fd-3s for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mT-0001HJ-27 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:30 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:37317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mS-0001Gw-Ru for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:29 -0400 Received: by mail-wm1-x341.google.com with SMTP id f22so2539233wmc.2 for ; Thu, 17 Oct 2019 06:25:28 -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=/83Mz82BQKC2u+/lvppbKDVj/7fy2xgMuJWt2PPj2Lg=; b=KSEEGCeoveMK9GkSxAEWdQjoOO2vWedfYvN3GhrUzYrBzM1ytlI73EP69E11h7QTz5 5qNJs0Y8pj7aiiX5xjQPDXARnAZw61FPWusYEgU9wxJUocDauPFSlJOk7Rn9CA2P+lTY HViSsFWuji7J1nVEs/8jcGQf/IqGKdceUMkMC2G9YX15khqfhoP0KEOhcHx7Paw9nF+J KCsFuZsAmkfvu+3XaqykrtW+g3jjDkvyJEOcbDHk8adaswRCb67o+CJWx6IV6rtE7qcM 2Ze2oKo8ZO+x/TzITitf9eoGxMWG07mJ6VSP+ozIo2LxPuBOs5WYLc0MPIuz8Eb083iV 0HPw== 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=/83Mz82BQKC2u+/lvppbKDVj/7fy2xgMuJWt2PPj2Lg=; b=kGywaAjAkDDa72efW+QSm/1FKKbRu4c+Jc+G84GPj0w+VNMjGz0Cnh8vbYolFUys9j 7lm98liQGAxH2sSZYQ1aD1tv05EvuUKxAUcwNS3nUdJO9prCBLZqnxyKrODI1AloSYqe pll14yCGnEi7gJJwATSeAqpc5tZb04sfJ61xON4wDGWM+be51uEskxMAcq1xOMulXugN hEFmkZW+rIXSEymEqLoG0T6ZMc2VkSngNCfwFm46uFOl5JH2ZC8Gi7+Dz7wnqY0Xpts8 Gw54452PWljNdY9pJKoZA3adtwcRkzBrncguWh+6QRlv95YzOlV61IGqMRTUQo2U3LcI leAQ== X-Gm-Message-State: APjAAAURtxps9GSzURcSZbCVgCXKdnxV30qYcSa1hotwzlUmF35DwwlA fH6AKVLBQfW10N2mtMzIvLYt1A== X-Received: by 2002:a1c:9dcf:: with SMTP id g198mr2986942wme.101.1571318727782; Thu, 17 Oct 2019 06:25:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s10sm2421829wrr.5.2019.10.17.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 39B191FFC4; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 46/54] tests/tcg: drop test-i386-fprem from TESTS when not SLOW Date: Thu, 17 Oct 2019 14:16:07 +0100 Message-Id: <20191017131615.19660-47-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 Reviewed-by: Richard Henderson --- tests/tcg/i386/Makefile.target | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.20.1 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 Thu Oct 17 13:16: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: 176620 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp942040ill; Thu, 17 Oct 2019 06:39:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAUta0H3xPx6s9OhxOI5KB6vujcxOVxhPaxDocP3N5Xt04Y0dSqCNtglqoEvY/UtBBjbn7 X-Received: by 2002:a05:620a:215b:: with SMTP id m27mr3351193qkm.328.1571319551879; Thu, 17 Oct 2019 06:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571319551; cv=none; d=google.com; s=arc-20160816; b=KH5Um9u8yig2/wsctn2k+728IkGBdm+kg+2bDwTB/D1zcQL1cgdC1qsh4FD1VATPqS WRpZ64/7g5KCxiwzrm+E4C+YKu+Xj1j/n3pRrY/dTSLVF/Tl5WWsZDbEUbzPJBKS1Ygm 8LzQt5GssjdDQau73ZNyBYjZYieRNGwQkFY1v0/ZrnGoTtEeL6AcwnXho1xoGKJoeUqo urtoIsOPgckH9WC5Ng/CtVUodEJ6LFRnNStOy2DxCdS8NCtwYAWwn/PfG1cHapr+IqHn iJYe1vVzJMTAMSLspORU52lVuUv/OeEPzrnYU/wVg+tnJI6HjOp8O24OoDVsWqvUdJZw jRbw== 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=Shj2sUFHREFoNKEY0G4KRrT2p/DDO+h1POzPYyb7/oY=; b=OX0T/EeKtzCzJJFmllZSdIcWKwumZjNX2woz0hAGqaASyzOjd2e1arStcizmSwucVx /w5a8aYynyk9Q5GZ0IOB0Yv705cZWwR+GBtx5NM/pNZT95ESLOvOLAeTEoS6G1grypCe J/DB5wwjMwpJKWpP6uzZi9LQv0p13vYiHrKWvLtVwB/37Vu9kEuXzPGg2H1cejG6EkB1 KMjmawAtHw18vYxnLvd1/QjsTsGdeAzruBX0uwVwG6FCXjhZ285+JTwEcG+3dul1lOqW NZ2gNpj9kRU1nSUdKdwuq08G1+DiOrQ7/di7fPjUweyq1MOKNa24J3jrXrnCSuLZ9agy GgHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="T0asdU8/"; 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 a5si2113972qtm.220.2019.10.17.06.39.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:39:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="T0asdU8/"; 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]:48124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5zi-0001xu-U1 for patch@linaro.org; Thu, 17 Oct 2019 09:39:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35517) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mS-0002DM-Od for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mR-0001GP-9K for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:28 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:37759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mR-0001Fo-2c for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:27 -0400 Received: by mail-wr1-x431.google.com with SMTP id p14so2359312wro.4 for ; Thu, 17 Oct 2019 06:25: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=Shj2sUFHREFoNKEY0G4KRrT2p/DDO+h1POzPYyb7/oY=; b=T0asdU8/UtNNPnhq+7KesM5zKbF1Mp9KNB00J3msfMlctmw75FDJ9OfF2hHs4090M7 mowtYq/TnPhB89E8I4t6/1paq+00pMnLVA8WCUzBDh05ILD1Zcx6H4nh5ak1hCzCDKRU nD7lVp+a22NnZT6UGZukmJjA6UN17bggu2CYPbQ12R1/qbcZVcRF60YMv7I66ngU+Eua WTOcDqNjJ/IrRF2hkXQnGiKRUdfLeG33p78YmlFAMwVaXap21FUrZeLBZrkU3WkurQRv Qc3gINfsvf4zs651MD98gkHU2pg14pefvMvbvOG+7/zd3O1EZk0h5W0cc6G6yeM4k4PT YO8Q== 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=Shj2sUFHREFoNKEY0G4KRrT2p/DDO+h1POzPYyb7/oY=; b=f/qzgZvLb+Adsr6jyKmrdw2HonI+Yn1JfvWiH49xPn/hkHJnKHAXGAgUIQFNIRua29 NEgHXJvGhbnRWjaoUbsSJbnT/RLcRw46649WVYzdw+6RrIM4k/hNdGqpq4SPIjSzLaJR GhWKkkGvZZLWGF+fa3fu2hZYvhyZDOP7RRb6qt12naOi7Ta9uCtbEeRfrT12A6oWTZil +p0N6yABAEup4OP55wDUYdgvkI/warwveD509ETJJcuAG40cC55ywBrKtin4Pwe65U2V If43ga1Epsv2JQMeKc5yhtjVobjIJOuQyjI/3RvBNkmyGcdNsxDi3/i3NRkb6JSM5Tva 9K6Q== X-Gm-Message-State: APjAAAVZCGhpIAsecBKlzVbVOSihOKvRNFr+Sl5rnU/a7+7E6LJJyxGr p/vA+QSHc8SEqBAAOZIYuzVjXw== X-Received: by 2002:a5d:46d2:: with SMTP id g18mr2924439wrs.245.1571318725828; Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g11sm2202766wmh.45.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 566E31FFC5; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 47/54] tests/tcg: enable plugin testing Date: Thu, 17 Oct 2019 14:16:08 +0100 Message-Id: <20191017131615.19660-48-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::431 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?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , 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?= =?utf-8?b?w6ll?= 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 Reviewed-by: Richard Henderson --- 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 v6 - outs -d plugin output support squash! tests/tcg: enable plugin testing --- tests/Makefile.include | 11 +++++++- tests/tcg/Makefile.target | 37 +++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 6 +++++ tests/tcg/arm/Makefile.softmmu-target | 1 + tests/tcg/arm/Makefile.target | 6 +++++ 5 files changed, 60 insertions(+), 1 deletion(-) -- 2.20.1 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..3c7421a356 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -123,11 +123,39 @@ 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,$@) \ + -d plugin -D $*.pout \ + $(call strip-plugin,$<), \ + "$* on $(TARGET_NAME)") else run-%: % $(call run-test, $<, \ @@ -135,6 +163,15 @@ 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,$@) \ + -d plugin -D $*.pout \ + $(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 Thu Oct 17 13:16: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: 176634 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp957970ill; Thu, 17 Oct 2019 06:51:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZL/qgKKveVOzARbP2CGm/Baw7WqHBN5RLyLzWlzssgBCwPXp2bJqVyEpbVik8WYwcEA6Z X-Received: by 2002:a50:e445:: with SMTP id e5mr3789727edm.257.1571320311608; Thu, 17 Oct 2019 06:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320311; cv=none; d=google.com; s=arc-20160816; b=OKNCINGkVLfHGPLSlBBALN3U2B3jIX2Oli1/2tIo5AajXVmXD/p/LAJPA9DU0gNkno Dmu0y9MyzRXVOQcNfUWflow53oEIotGUHuBeROKwkaycWpI8s9e9baHKfWeRcAwbr6nV wMBPYyrCAHw9PPRAuDEAQ/4O02eFhFZH7lirai3ITjG13tuQkkChKx44vfmjSm2bfnrM pkInoHK5qjd5IE6p87fEDt6wzKU93F2BptXd21F04AEb6EyoL5ivTaj1IQ2j7GYfRtAp hFE3CDSRDWtwolAzF3zsC317FDmkaYICFG9Cht78bEUK/jB7y7iDwXuMboY4I6snQ5+L SB7w== 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=2I9Xg4qOydxt2Irqp2d5IKEYfjCajVr5MTKGy7FknVU=; b=JjjCngC5pQzaeliwTyTrVUj1EK+grlusM0Fo7lr1IMWLfqLfOuuM2g19WtIZwWcc6o 29v5mjlWlNO1vzFxsXdyujoUqxh6zekvuHW+nEvfRVv8mDKV732Mq5WS6iWuZ+pTk9t2 ferCjtR6Krb0Csplokp2gKHhnNnp+0itO2Bz3us4emYBtFI7hdlL5GEgWobjjcKDmKp5 KzLyq18O4PyC8PPnQEB/P1Q8uwwzr6qlWa74qY7G7o0V2PDGANsB9w83s46UrAGZQgSx hJjlrm7SMnK8KfCxhHcfo3brpyZfjZb2pyfpNqIDmU+U5ijsUZVVt5CaYtzm4peT6KM4 4kYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="SC8qN0Q/"; 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 b42si1540757eda.367.2019.10.17.06.51.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:51:51 -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="SC8qN0Q/"; 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]:48416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6By-0007YN-1r for patch@linaro.org; Thu, 17 Oct 2019 09:51:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35570) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mV-0002Hp-FW for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mU-0001Hr-2d for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:31 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:53409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mT-0001HP-S1 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:30 -0400 Received: by mail-wm1-x32a.google.com with SMTP id i16so2564614wmd.3 for ; Thu, 17 Oct 2019 06:25:29 -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=2I9Xg4qOydxt2Irqp2d5IKEYfjCajVr5MTKGy7FknVU=; b=SC8qN0Q/Mg/qkl7yS7oEgA6MzUQqgH8zj4IUo8bCf4WjlZhT5PrZYFs6bqJTg9iB3H xp5UZWt61Qy28ReYoZ29Ui/WZKudfG6oFNLp/95mXnD3vou3E0ZmhaVFfNClUXOB7pna jthDjALf5lV8q10E9S/d0+vCzrV3eSA06QRV1xk19ewvkwCETBh+WSXGTWGqxD+vEyGB ixgmoxYj5wSJcIVhEG45OVSO4GpMbx94XZ7AxcUtUPPi9B7oXjPLOrQbTtbwbnk5KXGN /WKqHAU1YpViFd96DVojtcncp46asazssDwk4BwNLAHqvM31gap+lXlqBmkxvQyZX9i6 c8+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=2I9Xg4qOydxt2Irqp2d5IKEYfjCajVr5MTKGy7FknVU=; b=saloc1i9nJoJEo+cawvx1+qkTAtiwNtF2JYUhYc5vlcgRjdava3ytRAFcjJDR8S18t rQrua0LSMUr9gelg/AzuShn/U6EayfokunPG4Uq44LzNpA+5I51CilPVIL2K10O8tG7O dA+EOXccFFzfoKXe3qojX/8MORRYCXo9dbHhfAxu5Jjro/JSVHs99Gd47roNPvWNTq6U WVj4ws1uyOMbTIYNLckxIEcfmX9OjNR4sKXzLXlWhPM955GYx2mCiGIih9DKM2MOOCeC KiG+EPbvzJotqIjGarQQ36hRTqi4CcF9O+EUcfEq3vYW5x5N31MfQfYAR+fjvSC2WU0w W68g== X-Gm-Message-State: APjAAAUGYDWVrqvdoxPOIg1D1NB3zQ59rhgU9XixNPUsbJOcbHvmbQcM JnvXjhdv9N3K0RZzOgpXsZlAxw== X-Received: by 2002:a7b:c938:: with SMTP id h24mr2912915wml.117.1571318728580; Thu, 17 Oct 2019 06:25:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y186sm2689296wmb.41.2019.10.17.06.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6C3471FFC6; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 48/54] tests/plugin: add a hotblocks plugin Date: Thu, 17 Oct 2019 14:16:09 +0100 Message-Id: <20191017131615.19660-49-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::32a 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 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 Reviewed-by: Richard Henderson --- v5 - handle 0 length report v6 - init api update - use plugin_outs squash! tests/plugin: add a hotblocks plugin --- tests/plugin/Makefile | 1 + tests/plugin/hotblocks.c | 143 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/plugin/hotblocks.c -- 2.20.1 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..1bd183849a --- /dev/null +++ b/tests/plugin/hotblocks.c @@ -0,0 +1,143 @@ +/* + * 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; + +/* 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) +{ + g_autoptr(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); + } + + qemu_plugin_outs(report->str); +} + +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, const qemu_info_t *info, + int argc, char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + 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 Thu Oct 17 13:16: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: 176680 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1062767ill; Thu, 17 Oct 2019 08:08:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+1j15DTTyIZbKSNiaWaOmsmoHMEzoR3xkkINzzMSo5EQA5zBL0pQBj09lYPhHzz0BfQZO X-Received: by 2002:a17:906:c317:: with SMTP id s23mr4096798ejz.251.1571324935183; Thu, 17 Oct 2019 08:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571324935; cv=none; d=google.com; s=arc-20160816; b=Qvne4dJdZdJ+YQjCuAF4+AS2//19V4APA6eQtlWaZYQArJdTUlbcyGDJEqGZThZE28 HL1xc8z0/f6HKhRoh7tJbYQ/VEHNL6dyESEh94vM24UI8fcFU+wDI9T4dbuIix/apg9+ +p7dSWkN+JhsP/nGlI0YUSlgapJH8C+dLb96qG5ccivc6jZ6dThKxUhJ82FCyfousr7T d/W4Ok0425h7va1qX6CxsnluEFH8RBNz2qP+UD5slhYhgW5j1QMdZM2UNy7lqSUgVrqr yi2C9ooMCcZSIF7e8VusOGeOsO1aGqHWQa0WQgPzTS7xBzbK3YWIclyhSAbzUO8YRRdP MPQA== 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=UAfNHpSu1q4jsSZsZFURmMCcsErYD9hTjhzerLvdncA=; b=iDEDCwHxwe1kXKn2LSAF6JxTf21mBjK8jCnKV2DuaVIglf6ibiFJA7IQKq3tDMOROM lbXj9uwf230WY8xUKK8kbddGwKsd3B3OVzy3j5wR/24Wvm0jKLrksf8CtoT2DfKCBoDQ qbeuxg8gca3gMVanTR3kCiaCnXcAyPydBW6mJpIJUSB/FPas112zodckSX0juf8XL9Xy bUYyt1SSmctCUeStxJ3J9TcuK2DN8lWgsNap5s6CZADl51XVsYcPdWLWtyIGgqZHJZJQ oAQdOqrF4SvuUNz9ML6HDxf3fd9dsaUSxso23gRV1ZZY3+Ef069c2iPfYKPx5U5ywwnD SpQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bY3Ph7P3; 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 um16si1470548ejb.12.2019.10.17.08.08.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 08:08: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=bY3Ph7P3; 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]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL7OX-0003Xw-Fi for patch@linaro.org; Thu, 17 Oct 2019 11:08:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6FY-0004ez-NS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL6FV-0004F3-5U for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:32 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:46429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL6FU-0004Ds-Ss for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:55:29 -0400 Received: by mail-wr1-x42d.google.com with SMTP id o18so2438458wrv.13 for ; Thu, 17 Oct 2019 06:55: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=UAfNHpSu1q4jsSZsZFURmMCcsErYD9hTjhzerLvdncA=; b=bY3Ph7P3daoGf0qIgjcPKVEioKRAuuKVATDpzO9LY3QIdoe6Up9B4hTRArEN21L60u 1Flvv/huPPgluU7+MTDt31Cc7BDrPye4raIqevTHW/oj9Fx2ELubjp7Hkx1gSafDFtH3 pkFvedc9tzH0Au/7JNdCiB9xjCehvxTUQ0XjJPPStikNAMclXb5gdV3jsmHZExWevv3e hPE3yL7dIOI1E0ayDutSvc24sbslTh1DfJk8kV60tRVi5LBne2xSoAAPabApb/MBAyJ5 JOjxSdutP/ndv56CLV1rLF8jXR//65OdEeaCS0L/l44UD2uKTojLq2HX1ul+rNpPHGD3 m+Fg== 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=UAfNHpSu1q4jsSZsZFURmMCcsErYD9hTjhzerLvdncA=; b=kY13heu/E+zHtIMC7ZJ83h/kxiA52l68AZWDltn2L6mL7LeVyxgeHTCyC1XDmJJS1w mm8xiq+dGjqa/uECoy/tWlbDemk72+ee2tav8rIG7W/hSnkrf6JKoEhTfyAtjAjMzwcF Uhu9ElC/1NAOcPt/HQvX3saZBPMpsLIHIRxqkpYnRjVdx172Wluf5EsybWi8EzVseUMi BsiQ7GeegZ4v3Hvj8PmCAyHJGt3RJ6AcSU6fbSkpaX843WVTVkYj5jUwQp/Tu5HlFyhT LKNxFc60eyAzoyS6KtPyHcfwmD/4ibuzTVnrjf8QgLHYStGGh4OtTSez4SksUKPr/ljx PkVw== X-Gm-Message-State: APjAAAVZvOptq2xF8fGVVJe4JSdcr0/4AtIwdujdALd94ZbOPVLDlm6R HGOx4jrnzF3tLRRaenFW01GDmY5zQ/c= X-Received: by 2002:adf:e283:: with SMTP id v3mr3377162wri.20.1571320524721; Thu, 17 Oct 2019 06:55:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e15sm2439293wrs.49.2019.10.17.06.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:55:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8404B1FF93; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 49/54] tests/plugin: add instruction execution breakdown Date: Thu, 17 Oct 2019 14:16:10 +0100 Message-Id: <20191017131615.19660-50-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 gives a break down of instruction classes and individual instruction types. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v5 - add a bitmap guide to the comment ;-) v6 - init api update - merge updates --- tests/plugin/Makefile | 1 + tests/plugin/howvec.c | 352 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 tests/plugin/howvec.c -- 2.20.1 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..58fa675e34 --- /dev/null +++ b/tests/plugin/howvec.c @@ -0,0 +1,352 @@ +/* + * 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. + * + * 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 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 + */ +static InsnClassExecCount aarch64_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 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}, +}; + +static 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 */ +static InsnClassExecCount default_insn_classes[] = { + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_INDIVIDUAL}, +}; + +typedef struct { + const char *qemu_target; + InsnClassExecCount *table; + int table_sz; +} ClassSelector; + +static ClassSelector class_tables[] = +{ + { "aarch64", aarch64_insn_classes, ARRAY_SIZE(aarch64_insn_classes) }, + { "sparc", sparc32_insn_classes, ARRAY_SIZE(sparc32_insn_classes) }, + { "sparc64", sparc64_insn_classes, ARRAY_SIZE(sparc64_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; + InsnExecCount *eb = (InsnExecCount *) b; + return ea->count > eb->count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report = g_string_new("Instruction Classes:\n"); + int i; + GList *counts; + InsnClassExecCount *class = NULL; + + for (i = 0; i < class_table_sz; i++) { + class = &class_table[i]; + switch (class->what) { + case COUNT_CLASS: + if (class->count || verbose) { + g_string_append_printf(report, "Class: %-24s\t(%ld hits)\n", + class->class, + class->count); + } + break; + case COUNT_INDIVIDUAL: + g_string_append_printf(report, "Class: %-24s\tcounted individually\n", + class->class); + break; + case COUNT_NONE: + g_string_append_printf(report, "Class: %-24s\tnot counted\n", + class->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); + } + + qemu_plugin_outs(report->str); +} + +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 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 < class_table_sz; i++) { + class = &class_table[i]; + uint32_t masked_bits = opcode & class->mask; + if (masked_bits == class->pattern) { + 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; + + 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, + const qemu_info_t *info, + int argc, char **argv) +{ + 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) { + 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 < class_table_sz; j++) { + if (strcmp(p, class_table[j].opt) == 0) { + class_table[j].what = type; + break; + } + } + } + } + + 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 Thu Oct 17 13:16: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: 176638 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp961363ill; Thu, 17 Oct 2019 06:54:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYTyWElow/4Y3TAXeweeOG0hqycMcS/Zh10eIG4tpQBSKCpVLtdpdL130RVC9sTarGti+M X-Received: by 2002:a05:620a:1355:: with SMTP id c21mr3419070qkl.288.1571320481606; Thu, 17 Oct 2019 06:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320481; cv=none; d=google.com; s=arc-20160816; b=KSVFyrr72mYMx/XzGQ4gutQneTFvtkL8Kkru39mXZXNZDAGDgezg5f/Y4DtiwqILbK VU2f9MpAOtKKmv6+yTQA6OAV8GFJ9HkU/Ii6+9U+vZcOK5qtUpRfQe1ANJbwW9voHWpA rGtmFQ4XZJ7u5XirxF0s+i/gyfvf8hLmCJg4heommQR03GzIdHy9mvqqq7CkRkSp2CoY zWQlrN9PvfIu9JGoQuHYbnwn/hgsF+jWDmi/2/TtwV/aY4OdlVLc07ky5mYlHR9lCdKo e2yQWA8wg4euAyorqfOG6cH5J61EoaDfLzqlTt9cyAK2aHBj+P4KywEYILN/IG1cFxDM 2A7w== 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=5xyamaZcxYkKnEujCxiwYlmoCoUtUZYHxGEu/iYbDUk=; b=HhSZNOmiV/mHx6BGRDiAqAI2H7YsqP2XK6gfQ0j7xHCR17n4x76bWkmlP5LXHSkIGg DA7JJ5nNmrt5Ls59bznVesrJvYqpDiZlLOj8YDpnuvYM3MytTRhK0ARz6d+F8Z6WAnLZ o12BuMaSW3v79WY7bS2doWBJEHAeLCKcgeTH2KY1peShoZqJFXdsAamFmgvx2KK0c0BO PUvwcixns6wg2Qjid5SVQWvRrTmHxtBMkLlPxFCcKTATop+2UOoiI/tqHNU9xpsxqDbv I5NrXBI82JOZCsPPMgrpzWt+L/k6j41fhTpti9RlYc/Wvm3JVhCmE3ON1Zis+ubajFa+ FeDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VscMljlW; 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 n187si2108563qke.161.2019.10.17.06.54.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:54: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=VscMljlW; 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]:48486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Ei-0003cz-KQ for patch@linaro.org; Thu, 17 Oct 2019 09:54:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35470) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5mQ-00029s-LQ for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mP-0001FM-4o for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:26 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mO-0001F4-UP for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:25 -0400 Received: by mail-wr1-x442.google.com with SMTP id j18so2336580wrq.10 for ; Thu, 17 Oct 2019 06:25:24 -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=5xyamaZcxYkKnEujCxiwYlmoCoUtUZYHxGEu/iYbDUk=; b=VscMljlW+bhzWbx9KzUTxM0ngs+ResiQ/zEJce5koV92QX0yqrZU2HP7sW/gU46NvL nXmTBf6ZQ/Qr5KwY0qWM6jSiiw/TwpHjDlYSuxHrapOEXUG0GN/X/wJLUFsqOz9uUaIj RlXf7nVTm6IoQnrQcnPiThk6K2FO85e/sHdU79+fdu91u/mD9TFcuk0E7ddw6+sMqOWV CbULwVc4Ds96+vJYgxYhlQcF1IBGHRLN/5OXn0Ifm7+vV0UQzYF5c0GJ3Th0ya2R7dz2 M9UfWv+blllcRoxe+2vvIXw43+0hwn56IcCdz5cNZ0HgV+4j+sytIj8iGU4wdZKa3K20 gbug== 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=5xyamaZcxYkKnEujCxiwYlmoCoUtUZYHxGEu/iYbDUk=; b=AcK4SqV9JaiDcrSrel1Gv9jVSd+c5LyHTJ6n/tOlfo/DOaj9E7YDtuTq/ZjHIDJukD Dn8rT+agvj7VDBlrIHIVocERjBAhpePEajVGaG0+qCB8ydr3YSRp7ygGgy+ewWgHaNVh j+anIUdJ04Rhl1ctIApCr7EOV4ESYTrQ+Fb37iOmaebcXzb0/0Pxp8wvXpLxo/clDEsD Kmeb7rF0HExq1ERH5wFSq2+IQvvmq46bx6F7PTMgFjlGMN/8aGOiKxGCKZBBOqqmYG/b WenElLj1FhzQWlSU+jAkADk3IX41wzqX+8qtOFK8g4ftC4xwoxbR7dhUHV0Fw1ud/C7g BRLg== X-Gm-Message-State: APjAAAU0KaKUZRXAqK4gSRTwzdbRUgmdtpNUccZ2S8e1BxFiCL9cAyAA KAXS5dZsVXSHQtsCju3CnkQA1g== X-Received: by 2002:adf:f30b:: with SMTP id i11mr2798512wro.377.1571318723722; Thu, 17 Oct 2019 06:25:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x129sm2894016wmg.8.2019.10.17.06.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9AF621FFC7; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 50/54] tests/plugin: add hotpages to analyse memory access patterns Date: Thu, 17 Oct 2019 14:16:11 +0100 Message-Id: <20191017131615.19660-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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" This plugin gives a summary of access patterns grouped by "pages" and showing read/write patterns by vCPUS. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - tweaks for new hwaddr api - add sorting and pagesize selection args v6 - init api update - plugin_outs update - add sort by address option - add track_io option --- tests/plugin/Makefile | 1 + tests/plugin/hotpages.c | 191 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 tests/plugin/hotpages.c -- 2.20.1 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..77df07a3cc --- /dev/null +++ b/tests/plugin/hotpages.c @@ -0,0 +1,191 @@ +/* + * 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 limit = 50; +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; +static bool track_io; + +enum sort_type { + SORT_RW = 0, + SORT_R, + SORT_W, + SORT_A +}; + +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; + case SORT_A: + r = ea->page_address > eb->page_address ? -1 : 1; + break; + default: + g_assert_not_reached(); + } + return r; +} + + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(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); + } + + qemu_plugin_outs(report->str); +} + +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 (track_io) { + if (hwaddr && qemu_plugin_hwaddr_is_io(hwaddr)) { + page = vaddr; + } else { + return; + } + } else { + if (hwaddr && !qemu_plugin_hwaddr_is_io(hwaddr)) { + page = (uint64_t) qemu_plugin_hwaddr_device_offset(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, const qemu_info_t *info, + int argc, char **argv) +{ + int i; + + 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_strcmp0(opt, "address") == 0) { + sort_by = SORT_A; + } else if (g_strcmp0(opt, "io") == 0) { + track_io = true; + } else if (g_str_has_prefix(opt, "pagesize=")) { + page_size = g_ascii_strtoull(opt + 9, NULL, 10); + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Thu Oct 17 13:16: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: 176675 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1040558ill; Thu, 17 Oct 2019 07:52:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOqIiV3u7N+ckaUSbCe3zKWW3Rq+0HspSDHPPcjaROdIG3X9goOp2erCV49su/4E54sBOt X-Received: by 2002:ac8:2dcc:: with SMTP id q12mr4272028qta.302.1571323961445; Thu, 17 Oct 2019 07:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323961; cv=none; d=google.com; s=arc-20160816; b=rbwZm1X4LH3myFIReWQcUvMgkRB6h56MMjqFw9U8FRYFRdeXy3ulqtQe3VaX1U72Ic OLfAsdlPS8zWtXFFMroemR/7IHnYSBkcFolEKdiEEUNbH2LzEA1dJzUNX+tqU5PYm8IN v4U12gc+mrjsZRc7OWi9w9v/NDhEBqkeI0zF07KgK7heC0KzyYQae5QZ7sZ+RBpL753G d6FtggdZ5aqJBYoZI6UvRDbyK4Y6Z8IH71s6Y6wvzzgrGJMQLykr4h8wUN85Wn6SyIt2 wBTiObnbg9Kyrko2jVgujUc6dbXDNl4wz5if6PGIeyX+5tIQT1ULK15ekgsHq9IxZMnE WjHA== 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=KVyz0Piwp7qXfaF6Xd8Ppag1b9A/Syk/TuTsZ2DMwTaRTXt5qa1GRPPoqsxmV9TyhX bHPKlXFnDi++Yp4TuKy3PJGpTAbURw8b2EtxMiGp7RqJZPDFYarK/e+K6fT38uNjRVeZ fm1WlE3IGVrWHuN5UqCTRqYZlLwqBUWIwq2OU40EPGT/zsWI2ieafbxXDNAVY3KwIOpz 8RiLdvG/qjNEOXPrw4qJVMfpv5Szsrh+dLd3LK4HWfsI/ax8STX/g5fsKFXb18boKi4z uaDP42XbocgtwOGkg3lHbFEI5Mo78BS/J5tQT3Dc+q2tYaG9P2tr67xO9MRPBcU0KqLM 1m5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Fn1iFLQw; 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 z34si2179610qtd.120.2019.10.17.07.52.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:52: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=Fn1iFLQw; 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]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL78q-0007fG-Bc for patch@linaro.org; Thu, 17 Oct 2019 10:52:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37587) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wD-00061t-5R for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wB-0004TT-2m for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:32 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:34091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5w9-0004Rq-5C for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id y135so7059961wmc.1 for ; Thu, 17 Oct 2019 06:35:28 -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=Fn1iFLQwMnhoxS3yIPFju9E96YfLjx54BdqcfhmrWNVrygLbKNGyEfeLQ2ATJTGKBj 8eaJVRsCZ4YYfBxWiiUQ7ObY9poNZpZo+Ii/xu+pBFMmsDDtTW+zbLmMShsI7ch3gPeQ Ibh0+BKPNGv2ZCa4Q9KNnnSITSSyDRWi6YtTbupvHJ+10medIFoh06pOmQKp5t6cSbK7 5Pgj261wcEltaMNNrsV5G3STQw00cuZ+zCNUEDpmUKeTgL1vta2tygeiRMKILPzvUq9O xV4F1+jCGXdnWxIJRCo7PL9NumsqDcqtTN5SbUfrwvcyyhL3/CnmMBl4bB84P4kpDuVr pRtA== 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=LD77z2rGUHOa/LX0VLktgTZi3cLWaMK5dq8pP052xJwtux7D/KxwVPHCdMB+NBFFNU pl+QoY63YguQCsGjc126Po5TpwSb4IJTi2pLGNPU/ypi2sFBdCL/5cBI0EmR8ntxvP77 9tEMW6qMUXRTEmrUnbJDu/Hl3NQgLTjcAm8LZ5VX6pp0KLTaxrrtWDSZKWkp8hlTrdXA /OrDxWVjo4+INNXNF/GNwLo2ykuX0tclUkTanODwSsIoniPtnXSXPEeQ55qKSOFvg3K5 6abFPtYnDoEm7AqX9k8rZGDZIGVBz+kNBSUSnoSAHT9PrWy5BFzJiVRXCaBZI+IiZif7 DM4Q== X-Gm-Message-State: APjAAAWI6TFy52qroC5U70jX3HC+AivEK4f+kvwT+CcuC3eIddFW/19z D+ow3OwVVmuYK6A0zTgBZ5Lvzw== X-Received: by 2002:a1c:2d88:: with SMTP id t130mr2927385wmt.75.1571319327222; Thu, 17 Oct 2019 06:35:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r140sm2650465wme.47.2019.10.17.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B18361FFC8; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 51/54] accel/stubs: reduce headers from tcg-stub Date: Thu, 17 Oct 2019 14:16:12 +0100 Message-Id: <20191017131615.19660-52-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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: 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 Thu Oct 17 13:16: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: 176666 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1026815ill; Thu, 17 Oct 2019 07:41:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqytfk7eXQym7ZTz2J59dNkWYZFOtqFcOT3nH9n8HCt9ZvLGEtmrDHa64kKtiqQznwXMpIHH X-Received: by 2002:a37:614e:: with SMTP id v75mr3754838qkb.166.1571323302326; Thu, 17 Oct 2019 07:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323302; cv=none; d=google.com; s=arc-20160816; b=ZCU7cVil0Pad0A4Tr6twhngIyjGBqv6kO0+gJgQgmmbLXr5KNlEEqAdEs6AwA4cr/h U205vU3Lmr6pzztoVV3es9fxMhqvFkwRm6AjdLNMT1zrKkFDy1PkAf+/z7/hqpvxy0Zk hrIn/mmJIOvDqjM9nk8Zply2sTETpjegAf+o7l39g6VGvgSt2CwDQsFWh2Fn1fkULv71 h29QmC3rHU5RlWtpo4p3qUN9+9dzI/bgVqS00rheKnDHYz6YdYeV7cj5TYca/QDsVdoI WVeTs6HzCpB9LyRvLruYcgLgc1cKPMrZ9iUoE0md5oWUv9kfwP8lQheUtfc9vcff/flC 1d6g== 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=O//gTJ1ccAn0kLqEOJo6VegQQGC/e2rAI1ZBzD10O1k=; b=1LVoPBqb8wW71kgQDb6ScdIL20G0X+3JB1NpLF8ZfvLnFa2rEXig2guNP4kPvw2OWN Okpe/xF/2BXIF2WHTaRRUscq/hI62WoHkiNRFjamh4sEby+/zN9eqKhjqZ0r3eQ5E2DX VicMG8BesA5CM7LlamMjO+fgFRWl43W6E2ZY0WTU2grKG1tysz5aAUYvByhi/7TPOzL8 TtuKihWlrukcoR24V2BVH7c2eopMATIiog8fHMtG7hjQQzAG8QWVCp5mgvT38UfNIh7+ 44aLG4SiXUTvrb3dWMMWUFACcPyKdoY4QdUrqmjE6gnfNleFQH/1cT4WVoT1XFMtAuQT Sgcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RNFSjOXl; 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 q55si2154542qtf.347.2019.10.17.07.41.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:41:42 -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=RNFSjOXl; 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]:49526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6yD-0002bf-Fg for patch@linaro.org; Thu, 17 Oct 2019 10:41:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37626) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wF-00063L-77 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wD-0004X9-3J for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:34 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:35842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wB-0004Sl-0N for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:33 -0400 Received: by mail-wr1-x443.google.com with SMTP id w18so1831167wrt.3 for ; Thu, 17 Oct 2019 06:35:30 -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=O//gTJ1ccAn0kLqEOJo6VegQQGC/e2rAI1ZBzD10O1k=; b=RNFSjOXl9v9bTA5OvDtJOyOS8h2aXGXrde9DC+4IxO9k8VgdrdfC3yt7Qg6g+Avtv2 iFcF2M0K9hSplqXK7iYFixgYZ3lIle6StsO4T8vJy7aGSEaY5k2nQSy7QrKHDT0jZ3mb Qihi8RC0OKMLjhf4M4yqr+B9osx43RqgGM9tufDgpw1MkSWAwiMsc5SsLXbLQ5nqa49L r4LJmGNrJadYLEz91liA50zMotyA5fbUIMqRfBjiyLJ64EFj7Bh+N3kj+y3SXLD7y3J1 dcfP6qNjln5p4jMwZX7TmVRxT7dLihDDJnIz5XON2Q5CC4AqLmt4sws3yhnPD6IF0SOx 26tw== 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=O//gTJ1ccAn0kLqEOJo6VegQQGC/e2rAI1ZBzD10O1k=; b=CkYlENzLXNe66sxCFBw/1x6hCAEZgjApszHfwhWM/QkWXCzcbiyMSwd7kPSWueVrdQ pX1KW2ZFYLnLn3IyVsPdRFR2WseUx3dUk7x0nQSVa+3YUqRorgAxALCV1dJf2vqFJvnx +sZ7slqe1/EK8klSwCGQwxX8fW+3t8bCbI0O/Lkpq4Msa4iRFILXDGbBV0cjlFMNnyXf he+kIQIquT4GbplezWsiRyA5V6+DckQn8P9OCfx3Neb4q8holL0/doNWFwzbBBpuV7mz VyjAXcmwRzj8XFKNC21sj+fMAEmkSSzxgZvDGi0baxUEyu34TcKbVquQTLrhnZacI1c1 fzWQ== X-Gm-Message-State: APjAAAUBaW2457qBZy4ekmAH5Yk0VoCd+9fYGQhmQZLQDSVXlPQtGl9x zJIgoGdyFz7P4oe7C/QNRoJgyA== X-Received: by 2002:a5d:4588:: with SMTP id p8mr3079161wrq.180.1571319329410; Thu, 17 Oct 2019 06:35:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g11sm2227301wmh.45.2019.10.17.06.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:25 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C97401FFC9; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 52/54] include/exec: wrap cpu_ldst.h in CONFIG_TCG Date: Thu, 17 Oct 2019 14:16:13 +0100 Message-Id: <20191017131615.19660-53-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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, 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 eadcf29d0c..d85e610e85 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 Thu Oct 17 13:16: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: 176672 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1035508ill; Thu, 17 Oct 2019 07:48:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpd3s3KEV6nFE23diG2hpvOk9NYJ89oPXgL54FQcOpRf93tlcRq42vNJH4CtwhcV6KI363 X-Received: by 2002:a50:ee81:: with SMTP id f1mr4202073edr.243.1571323713123; Thu, 17 Oct 2019 07:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571323713; cv=none; d=google.com; s=arc-20160816; b=FjxX6PeKkIBaehmc6wyUIMgZZ6kviNtBN5UQoP6sAGDDxUWPJCLHgL9Ewu2EONeN3V vi9Id2rp4eaX9VMvW3u9SBi6FnLsSV/O1xpO1ORWAZTnJuGk2hrjpA61yc5ID+OvtasU tji6gRxPI82xcHyVklXL8fwk9YpWb164XF0LtyQAHg1L0zVLSOqVBjr26HCXi9BniZGX XOEluB8m7O+AyuIPf1aqh/AKrIK0K9WuBN07BjPxSIv+q8b0ZPU/GGRA2n9N4Hg74dkQ sVTGhPoPpCkw+86VI8nZNNUod0eQa7dKke5EK75jC3eUxM0nr27icN9Q1sPJSqV0wi8O Lovg== 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=DKDSgoO4X4mkmor+GmSjidzV3ElN8/JotjJqlZ/rV+M=; b=h8RnZw1rsZH3vMGS/IVFrQNLqnjaDbu2ZX0JDwuXaCypB7unOBTG+cE/PSiQ2qaVEN GJHD74+Shpbxg/M3lQtqeTKLcqBqKvX80d2QfdizMs/G5LT5dLZ7mqm2eyFpkEL3b6EL qtdlFMX4KBDpKtirfHIa65oG5tlQQHvLQS6F+N23DwM/RYhh85kpT6YbZAFtbEt2sJrC UIQR9c5oO75BFxxUMRa2zuRkN0vnMLSroRUIbMxua9pp9c230ugnqqhBF189i7+9DjcD uFjPMOEWya6uyns7P+m81UqSE8eYHIRUpbLfnbXep7ot8PitA0eX0cMC/esc2k+qjvDQ /Bww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fDdOyxys; 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 ec21si1391291ejb.26.2019.10.17.07.48.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:48: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=fDdOyxys; 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]:49696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL74p-0002YS-G0 for patch@linaro.org; Thu, 17 Oct 2019 10:48:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37663) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5wH-00064X-5q for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5wF-0004ZG-1R for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:37 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5wD-0004Tr-08 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:35:33 -0400 Received: by mail-wm1-x342.google.com with SMTP id m18so2583023wmc.1 for ; Thu, 17 Oct 2019 06:35:32 -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=DKDSgoO4X4mkmor+GmSjidzV3ElN8/JotjJqlZ/rV+M=; b=fDdOyxyslCaLjYImUfgtMRcY8xcqNA8jKLeVNarCrrUu7SIyH8A6LfzwxY+joqt7O8 U/91QMBkHMVEmdyuNm9yHsaqb1kONfPgck4pR1YPVS6rqUhOsrGg9yU7LNRpsvzRPx6c 7+Qr1n6pBkJgmdPeQr/r7KKYTq63Kcu6unWhRGpcFRv53gFYf9qvOsmBTqHzPeGqtp2/ Gxq1XySM15t1D4WMZ4eqpwBf08ebWiPv1K6ilelwGQddEiEa/300+ZDmAwWfA1bMd533 ElWC0HXHosvaAbgkV5Dt5NC57NfjVypTyI6OhH2g+SB6hZo1HX4v/W5sCv4eQPX6B8ck I00g== 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=DKDSgoO4X4mkmor+GmSjidzV3ElN8/JotjJqlZ/rV+M=; b=ai3UdLew4uT03KXhXKfYWE8GdiDEJA4btqo3l7sbtD0KZ+8N5/xxe0SVeiZzhZI/Zx q4PAWvtE0ckeV8I22/udku7JL/DlCy7vwyBMBPOefc62p/+HpBp3rZ7JgcDKrzKdGzvv oUPZkavaYlj3V4TtloUxDCIpZTmlAFfsbo0UKEa4fQ9Pfn3Qz62jnheP/pAe2sksrnML V0v7ijMpKxpXipk4o6UZ2+z+VXZ4zY+GRhwzEI1OmpJALZdGIkQ2m/rnT1vl7Vg5if/S GOygG/pnSC6b8H30KADdt/nwJ/wk55eOEnTkaxUXf++D7xY+KXcJVv6l36ZJlaSAo2sZ YUgQ== X-Gm-Message-State: APjAAAXRnSJMoMn6df0+jK/hwYfaF39gEzqk1IdPKnq8w5ZMmQ8FCvFe t5QKwY3Z2W+Xx9zAFHJfQ+k8pg== X-Received: by 2002:a1c:ed04:: with SMTP id l4mr3096433wmh.116.1571319331023; Thu, 17 Oct 2019 06:35:31 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e17sm2256294wma.15.2019.10.17.06.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:35:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E15171FFCA; Thu, 17 Oct 2019 14:16:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 53/54] .travis.yml: add --enable-plugins tests Date: Thu, 17 Oct 2019 14:16:14 +0100 Message-Id: <20191017131615.19660-54-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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 Reviewed-by: Richard Henderson --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.20.1 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" From patchwork Thu Oct 17 13:16: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: 176647 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp967566ill; Thu, 17 Oct 2019 07:00:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDlah50WJ/ekNlcPr5dUmFVcGKcQ5hH0bFoN/jhxaM7e3p8wyARYQg/ehURPhLzMJopBBP X-Received: by 2002:a05:620a:4d7:: with SMTP id 23mr3376327qks.274.1571320800574; Thu, 17 Oct 2019 07:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320800; cv=none; d=google.com; s=arc-20160816; b=0o2K5PlMmZrnwnNCFoaPH+xb/U9IuAY9c+A9ncBNfZgMBmzupiO3k20R/JaW+gCZI5 WHyY5ssyAlJC7a9pzgx1YA9BUuWKfZEZ4xM5cahdLpPY9cnY+Ejkagl4YPpp2fBY3cAk x+tQa7KcsGAq0UQw1Nmv8lWPTK3W8nRYE5oW1RmPQCghhSgLGMwGIGYB51yzAhcEOVVC YYaQKFbOkRVvt4L1ZCzCPixhXEWKAZrIQQaN+3dtfTNB3g8r63QZ1MWCM3NY5NH2Xvli zfyOyp7aeFiy2dbSZ7xvaBYy63gLtwbOY85CgxJLvs1qkWrt7YQUc823yakAgkHnnvpl AqGw== 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=XmG2LtoiX+Cg+MugL8I+LN/rDbeWOzTWr6UI0zmW2pc=; b=IPac17K2nkEB+cPNQhSKhYDP6Wb/pKS2rMlvrqbWrrhgwKcXoi+Xwp3JjTlE+/tmCu pCE450OsOYtdgta1bi15i3fb8n/r2WMxMvkn27BbWgs5WMM4vg1+KAe1wfG6BnutZaQc kL7gdMp2fkn2NNoO8IN7IwuM7iI85n09qw1pQJZwNCVncmCvr1sq3dcFbQxtzuVQX22n YXDqbCmxDYQFDD88qeYS3VZzMmr+VNMBBTfZ/cu1Air3gYg2dmqLWg7ff0wKojMqlY7w oFKLE1uSiAKhvwstl6IEOqJd28N3oY4zIRT445fL3F1Mgf6Q+6MlnHaYrRy3Aji/6nm+ xy7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="nDCy5Z/T"; 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 m33si2303126qvg.109.2019.10.17.07.00.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 07:00: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="nDCy5Z/T"; 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]:48640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6Jq-0001xN-WB for patch@linaro.org; Thu, 17 Oct 2019 09:59:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35654) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5ma-0002PN-D7 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5mY-0001Jq-AS for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:36 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5mY-0001JP-3b for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:25:34 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5so2580995wmg.0 for ; Thu, 17 Oct 2019 06:25:34 -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=XmG2LtoiX+Cg+MugL8I+LN/rDbeWOzTWr6UI0zmW2pc=; b=nDCy5Z/TRTPUe0KHndfJE4gP+kZU21oDfjwgPIJZfyqSS4YZCb7pmjAtwjDUSfKrPZ tqmOtE4xzlFgBKLzFvnH9/8QhMP4PyTlGOOaG41uPoVSLvXjoWXVo3eFEGx8kQYVBmWZ cNid4V9Fy9vCL82p+4SsXyQCa1VdCuvDl0QeQz2A4ZF1skNdINGRIu/eT19zFLwDYONx D6zpUP0d3VW3t7Qw1J1OUArs7kLPCcRoHloAJKDoytmCgiqF3oCWRJe2mSB6/b4ftcoO 00Pellt60T4duKBLFuA+sjhnWcMZri4aEHNtSnK+xfxFs3JA1lDegSMR0pmUgM9fR6yn gGiw== 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=XmG2LtoiX+Cg+MugL8I+LN/rDbeWOzTWr6UI0zmW2pc=; b=QHmN9aHQvUVmpX2W9abgRth+norFBUxvpXOEl3jfRXiTmMzyTMXxyei8bOt4jwtu03 5nruabvrmoXFAAVRU/YmaFjb4mb6wqyj/ISY4wSdr+fdoandsq2AibxidoKi786MdYxQ ri7cniVLAFUhPx2HMfhRC/A9Dz0n7lRvEaqH5xWzExuYC4gXUoi37nxauRtYOb4Xe+3S PVmBTPM8P2G1QgXm9GFXe1it5PrOHnn7QSOYFa/PF4QQwOS3ucQ+gGo4umBq7HFhcCwD wKqVJvKFmFt5CPdZLg2104+VMmJcLWj1uw5M0Pt6FAjI7+o0YclIG8dPp9BMs6c+Vb6E Ci1A== X-Gm-Message-State: APjAAAWse3SE27O+mQLP2dDhPYvGUA3er0P/TVSC0QaRu3hgQip+Sikz RifcJnJs0RDQ4ymNLz0jpI9/3A== X-Received: by 2002:a05:600c:29a:: with SMTP id 26mr3100450wmk.127.1571318732938; Thu, 17 Oct 2019 06:25:32 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i1sm2866432wmb.19.2019.10.17.06.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:25:30 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 011E21FFCE; Thu, 17 Oct 2019 14:16:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v6 54/54] scripts/checkpatch.pl: don't complain about (foo, /* empty */) Date: Thu, 17 Oct 2019 14:16:15 +0100 Message-Id: <20191017131615.19660-55-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017131615.19660-1-alex.bennee@linaro.org> References: <20191017131615.19660-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::334 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" It's quite common to have a mini comment inside braces to acknowledge we know it's empty. Expand the inline detection to allow closing braces before the end of line. Signed-off-by: Alex Bennée --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Aaron Lindsay diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index aa9a354a0e..db67b4da87 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1639,7 +1639,7 @@ sub process { # Block comment styles # Block comments use /* on a line of its own - if ($rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ + if ($rawline !~ m@^\+.*/\*.*\*/[ \t)}]*$@ && #inline /*...*/ $rawline =~ m@^\+.*/\*\*?+[ \t]*[^ \t]@) { # /* or /** non-blank WARN("Block comments use a leading /* on a separate line\n" . $herecurr); }