From patchwork Fri Jun 14 17:11: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: 166854 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2335230ilk; Fri, 14 Jun 2019 10:37:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9qnigJjcroISCm/lhLOZI8paYsMHNCJZ8rQ8WyRlr7l4tK7hDDXiItu1jmNbOdMM1hKF7 X-Received: by 2002:a05:620a:1404:: with SMTP id d4mr31608582qkj.228.1560533827575; Fri, 14 Jun 2019 10:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533827; cv=none; d=google.com; s=arc-20160816; b=q5hCHOwO+rw5bUky1v9DCLiFtpPE83jYgXBKwfrpBOW64miW8HPRFu4sNiK2em2VPb KJThkyD0ywzRQ572GUzQoHPAXpAKlF4Gh7T7njpuz4etk44TE40LZl1/0/yHQWFEYMyU DqHaXsafDb/pz5Akz/6J7Nal6i+wG5WndxgYaFMsr6j7s1ZVkSI+wt0bSoE+Y3E+KWlG wIG7gB/guMpLJ3oXyApia1ybGkXqtHMn5k0g30XhW5dRpI8qxH+/Iz3KKrjZhd56pSAE nyWhtuFgujsR49ceJ+H+tj1Kj3HawYf+3AA4WbqcLOaNgKvBSBs/GkWVXXLO1QIErDS9 71Rg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Oj/0oPpqLDS/GX/KzCrsGX7DQFLG22FAaJqDHl23Ay4=; b=Yi0Y1PLoUIPudYlB4gwXQ1Apk39Uujxz6PxknCFV2LWyZsjZvvZs2wBC7LXktY2Vss I8vHEYibDTWCzqi5/Kp9FSPOUEGkJzKwM8V7VuAbQ1AHftQQ/p7z707/xYRHIEmgtpzl dBuRIRkdZmTJSXx096JbBuiTM7mK6Xl5RIBkgNFy8fiY4OZQ4+7qU9Awi4rpwtiL2gZ4 mUAgS0fwC5PoyUgw9kTwSXwdjkKUvOh4G8yaBSlaESkUVxzwJXdtBjRu+XZzL3TZwvk0 3lcW0CezhnVXyacMGu7AeND/2zfViG8TaWTmqzbyiA6/oArkx84nMSfPepHG0nVy3Ojs dTmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kjen5fso; spf=pass (google.com: domain of qemu-devel-bounces+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 o3si2268217qtb.21.2019.06.14.10.37.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kjen5fso; spf=pass (google.com: domain of qemu-devel-bounces+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]:53822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq8R-0003zQ-5A for patch@linaro.org; Fri, 14 Jun 2019 13:37:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55863) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkC-0000NH-PP for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkB-0002ut-Gc for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:04 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:39086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkB-0002ti-64 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:03 -0400 Received: by mail-wr1-x433.google.com with SMTP id x4so3315244wrt.6 for ; Fri, 14 Jun 2019 10:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Oj/0oPpqLDS/GX/KzCrsGX7DQFLG22FAaJqDHl23Ay4=; b=Kjen5fsoYTGAeB1k2EAmzlv51KrS5lr09BpoulPDbZXumh3IT85rtXJcMmXSPXjUHC cLqFUov2x2tdBdQ+xNYzyB+Qj2EQ9Rm5qR9FAQiZiC38X0LMqEROpWGh4pfVTEM0JzSF v85N/vLObTEcTo6J07vdvOTp6Ul90yBHSPvfIkwNJE5bHryoTbpIgxSevGd+bfI/1pZV GuNUry6nJdEL7AHc48r9g0HHKM1rzsPh8KnOqithZ2RcSaj/ZopYW5CUW65E/1v+R5oF izQ7BJKbtnvL2Nsp9zEkX1P9WJwbo/JA92AP6ZDY//BwPK9ePVeB9jLhX3YPKhfx6/Dj jJsA== 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=Oj/0oPpqLDS/GX/KzCrsGX7DQFLG22FAaJqDHl23Ay4=; b=N5DjqSBAtrI2cfOjJEUyXKLCGZEUSlVYJ3qas+geM23QFMaRh+DGJhLENqqr9MJrn7 i+b/7outAw+lenhc2R8rCOpUkGnoNJZh2O0/ORXAJIdotHeYl4LS481Mbl8jjqOfnk1/ g5d/hzFvZyPXxk/JuNoF9l+Zq1m1/PikOBQYIU2tQmy4P2e9dMtMlRFMN2yT0PYsl0QA 8DRAx/2cZ2L89k9YihoSO3b2vE5rL5gIwmH0hJO18P++jnHACnD4zuoxIqevwE2CAE8N mkqfqwyijuvl+9Kdcng9Y7ZZ97jtI4sSWHzY4EQQElUMA/5w6IZoUVNLoAnBu5DhJf7T JNiw== X-Gm-Message-State: APjAAAVE1LY76cYmSVadTN87n1rCA12zRh+1S5tL6vrFwgg/8TtvzuAe 772q0W+nKL4fuHqV3s4zFlyQ6GcoV4c= X-Received: by 2002:adf:de90:: with SMTP id w16mr33056671wrl.217.1560532321714; Fri, 14 Jun 2019 10:12:01 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o8sm4715854wrj.71.2019.06.14.10.12.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:00 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 854831FF8C; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:11 +0100 Message-Id: <20190614171200.21078-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 01/50] trace: expand mem_info:size_shift to 3 bits 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: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This will allow us to trace 16B-long memory accesses. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/trace-events b/trace-events index 844ee58dd9..037169aab3 100644 --- a/trace-events +++ b/trace-events @@ -159,7 +159,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 : 3; /* 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 */ From patchwork Fri Jun 14 17:11: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: 166845 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2319361ilk; Fri, 14 Jun 2019 10:21:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKmJbjovZT8byhIgOeH8pGu6OkRqlzv5KZNzLwG+sZfvyNgSHbKZ4Bi8qnT78stDhge5Wx X-Received: by 2002:ac8:5407:: with SMTP id b7mr75049132qtq.48.1560532873930; Fri, 14 Jun 2019 10:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532873; cv=none; d=google.com; s=arc-20160816; b=GovLGpFU7JhDZ+mB/FGxRdwSnXlq9OmKR74/Yt3RDo58vmi5AjPjTBTNkGEDR7c6zs kurXWRFrEwlNw5utqBVYJsIERaGh4M0hcJDvXmnxJslLzmK92bFl1kVzVAwPESHxsqA7 zQhWJ1XRXTinJ/jTPUJr6ipzhNmKQoAplvkPi41Tgtua9WOl40jTevjVlUy09HqYP++/ D8ZMARweuh1ZYs9VWJLQNqr/qSom4qjQBfZXzV7BBCH9Xo+iSwOy59A26sh1lNqZ0wgJ YXdSc+xLDIu/W5P2EfBRe2hOfmBIIF9zDkEorhrHW78Bexj+ya82oDpJGaB8KPLKnpB7 FqKg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=uuSP1+OO4V0J/TIomTItZc3CIXnPAwyQAIRCHYQETno=; b=la0dMEOv8N3Sh9CE4bf2UOD4tvVqWJ1BXKQPrJp4JFtEC5mDUUMYuKooy2NcoupTVT ZGBnKbJoNEKBd++jL/Oz04ObzTDN6hNhMtlBp4UTKtFzxKVEawDzrVsmXnqUxhTKVP6D IAuI/ASZfG9nbdHsapyWELOcq1fF/ChBhj9R6eDe6q472SGp9QzryZoqAW4jsuLW53Il vMYMBBit3eVGHcVSvvELwYQUj3J9eEMuw097NAdDx2Wkr+VBoldtIhKCEmODgRRZcVS5 FJ0+G+PBWk6BaWTZuMK9zuilbm2JZSJlthWJcOxZtu8zE2Fr33Tgg2oyuzRLY6q6ula/ ilNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZkeGprZl; spf=pass (google.com: domain of qemu-devel-bounces+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 k23si2201315qtf.87.2019.06.14.10.21.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:21: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=ZkeGprZl; spf=pass (google.com: domain of qemu-devel-bounces+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]:53718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpt3-0007t4-Ag for patch@linaro.org; Fri, 14 Jun 2019 13:21:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55890) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkD-0000Pk-VJ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkC-0002vs-Ld for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:05 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:52338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkC-0002uq-B3 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:04 -0400 Received: by mail-wm1-x342.google.com with SMTP id s3so3119409wms.2 for ; Fri, 14 Jun 2019 10:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uuSP1+OO4V0J/TIomTItZc3CIXnPAwyQAIRCHYQETno=; b=ZkeGprZlGrZGdkPuX0znJNtIeQ6gD1jhae/wwKqrzu5J4M79SkJl6vCA9qxSgkeUAk 9Q4a5yM15SdnWxg4ewbuRgS5kCkNSJ8FwDa172pwJMeu0Ree+/V45/VIn9VfNVGeUTCV 2GQA+1ohQ9RquAeQImH+fHrQZLebX8fBQC/oRP/hBVdQVULiRMY5oEyghaRcmV8Ho4Fc tOgibV9TcThEDpOLCktQibl87+Hj8lcjs2IhXzR+yzBqVlmxbofd2Pkl+cegnd5Y9ngG 7roCgzzNnasV1iTgDVe0yB12nWmC7wGl5v2L9PFAmBDX4gKMBpqbRHHwZ0vLZgo3xwwO iR+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=uuSP1+OO4V0J/TIomTItZc3CIXnPAwyQAIRCHYQETno=; b=BGPfIJFYZEZC7hBOKK6hYvR6JebQWzgw69vjwo8WzOzo5TUAaVqTNWdJomCRbqbMyK /IK2MQWPbasi2yZWA4Kn198OFwa7XES1RgnwTUpoHK3h5J4ZsJeeinUHlb2Vbl/2FJRS 8B+ArVU85QZoXLyWZEnGarDHZCeEry+T67fq3ackmgI/hjD1blrdDY1MimwESECnUW7e x0wuG4924+bhYt8/XFOW7DUOJmmA4JxxVOc+x99IRaF2dO6/J9hJGcJS8BFgCHSPestr U/1ELxg98s1mTBYgY/vWJJob4q8GY8oS+7SYpUsboMI5f7bHwF8NlCAqI9obRGMDr9uM JnBg== X-Gm-Message-State: APjAAAWkyADBlz+DbX3S92cnBtjjflf/PXCP1JSi4aSVN4ajHtSMTFDt ts3xnnj8NBB6y8P6O2mrtKl6Zw== X-Received: by 2002:a1c:be0a:: with SMTP id o10mr8688679wmf.91.1560532322971; Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r5sm6196915wrg.10.2019.06.14.10.12.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 982821FF8F; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:12 +0100 Message-Id: <20190614171200.21078-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 02/50] tcg/README: fix typo s/afterwise/afterwards/ 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: "Emilio G. Cota" , =?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" Afterwise is "wise after the fact", as in "hindsight". Here we meant "afterwards" (as in "subsequently"). Fix it. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- tcg/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tcg/README b/tcg/README index 21fcdf737f..ef9be5ba90 100644 --- a/tcg/README +++ b/tcg/README @@ -101,7 +101,7 @@ This can be overridden using the following function modifiers: canonical locations before calling the helper. - TCG_CALL_NO_WRITE_GLOBALS means that the helper does not modify any globals. They will only be saved to their canonical location before calling helpers, - but they won't be reloaded afterwise. + but they won't be reloaded afterwards. - TCG_CALL_NO_SIDE_EFFECTS means that the call to the function is removed if the return value is not used. From patchwork Fri Jun 14 17:11: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: 166842 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2310636ilk; Fri, 14 Jun 2019 10:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqze0VpCXJ6zzbAVao7nWHezfoXQPfX2ALsDT2AceHvq6LCkClTHJ9KGoGDDonJfrJeK1EJG X-Received: by 2002:ac8:373b:: with SMTP id o56mr84333090qtb.133.1560532361168; Fri, 14 Jun 2019 10:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532361; cv=none; d=google.com; s=arc-20160816; b=qu8WvEXtXiHyQgeXl+vfiT3nJG0ZS5oc9LoNF+8x3il3559eS5aIub4lq6iqpiAePQ Trrm67kYd7n15jr7KS0nIw/PE12KNNkZMTZX+ZTLW1/9fpYtOz9ouYD0VqEHyfMsXPTt WVd1zTdc90RwECL5Hc4RKSjzAEonm1qlMmuaibbxh37bXCZ5VEZgU2X1kngoQFTbt2WY cXKdrpWUIST6zeq4VEpgwiBSeJbslPnHXNCsu4vdgF020+H0CqfRSzQ+wOyAsuZSEuJC GsBjCIafA9DbKnbPWoYeuXC4hNPsBQ0QGb/xB2btt3UcBTxtJYtIXA6xgql3NZhpvY59 eIIg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=LBYsLFFlDbNrFNkTq7NtNY03tPUa5o/RrdI0930b6Ggs87MWgZog6xZwSeOxtN0UP7 oqWp6TOW5cMh8WppJAhDNUGOoHJuZGdbEGPtP2PwbPz6sB8l1yYYPBrl9KhUIwfIIm8v IZTT7EluatJKAj+9p7xNRCyH5sujHHknE7bAn8wHciM+2N7hIwtMMUlOanBDVwX+Wpem DGNE7dqSpGjg9DdQ+1LUDM2IeuQuWuBY5amoEyFpZ+Cbyq+rS5Gqs623xp8SJldXvKJ3 QI+XAC5lKHuttwSHdW+SGHxmp0yJI8HcKIfS+5GHst7ZBZ6PlfzpEHQGCCoCorHaWV9q NqrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=liNlhIYr; spf=pass (google.com: domain of qemu-devel-bounces+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 b20si2183393qte.321.2019.06.14.10.12.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:12: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=liNlhIYr; spf=pass (google.com: domain of qemu-devel-bounces+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]:53650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkm-0000Z6-Mf for patch@linaro.org; Fri, 14 Jun 2019 13:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55908) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkE-0000S1-Ug for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkD-0002we-EF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:06 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:38190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkD-0002vU-5a for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:05 -0400 Received: by mail-wr1-x442.google.com with SMTP id d18so3321244wrs.5 for ; Fri, 14 Jun 2019 10:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=liNlhIYrR8Z2D81wKr24l4CaxT63ZZlnWOLIYKEA1hOU1+VGh8aZeU6f7EXWrBFNft 7vjeWU61sMupXH7ZrVWJ4hrgHbTYvynUf9+D15GulLp1eE1xu5vvsmfLVTVhakEt7AsQ xlRMjzIz15yKUp3wXeUnOvWVGZFiropttAWk8Qh7ud0xC3bWHgSTAN2K9P0gJ9G+5bFp HizKJLAr2DJhPu/G9cMoXOLUEKG9ftCssd6lnXVNwHTJ7rXBB586jixWQWeMt/DbjrLl EE9vFU7V4LGGWXiUqZcOxkmS3G4wtFMovfkFLwuqc41iKcsBLRnNZ35ls5Nbv9qIIWxS lSaQ== 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=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=EI6fWtJxNgJGtP9Ha+9XnM3IpYDAnZr3/pJY9CqJih0VoaAKAh+HXpaZt6wIGxp9P9 CtYUGSdqL1VXau6aYWee0g2EsZY9Fp2MWQNiMDrdFD/6n6dnzTs9gPpAxn7NEdiwvXTq d6OrariCsllR5lvBJ95dXfDI+50K7VY8W7fjVVuRuvBMO/5oiqiGhQE8KTmkYRMSOb6L 9wKbdHc3xjQc2BL2qQ6dmy5bgv9MLWWBP9UHTH5I7g7Db004AwRFrnd1J0IqKzzHk3cg gRaaP+G56Fkeod3ZbFXa9ADjRtRRlNUAkpWQaN7a8h696RcLPWTXvgaphf6D8dF3OEyt SyBw== X-Gm-Message-State: APjAAAWEF6ZiBSPIVLXOl2Hseb9mK+z+wZ7MX+YLUlZArjbWtlo9IPa9 ED8DgyMWznNFZLJLWscsKB0DXr5hgis= X-Received: by 2002:adf:f186:: with SMTP id h6mr719115wro.274.1560532323665; Fri, 14 Jun 2019 10:12:03 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 18sm2315024wmg.43.2019.06.14.10.12.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AC1651FF90; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:13 +0100 Message-Id: <20190614171200.21078-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 03/50] cpu: introduce cpu_in_exclusive_work_context() 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: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- cpus-common.c | 2 ++ include/qom/cpu.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) -- 2.20.1 diff --git a/cpus-common.c b/cpus-common.c index 3ca58c64e8..960058457a 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -335,7 +335,9 @@ void process_queued_cpu_work(CPUState *cpu) */ qemu_mutex_unlock_iothread(); start_exclusive(); + cpu->in_exclusive_work_context = true; wi->func(cpu, wi->data); + cpu->in_exclusive_work_context = false; end_exclusive(); qemu_mutex_lock_iothread(); } else { diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5ee0046b62..08481ad304 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -373,6 +373,7 @@ struct CPUState { bool unplug; bool crash_occurred; bool exit_request; + bool in_exclusive_work_context; uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; @@ -785,6 +786,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_work_context() + * @cpu: The vCPU to check + * + * Returns true if @cpu is an exclusive work context, which has + * previously been queued via async_safe_run_on_cpu(). + */ +static inline bool cpu_in_exclusive_work_context(const CPUState *cpu) +{ + return cpu->in_exclusive_work_context; +} + /** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain. From patchwork Fri Jun 14 17:11: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: 166858 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2346300ilk; Fri, 14 Jun 2019 10:48:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2pj9/aUu657D+uZ1SkKQBANl3NJEsBewmJMx8619bxh8S9SG9Rqhb5hCeHwlXAWchagBT X-Received: by 2002:a37:de13:: with SMTP id h19mr6553818qkj.59.1560534504012; Fri, 14 Jun 2019 10:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534504; cv=none; d=google.com; s=arc-20160816; b=ON+3O6+x9/WBwRsVOIyUJZI9SDSxtATg9EUWgHmlnysCHZue3trhlBbK8PuUMDmxG1 T7qZge2fI6iyfvFN4dLj7q7QJCDpYKJv1f/zn89uheP6mdDD++x4t6JjijZ0p/ZKdcMP fyyQ2UnxafP0G8dYLCh7haYFlU+pQiU2NOpxPU+Pth4ZNIRtDGyZf3BJQ7Ru1RCsMPuU s3BJ4v0dYoOCOFFHei4KAkIaADiiYvpjyP/tLtngPSOhPAOIrQ0QfFzIrRPo+bUtvlFV mwFRiwh61U8geIArd1Jf32XLAh1WW9tRykN01LGsJm5ukjDPph5E7jh2L0WgEHeNGNny 8mvw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=08HscLjvD+PkgROa+8EpI2roPOdpCcPPJ5uFR5Az32c=; b=cf3olnfOE+XMnja3/4eIjt4r6Q0JXAMGnvIV6cqbnImcjQxtPruQ6zaMXR/qxemfmD 72XX8KLk4EUkI19uysjcHZ3+VmekmFVszaJfo8ujWUZpA5Qpyzq6jkVJkCzlKm/6JbRe rd/gAovLFuOmEtYVYDZnBunwe4ln2drfta3C3mre4KH5ZOH9vNPEkw42SQOVyg1mA9iK Y/zL/5YCFzR9Vxaf9A57PhgxjHdsR6D1rKVMR762pQv6rKYTsvdVVCtNYOddcACH7ECF Y0W3ozjvWGMcaHocP8jHOMqddRHXzwOBYCgOOGnYSfg15w2EPytzRC1gcuQGX1OwjvM4 SUJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ky7YLsxA; spf=pass (google.com: domain of qemu-devel-bounces+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 h40si2280406qta.172.2019.06.14.10.48.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:48: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=ky7YLsxA; spf=pass (google.com: domain of qemu-devel-bounces+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]:53876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJL-0004FV-J0 for patch@linaro.org; Fri, 14 Jun 2019 13:48:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55918) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkF-0000T5-EM for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkE-0002xY-6p for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:07 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkD-0002wC-TO for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:06 -0400 Received: by mail-wm1-x344.google.com with SMTP id v19so3033768wmj.5 for ; Fri, 14 Jun 2019 10:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=08HscLjvD+PkgROa+8EpI2roPOdpCcPPJ5uFR5Az32c=; b=ky7YLsxAcIiyof1matNxkkgrxHSdO/GiNDxXq3/tXUK6IyZU0XmeR6eE3mig9pHNo7 diWt4nPa2NBfaM1SJ2jWGulR1Z2nwHQPV0mS+BdsO6bsbj43J1eSe2xCLbcc47sH1kwD M5995shcL2u81R+8bJTOLTAKNBkvEwy8Z/5e1ygRx+oS+B9m1pIy5EvnWtuCXrhKimL5 L4YWyJKjQccSccDp8JOrD5ziODbolvbP/YrTdEZzP7buw6yiUTu9XpAdyuU+FkIhs6Sf CWdOovEwRt+aPW//tsu3758borr74wZ+0jtNw5lDCNrpDgxrzqz4CVCgXmdkWHNqLBmt gmjA== 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=08HscLjvD+PkgROa+8EpI2roPOdpCcPPJ5uFR5Az32c=; b=ExJ2tuozlf0QED8fWnyXFVqW2YW1JqsUsS9nvslfGJHV9Ezuleq3UJZRlRCJ7EPgSY 2R7BvTHVShQAna5bEM77ArvDGHU4wKPKs91XRwvwWlNdOfwRiW1qcLyLkg33FF4mIz40 7rYzgSy1rAu3mEvMmRsMCxsqZJKs4dwfSDB/ehimYzCL1FbS1mXS1nwZ7T1st1d/IYQb T6LVkgpicWbfLp0I9O8NomZPR/zOM+YHiYJ5xVjcMiBEWmIQjwy3QH0uEKdGXByIclHC lv4i24eFOZoCY4EXdppsGvwDoWopzLhFlK7uR5dj/6ziyzvFHsb/OVNEpmc/05WLpEMC 9aZQ== X-Gm-Message-State: APjAAAV34E5jAulARggNoi/VXdIANGbRO76ar0XI2+XBj7haoI58tKaR F3xmrfeL6ZUosFPA8/34x76WW48s0uk= X-Received: by 2002:a1c:305:: with SMTP id 5mr9092711wmd.101.1560532324399; Fri, 14 Jun 2019 10:12:04 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b14sm4225685wro.5.2019.06.14.10.12.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BFFB11FF91; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:14 +0100 Message-Id: <20190614171200.21078-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 04/50] translate-all: use cpu_in_exclusive_work_context() in tb_flush 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: Paolo Bonzini , "Emilio G. Cota" , =?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 --- 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 5d1e08b169..54998e39c6 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_work_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 Fri Jun 14 17:11: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: 166844 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2317371ilk; Fri, 14 Jun 2019 10:19:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5dNdqgPd3b8VpHHySeNj8DRRUMiaWkumc1mE/eNH2nynkrk9NAWsTr0dL5cTqNKazDY5b X-Received: by 2002:a0c:ba21:: with SMTP id w33mr9391516qvf.122.1560532753627; Fri, 14 Jun 2019 10:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532753; cv=none; d=google.com; s=arc-20160816; b=m/sFq8JqpJak6s7i0u+LimxLTKIJr7tBVl098aD62rrC8K7/yx2rIRC0zJjFEGYyFL VnCI5K9QWj2PAiY3Oj9MTHtXkkeEwe8+rTvjnO2T0FJkS5VJqUf1NQae7xCDYZceh/lV dTRefXtnLXQIICe/tml9EOl+IL4Slc5l8xIQAudoAFEV4f90wvC0MgzSzwbuLJZvMzM/ EIir4EgEWO9n0pCNeHtV8TS2DqRK0zHgKQjdkK47wp/4XmgP55bJ65e8sQIekvvAZ+rX 6RNj1VrEfhTBUpH5OeaMPHABd+gE2kLedol7rd55QlbRUw0GmVJMNKfB7mmtnyV8lg4i WNfg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LmI/mBSkUBusQla1865jT/J9Nwa1pt6elfDdpjwViYY=; b=Wzm7tm1GMwak4033QzmXiTV5Ai10fajD3vpNZlIpG6xyhxjq2K0x6pP1Dxh9NyL298 toLNsM0mLF6cRdLAsMNLTOpfA7+prcCcXSc9oYqhvhUyArjrsKvGT6D8lx/Y4a+Qm9k0 UkQrn6nN+CbG+weOjDLqLkRNJ+gGcgzGgqlRIRpKjsjPoO07zKUcLRjrC2EBkaj0NyUP 4eTyXKdyjS2CN3yHu9stjtU+b3m1Cwv3vfnXv++c1VDyA9b2RNgrIC1L115I3UKUqdUS wxA+ptA/mfHEN2Ei2BYC5bKBKS/t4Y333sb+/MBQI5pQYdtKPIzLUw+U9hd/1YaRbabZ EmjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=uquMfLGT; spf=pass (google.com: domain of qemu-devel-bounces+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 k93si2093103qte.13.2019.06.14.10.19.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:19: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=uquMfLGT; spf=pass (google.com: domain of qemu-devel-bounces+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]:53710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpr7-0005Fz-5Z for patch@linaro.org; Fri, 14 Jun 2019 13:19:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55952) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkG-0000WF-Pl for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkF-0002yp-FM for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:08 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:34935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkF-0002xt-6i for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:07 -0400 Received: by mail-wm1-x333.google.com with SMTP id c6so3058468wml.0 for ; Fri, 14 Jun 2019 10:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LmI/mBSkUBusQla1865jT/J9Nwa1pt6elfDdpjwViYY=; b=uquMfLGT0bzb1W7jFdk6JmHnArAfpiR8pgyFKkVjm6Jlt6mZl5MMic2J5EtTl4jQzz bXVp6Jx1KQDQWqWwXgKMGOGaxU24ChVXoNWpmEIj70QUp6795aTV/slTUq/LGMQaFD40 uedjmkmTDOrevmLGcCuDuSLMd1Tw0mL25KG3TMV/m68bb2La1OmW/37MXZ0RZmrgVcIC 3ve9X34WEEJrMtekRX2/LfgZv6JVI8MEHLm4vETNPZElE/CjQ+zlboJnjDIQ657RfgXh ZA1Xi0GOqMfmyYp1Ua2YGoQhlnqM82MSdcQJWfmS7x9ZJKd+exqdhEjYOS9Mvaj/vhD1 21eg== 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=LmI/mBSkUBusQla1865jT/J9Nwa1pt6elfDdpjwViYY=; b=kWaaGPMY7wHsfiReQdlB2qsSUzFKZAk2ZPI+5+RSLjTuS22xPbmbgXjqua0TpWyuhi Ej7odFjvQkI0+Oq2pJL0bT3PE69KKWAxeTuOrbbTOPW56wfjkoZyhqMEtiHWkvIHXQe0 d7H2L6+Ob6x+viFsachq2Bz8yvByakVU0RXLdqhL8w39z80erFdhqmColMgv94HpYaz9 DQpYknxWXM+6ZiY+ab8TGe0vjELkSKGw5uYWFDenZ7C342EIDZj/1VoU23FyI0HUl+x9 tgrMM7B8rNw6/BxO1lfHqrYaw5G63dS7hGFGcniR9VOzVIxbhgKcdkwK6X06ngYwpNoo km5g== X-Gm-Message-State: APjAAAVYv7yav4Vx/q9lFf+Xg+gMiso823cqZpkCX+Nf4wHPbS6sm8sv R4EYm88fwed6FMKjq41jOCONNA== X-Received: by 2002:a1c:f713:: with SMTP id v19mr8695931wmh.159.1560532325862; Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o4sm2720965wmh.35.2019.06.14.10.12.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D57DA1FF92; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:15 +0100 Message-Id: <20190614171200.21078-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::333 Subject: [Qemu-devel] [PATCH v3 05/50] docs/devel: add plugins.rst design document X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- docs/devel/index.rst | 1 + docs/devel/plugins.rst | 99 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 docs/devel/plugins.rst -- 2.20.1 diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 2a4ddf40ad..7e6d20c970 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -21,3 +21,4 @@ Contents: testing decodetree secure-coding-practices + plugins diff --git a/docs/devel/plugins.rst b/docs/devel/plugins.rst new file mode 100644 index 0000000000..b0c30375ef --- /dev/null +++ b/docs/devel/plugins.rst @@ -0,0 +1,99 @@ +.. + 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. + +API Stability +============= + +This is a new feature for QEMU and it does allow people to develop +out-of-tree plugins than 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. + +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 + +Plugin Life cycle +================= + +First the plugin is loaded and the public qemu_plugin_install function +is called. The plugin with then register callbacks for various plugin +events. Generally at least the atexit_cb is registered so the plugin +can dump its information at the end of a run. + +When a registered event occurs the plugin callback is called. 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 +the plugin must either keep it's counters separated and indexed by CPU +or use a callback which can ensure atomicity. + +Finally when QEMU exits all the registered atexit callbacks are called + +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 means some callbacks might still be called after the uninstall +function returns. The plugin isn't completely uninstalled until the +safe work has executed while all vCPUs are quiescent. From patchwork Fri Jun 14 17:11:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166874 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352206ilk; Fri, 14 Jun 2019 10:54:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgzgnk6n2+zRQN5EY9E7x2BFn1mhrZ+nbvw1CXGcNQ4qRevOA7YXU3BgXrw8crHfkeH8xo X-Received: by 2002:ae9:df47:: with SMTP id t68mr8497093qkf.8.1560534874586; Fri, 14 Jun 2019 10:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534874; cv=none; d=google.com; s=arc-20160816; b=HMNjng1zNvM+nL5GFaEMo8eERokbc3iCFV7uwoAQ+raY3PDSROw08U8f6Omaqe2g0r gNsJXV/HwrXfb0Un026MZQFFeBg7tS2QiWUGCXCgcb1+MIMa3l6Nn8VXTJC/Ghdr9bHZ bCyE1npRCwXBS9MSw2lL/Z2msowUhWYxiqJJQp8L0mgMr44okx3cSxS/37jreQ6e5jRe y+tfPepR/7ugB3NiSjZqU4HItAkSefqAOy5C84z94nnhTSSIJfY2x83vOTvVQrduROlr jXFc9xD9IT3/rTkzVZpD5d6K8LYYVnvk+caL1U975iTt1Y4AB4k6ApwKBMJb5kLEsA0K utvQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8bC4Ua5+cmFCH7/z3JbOgJMbpPZnAdyKgQfwrXL9vnQ=; b=PdKVYufFIcSHQC+ILDjWyn4QXRA6ni7+qT/CtEPHysaXENTeVoh6BbeTqNwBL8tI3u 5An9y5mNub7b/+k0Ym8I5EACk5B3JYytmjv1Tt2791fzzDefj+uyPXDKeATSIHVdkgGc 3M8z/JyYV6fjbXMtddfAzIzY1X1Vz2DbYmEvAn3f6JbPkFJjAoS2JA6GNiACGU05t0Uf RbEgV3BEhuicMaIoT8la9ihTBuiHDpNf7l3GUZUDScUJZk6zo806FaOW/i1FEvuG6+LX WFa1Ygu1zhuSRrKE2bxSi4aNhWK6nZIcnQgQ1JHUgLMToaVuB52YLZPQ+iY1Bqusz9YA Hm+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pTYPNeW8; spf=pass (google.com: domain of qemu-devel-bounces+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 u13si2164188qtb.57.2019.06.14.10.54.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:54: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=pTYPNeW8; spf=pass (google.com: domain of qemu-devel-bounces+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]:53908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqPK-00006A-5s for patch@linaro.org; Fri, 14 Jun 2019 13:54:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55939) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkG-0000UQ-2Z for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkE-0002yH-UZ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:08 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40669) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkE-0002wt-N4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:06 -0400 Received: by mail-wm1-x341.google.com with SMTP id v19so3033807wmj.5 for ; Fri, 14 Jun 2019 10:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8bC4Ua5+cmFCH7/z3JbOgJMbpPZnAdyKgQfwrXL9vnQ=; b=pTYPNeW88qhJChbZ2vWTHN6ODLLY+6x20uMSvv3RPXIUEJwMDOhLricPeOkm36L80T SGsemwdu8BZLJfvO6wnsKh8XnIeXDI+RK7h1Pk3PxseZFxJyepRr6TQ6aUeG03p7GK85 051t8jdB2JzvdzRwsI67vl54dZMfOItxXHhRolXXDx1yvNfswIL/PbahTTa/jYGoEn1I 7WvkU7hmELWdhX5RiGZBAoWLZAXZ8MQZNn2SkMXiPA6xrfvKkhovYBfUpyHJxWd6bDuR tZccAljadTN/U27FTYH01roEPQHeNA+B3BAas7us6mgFQzX+Wpr4zsuuqnltkYkyQdAN SF1Q== 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=8bC4Ua5+cmFCH7/z3JbOgJMbpPZnAdyKgQfwrXL9vnQ=; b=s2T6kK7RVCRALoByEAnPRk76QQuVH0nVOlq8IJOXpVMHOqbDq6uOC8f2QBzQ31ZSDn 5298/Na6EuDBxQ2rKgGtX0eIzFEubOWf1a3Pxli55Dpo/Dr3Kzwge721K7yLKQabj9y0 lMCcTr9b3tcFRyqQosRivNVPZh5Mze6A0dBkaVrN8SKy04mJk+qcXrzAVnd6JoThouDO O3YG6AodQjClADO3B50Iu8b+FD+8gIosMyNtyOBmxeRrdors0MFEyY7nYPAiq/PQoXfk YPWVcd7tGmNdE8t6djF8k5k8j4htyWAyFEBIjC9LXet6mGKc5wwjTuDtPgvOBVdX/Kml okdQ== X-Gm-Message-State: APjAAAUmXDfckktkwrbNmMDpvVois3Kzj1dp0yk7noAAmOmTDQnjHZxk 3adKv5hTP6NxE3D6M1Y5MkH7JOnQeuk= X-Received: by 2002:a1c:be12:: with SMTP id o18mr8616695wmf.21.1560532325117; Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o13sm5231579wra.92.2019.06.14.10.12.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:02 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E989E1FF93; Fri, 14 Jun 2019 18:12:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:16 +0100 Message-Id: <20190614171200.21078-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 06/50] configure: add --enable-plugins (MOVE TO END) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds the basic boilerplate feature enable option for the build. We shall expand it later. XXX: currently this patch is included at the start of development to aid with incremental building. It should be moved to the end once the plugins are feature complete. [AJB: split from larger patch] Signed-off-by: Alex Bennée --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.20.1 diff --git a/configure b/configure index b091b82cb3..48f3263e55 100755 --- a/configure +++ b/configure @@ -493,6 +493,7 @@ docker="no" debug_mutex="no" libpmem="" default_devices="yes" +plugins="no" # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64="aarch64-linux-gnu-gcc" @@ -1537,6 +1538,10 @@ for opt do ;; --disable-libpmem) libpmem=no ;; + --enable-plugins) plugins="yes" + ;; + --disable-plugins) plugins="no" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1734,6 +1739,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: @@ -6479,6 +6486,7 @@ echo "docker $docker" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "plugin support $plugins" if test "$supported_cpu" = "no"; then echo @@ -7296,6 +7304,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 Fri Jun 14 17:11:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166848 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2321810ilk; Fri, 14 Jun 2019 10:23:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlKYZoF6W4bRooyIdfAsN7hTWPiWKrIryrCOq6+TT7Hx5WGMnCcRxDTGVLrrq0wDjBswuD X-Received: by 2002:ac8:1c7b:: with SMTP id j56mr60647650qtk.247.1560533025752; Fri, 14 Jun 2019 10:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533025; cv=none; d=google.com; s=arc-20160816; b=qmuYRsCTWk/lo6LzafqwLMHMQy9JSGEIlpJ6Asy0oUyKPFdhdkL88CHLEI07BFZAJ7 O/UXCS0BlTjDaWmc+gfrKWG9yjbrwMinyXyBhxii9CuqUIOJc6ow2hVF/TKRymXadx4q Z7G5I2ER6fLaOa5sGbc/3TTh4L9RHVly6HdRyqt2stqWcGEBWYiISfFCZekd0eCW7WaH 5i3VwgDq3a3xqtP3f9ezOF5wpjh+9xL1TAzXZv+5dVEuONVNV+FALFT97uhNLtScWNSY LQSnYr1o2JcAh2BIKSrseLEXl4+SdczA25T/84zYT3jZ2JlF1S0mXdGK9/Ua4NXajjV4 lioA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+NsNu/fQ72HqiGPytLgCEAG9ztz6pLZ4BO4isDX3okI=; b=s1EhmkA+htqcgTpn9NNsCbJ4h9Qo6m3SqTwfTzXGVYypexdl8Ktiaj3P3KlsdZbNb7 4DOpM7ny/v3+GvMjFuUYGCzCPz+yfZLrqvYigN11L2FICxZzQnlcqNdVjOiCQsTzCtQX 2AiWSSp0GtauX2dgoQdbczTRHBk2biEQBqE1PTPUxn6RsDWoUrISquUSJKBRxWf7ZxU9 /nM+lzeOvmEodzP6vMihJOmFN+2FWxzmsQ7Zd7LdpAh4Gn28hXLanaXrrYIhurr+5LiW a2UxEpiqIYUCri09nOmN47cHhtrq9O8a4IhYmIR6OmVz04bEPHS+Qi9/jAFDeU3hLfEJ HaQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HaE+yRpn; spf=pass (google.com: domain of qemu-devel-bounces+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 q53si1968956qtq.306.2019.06.14.10.23.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:23:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HaE+yRpn; spf=pass (google.com: domain of qemu-devel-bounces+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]:53736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpvV-0001M4-AE for patch@linaro.org; Fri, 14 Jun 2019 13:23:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56048) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkL-0000fC-1a for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkI-00032P-KC for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:12 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:33422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkI-00031I-Aq for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:10 -0400 Received: by mail-wm1-x343.google.com with SMTP id h19so9330987wme.0 for ; Fri, 14 Jun 2019 10:12:10 -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=+NsNu/fQ72HqiGPytLgCEAG9ztz6pLZ4BO4isDX3okI=; b=HaE+yRpnAcYcrv/zOu0tsRujZo0VdTZdm0oYvicFr/KucEVxuO+sdL5x5ELipwLDat QB5an6c6CgPzBmA5WgOi5WIBH13e1Pl4TLLbGhPfdw3n6URG9Fm457znyuJ6apqB4Tzn baNH3jukTIbTO8mJATZtteIZn0mmTF1fh4nTiaLsZ/dAeseDipIB9XZCCDdPPmypE2Gz hv7ZNdVmn+h8zDCBcF72r9vOlBqQnEANDbZ3mx5rjhYLJxmxmS7gzEtP+PQqZR7zsysC CCKB78o2pSedK2N/wkWJ0PmEbXDU/VXSRcwEPse/WOMP1JDnf2XWHH7CkYJi75siaF3Q r5lg== 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=+NsNu/fQ72HqiGPytLgCEAG9ztz6pLZ4BO4isDX3okI=; b=iw1qgPi9oMe3MVqBoZvy5wl4Fva6O4rprz5AfVk4si4Fti7CXrS9yEAjNN/9AGouU1 ex7xnH7jTLsbukJbWTpn0MaDXXwPt/Wk1bacmlqeM/n6TruXuoV2t2F/Ed42QVd40N6x lN5C3B3wfQiBDSc6gHsv1cCIftqUxJWBkS/HrENEgEx5PUIu+sH4z6YNrO8EYJTzr+jh dABEkQZIGvlMUeAIVfUl3yFxPDIY908zoYm+2Y9Pg+lUnHsjECqcNWGaP+fd5qoYUpF9 eDj8/7u9O5tqlBOQDQ7gtOUBQwnzVehOZTXeh6YaJzPzO0U5wmJ7oUkMNBn0nlHV97+K 1H2w== X-Gm-Message-State: APjAAAUnK1KnvgGWKB+pm444w76b5EbBqIjJtPHTsKTqjNY0uYNY4djY hgtFtUQrxwHW50tkI79zsec2+Q== X-Received: by 2002:a1c:f21a:: with SMTP id s26mr8512836wmc.163.1560532329097; Fri, 14 Jun 2019 10:12:09 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m9sm4276670wrr.14.2019.06.14.10.12.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0BC9E1FF96; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:17 +0100 Message-Id: <20190614171200.21078-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 07/50] plugin: add user-facing API 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: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- v3 - merge in changes to plugin install/reset/uninstall - split api file --- include/qemu/qemu-plugin.h | 339 +++++++++++++++++++++++++++++++++++++ 1 file changed, 339 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..0db1ef9714 --- /dev/null +++ b/include/qemu/qemu-plugin.h @@ -0,0 +1,339 @@ +/* + * 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 is 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, + unsigned int vcpu_index, + 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 + */ +typedef uint32_t qemu_plugin_meminfo_t; + +unsigned 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); + +typedef void +(*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *userdata); + +typedef void +(*qemu_plugin_vcpu_mem_haddr_cb_t)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *haddr, 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_haddr_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_haddr_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); + +uint64_t qemu_plugin_ram_addr_from_host(void *haddr); + +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 Fri Jun 14 17:11:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166851 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2325196ilk; Fri, 14 Jun 2019 10:27:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR75Eis3T3GrHxmBkT6r4tqRX+PvGXLsNqaQ6cf08BG/WsakVSmc+ztyWxd/RiAYmT2s6h X-Received: by 2002:a05:620a:15c9:: with SMTP id o9mr35973001qkm.195.1560533243579; Fri, 14 Jun 2019 10:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533243; cv=none; d=google.com; s=arc-20160816; b=eO9QpCLwoPvG4pcswiCOTOWQb3vnCf/PaJVyawpgI6MDs8PqzPJbe8fjw+dcWz7hNW AfHlQq7b+EsqYU/UAijIb+zXx+pPNr30T4XqkXpuk9qEI+4upKQrzvQm195JVhgm2Pcb n1yfy+FwM1oiVszjPUZVx7/zTX2IMh+WsmKHYpxnjYZ1nM8gR7/Pgfk6gc5QRwQdwx8n w7gLkVKcXSB11jX4+Kq0PtlUBoMb16FVia4uaIiuUk8lPDZL+a9qChkTDAMYcvF9VKRD uEAI+VO+yHoaiByvK06j8uulbw+taRwKjkZKig9Mf5s+HERMkUoBU2KW5myeOugJ90yL nDcA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8sZV78BJLDD4zzBRyO2MtNsLdyftsD11BN9/V7IukGo=; b=LlKE8NNcf8nlH17VK+MkHOYes8of6q2XemEOvnGRtruamg8ulHZgolgVoubCco9FXi 7fr4YXzVLxCwUvKmteKcCz1voun7FqZUN3EwnBCDi3qAtuER7DsfaaRqnvCxEEvfLfMS 3+OLqBoV9rqvPMnca8ZSKs0MutI7YKHKP9xQhPGsY6M2vm6Wao86mPsfDzVfR3yQLyEv UIvwMgChtXQ68bZlqwUDcHUQ+thQm09u+xkBEWAUKwsC8nhM6TcNr3lglyYAu3xg1f5U MANLyXPr3t7m8Q9G96qrCCRPqRrCBRg3uGjJdR4ueGzKVqlj9mMKZ5PyBenWj8SOA8iV 8+Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e0+xh5Ku; spf=pass (google.com: domain of qemu-devel-bounces+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 d18si2046843qtj.19.2019.06.14.10.27.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e0+xh5Ku; spf=pass (google.com: domain of qemu-devel-bounces+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]:53772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpz0-0005Vh-QX for patch@linaro.org; Fri, 14 Jun 2019 13:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56128) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkN-0000jv-DO for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkI-000321-9t for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:15 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50711) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkH-00030t-Sw for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:10 -0400 Received: by mail-wm1-x341.google.com with SMTP id c66so3125530wmf.0 for ; Fri, 14 Jun 2019 10:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8sZV78BJLDD4zzBRyO2MtNsLdyftsD11BN9/V7IukGo=; b=e0+xh5KusRz+DBlnwBba9OIrkM5wUC5uwmkBzrvkcduSXoLwyQ5783QeZayfckqmU6 35RdT9uelio/fSKPo6d9z0laBMzVGnXWdtirQeKEDmKX1hWT4Ptl1ZntrzuxtP7kENvK vJTc+b5sdIhD+STQU1MRrsvTp/NjljL7vU3zsfBEMGeGx9EWpd1DclOEmIeJfRf1/uLj Kdo/C5bc2D1Z6wI83kyxCLR+5PuYPK7YtAZa5fmG+yzkUHUJ8/EysF2OpjWPJ7P1eIS1 WVMjKWCctPAlnSI2Z2nXi7gR6ThYF+3YAcn75Yy5YhfHlB+U1CDPayeUU/h1Zd8E078V kgOA== 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=8sZV78BJLDD4zzBRyO2MtNsLdyftsD11BN9/V7IukGo=; b=P8u+pRoxIG5EgnXEyPSgKjrE+lH777iJI8XSjODW/qoTK90yRNApE0dPuVbPTVZ/dF dAFSZ72QeG4nZ/aobZ8CufKhNsgdb2NTp3pABGNDfnGnusS9blqK3/NJVkXCt1W8tcX4 sQTYxbEhGfGJ+6OsqFxglk1t3gKJHIECQvW326HCrnJ98DgzgB3XGCwhthQxvMN8+ksF wkEZOPp9iHzZ7kJ1A9igWVoRXsPWAJaFc1iTHBC4tBEHxYXF3+DcL0go8yXL6iGm5OkM 0WQTGSmyyIt+g2NtiXeO3B+Q5XtrUqWq5k1QQKwy/pmmuCwA4+ucvd4uN7rH8VePSP0h Allw== X-Gm-Message-State: APjAAAWYRe2hXUdKC4MWgv4TEsVuDASvXTL15Hz76ja8ODrkqunHkGF7 7PDtwREiFn0Z4rXrrpyGJyGtu2/XPkI= X-Received: by 2002:a1c:968c:: with SMTP id y134mr8586227wmd.75.1560532328224; Fri, 14 Jun 2019 10:12:08 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l9sm2370823wrt.13.2019.06.14.10.12.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2DB301FF98; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:18 +0100 Message-Id: <20190614171200.21078-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 08/50] plugin: add core code 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: "Emilio G. Cota" , =?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 [AJB: moved directory and merged various fixes] Signed-off-by: Alex Bennée --- 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 --- Makefile | 10 +- Makefile.target | 2 + include/qemu/plugin.h | 261 +++++++++++++++++++++ include/qom/cpu.h | 6 + plugins/Makefile.objs | 6 + plugins/core.c | 524 ++++++++++++++++++++++++++++++++++++++++++ plugins/loader.c | 353 ++++++++++++++++++++++++++++ plugins/plugin.h | 95 ++++++++ 8 files changed, 1256 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 8e2fc6624c..37d396ab88 100644 --- a/Makefile +++ b/Makefile @@ -827,8 +827,13 @@ 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)) + ifneq ($(TOOLS),) $(call install-prog,$(subst qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)$(bindir)) endif @@ -888,6 +893,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 ecd856e3a3..d492e24da2 100644 --- a/Makefile.target +++ b/Makefile.target @@ -118,6 +118,8 @@ obj-y += target/$(TARGET_BASE_ARCH)/ obj-y += disas.o obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o +obj-$(CONFIG_PLUGIN) += plugins/ + ######################################################### # Linux user emulator target diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h new file mode 100644 index 0000000000..93e39f44d2 --- /dev/null +++ b/include/qemu/plugin.h @@ -0,0 +1,261 @@ +/* + * 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, +}; + +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_mem_haddr_cb_t vcpu_mem_haddr; + 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_CB_HADDR, + 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_type 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 { + bool haddr; + } mem; + 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, void *haddr, + 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, + void *haddr, 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/include/qom/cpu.h b/include/qom/cpu.h index 08481ad304..27b67a4e49 100644 --- a/include/qom/cpu.h +++ b/include/qom/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); @@ -345,6 +346,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. @@ -430,6 +432,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/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..8c46373773 --- /dev/null +++ b/plugins/core.c @@ -0,0 +1,524 @@ +/* plugin.c - QEMU Plugin interface + * + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#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 "qom/cpu.h" +#include "exec/cpu-common.h" +#include + +#include "cpu.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" +/* #include "exec/plugin-gen.h" */ +#include "sysemu/sysemu.h" +#include "tcg/tcg.h" +#include "tcg/tcg-op.h" +#include "trace/mem-internal.h" /* mem_info macros */ +#include "plugin.h" + +struct qemu_plugin_cb { + struct qemu_plugin_ctx *ctx; + union qemu_plugin_cb_sig f; + void *udata; + QLIST_ENTRY(qemu_plugin_cb) entry; +}; + +QLIST_HEAD(qemu_plugin_cb_head, qemu_plugin_cb); + +struct qemu_plugin_state plugin; + +struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id) +{ + struct qemu_plugin_ctx *ctx; + qemu_plugin_id_t *id_p; + + id_p = g_hash_table_lookup(plugin.id_ht, &id); + ctx = container_of(id_p, struct qemu_plugin_ctx, id); + if (ctx == NULL) { + error_report("plugin: invalid plugin id %" PRIu64, id); + abort(); + } + return ctx; +} + +static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data) +{ + bitmap_copy(cpu->plugin_mask, &data.host_ulong, QEMU_PLUGIN_EV_MAX); + cpu_tb_jmp_cache_clear(cpu); +} + +static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata) +{ + CPUState *cpu = container_of(k, CPUState, cpu_index); + run_on_cpu_data mask = RUN_ON_CPU_HOST_ULONG(*plugin.mask); + + if (cpu->created) { + async_run_on_cpu(cpu, plugin_cpu_update__async, mask); + } else { + plugin_cpu_update__async(cpu, mask); + } +} + +void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, + enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb = ctx->callbacks[ev]; + + if (cb == NULL) { + return; + } + QLIST_REMOVE_RCU(cb, entry); + g_free(cb); + ctx->callbacks[ev] = NULL; + if (QLIST_EMPTY_RCU(&plugin.cb_lists[ev])) { + clear_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__locked, NULL); + } +} + +static void plugin_vcpu_cb__simple(CPUState *cpu, enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_VCPU_INIT: + case QEMU_PLUGIN_EV_VCPU_EXIT: + case QEMU_PLUGIN_EV_VCPU_IDLE: + case QEMU_PLUGIN_EV_VCPU_RESUME: + /* iterate safely; plugins might uninstall themselves at any time */ + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_simple_cb_t func = cb->f.vcpu_simple; + + func(cb->ctx->id, cpu->cpu_index); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__simple(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_FLUSH: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_simple_cb_t func = cb->f.simple; + + func(cb->ctx->id); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__udata(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_ATEXIT: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_udata_cb_t func = cb->f.udata; + + func(cb->ctx->id, cb->udata); + } + break; + default: + g_assert_not_reached(); + } +} + +static void +do_plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + struct qemu_plugin_ctx *ctx; + + qemu_rec_mutex_lock(&plugin.lock); + ctx = plugin_id_to_ctx_locked(id); + /* if the plugin is on its way out, ignore this request */ + if (unlikely(ctx->uninstalling)) { + goto out_unlock; + } + if (func) { + struct qemu_plugin_cb *cb = ctx->callbacks[ev]; + + if (cb) { + cb->f.generic = func; + cb->udata = udata; + } else { + cb = g_new(struct qemu_plugin_cb, 1); + cb->ctx = ctx; + cb->f.generic = func; + cb->udata = udata; + ctx->callbacks[ev] = cb; + QLIST_INSERT_HEAD_RCU(&plugin.cb_lists[ev], cb, entry); + if (!test_bit(ev, plugin.mask)) { + set_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__locked, + NULL); + } + } + } else { + plugin_unregister_cb__locked(ctx, ev); + } + out_unlock: + qemu_rec_mutex_unlock(&plugin.lock); +} + +void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func) +{ + do_plugin_register_cb(id, ev, func, NULL); +} + +void +plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + do_plugin_register_cb(id, ev, func, udata); +} + +void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ + bool success; + + qemu_rec_mutex_lock(&plugin.lock); + plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL); + success = g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, + &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); +} + +void qemu_plugin_vcpu_exit_hook(CPUState *cpu) +{ + bool success; + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXIT); + + qemu_rec_mutex_lock(&plugin.lock); + success = g_hash_table_remove(plugin.cpu_ht, &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); +} + +struct plugin_for_each_args { + struct qemu_plugin_ctx *ctx; + qemu_plugin_vcpu_simple_cb_t cb; +}; + +static void plugin_vcpu_for_each(gpointer k, gpointer v, gpointer udata) +{ + struct plugin_for_each_args *args = udata; + int cpu_index = *(int *)k; + + args->cb(args->ctx->id, cpu_index); +} + +void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + struct plugin_for_each_args args; + + if (cb == NULL) { + return; + } + qemu_rec_mutex_lock(&plugin.lock); + args.ctx = plugin_id_to_ctx_locked(id); + args.cb = cb; + g_hash_table_foreach(plugin.cpu_ht, plugin_vcpu_for_each, &args); + qemu_rec_mutex_unlock(&plugin.lock); +} + +/* Allocate and return a callback record */ +static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) +{ + GArray *cbs = *arr; + + if (!cbs) { + cbs = g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), 1); + *arr = cbs; + } + + g_array_set_size(cbs, cbs->len + 1); + return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); +} + +void plugin_register_inline_op(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb = plugin_get_dyn_cb(arr); + dyn_cb->userp = ptr; + dyn_cb->type = PLUGIN_CB_INLINE; + dyn_cb->rw = rw; + dyn_cb->inline_insn.op = op; + dyn_cb->inline_insn.imm = imm; +} + +static inline uint32_t cb_to_tcg_flags(enum qemu_plugin_cb_flags flags) +{ + uint32_t ret; + + switch (flags) { + case QEMU_PLUGIN_CB_RW_REGS: + ret = 0; + case QEMU_PLUGIN_CB_R_REGS: + ret = TCG_CALL_NO_WG; + break; + case QEMU_PLUGIN_CB_NO_REGS: + default: + ret = TCG_CALL_NO_RWG; + } + return ret; +} + +inline void +plugin_register_dyn_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, void *udata) +{ + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + + dyn_cb->userp = udata; + dyn_cb->tcg_flags = cb_to_tcg_flags(flags); + dyn_cb->f.vcpu_udata = cb; + dyn_cb->type = PLUGIN_CB_REGULAR; +} + +void plugin_register_vcpu_mem_cb(GArray **arr, + void *cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata, bool haddr) +{ + 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->mem.haddr = haddr; + 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, cpu->cpu_index, 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, void *haddr, + 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: + + if (cb->mem.haddr) { + cb->f.vcpu_mem_haddr(cpu->cpu_index, info, vaddr, haddr, + cb->userp); + } else { + 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); +} + +uint64_t qemu_plugin_ram_addr_from_host(void *haddr) +{ +#ifdef CONFIG_SOFTMMU + ram_addr_t ram_addr; + + g_assert(haddr); + ram_addr = qemu_ram_addr_from_host(haddr); + if (ram_addr == RAM_ADDR_INVALID) { + error_report("Bad ram pointer %p", haddr); + abort(); + } + return ram_addr; +#else + return 0; +#endif +} + +/* + * 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..bdd875868f --- /dev/null +++ b/plugins/loader.c @@ -0,0 +1,353 @@ +#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 "qom/cpu.h" +#include +#include "cpu.h" +#include "exec/exec-all.h" + +#include "plugin.h" + +/* + * For convenience we use a bitmap for plugin.mask, but really all we need is a + * u32, which is what we store in TranslationBlock. + */ +QEMU_BUILD_BUG_ON(QEMU_PLUGIN_EV_MAX > 32); + +struct qemu_plugin_desc { + char *path; + char **argv; + QTAILQ_ENTRY(qemu_plugin_desc) entry; + int argc; +}; + +struct qemu_plugin_parse_arg { + QemuPluginList *head; + struct qemu_plugin_desc *curr; +}; + +QemuOptsList qemu_plugin_opts = { + .name = "plugin", + .implied_opt_name = "file", + .head = QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head), + .desc = { + /* do our own parsing to support multiple plugins */ + { /* end of list */ } + }, +}; + +typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **); + +extern struct qemu_plugin_state plugin; + +void qemu_plugin_add_dyn_cb_arr(GArray *arr) +{ + uint32_t hash = qemu_xxhash2((uint64_t)(uintptr_t)arr); + bool inserted; + + inserted = qht_insert(&plugin.dyn_cb_arr_ht, arr, hash, NULL); + g_assert(inserted); +} + +static struct qemu_plugin_desc *plugin_find_desc(QemuPluginList *head, + const char *path) +{ + struct qemu_plugin_desc *desc; + + QTAILQ_FOREACH(desc, head, entry) { + if (strcmp(desc->path, path) == 0) { + return desc; + } + } + return NULL; +} + +static int plugin_add(void *opaque, const char *name, const char *value, + Error **errp) +{ + struct qemu_plugin_parse_arg *arg = opaque; + struct qemu_plugin_desc *p; + + if (strcmp(name, "file") == 0) { + if (strcmp(value, "") == 0) { + error_setg(errp, "requires a non-empty argument"); + return 1; + } + p = plugin_find_desc(arg->head, value); + if (p == NULL) { + p = g_new0(struct qemu_plugin_desc, 1); + p->path = g_strdup(value); + QTAILQ_INSERT_TAIL(arg->head, p, entry); + } + arg->curr = p; + } else if (strcmp(name, "arg") == 0) { + if (arg->curr == NULL) { + error_setg(errp, "missing earlier '-plugin file=' option"); + return 1; + } + p = arg->curr; + p->argc++; + p->argv = g_realloc_n(p->argv, p->argc, sizeof(char *)); + p->argv[p->argc - 1] = g_strdup(value); + } else { + error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", name); + } + return 0; +} + +void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head) +{ + struct qemu_plugin_parse_arg arg; + QemuOpts *opts; + + opts = qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, true); + if (opts == NULL) { + exit(1); + } + arg.head = head; + arg.curr = NULL; + qemu_opt_foreach(opts, plugin_add, &arg, &error_fatal); + qemu_opts_del(opts); +} + +/* + * From: https://en.wikipedia.org/wiki/Xorshift + * This is faster than rand_r(), and gives us a wider range (RAND_MAX is only + * guaranteed to be >= INT_MAX). + */ +static uint64_t xorshift64star(uint64_t x) +{ + x ^= x >> 12; /* a */ + x ^= x << 25; /* b */ + x ^= x >> 27; /* c */ + return x * UINT64_C(2685821657736338717); +} + +static int plugin_load(struct qemu_plugin_desc *desc) +{ + qemu_plugin_install_func_t install; + struct qemu_plugin_ctx *ctx; + char *err; + int rc; + + ctx = qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); + ctx->desc = desc; + + ctx->handle = dlopen(desc->path, RTLD_NOW); + if (ctx->handle == NULL) { + error_report("%s: %s", __func__, dlerror()); + goto err_dlopen; + } + + /* clear any previous dlerror, call dlsym, then check dlerror */ + dlerror(); + install = dlsym(ctx->handle, "qemu_plugin_install"); + err = dlerror(); + if (err) { + error_report("%s: %s", __func__, err); + goto err_symbol; + } + /* symbol was found; it could be NULL though */ + if (install == NULL) { + error_report("%s: %s: qemu_plugin_install is NULL", + __func__, desc->path); + goto err_symbol; + } + + qemu_rec_mutex_lock(&plugin.lock); + + /* find an unused random id with &ctx as the seed */ + ctx->id = (uint64_t)(uintptr_t)ctx; + for (;;) { + void *existing; + + ctx->id = xorshift64star(ctx->id); + existing = g_hash_table_lookup(plugin.id_ht, &ctx->id); + if (likely(existing == NULL)) { + bool success; + + success = g_hash_table_insert(plugin.id_ht, &ctx->id, &ctx->id); + g_assert(success); + break; + } + } + QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); + ctx->installing = true; + rc = install(ctx->id, desc->argc, desc->argv); + ctx->installing = false; + if (rc) { + error_report("%s: qemu_plugin_install returned error code %d", + __func__, rc); + /* + * we cannot rely on the plugin doing its own cleanup, so + * call a full uninstall if the plugin did not yet call it. + */ + /* if (!ctx->uninstalling) { */ + /* qemu_plugin_uninstall(ctx->id, NULL); */ + /* } */ + } + + qemu_rec_mutex_unlock(&plugin.lock); + return rc; + + err_symbol: + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + err_dlopen: + qemu_vfree(ctx); + return 1; +} + +/* call after having removed @desc from the list */ +static void plugin_desc_free(struct qemu_plugin_desc *desc) +{ + int i; + + for (i = 0; i < desc->argc; i++) { + g_free(desc->argv[i]); + } + g_free(desc->argv); + g_free(desc->path); + g_free(desc); +} + +/** + * qemu_plugin_load_list - load a list of plugins + * @head: head of the list of descriptors of the plugins to be loaded + * + * Returns 0 if all plugins in the list are installed, !0 otherwise. + * + * Note: the descriptor of each successfully installed plugin is removed + * from the list given by @head. + */ +int qemu_plugin_load_list(QemuPluginList *head) +{ + struct qemu_plugin_desc *desc, *next; + + QTAILQ_FOREACH_SAFE(desc, head, entry, next) { + int err; + + err = plugin_load(desc); + if (err) { + return err; + } + QTAILQ_REMOVE(head, desc, entry); + } + return 0; +} + +struct qemu_plugin_reset_data { + struct qemu_plugin_ctx *ctx; + qemu_plugin_simple_cb_t cb; + bool reset; +}; + +static void plugin_reset_destroy__locked(struct qemu_plugin_reset_data *data) +{ + struct qemu_plugin_ctx *ctx = data->ctx; + enum qemu_plugin_event ev; + bool success; + + /* + * After updating the subscription lists there is no need to wait for an RCU + * grace period to elapse, because right now we either are in a "safe async" + * work environment (i.e. all vCPUs are asleep), or no vCPUs have yet been + * created. + */ + for (ev = 0; ev < QEMU_PLUGIN_EV_MAX; ev++) { + plugin_unregister_cb__locked(ctx, ev); + } + + if (data->reset) { + g_assert(ctx->resetting); + if (data->cb) { + data->cb(ctx->id); + } + ctx->resetting = false; + g_free(data); + return; + } + + g_assert(ctx->uninstalling); + /* we cannot dlclose if we are going to return to plugin code */ + if (ctx->installing) { + error_report("Calling qemu_plugin_uninstall from the install function " + "is a bug. Instead, return !0 from the install function."); + abort(); + } + + success = g_hash_table_remove(plugin.id_ht, &ctx->id); + g_assert(success); + QTAILQ_REMOVE(&plugin.ctxs, ctx, entry); + if (data->cb) { + data->cb(ctx->id); + } + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + plugin_desc_free(ctx->desc); + qemu_vfree(ctx); + g_free(data); +} + +static void plugin_reset_destroy(struct qemu_plugin_reset_data *data) +{ + qemu_rec_mutex_lock(&plugin.lock); + plugin_reset_destroy__locked(data); + qemu_rec_mutex_lock(&plugin.lock); +} + +static void plugin_flush_destroy(CPUState *cpu, run_on_cpu_data arg) +{ + struct qemu_plugin_reset_data *data = arg.host_ptr; + + g_assert(cpu_in_exclusive_work_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..e89f9ef0ea --- /dev/null +++ b/plugins/plugin.h @@ -0,0 +1,95 @@ +/* + * Plugin Shared Internal Functions + * + * Copyright (C) 2019, Linaro + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _PLUGIN_INTERNAL_H_ +#define _PLUGIN_INTERNAL_H_ + +/* global state */ +struct qemu_plugin_state { + QTAILQ_HEAD(, qemu_plugin_ctx) ctxs; + QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX]; + /* + * Use the HT as a hash map by inserting k == v, which saves memory as + * documented by GLib. The parent struct is obtained with container_of(). + */ + GHashTable *id_ht; + /* + * Use the HT as a hash map. Note that we could use a list here, + * but with the HT we avoid adding a field to CPUState. + */ + GHashTable *cpu_ht; + DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); + /* + * @lock protects the struct as well as ctx->uninstalling. + * The lock must be acquired by all API ops. + * The lock is recursive, which greatly simplifies things, e.g. + * callback registration from qemu_plugin_vcpu_for_each(). + */ + QemuRecMutex lock; + /* + * HT of callbacks invoked from helpers. All entries are freed when + * the code cache is flushed. + */ + struct qht dyn_cb_arr_ht; +}; + + +struct qemu_plugin_ctx { + void *handle; /* dlopen */ + qemu_plugin_id_t id; + struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX]; + QTAILQ_ENTRY(qemu_plugin_ctx) entry; + /* + * keep a reference to @desc until uninstall, so that plugins do not have + * to strdup plugin args. + */ + struct qemu_plugin_desc *desc; + bool installing; + bool uninstalling; + bool resetting; +}; + +struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); + +void plugin_register_inline_op(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, void *ptr, + uint64_t imm); + +void plugin_reset_uninstall(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb, + bool reset); + +void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func); + +void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, + enum qemu_plugin_event ev); + +void +plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata); + +void +plugin_register_dyn_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, void *udata); + + +void plugin_register_vcpu_mem_cb(GArray **arr, + void *cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata, bool haddr); + +void exec_inline_op(struct qemu_plugin_dyn_cb *cb); + +#endif /* _PLUGIN_INTERNAL_H_ */ From patchwork Fri Jun 14 17:11:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166847 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2320434ilk; Fri, 14 Jun 2019 10:22:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgRShdCDT5xbahdsADXBkjQkScOgxlAG3c2KsXQXEcM/pKXG5bFeWld0Buw82RUMRjf07j X-Received: by 2002:a05:620a:119a:: with SMTP id b26mr58183622qkk.332.1560532940605; Fri, 14 Jun 2019 10:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532940; cv=none; d=google.com; s=arc-20160816; b=jHuSwF1S7IFwalJKeG4mz8hXBGhCLQeeHpIayGFADAXDeMFgXUYgfLxhzoWZdGpEZR nHQtlS8WxHclgZclhPUgKMKsjIElME0u9X+JRneRRO/OzYz6AGYV3ADQwavjV6xqc+ux 9NNnThBuAI3rztTilkjb9Co/i5u1czl1l5R6AhZfTfJAlB0lSobBc7uaA/gAF9jRdiWL 5MGTSA4BBWGTkG0SWbWHKMOdxEnMJRIlM5V5HITG0G6qLhrqypNnpmmlPKnHNF1Mw2u8 cZnc9aZ41YXAkYE7OOFYA3PYezD2b42N9XmN+G6BBA9EfYUW2cH5m18zSIGfbU7m7kxC 80ng== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=92e5w8g18IqDzpvO8b8wKWyc5Ftp9KNxzA8ygeTKv0o=; b=ASkypjJDQxt7ldYWdXsIWIbIyJg/Hi2KjTUTqhE5N55Jyr5OImkJWIlkLtWisvrQt4 vWe+GBZfRwO/vE5IaMcrGn4wWC8VOhlfsLAsT53U30UuLQPOcZKDFSIJ+26iHFdEDr+1 nU88aXrZHbsoHTrrBCXrAGZu0LUrqE1nfzf2JaWDSqqkCXKcDpMDwzsi9mX8s4ajIzV1 hpzygpk4D0Z7Cfr6Vm3o58Y0euk+Mrx9IMRAmad31lra/PaYR5aE4/GbjnaJG4gxIkNf rBvCcjBMyIV8OABtpZnFOtH6S3nFVlBmRMGEQa92rtbKHnvzMIf9AjZTkZ9+4i5G4XPH K+DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bAek12Xd; spf=pass (google.com: domain of qemu-devel-bounces+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 v65si2039843qki.214.2019.06.14.10.22.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:22:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bAek12Xd; spf=pass (google.com: domain of qemu-devel-bounces+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]:53726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpu8-0008Rn-7t for patch@linaro.org; Fri, 14 Jun 2019 13:22:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56074) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkL-0000gx-Rp for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkJ-00033k-Q2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:13 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:33357) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkJ-00032M-GX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:11 -0400 Received: by mail-wm1-x32d.google.com with SMTP id h19so9331015wme.0 for ; Fri, 14 Jun 2019 10:12:11 -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=92e5w8g18IqDzpvO8b8wKWyc5Ftp9KNxzA8ygeTKv0o=; b=bAek12XdtEyb83bF64UDydH2kbmmGFeBBH+zVxvuJrlv4yrHOgrAPc2P4Z58zG5jR6 iWLP8VGklU8Vr8+QvGSiWhgYnk0iBA4zGOb27OQq/9xduviUotWW2upNHxkPQo3gOBWz zDganJlAHgHZfFFtGXmoWSIyDAKoKvBO2EmX4pZuMDP3UL1MNpnXF2qVnOFDkUO2VB92 P8iUl1OvvTfG/lCNHKpftha3DlcVljHwsLfhiv04EzL9feSdFh7j6DmfMwuywyuutNo4 S0ZD93zOvuh5pL62nTiqVDGIUvJxGeatedM27drNTY6RJHTJlZ1iHlBQSJrCUjR8MLmu PSRQ== 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=92e5w8g18IqDzpvO8b8wKWyc5Ftp9KNxzA8ygeTKv0o=; b=ebfCXni/hS6fdFzjWDp0W7e04Hpf3GDJ108UgMnU2C6bnizi+CF83WXnTpxHHsA0Fk dWttbPVyzLGJg086QJSfGtUSGXA2+E09TPC2LMhgQRlCeiQKMIZC90WnjVH9OoRqOtyk /I0FzBAOzlc5SpG79R3czfyj0KBlEci4asvPh9s41CxV/aC8kXPpPiC6KlqUfIHpO8Qw PRfSLsm5NCoZ4Gnq+wijauFrKHxB1N0g8YIzrETrYxeoMV47ZSfE2cHrVpP4QeOkpFjp ctn0h34sahO1eOARjZiKoMlLTqfswDBLJNJu6iGp4vlWr8JPtWI/Lost9NYugCB1zOqE WB+A== X-Gm-Message-State: APjAAAUU2UdPOiA7nANTjPz+JYF3HC1I1wo3GrDk7HcrOoQlXMIv3aZD VeN0lvIkbeeBPKIogAm/BB3hEQ== X-Received: by 2002:a1c:720e:: with SMTP id n14mr8794084wmc.53.1560532330031; Fri, 14 Jun 2019 10:12:10 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w185sm4025708wma.39.2019.06.14.10.12.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 43A8F1FF99; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:19 +0100 Message-Id: <20190614171200.21078-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 09/50] plugin: add implementation of the api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- plugins/Makefile.objs | 1 + plugins/api.c | 267 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 plugins/api.c -- 2.20.1 diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs index 58940335bc..95baabf3d2 100644 --- a/plugins/Makefile.objs +++ b/plugins/Makefile.objs @@ -4,3 +4,4 @@ obj-y += loader.o obj-y += core.o +obj-y += api.o diff --git a/plugins/api.c b/plugins/api.c new file mode 100644 index 0000000000..1c3aa64702 --- /dev/null +++ b/plugins/api.c @@ -0,0 +1,267 @@ +/* + * 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" + +/* 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, false); +} + +void qemu_plugin_register_vcpu_mem_haddr_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_haddr_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_HADDR][PLUGIN_CB_REGULAR], + cb, flags, rw, udata, true); +} + +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); +} + +/* + * Queries to the number and potential maximum number of vCPUs there + * will be. This helps the plugin dimension per-vcpu arrays. + */ + +int qemu_plugin_n_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return smp_cpus; +#endif +} + +int qemu_plugin_n_max_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return max_cpus; +#endif +} From patchwork Fri Jun 14 17:11:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166852 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2334018ilk; Fri, 14 Jun 2019 10:35:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3ucmNvkBQlx7AdHVO84Pidl+SqEGeq0ZgEu6yHRDf5jSUGHy9MO5+gEH0Pupgq53ZNcc4 X-Received: by 2002:ac8:25e7:: with SMTP id f36mr70079927qtf.139.1560533757867; Fri, 14 Jun 2019 10:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533757; cv=none; d=google.com; s=arc-20160816; b=osCV1rgpud6ByZdnjwLge8/WqTVtkVNmAXq9MpCYNQqKAMnzQNbq4iFgl0ctRwIy6u M+/MME7dYhvovk/xw9b95hXUTKMUSw1p9pc2ufPlQ72zV7X7pBOp0JetIqElk86RZCux xS0iT5l3Oc1U5QZkV9qJODdjqSyGX7sh5Gmebxo+OOhW1KL2Sa0uE6W6my5/kXzRNQIs +tGqWKW0V1cibOv5Ab+Z2Az7tfBg4FqB2Pd7+/58yKIivYJqvkc7gseqMzRVxa6vVctV xO+KnWTGcOlo1l8Cu1W/xLfYVbdHjrNwNf53qIZP05EJHVAmdRemGXCIAMgci1oix+76 BYGw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=aaXX3gQaQ+yIC35QS28KS1PNhW44kKO1FarcjHXQujo=; b=rwbnxCnJ+gVO3SUZNMjnY+So+eCaGMU1RmXy1aaGNk5PZ5tNvUs0by6+Opz9x56ehm 3GY+HbbotF2lR1CMO4reWvHgd9pJPB63rG9Q0K6kqUAUAzO+bRtQwrQCeLuQHyzs7j1C wwqUnsS6K54aD/LCDWCon8Nt0pfY/k0litabiwCqDucGgiZ2XJRf1loM+dfLzUuPtjQb mxSyNtMpZRmZG7dQqs+RC6j0X9TWQVZw9L1fIX3X/xl0vMzb/rQRWhMdCBFZDpI9hOPz mMsE6wdcR1rzQZkP41+Z1CnQHP3AwApG/swQ1acOUEzjswdxLr/camE4ottC0EurQAHo sLSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zcDMbdsV; spf=pass (google.com: domain of qemu-devel-bounces+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 y48si2207480qvc.84.2019.06.14.10.35.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zcDMbdsV; spf=pass (google.com: domain of qemu-devel-bounces+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]:53812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq7J-0003XG-Df for patch@linaro.org; Fri, 14 Jun 2019 13:35:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56082) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkM-0000hU-9d for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkL-00035f-2D for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:14 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:35204) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkK-00033o-QD for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:12 -0400 Received: by mail-wr1-x42e.google.com with SMTP id m3so3333187wrv.2 for ; Fri, 14 Jun 2019 10:12:12 -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=aaXX3gQaQ+yIC35QS28KS1PNhW44kKO1FarcjHXQujo=; b=zcDMbdsVZHKFdWKcOG1ih54C6DlGeQg9GtBKioQMfxzCTCA1Qhd7HGs5D3+ky2uSXR EtSVoNmPy31OKfsQ5DHKyOsMeVmmXIa5hEBNLvzUOEjLYxqRB4S+rH+458/yfWXfXvtr 1bijvpYtspE6nbwJRGRvafRKEoOl/UT7reve2TBwI9rUcRmF56lzfuoe1FyqiF/yBVGX BszD2krN+/GyYDdy3cQ/W3QRbGJwagg45VosMISpt61hBXavLLewFmkTzGbJCalHjJlR d+cLuCkhtiCA2DTIgyilVsl2GDBnguaHEeR3234z0Qf6rwvpjM+o8B9zR+wNRwVRydgU tieA== 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=aaXX3gQaQ+yIC35QS28KS1PNhW44kKO1FarcjHXQujo=; b=tHNQrjGwgUfQVcPo1ArpvNo6uFVH2CwVFtdjIBtUIMu9gefFfqJVs2ltLto2Vu1JdI 4bpghqSbsgA1aD0eOB9nzRGROIVJs9FfC4WbyJSicQx/qn5CMC/xcRxzFFOvFYMYy+cJ r2BlTHZANJr7OCVXfKfUZ/y49ArmgIEG/A2P7zw4LiRgOOyaAMdARPwxaPZvKsisUSlf mTOzUy3NvEcnuALFAuo+zITMXDiCvkGCgedYnheaGz/o104i7LTBqBXTwvAzNUYiUQnp R98v6IE8I5PGD/o2zHnncVJZ4BQEnM5McqKEl3KrimfBtGCWGahl0O9mvSkFqhV4dDwj NKWw== X-Gm-Message-State: APjAAAUK0PcLnd70sH03t4x2XOwh2B16DHFAz6hlVBPk7zoNrPzv40fl wYZ+sxM4OYcGbTGCgYuuNbdNYRIlveY= X-Received: by 2002:a5d:484e:: with SMTP id n14mr651654wrs.348.1560532331384; Fri, 14 Jun 2019 10:12:11 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g19sm4392261wmg.10.2019.06.14.10.12.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5867E1FF9A; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:20 +0100 Message-Id: <20190614171200.21078-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::42e Subject: [Qemu-devel] [PATCH v3 10/50] queue: add QTAILQ_REMOVE_SEVERAL 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: "Emilio G. Cota" 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 --- 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 0379bd8fdb..66e834dad1 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -422,6 +422,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 Fri Jun 14 17:11:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166904 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2357353ilk; Fri, 14 Jun 2019 11:00:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqznZJnEv4b+G/Pn29w28ao39mwbOl+UAUFgipkypgI/pkZEq6TVS8G/zPcj8AXAVJRUJwUP X-Received: by 2002:a37:6652:: with SMTP id a79mr58499345qkc.60.1560535215610; Fri, 14 Jun 2019 11:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535215; cv=none; d=google.com; s=arc-20160816; b=nMDCSiCpiQzP8tdUNR5rLFAFxF1QJOHBL/Im9R+ZV3c3vy4/FylbGdvIC5+tcNkjAs vw2m+Ri7Zq1IiB233kdnhi0SoRqJQjxDQts567L0yxOfbhqPLVrh6NIegewrrfwd2yi5 7W1gFSdwqyt8bNYcLYGpoA2Q6FSE/Jjb3LBGsdlKogmYNlMKL4vxjisfM9N6zH4zPUw8 WedQ5LvPT7oI3ZinURb1MonO3vrafV9J+vhx4s7tYp46vxwLFOO3y0F6YYofJBrwEOtc ywfTnhB9s6pxivQKdbZC7toNIkP+RYIrqcJx96bf8NCBZQy2zG5BeYI7+sjWq9jP8F+V Ahzw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=wTzsgKyezzklLe62p3Xhjbs91VZGkyagGHfvJN+obus=; b=GdALJ3DGuxuTsmxng4TSYn/0MAw8RsQNRiysHvosrzkCRa1OWxG56mcmLa8eECrSq2 H1qqqaN1ZBirmgNzOemfGSikKpy+uzscSShj8QR6rr/vQOLNs1bX6uQKpKfV+BpIpgu9 8ZkHxduknARcJ/q4aneRN6DgjgFy5qXE8dod5Y0RKiV8E2wW3epG/9wNnQYnkXozxmjG +wT+7qQVlfkrOiDf8gysw6d8Zx6/hxfvqWrlxSRm3zBBgF0wmbl4b2m8J4evmCRoRpHu lqDzaj8HIQwpi21YnTcUNwvRszyTZSsYLSVPR2nGAyf22xNcAnGpg4wZxeRaIPx6C4dM z/hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xylxhynK; spf=pass (google.com: domain of qemu-devel-bounces+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 o79si2269428qka.13.2019.06.14.11.00.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:00:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xylxhynK; spf=pass (google.com: domain of qemu-devel-bounces+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]:53944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqUp-0004Xd-3f for patch@linaro.org; Fri, 14 Jun 2019 14:00:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58596) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005aq-3s for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00076Y-50 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36067) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006iJ-NR for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so3355415wrs.3 for ; Fri, 14 Jun 2019 10:18: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=wTzsgKyezzklLe62p3Xhjbs91VZGkyagGHfvJN+obus=; b=xylxhynKuTsGMmspgASfMRRvc1v7UD0zd4h0c+eo3PIbebB7xn9FAaJXh8JnwvYJmD 6HGmlmqRAJHss5vahRw/8MOJuhVBDwsfPTl04eytddPGkRQWqNJIhUzjW12rQSPMx5BF nkkzkvv7R7PHXhMOvf+tDaluFvtL5YXX4OETt9/x/+PObGv8Lq1mNDQ51VRQUMjciiWE No2huPuf57BqHupDU/mi56IjMO999bkKvMEPxGAbTjJEswWoJKGnBRtjQTQodr4+BrX1 423VUIT2YIqAmK95Tcd5NlB2NWrwnGdAiB/TLX3JjuKet0XUUAJNaeTJgcrOOJ0D5JRC OyPA== 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=wTzsgKyezzklLe62p3Xhjbs91VZGkyagGHfvJN+obus=; b=pAgk5Ein5hYdfg7kzFBjc3Y9zhKqILtgyS1ZdrNJCepKdCSoR3aUCCafncswfYzsVJ 1Q6uEc5uNeBI5CNKcC1b/tdBQsyU/w5ambTW1ZDmkc0DSnwAx7OSFxz/NoSgkd6brwP8 DobKJT16TD37ji3LOEj86wlBN8adOxZOUi+fLV7h9O0cMnVGXoIkiZ+sJrecqXGv7IWw ToN52kY+I/QhgMPE9GtxX4gG+lCmPDHHZ0hXu3TggI7WpFnb1QBnXy5/lFQskBU7vnTc p8OKIlU/8iNMVu34Bg+H80BjXbxcrX4eke6DMjOhXWjRLdrlMNjhWm749otUIjOcFLrg oLdg== X-Gm-Message-State: APjAAAXTx+nIZdMka0K/175noDIzvWNPlsDSgRxYvQKKqNQ80PrrUX8y ADb1BhtF4hjaFyd8gujhQjX/ow== X-Received: by 2002:a5d:4ec1:: with SMTP id s1mr13199824wrv.19.1560532712075; Fri, 14 Jun 2019 10:18:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g19sm4416496wmg.10.2019.06.14.10.18.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6F3FE1FF9B; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:21 +0100 Message-Id: <20190614171200.21078-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 11/50] cputlb: document get_page_addr_code 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: Paolo Bonzini , "Emilio G. Cota" , =?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 --- accel/tcg/cputlb.c | 5 ----- include/exec/exec-all.h | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index bb9897b25a..3237ff4def 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1015,11 +1015,6 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \ (ADDR) & TARGET_PAGE_MASK) -/* NOTE: this function can trigger an exception */ -/* NOTE2: the returned address is not exactly the physical address: it - * is actually a ram_addr_t (in system mode; the user mode emulation - * version of this function returns a guest virtual address). - */ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) { uintptr_t mmu_idx = cpu_mmu_index(env, true); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 16034ee651..8b1c3d5b9d 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -480,7 +480,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; } @@ -488,8 +496,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 Fri Jun 14 17:11:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166849 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2322980ilk; Fri, 14 Jun 2019 10:25:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDd//RoEwOsav6I0HDoP/qKjq5/0qE6lUtlFc+scezbxBGa4pRpyDICemIBF+aVBPnw7Dw X-Received: by 2002:aed:3535:: with SMTP id a50mr83715784qte.237.1560533104708; Fri, 14 Jun 2019 10:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533104; cv=none; d=google.com; s=arc-20160816; b=s3T601WREA3pfeMCngVQ1wynlo1QDnUbda3RPPgerxU7W2LOkCQ0a2pN/FAfJ+jWLv cRah92xOObm6AnNmqqYHewX2DpLGXVrtkKw1HwqkV8ZLlJQZ8yZANXEM+IOOfoLg5TCY pP7SUl6do9looAHH77qACejQiZrNIZKFcTu43mSm7hx0+9BoKJifC7+HPzEx6AgP1j44 9TuHXBdE/cM3F2DwDJQOFISfJHKyxqlOmFTTL6fciTNWuofiB6rOytO7sS88FK1z72lg T9FHQBpZQVEpQLMILXwNZoIat52T4V9mP3AHlAQI/ODwpQxXpPvGxUPASNGz9vYliPka GI2A== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KBrLiVlOKane3sjR6CJw/FTpjNMv1c4o2EyAw7JURhs=; b=Fac15T7g6iwx9SoJ5cGAXKACvVdlVNq+DkNSpTRJ0BcExpEmLMiKP+An/2+g9VoiNm U3I9RlDi9yXuE7u/m/N9CRPxR6WBiIvq4T3h5k1ijm6yKkbWvd3612JFe01bbtv2WmHd spB8VzPu2H1iARzEOQ7q8Y+V50YB66pvSEdUmLe5HcHIFB0NL/xUCaz6vTrLU7tJJXHF erRHuvIbDHJayKYsWDGcWMTX3MTfJbw2po9Y0IvbRSLJdJcQ3jNk+LbxscThb5yQiQ6q 3REk9vXLkQ1MQ5XdUSByT1msCiMEutp0jqhL3fBk8CCM2ql6mfAsJXSvpVn+GJx3/vBF 3Xjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ti82dWU4; spf=pass (google.com: domain of qemu-devel-bounces+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 y203si2177219qka.30.2019.06.14.10.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:25: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=Ti82dWU4; spf=pass (google.com: domain of qemu-devel-bounces+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]:53752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpwm-0003X4-9l for patch@linaro.org; Fri, 14 Jun 2019 13:25:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55998) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkJ-0000br-A4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkH-00031b-Uy for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:11 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54610) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkH-00030g-OF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:09 -0400 Received: by mail-wm1-x341.google.com with SMTP id g135so3097192wme.4 for ; Fri, 14 Jun 2019 10:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KBrLiVlOKane3sjR6CJw/FTpjNMv1c4o2EyAw7JURhs=; b=Ti82dWU47HuBOveUZ5xgg1cKpf85bosw7nlQBOdaEpfiQjOzUNIX+1Iza25OljDCd7 xIDDEi1Rg1mBLZ0wRWimallZdXE0c1qkJ00NGsJgGZv1e/5C91JTdYGd9s5rj5MBnscm K7DTVa+FlFdXrdjEEc71zjJYrJz14VVDmMxCtuoLbEs/SxcJZ31JQcL1gfOzjbr8WOUP yuLkd3SpvWIkGBmMX3lTrxqfln7CGD9v/eMiePYvtTpjFSEx7SEL6DrVWnh/SR36GKlH H2GURLDjfPqNVefOgM2mRfGzGxLIFn04xycgDQTFAPhECMFxkRMXWmFc/Y4gmxsz5w++ 5aKw== 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=KBrLiVlOKane3sjR6CJw/FTpjNMv1c4o2EyAw7JURhs=; b=QLrFhZS5Uyc8JvmtYWtYhwQhBte/ndAlNN2TWm/fIy75sK1sTeVUlK5C9sDBdU3zv7 cNoMWH2DMup//6+3yjiwp3rMAnCZ0Sf88Y3frZtJPdUddyv/hWEardYUpRix+VMW6Iqh VMTPqZRFYaPYwbrlxDWW1q03R90PngC6pGnR+UWVdD/z6+eyvmPruClNZIjd9VP2u+z+ dcMQVPi36/FCZliVBLamVYjqqbMY7D/zflIW9JYX1f1Dw7XSf3PNC89gYdGOPBpQU5Hx a4yaU8J24V6LtCeJPF6YPnl1u/L1K9XJsBaGlzRZLcLyBhUpwvTvjPmi6Ul1CQosrzC2 AQhw== X-Gm-Message-State: APjAAAVwp+v4zVjvQdJseiXKBFLMX2UwoDIbgWUQ3xawFOJNeEdEYsdE 3cpwHqZA4HzLMmNIUOfCaT+UBg== X-Received: by 2002:a1c:c003:: with SMTP id q3mr8730823wmf.42.1560532328662; Fri, 14 Jun 2019 10:12:08 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o126sm7656157wmo.31.2019.06.14.10.12.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:06 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 85C7B1FF9C; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:22 +0100 Message-Id: <20190614171200.21078-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 12/50] cputlb: introduce get_page_addr_code_hostp 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: Paolo Bonzini , "Emilio G. Cota" , 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 --- 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 3237ff4def..6a0dc438ff 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1015,7 +1015,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \ (ADDR) & TARGET_PAGE_MASK) -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); @@ -1040,13 +1041,24 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) * than a target page, so we must redo the MMU check every insn * - TLB_MMIO: 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); +} + /* Probe for whether the specified guest write access is permitted. * If it is not permitted then an exception will be taken in the same * way as if this were a real write access (and we will not return). diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8b1c3d5b9d..90045e77c1 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -21,6 +21,7 @@ #define EXEC_ALL_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 */ @@ -492,6 +493,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) {} @@ -509,6 +530,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 Fri Jun 14 17:11: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: 166914 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2377320ilk; Fri, 14 Jun 2019 11:18:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnl25k8LnIO3lFCPhkgpgNVcRVqC6xBpb/RvhC0fI8wBPpG0goV++wfm+oVN4hjpIuj37O X-Received: by 2002:ac8:2f96:: with SMTP id l22mr33351523qta.188.1560536322764; Fri, 14 Jun 2019 11:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536322; cv=none; d=google.com; s=arc-20160816; b=fMANPkpg9YU1HCmQacpn1UATqatKJd5IcerQTrXSIDdXUO2q4xs5wb3E2zfchjeWwA ntfJjxcjNkIVuMLtJP4nbKg/kQcrznQNexy/CvU2gDQZCwO1ug2Nu3uSdKEkzo2UisBf nT7Yt2hI68MKZ/VmVcx2LNDqoOGsfh9gAgsxrWh/bSDh3zyz41W9jIqKx9VwWq8EGbMv KmC3AiZ+erUrYxs2sLw2dEE39ZUM92ebF6rnhnYhR5sihjSshmjcbFkFOd71EZoE4NIr avhRGsGaXK36R6vPLc48IEVLbu/EMLXYZVCLfeyRu8v6jdzynzUo8lPR9ocZRhbFGYmi Mrww== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=X4C4YGVZ3pcwybUGTfe3xxdYoIZorIOdd4k/ZGNzkiA=; b=Ojv8J4WiEkrAOY2snWcN/R7BWsM6bZljXl8rnyXzXxWvMkLRTRMKU6tBfOwQ5b7cV6 zdhzvPc4snaGb1PvCrMszIMJFjSkHBOGe0r/TqavPlIQYvmhYHyF71bwuX7qs7IRvsMo N4X2YZ+MliHXP8t/4t34xYYgxqT+zs0zJmyKmD5dUk2l/6kW+2Cb5xUYe3R7VKCVkRjY NC7kd9yBLVfcuF7MbTk1TgCS1l+S514bPBv1n7vDofGDoNT+ixAR227aTZoEIzvQhMr+ 8JkIwQeErfTaV8R9v4LStNkJWt+MmecUVBFKMH9nuTrJzv37o2iQFN+IE4DVsXwX3Ypj 0eng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=uzDvo46O; spf=pass (google.com: domain of qemu-devel-bounces+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 y2si2362136qth.97.2019.06.14.11.18.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:18: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=uzDvo46O; spf=pass (google.com: domain of qemu-devel-bounces+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]:54048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqmg-0001J3-6B for patch@linaro.org; Fri, 14 Jun 2019 14:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34204) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0S-0007A7-SN for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0K-00045W-My for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:50 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:33816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0J-0003pB-1a for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:43 -0400 Received: by mail-wr1-x42a.google.com with SMTP id k11so3378566wrl.1 for ; Fri, 14 Jun 2019 10:28: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=X4C4YGVZ3pcwybUGTfe3xxdYoIZorIOdd4k/ZGNzkiA=; b=uzDvo46OlfdvMfX+5KCZ9PaaSaU0pvvSWVzOZ5gWXIooyiPG7l1AIXFLx3gJePFgzK V4n6sesEQnZ1DM8X+Y4+sTNbHaopwjMckdfx9zeBPtwMeXMF+mpx5SX8MUFv0xiOsWNf ZUzUjjqvfOiy5CtomQQKd3d2jw6TySKw7TiPvKNr5vML89B4CKTmGAlH6MneYpz+3ruA NNTOFnfCRO1amvXgWBV6g2CFcP6siJUzHLfGIRikZHGTYR67RLrRubbG8vH6aUyUBYCB LiKQquNX+7qmevO1lBwnvRlAhrry24tWV97oHrrvFNFre3Q1RHvw3dp4WnpjAwlFvx+t 3cFg== 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=X4C4YGVZ3pcwybUGTfe3xxdYoIZorIOdd4k/ZGNzkiA=; b=HFPJlu7m7Z2wYv3NDgTfb7VO7EAcdlo7bPEbU7NFSXF0ttB4wgeSNFFu8nRdbxi0Fq 6j+Q6sFElBhE73KHlmqgNWCBbDckzqYwYRsJON45xoBshQguJTcw8tED2wD65LN1B4Ky MSRaSSB6FXGiGhZSL5fBm7f+cyWe22N9mHOxtNHdjCov6FhA48aM39uO/l0XnGWOflzI 4nPd0Pu+vOwLSORfOBsZYNR6261KabzqtKHDGNchprJdKdEAHXh9a+x4CUwOc4gl3v4D sI2CZ3wUuNUR/EqtQYygMfC5lLG7D6kZdBXn1tPaVicvxTLx2fa907ZeY1FTvHa/KWs1 OsdA== X-Gm-Message-State: APjAAAWKLAZ/5pokbHSjmZAPnTqvXmu6K/44g2O1MRuh++sgpbz3CY5n Jftfhi6XLEMlp5s030+WiXHVSA== X-Received: by 2002:adf:f64a:: with SMTP id x10mr8598238wrp.287.1560533312471; Fri, 14 Jun 2019 10:28:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d17sm5117935wrx.9.2019.06.14.10.28.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD5DC1FF9D; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:23 +0100 Message-Id: <20190614171200.21078-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::42a Subject: [Qemu-devel] [PATCH v3 13/50] plugin-gen: add module for TCG-related code 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: Paolo Bonzini , "Emilio G. Cota" , =?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] Signed-off-by: Alex Bennée --- v3 - introduce alloc_tcg_plugin_context - allocate GPtrArray for tracking insns --- accel/tcg/Makefile.objs | 1 + accel/tcg/plugin-gen.c | 1072 +++++++++++++++++++++++++++++++++++ accel/tcg/plugin-helpers.h | 6 + include/exec/helper-gen.h | 1 + include/exec/helper-proto.h | 1 + include/exec/helper-tcg.h | 1 + include/exec/plugin-gen.h | 66 +++ tcg/tcg-op.h | 11 + tcg/tcg-opc.h | 3 + tcg/tcg.c | 22 + tcg/tcg.h | 20 + 11 files changed, 1204 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..7994819fe6 --- /dev/null +++ b/accel/tcg/plugin-gen.c @@ -0,0 +1,1072 @@ +/* + * 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 (defined below) + * 2: set to 1 if it's a mem callback and it's a write, 0 otherwise. + */ +enum plugin_gen_cb { + PLUGIN_GEN_CB_UDATA, + PLUGIN_GEN_CB_INLINE, + PLUGIN_GEN_CB_MEM, + PLUGIN_GEN_CB_HADDR, + PLUGIN_GEN_ENABLE_MEM_HELPER, + PLUGIN_GEN_DISABLE_MEM_HELPER, + PLUGIN_GEN_N_CBS, +}; + +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) +{ } + +void HELPER(plugin_vcpu_mem_haddr_cb)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, void *haddr, + void *userdata) +{ } + +static void do_gen_mem_cb(TCGv vaddr, uint8_t info, bool is_haddr) +{ + 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); + TCGv_ptr haddr; + + tcg_gen_ld_i32(cpu_index, cpu_env, + -ENV_OFFSET + offsetof(CPUState, cpu_index)); + tcg_gen_extu_tl_i64(vaddr64, vaddr); + + if (is_haddr) { + /* + * Can't use CONFIG_SOFTMMU_GATE here because CPUArchState.hostaddr + * only exists in CONFIG_SOFTMMU. + */ +#ifdef CONFIG_SOFTMMU + haddr = tcg_temp_new_ptr(); + tcg_gen_ld_ptr(haddr, cpu_env, offsetof(CPUArchState, hostaddr)); +#else + haddr = tcg_const_ptr(NULL); +#endif + gen_helper_plugin_vcpu_mem_haddr_cb(cpu_index, meminfo, vaddr64, + haddr, udata); + tcg_temp_free_ptr(haddr); + } else { + 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, + -ENV_OFFSET + 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, uint8_t info) +{ + do_gen_mem_cb(addr, info, false); +} + +static void gen_empty_haddr_cb(TCGv addr, uint8_t info) +{ + do_gen_mem_cb(addr, info, true); +} + +/* + * 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, -ENV_OFFSET + offsetof(CPUState, + plugin_mem_cbs)); + 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, uint8_t); + void (*inline_fn)(void); +}; + +static void gen_mem_wrapped(enum plugin_gen_cb type, + const union mem_gen_fn *f, TCGv addr, + uint8_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, uint8_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.mem_fn = gen_empty_haddr_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_HADDR, &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_ld_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX == UINT32_MAX) { + /* ld_i32 */ + op = copy_op(begin_op, op, INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op = copy_ld_i64(begin_op, op); + } + return op; +} + +static TCGOp *skip_ld_i64(TCGOp *begin_op) +{ + TCGOp *op; + + if (TCG_TARGET_REG_BITS == 32) { + /* 2x ld_i32 */ + op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc == INDEX_op_ld_i32); + op = QTAILQ_NEXT(op, link); + tcg_debug_assert(op->opc == INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc == INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *skip_ld_ptr(TCGOp *begin_op) +{ + TCGOp *op; + + if (UINTPTR_MAX == UINT32_MAX) { + /* ld_i32 */ + op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc == INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op = skip_ld_i64(begin_op); + } + 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 void set_memop_haddr_ldst_i32(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS == 32) { + idx = 2; + } else { + idx = TCG_TARGET_REG_BITS == 32 ? 3 : 2; + } + op->args[idx] |= make_memop_idx(MO_HADDR, 0); +} + +static void set_memop_haddr_ldst_i64(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS == 32) { + idx = TCG_TARGET_REG_BITS == 32 ? 3 : 2; + } else { + idx = TCG_TARGET_REG_BITS == 32 ? 4 : 2; + } + op->args[idx] |= make_memop_idx(MO_HADDR, 0); +} + +static void find_prev_and_set_memop_haddr(TCGOp *op) +{ + while ((op = QTAILQ_PREV(op, link))) { + switch (op->opc) { + case INDEX_op_qemu_ld_i32: + case INDEX_op_qemu_st_i32: + set_memop_haddr_ldst_i32(op); + return; + case INDEX_op_qemu_ld_i64: + case INDEX_op_qemu_st_i64: + set_memop_haddr_ldst_i64(op); + return; + default: + break; + } + } + g_assert_not_reached(); +} + +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 || type == PLUGIN_GEN_CB_HADDR); + + /* 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); + } else { + if (CONFIG_SOFTMMU_GATE) { + /* ld_ptr; note that we only have to copy it once */ + if (*cb_idx == -1) { + op = copy_ld_ptr(&begin_op, op); + find_prev_and_set_memop_haddr(begin_op); + } else { + begin_op = skip_ld_ptr(begin_op); + } + } else { + /* const_ptr; set it to NULL */ + op = copy_const_ptr(&begin_op, op, NULL); + } + /* call */ + op = copy_call(&begin_op, op, HELPER(plugin_vcpu_mem_haddr_cb), + cb->f.vcpu_mem_haddr, 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[3]; + 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]; + cbs[2] = plugin_insn->cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGULAR]; + + 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, -ENV_OFFSET + offsetof(CPUState, + plugin_mem_cbs)); + 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_haddr_regular(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_HADDR][PLUGIN_CB_REGULAR]; + inject_mem_cb(cbs, begin_op); +} + +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; + case PLUGIN_GEN_CB_HADDR: + plugin_gen_haddr_regular(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_CB_HADDR: + type = "haddr"; + 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..5457a3a577 --- /dev/null +++ b/accel/tcg/plugin-helpers.h @@ -0,0 +1,6 @@ +#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) +DEF_HELPER_5(plugin_vcpu_mem_haddr_cb, void, i32, i32, i64, ptr, 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..449ea16034 --- /dev/null +++ b/include/exec/plugin-gen.h @@ -0,0 +1,66 @@ +/* + * 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" + +/* used by plugin_callback_start and plugin_callback_end TCG ops */ +enum plugin_gen_from { + PLUGIN_GEN_FROM_TB, + PLUGIN_GEN_FROM_INSN, + PLUGIN_GEN_FROM_MEM, + PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_N_FROMS, +}; + +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, uint8_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, uint8_t info) +{ } + +#endif /* CONFIG_PLUGIN */ + +#endif /* QEMU_PLUGIN_GEN_H */ + diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 2d4dd5cd7d..e997346c97 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 02a2680169..962e17da33 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -729,6 +729,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 @@ -772,6 +781,10 @@ void tcg_register_thread(void) g_assert(n < 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); @@ -968,6 +981,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 @@ -1671,6 +1686,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 b411e17a28..2385e758e5 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -625,6 +625,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]; @@ -726,6 +729,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 Fri Jun 14 17:11:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166843 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2314233ilk; Fri, 14 Jun 2019 10:16:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEYC3tlNs17luoomw3nO4AOi2e/rERLnmaCIwOUst4/a5O5SUBmovhdqlIZjs4TFYYCtUA X-Received: by 2002:a37:97c1:: with SMTP id z184mr12288044qkd.198.1560532569681; Fri, 14 Jun 2019 10:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560532569; cv=none; d=google.com; s=arc-20160816; b=bZBvIikV8VIoU4/P8je9pqSACizR1FbfcOP9T87X7geBlj1ShT3xMgHjDuBaV81wIY nHi/SfXAqI4arGcn0cuSo9VCKQC63kc2TbTSdJ1Sg4TZRTvRPa7GF8VIpumGVtZ3wFam 4PwS0T0SZitcazi2vhxHVgpamsHuVzBrVVefwYxLsgAndkNiONvubzZkpjYPI1Df1oPc V1c29hTxBnfI5aFRmMljXdL8OXCyqfNpXODWSd9Hoi05lccPUjqvZw2h0rZ4IFlrhlLi 2MQt5qyCiJ6CCW1shxyJPGYdaebrJVTABNIal3EN/gWbI03q6UehEfU7mwT5on13Hi25 Amog== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZGytCy7dk/rtAnR0c8LWL1u/jXw6ywf1Xd8f/B0+XIs=; b=pPirpas1HpaAd1rHhH+zn1Q7h4YoPrhyVq5UPkrbPR7L9hmvh1NYntPP41v2ixHgyE y7kObMzvpufFO4/9QAzrq8pTTHJE2XHkXGJkzusrNHxnz44plkYRKRocW6NbylfjLcS0 AFAA/tt1R+8gh0IrsW/YP1uzSy+vAEB3LN9NPZGqpXCV5+HfZxPjiXzdl7b9pETLREFU 3Hf3rvZ3glub6L1s+v+dKeq2hYI085eJ8YgpZtHOJor8KZwd8Vd1HEiu+pdWnmn3GEIt q7RjqIwMcc0i4VrWlUpOYV7EfBxf/UAuaWeOJYZVdpIbeqIp0Esl5+a2utgtmfSmXIK1 iCDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pxq5Zjpa; spf=pass (google.com: domain of qemu-devel-bounces+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 c6si1733517qvu.178.2019.06.14.10.16.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pxq5Zjpa; spf=pass (google.com: domain of qemu-devel-bounces+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]:53700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpo8-0003Qg-VL for patch@linaro.org; Fri, 14 Jun 2019 13:16:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56054) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpkL-0000fh-8e for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpkJ-00033x-UJ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:13 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:32795) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpkJ-00032n-N7 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:12:11 -0400 Received: by mail-wr1-x443.google.com with SMTP id n9so3339344wru.0 for ; Fri, 14 Jun 2019 10:12:11 -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=ZGytCy7dk/rtAnR0c8LWL1u/jXw6ywf1Xd8f/B0+XIs=; b=pxq5ZjpaQRToCSpwt1pPvpFRVNiQ/D2WAC20IMEsDa68lIbIrN10EdCAGtSUHvzw0E BrsvDTpj+l3hci0chuojJBL8/g7sVrs2Te8k0EjoDS2jo9AELtK9prZpz9yM1mwAf4SI VeijTvFGOH2HXejJGQBEzzn6hO4eleuDXd6X1gQ76auaK0mBDht1wWvlNNB08zKyxCoS s8VWmJax8aqMpLmZwj/tGAQAFLO+5AoFkomr5VneX0QCfVwxWXFCfSkNtZhWhBrFG5cn hQLpj/2WwACaD18/A0gJU7LI8naSZWC1So1W+s0Wge1B6McQBRbIkewb8PEJVm09J2Xi Oj1Q== 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=ZGytCy7dk/rtAnR0c8LWL1u/jXw6ywf1Xd8f/B0+XIs=; b=gsfSNunZnPZdv+hWACWZZRdOqkj8/7I+yHw2dJFks9hTzsdwD+n+5y5scTqwMIUzRl VJE0pitMeZDQyQXz+YnkLcd/mVDS8rWK9w1vZMpQlqreC1XsmViPOhh7SCQReuBHGe71 GIl/W6N+U9WcjGMZDUhZFe3Q5GT2H7gBWlk1SpLWA5PHtdCKnXHqsQnngw5AtlfGKlW/ p+WclwZd+xEcvoqhHid4lfmSBLncxgpbPlJ7Aj5zXNmUivSQnbBmFAXflQIOFaJ9Z/Ac o/1VRVDxYYHs80KDFImDgdMv+adFT9PbpfGra1yqlD+6aGh9U225SLT4FUai58ZTtXH8 QSdg== X-Gm-Message-State: APjAAAXR2fQSXpiVabV6W2ADEvQcPGJiuyRNwqlD4GbFWPgy2Ynk16aS MRJXvUJLL9PQd685YAn9nMUtEw== X-Received: by 2002:a5d:4a8d:: with SMTP id o13mr31265800wrq.350.1560532330517; Fri, 14 Jun 2019 10:12:10 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d17sm5047352wrx.9.2019.06.14.10.12.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:12:06 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C11701FF8C; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:24 +0100 Message-Id: <20190614171200.21078-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 14/50] tcg: add tcg_gen_st_ptr 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: "Emilio G. Cota" , 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 --- tcg/tcg-op.h | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index e997346c97..edf12de1f3 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -1260,6 +1260,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 Fri Jun 14 17:11:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166921 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2394520ilk; Fri, 14 Jun 2019 11:36:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIcD/MRd3iiOTz7oHlLtzgRX/m4rnj5ITWKCgx5E6Xy1H8Ydprd0iLiKHCGeZlvRr306SI X-Received: by 2002:ac8:68e:: with SMTP id f14mr2953194qth.366.1560537416647; Fri, 14 Jun 2019 11:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537416; cv=none; d=google.com; s=arc-20160816; b=QT8BGBUM40u10/K/AnCscn7fqcIjWpfq+qEYaPKWL/3uIo37sNjNKkC5ude0fYb8Lr APTomYOZ+BKc6nCwIvQ+1a8oM5GN/hECyA4IFpbc4FTbHish7qK3zqPA3pEnyeJZvOQj aGaJQt3jVEyfpSfGgfYoFabqfRwtGOUNBS7BRazUCa64q5Ba30Jgr2n9otwRUxqBUITs M+j4fUySZES2MDYGrcCMijoimwhQDA/SwEeB4Xzo6ATdNmHYVUKo6U202O9tqSizG6ie wMyGuHrgkIaAUAWpv3tRDo0ArZ9MD8UNQPPgs+EpB4MtECgYzWoLNiDeRR+bhHsupml6 BCYQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=aDs2dqXGIEF28FBqcTkP/2L64OJ8gLbRaNrMScFtO/w=; b=0nTABBLu+270InlKY3anXJYi/ByQujvgIKfFLf/hFaVoK4QZivIHTmXWs5rWrDVLJr bVxPySzj74A3DAyBrIebW1DEVmKMQZwX4QQPdGN0ChtnWV0I34tXiBgrQ7TtWmq95pTw mRvZfy577QJqZR9pCOao3ZtIorL5AxS5jXEsaknECWZGn0s0aLhUi/npR4QOD2UUt3zO c/del4SIDuoikYmvtYwW1esdlyYdPa+uwOHQo+WqACfYrX1+t2q7zj7TIDBTcuQ1FI1G Qs5Y+Oxysw3qJW1I2j3VvMqcWp7Xna6/I4zRZgsPuVk9R3QAiE2KpcQB1h5Pz9i2oaKk zn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ZPtRlsp/"; spf=pass (google.com: domain of qemu-devel-bounces+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 j68si2236999qkd.228.2019.06.14.11.36.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:36: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="ZPtRlsp/"; spf=pass (google.com: domain of qemu-devel-bounces+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]:54160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr4J-0003ch-Sd for patch@linaro.org; Fri, 14 Jun 2019 14:36:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34207) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0T-0007A8-MP for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0P-0004CT-DQ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:51 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0N-0003lJ-C9 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:48 -0400 Received: by mail-wr1-x441.google.com with SMTP id n9so3385901wru.0 for ; Fri, 14 Jun 2019 10:28: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=aDs2dqXGIEF28FBqcTkP/2L64OJ8gLbRaNrMScFtO/w=; b=ZPtRlsp/dKt9phzGVfveJ4SI5hzBAoqTmaMYqWk3nCJ3rRIlHomccMJmVbcQc2N1Mk znKQOikQGwZdRcH50kRT5CVggCPB58o7e+G5veruU+mXkkqazfhjteS3LoLpmPaztuTB rvwyzR9apG09I8prKRts/e7DjwCFEREXcgamlPwqAShujI5jsrW7oSiv7voNyVYCyny/ bX0gyzPdAceDYOuTS3jT7pMc1X9unVJXUOZFXmKaYgi/57qq1Or5fVmwYcIF2KdHmRGr VAus7RaRr8BbGLVIc40QNgm08sy9oTRAHrCHpzCaHexzPaTx5gGRqP7NiGwQwlunJ9CK dZow== 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=aDs2dqXGIEF28FBqcTkP/2L64OJ8gLbRaNrMScFtO/w=; b=HFIrl5vOIVNTDXB8OT1C24rJFW1XQoC9RboDWjB9hRYhV+thnSBmJW/TAggcQMPeo0 KhfQEBgrVSqbjY9o6cuKtFGrJxkDkNljhXmg+ipLs/VmOoQbBsddDQzLqTN/uJRatryP nukeDPr15YR/aOr8pemlEixJJZkdugZFhs1zo/aWsnOcaOMu3EC9Q0VCIa14nGuhqMr/ D1Led6zRuiWCn8NxjKK5C0FWlTa7sVO9EHu57NjvXSsL+n+1VBnODaYPaCcGAIJxbVs4 FHae8NnmCxfaokI3U+Pwc/N7TCwx4X3c+M3apcxrVESufUCo9oxv9yVTzId3MThKcqur lhlg== X-Gm-Message-State: APjAAAVEFmSFqCZv1qHXZbluPrqU10ElQ7MsWTajWYs7OR0Tm9eqSzLQ beSZOQmBMkawWHGaLLsOkW9Rxw== X-Received: by 2002:adf:e301:: with SMTP id b1mr14118389wrj.304.1560533310627; Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l8sm9147281wrg.40.2019.06.14.10.28.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D52821FF9E; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:25 +0100 Message-Id: <20190614171200.21078-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 15/50] tcg: add MO_HADDR to TCGMemOp 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: "Emilio G. Cota" , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" We will use this from plugins to mark mem accesses so that we can later obtain their host address. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.20.1 diff --git a/tcg/tcg.h b/tcg/tcg.h index 2385e758e5..966e89104d 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -367,6 +367,13 @@ typedef enum TCGMemOp { MO_ALIGN_32 = 5 << MO_ASHIFT, MO_ALIGN_64 = 6 << MO_ASHIFT, + /* + * SoftMMU-only: if set, the TCG backend puts the corresponding host address + * in CPUArchState.hostaddr. + */ + MO_HSHIFT = MO_ASHIFT + 3, + MO_HADDR = 1 << MO_HSHIFT, + /* Combinations of the above, for ease of use. */ MO_UB = MO_8, MO_UW = MO_16, From patchwork Fri Jun 14 17:11: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: 166922 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2397075ilk; Fri, 14 Jun 2019 11:39:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeI0u0vsESja8ddBB+XGsuwVGieirFSH8/Oa21+D4LE7pCFxjYyXzWaMxPYU1fzUvIKDgJ X-Received: by 2002:a05:620a:3da:: with SMTP id r26mr59958302qkm.279.1560537591642; Fri, 14 Jun 2019 11:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537591; cv=none; d=google.com; s=arc-20160816; b=j+4rquHILb2RC38pSBNfHEsakPBldhWTHSiOYd4nDGgL++E/gXD4/6ZqqzMtiCJfmw QB53p+Mj8rzDw0f+nohd3Mv7SOrbPz/Oo4mXab+3fSDJvrA/AuovxqeKceMHM6vyswye 8Yj6Z5ESCAyIbptqPnbQlsr3PNoN3yTu3iFQH6iqI2w7w1L5F7P80gj2Nf8X3vCZ3JYr atqNIR00T8Vn/OfV22uYvi+aCM3fr2PCqQjAqkQQM9X3h1Zt7fb9wuxfElSm8u5tR/Mi WnQoRIBemiCeO9enXVrdMaHM0UJfPpU9MazEvzMfUu5cpxkO4ZWm9PwJPKuNldMc81U7 rrbQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7LkO/RwU961CsHjb/1835Cx9O+zFCubxVzSPwrwohBY=; b=SpWsWkkxfcuYaiOlFnbwgwWol1ruHyZW3SNT/+8gcugxnbO9ukpidcxVLLviTuvbI7 kpGg4IbUJSl/x0SPv1q8P3yreFmiRPsbz7M85zRhdzdfKfoJX/XBUSBHoO4VmXq06wB4 a1EUpaeMWyg7HbWMzmZ03adNS1hVPkC/Xb4NJZ5n1vmPaUiHD+4rkrm4VeB5uwZhOFPv f1nLzH2lqs7tLMkO/xFamUDulX6YcF/dfrbCn5qOw6CFiLlOkJm5HzIZ5Rz31ZldYnyX qctYAqQTmvta4CburjUplRFU7ZAteJSW61YDFe6rGy0hlGn1mWhzWHTxbJHcOCR0bCib s/gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W6EqP8YJ; spf=pass (google.com: domain of qemu-devel-bounces+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 k37si2333428qtk.33.2019.06.14.11.39.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:39: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=W6EqP8YJ; spf=pass (google.com: domain of qemu-devel-bounces+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]:54194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr79-00072r-8E for patch@linaro.org; Fri, 14 Jun 2019 14:39:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34063) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0J-00076W-Q7 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0H-0003zf-J4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:42 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:37322) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0F-0003wu-Li for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: by mail-wm1-x331.google.com with SMTP id f17so575593wme.2 for ; Fri, 14 Jun 2019 10:28:39 -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=7LkO/RwU961CsHjb/1835Cx9O+zFCubxVzSPwrwohBY=; b=W6EqP8YJ+T9LS2axiftttPSXbxy78ZYzJJ8MKjFCDwGsLUHeGuD00S/IKsLeLBVP69 zN4lQloUzN0iJ7hr8bKOItDQelJc4aE9XL+ag8Kuki+qQzl3oqilwdnUoaVViskIolnM vl4UfQ4UOmLecQSm9ZPwk1Ue2lIq9IzYbzn/mQODII8EENhknYA9Lb71O3ivo0C3wA// Z2S0bV+o9cBvCMPgeCEdkKBwKDd5linBPIVdqOWrV19FY5+i+w7vV8hIIX/7EEFlw6dt FGzGHrSFR5OM1B1FpU4Ahzt67ZREHcmJZcTf2pem1yMJg+9qN9rUb3dYCMmTMvF5yUz5 8vAg== 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=7LkO/RwU961CsHjb/1835Cx9O+zFCubxVzSPwrwohBY=; b=eSXQt8SF8Zlaqb1O9LDUPbeXAaTHDHFcCuGDHQ2lVV4CpHGvEdFK68xl3ycKCkqo7M 0IMfQO3sGQD1zirGZrG8pNebiMrdXL5WTNN50dcw68Xn4QgKXD6S40TTl3g/W1ek2boZ QgXQbEoIYQem0WYHVxRSc5Y/oP4RlDZalk7VY7H2HBS/cOCmkkrHb3cJMR8uuf8Lc/fC L1ijOcs5TMExRr0p6sUOYJbr+w6UpnHd9gBi5GTOK/8Zx4AuPRFFl2T4WMabdbhL+h2e x3dj0TYF3gq5/C2DDX4B5nBGgdjQSiEz8LVQ/KsI9eq3e+EQJb0oTHO+WoPH+WSkNY/w pW5g== X-Gm-Message-State: APjAAAWNrG3vxZ0YVl5fXvbXCw/6W6tuxztqtzly3zZNuPAjf+fBPl3S Jhaifu1t4wJQyp1TodZ71+KXmg== X-Received: by 2002:a7b:c057:: with SMTP id u23mr8968631wmc.29.1560533318513; Fri, 14 Jun 2019 10:28:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v204sm5834489wma.20.2019.06.14.10.28.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EB19D1FF9F; Fri, 14 Jun 2019 18:12:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:26 +0100 Message-Id: <20190614171200.21078-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::331 Subject: [Qemu-devel] [PATCH v3 16/50] atomic_template: fix indentation in GEN_ATOMIC_HELPER 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: Paolo Bonzini , "Emilio G. Cota" , =?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" Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- accel/tcg/atomic_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 5aaf186253..df9c838817 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -284,7 +284,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, #define GEN_ATOMIC_HELPER(X) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE val EXTRA_ARGS) \ + ABI_TYPE val EXTRA_ARGS) \ { \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ From patchwork Fri Jun 14 17:11:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166918 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2382308ilk; Fri, 14 Jun 2019 11:24:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqKZ1QWcue9Hxd3xlMRwx9NwU7l4WVQTOeIYWG1W6DuAWiBi84316ftHg7ueXx+MCoinR5 X-Received: by 2002:ac8:18d2:: with SMTP id o18mr33201002qtk.243.1560536652251; Fri, 14 Jun 2019 11:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536652; cv=none; d=google.com; s=arc-20160816; b=luG+aM5PAy+4wgycULY9PjyJJTNFUasp09BTrn9jaK2X5YGkzJw7qvu+chkm9nMPnL rpWHiPQp0GdBCmz6bliARQqM7tw6416jLMcoUtrNpzRzStqPSMI4eIfFFBFKVJjg+Ivy 0bXFJ1lSalxAKekvfII5/E4tb1g//8sX+DNPuSBqSHoJJMuDYs+ypT3Po/+4SEus6Z+4 cV7V5bBTVvyDitf7YhIifpmv9mMoK7Fi6p0al3adCLjBdhLvYFUSbclD5YIyhtoaxSN5 UcfM6UO8y+K99eZ1SnSVuoa2SFWCEByHoktoyVegVKkWV0YsoBdadbosDR1LHPu9Flys N35g== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=il3aOSQFRSZJ2/99Y43bBqgnwxHoXzOMQ0saAfzkh+I=; b=jVBqrvdKnq+MJH/nXS+FPMHs4+wiQkRTmO0EVFmwIBKpUQbkIYEZTfxGEdJ5GFwBhS As0Fj180w1flCZzEanmXP0Kay8QdKGzOLF8UOq5wRWLbd8IgZyXh0+MmkwplnrSQIfua +YlwiQLCEJIMQWMGthHVpoBSqozclac+oVdqyQG7eMe174yR+Y1lV9fk82K166WMhUW8 uWR6yKynbLPgf0S/idCq3XFG5+idffVcacS+ZxNmBtoNEzS2hWD/svb+Z8ul8t0VvvdA jYScwxmqL+cLV/vqzohgrhfV3f5rNhdJ5npPBm9I75bRcUOuYkhDP+Z0AfZyGShxhdxA LQtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FtKApfm1; spf=pass (google.com: domain of qemu-devel-bounces+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 w16si1869336qvi.160.2019.06.14.11.24.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FtKApfm1; spf=pass (google.com: domain of qemu-devel-bounces+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]:54088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqrz-0005H7-S7 for patch@linaro.org; Fri, 14 Jun 2019 14:24:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58661) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005b2-2C for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-000769-0M for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:32898) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006sD-Jq for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wr1-x444.google.com with SMTP id n9so3357124wru.0 for ; Fri, 14 Jun 2019 10:18:39 -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=il3aOSQFRSZJ2/99Y43bBqgnwxHoXzOMQ0saAfzkh+I=; b=FtKApfm1D/p6XGZGeDjMfRGy1o4ilmmub4IZ9hnbiP9zgmxz4dP2VZ5w5yo60JS7RZ uYGlXuBVAnlTwoiTV7cNdAOLjvGdoFn9rcnOChLHS6GI7+LWy+1pVLp8Z1ddGzeDxKEA BCkvz6LLIl3RosA0LDz225csT1b/tPlEuteqIYGlus6p3P1lMX7XPvAQz6WjGTFmOGsv YYTBHd+FQ+Df2QW5n/KaGqmWHJwTvSWdzvdmXPok3PcgL1acNWP4e2ZNRNnBnnqmQNhB ittPiVVyhn769RuDw8RkO2kbYezaQPNtYKJ3FG86Pnfci/a2fy7RynfrX3CWI2rCHbA9 Ml+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=il3aOSQFRSZJ2/99Y43bBqgnwxHoXzOMQ0saAfzkh+I=; b=i+laC9Llr82HTJLV/1KQqkol+sOfhc9nGlUZsfvPLVRgwB1yQQKD99MijSlgP3mnIp J2NCdt3/Vncm0xxii3yxnDJc+2MT8R209YMNkq3AasFSEtAI8fOxRc/axl2N3TdosaB8 +WNzKsgiPRHzR2Fwvrah29pHeDOpC9NfxpJoZndi5o+tSVdUdOru+P1btWl2/iqJb92f ZJx0GdYyutCV6qm5CTYr6vgJoxyHTwGScJzNeK8X+Z7MnwYtOJkScDfmmj93I8GpwcCa QlYOgoxPDUD42MzVhKB2VtaTgQVMDXCvCztgYbSFeMiSUFTvzg2+FGj1WszgqIuM8vrF EELw== X-Gm-Message-State: APjAAAUUYqa1zGDchFhsW5Ybllwe3ijSHS0lAjibvDNEi788exqFhF6h RShUpr4fh6rALnxmK+aJk5FWAQ== X-Received: by 2002:a05:6000:110:: with SMTP id o16mr62393959wrx.200.1560532718511; Fri, 14 Jun 2019 10:18:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s10sm4486428wrt.49.2019.06.14.10.18.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:34 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0BFBC1FFA3; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:27 +0100 Message-Id: <20190614171200.21078-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 17/50] atomic_template: add inline trace/plugin helpers 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: Paolo Bonzini , "Emilio G. Cota" , 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 --- accel/tcg/atomic_template.h | 110 ++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 35 deletions(-) -- 2.20.1 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index df9c838817..04c4c7b0d2 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -59,25 +59,44 @@ # define ABI_TYPE uint32_t #endif -#define ATOMIC_TRACE_RMW do { \ - uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ - \ - 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); \ - \ - 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); \ - } while (0) +#ifndef ATOMIC_TEMPLATE_COMMON +#define ATOMIC_TEMPLATE_COMMON +static inline +void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint8_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, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint8_t info) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint8_t info) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline void atomic_trace_st_post(CPUArchState *env, target_ulong addr, + void *haddr, uint8_t info) +{ +} +#endif /* ATOMIC_TEMPLATE_COMMON */ /* Define host-endian atomic operations. Note that END is used within the ATOMIC_NAME macro, and redefined below. */ @@ -98,14 +117,16 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - 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, haddr, info); return ret; } @@ -115,10 +136,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return val; } @@ -127,10 +150,12 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); - ATOMIC_TRACE_ST; + atomic_trace_st_pre(env, addr, info); atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_st_post(env, addr, haddr, info); } #endif #else @@ -140,10 +165,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - 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, haddr, info); return ret; } @@ -154,10 +181,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret = atomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return ret; \ } @@ -186,8 +215,9 @@ 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; \ + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ cmp = atomic_read__nocheck(haddr); \ do { \ @@ -195,6 +225,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, haddr, info); \ return RET; \ } @@ -232,14 +263,16 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - 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, haddr, info); return BSWAP(ret); } @@ -249,10 +282,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr = ATOMIC_MMU_LOOKUP; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val = atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return BSWAP(val); } @@ -261,11 +296,14 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); - 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, haddr, info); } #endif #else @@ -275,10 +313,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; ABI_TYPE ret; + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); - 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, haddr, info); return BSWAP(ret); } @@ -289,10 +329,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ \ - 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, haddr, info); \ return BSWAP(ret); \ } @@ -319,8 +361,9 @@ 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; \ + uint8_t info = glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ ldn = atomic_read__nocheck(haddr); \ do { \ @@ -328,6 +371,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, haddr, info); \ return RET; \ } @@ -355,10 +399,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 From patchwork Fri Jun 14 17:11:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166862 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2350096ilk; Fri, 14 Jun 2019 10:52:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1ZRRqOEh99kvThD9PWXXViNpGTn972seoUxqYEqIJHJTk4jt42g8pzLnLyt0wRVmDvztW X-Received: by 2002:ac8:2a69:: with SMTP id l38mr15859997qtl.212.1560534735288; Fri, 14 Jun 2019 10:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534735; cv=none; d=google.com; s=arc-20160816; b=dgZ2vxaDSgJ+zKfUvBDyyokUC9gc0WXszIHR99cj5OVgWU47uvbTIT2nLWdsULg9r+ MVYQcGWjk2k4FKWUoWlYVvwwIQ5W8FLenTjPt6fYzkPOB/A4/LMKqCxAQDk+ioMV8gmE sVC/R3nsnaHox7iSHmfK7yzkcB7kd2YJAwEE0x943Kl91Rj0MofKYy+29Esg4fgCDLow PVXt2nPheM7JWRC7iUw48GpjepqEh1fVUJbGCaiHvnOMi7L9oEDysoz/6q1tFG0Vcfrz KpcgmOEK0+gynZabySHTN9QsmAjegFpSeOovxzYSgTl67KUfmW36YkkNW8/ZbZCf46Vl uehA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=kv2IwrRCWvjl90KLYznRzS05j6rVbW2oPC3nXpHDO7s=; b=CS3QDS6+yKhN3oZnHxFmjDYlsD39ly51fPhkJLkeOu58VUdtDikD+G5McRyLSFspxY Mb2kHCQZ+Yrzp7yjAvBUiS4LLkSqWw1A1DcyeLazlh7wo5HdkABLrCfRYXNRobULge5S BWDOP0KHIueyPnNmpyLpcHmp3fxcWBfwbMgnQOp9JCKGM+bN40qsPNH3CTRvPnhP6EAb LjT6xDq0x6uWDR6u+0u7zmp/hDHvSipS4sluKYifJ94S8EcaJhp3/+8oLFaKazVZKEtG y4ckEiD+8K83BxKxeSkyqyWm2Q38tEm628E1U/VmUsyLr+51PC3YareUE7knQC8Trq2Z vNzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="j8yZ/nsx"; spf=pass (google.com: domain of qemu-devel-bounces+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 32si2163290qvf.143.2019.06.14.10.52.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="j8yZ/nsx"; spf=pass (google.com: domain of qemu-devel-bounces+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]:53900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqN4-0006i5-TJ for patch@linaro.org; Fri, 14 Jun 2019 13:52:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58561) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqg-0005ag-K3 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00076D-0S for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:45 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:51645) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006kG-Jl for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wm1-x335.google.com with SMTP id 207so3138076wma.1 for ; Fri, 14 Jun 2019 10:18: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=kv2IwrRCWvjl90KLYznRzS05j6rVbW2oPC3nXpHDO7s=; b=j8yZ/nsx5XFzLvuXh2zG1smzMo3gJeJSZbv7JmjY51Zq7WrkrQGxn1AL71ZVyCJiil mqh+2D2O481jVu73cSpNy/y42OOovK3qH19/BIJLRTSgrLnp38Lb9A59wxZbxov0KY1R HNeH5t79GtaBsGQ7kDrYXELa2ztoWMVp6YXa4R1/EURcRrYDCQXq798ATK6fk49uRDJr 46SPXdEXZAGbbTH7r6P2Yu/xKHbdKbEeihIE01qwwOzPbnfdkfyCGC17plMQkaYgzpAU fVzJaZ0oRXKnh60yLKDUkKDTz3uPQsxTKnghE+ncQZxjz6G0l/6duGYXCDsXGa3Z0gWk Djhg== 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=kv2IwrRCWvjl90KLYznRzS05j6rVbW2oPC3nXpHDO7s=; b=gDs5qcPKVJxX5hcBGa19mwhBj2Ro0xED2SLcll3qI4JzSWdjhOyPI6NEH9kXg43/Ij wr2riqqBEpduo3nX+IB7ZM3V61U5LtLcRDlbsWfEaWkd5tzJl2xgdFXT/7t7t3gsQPFP ianoBYXX3So6AyEThwJecE/rjdO9HQVeGDLkVDe4rZXCH6/esnKs75Fzh+r2lyfg3yDT ZYwR/a9QO9OLqVxUCoqw+Vz5lz2dlW1Qe1mj7uDnXFTqWnTBklLIHXa72oQPGPtjmGmg D++euw1VbrZrWpvTZRx83ILshLWtIcqJt3z4nJmRRJmOzctnN5cEM3SMSNMVER2oEq9a xTeQ== X-Gm-Message-State: APjAAAW0azt7JQgxkYueWMWBiV2gjPGhsmr3q2W6pmlcaXBjUTisKNDv 8ZFCsP0FSvRgsgDTAuTAJYFRiQ== X-Received: by 2002:a1c:b189:: with SMTP id a131mr9145569wmf.7.1560532713548; Fri, 14 Jun 2019 10:18:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w67sm6030603wma.24.2019.06.14.10.18.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1F4EF1FFA5; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:28 +0100 Message-Id: <20190614171200.21078-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 18/50] cpu_ldst_useronly_template: remove redundant #ifndef CODE_ACCESS 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: Paolo Bonzini , "Emilio G. Cota" , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This function is already under #ifndef CODE_ACCESS. Signed-off-by: Emilio G. Cota --- include/exec/cpu_ldst_useronly_template.h | 2 -- 1 file changed, 2 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index bc45e2b8d4..42a95237f1 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -114,11 +114,9 @@ static inline void glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, RES_TYPE v) { -#if !defined(CODE_ACCESS) trace_guest_mem_before_exec( env_cpu(env), ptr, trace_mem_build_info(SHIFT, false, MO_TE, true)); -#endif glue(glue(st, SUFFIX), _p)(g2h(ptr), v); } From patchwork Fri Jun 14 17:11: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: 166917 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2379809ilk; Fri, 14 Jun 2019 11:21:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpbHNI432yTcAL5iR/abxmBfBy2p05qfNHWR4XWjhNNLmAK9pnm7QPRAXXmrzcaBkzWFvP X-Received: by 2002:ac8:6b95:: with SMTP id z21mr79387614qts.337.1560536485433; Fri, 14 Jun 2019 11:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536485; cv=none; d=google.com; s=arc-20160816; b=bpp/V53klHg7gdK51e6uXg1Rom51z5CRpfq7Jmm/idCh0zUsTF3Sz5bBabVss4HlN9 vQgjDgf2PBnCQwGdLdtrRbyJBBk7/axCZRb8Dha3uhzV20ZOxaXfXbeyApJUV49idE0w tz7Wn4EyzFQaw6E2naCR4bZFkbGR043wTxuEuxraYnT5/6hZxjdoAqTYGgiRMaQ+l8DN LCnBNJDiVWowquds1bYDDMWAwGYfN2KdUiHxclJWWFOBMYcszD1GgIzu59XQ7ncFYRhn yDny4fxWrq+0ej0JcIr2FpER8/cBAvCgJd0dBWlpgYXMutW04ziWNGaBEhi1tb/ztHy4 D0Dw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=0Pim99RaJoGz7KvkA/uPJ/GgI2y9KeaVPRnEwtwD6pM=; b=bugLbGzbhXdCDFMR9YKAV1xW6rwrUVgriDCaRBUsZuNJI7wHmd6RjRhiPifoSYtlxa Rr2u0wpGDhyUXnqRzAWk5tsGEzLUSDacsv4yxg5IFG5pZ+3Zm+SmozFEmr6QIlAg67C2 FjYHj/XTnLdTT+SB2X2SRNR31mGLoorXznb3kYvNtl/+s6SAAmhc3p11nvUs+eto4qLl zEoET927f9axU/E5UwQ38tc+Bs29C2LQoZoHjviYViEWkONLfpyut1eyFF5ySR9M0dD4 sUGvDzWXaJR8Y69bHLBj4m09C3Fx4zqmBT2tUnnMgmZM4XYDP9bkWs5J0civ5sbVDnEp 6JOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AXmQJYi+; spf=pass (google.com: domain of qemu-devel-bounces+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 w32si2202975qtk.215.2019.06.14.11.21.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:21: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=AXmQJYi+; spf=pass (google.com: domain of qemu-devel-bounces+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]:54066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqpI-0003Ru-Kq for patch@linaro.org; Fri, 14 Jun 2019 14:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34114) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0M-00076t-BR for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0H-000405-Qo for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:45 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0G-0003kU-R6 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:41 -0400 Received: by mail-wm1-x342.google.com with SMTP id f17so575186wme.2 for ; Fri, 14 Jun 2019 10:28: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=0Pim99RaJoGz7KvkA/uPJ/GgI2y9KeaVPRnEwtwD6pM=; b=AXmQJYi+maLcyOjnzjagS/FMhFG0lrIcC1s4cCtngwLFHUJdklkI6NwN6wQL75wY5R MZSwk3MmHvqqkMPFFBmYNHJZlof3Z87hisXGGj/IYf9emPU/BWSRbhkX4NcxPrD9hsRD WsFkFk6a3KhKMDFUUGmnwEgtXlKiEpycbYX3OtWsqPkN3UMgQvI24VVKCwjvYN7XCgw+ vc7xH5JYVIFhCJflBV2bQQk+o6sc8opVl5aS06KlazJ+yCBvue+QmQFo3QidanCTJJto ZFNVD6f9eN4nQP6JtIwxIWCoK/+qRsWXx/UMrwLF2kKbYJsPxLnoyeMQkTHaslX3uQ2E Pp+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=0Pim99RaJoGz7KvkA/uPJ/GgI2y9KeaVPRnEwtwD6pM=; b=O95zwFgDqAmP/pDGQGzfAPOQdwfI7tETaWLJCzLl2Q2WSOExZjItpVqlFlm/mEt03U BMlFjWZN4JP8G5p13NLo3LJcwydpVhGjy2bCGnpID7tHiiwVp9hfwsiWKgDyfK/5uaIn oa8PHK8/85HUg5dggDMFnCd8+Q6NYLyu6AtXLAiMJnPSrk6c4o4tRfQ4hC1XdD5YZY5o KtREQLTvrfBBp60Saa8EZq35RrC38SacCREBGe8gdRdYxgFwjhUTf4TnMsBy0tslORQ2 KAB7E+ncQsxq2qHZK/F9Q674Zd5GlQDxs6SrmcOjhnqaJXfye3I+2c5VVDvqQSiv/uRJ YWrQ== X-Gm-Message-State: APjAAAWdYTQamZC4KbWWw+cKl1sXbFvPkJL6iyMWat7rMQGPxCZ3F4Wr 9iOFvx31ICv9iyU8vJvSNjzEgQ== X-Received: by 2002:a1c:c747:: with SMTP id x68mr8912858wmf.138.1560533309075; Fri, 14 Jun 2019 10:28:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q20sm6566985wra.36.2019.06.14.10.28.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 433601FFA6; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:29 +0100 Message-Id: <20190614171200.21078-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 19/50] tcg: let plugins instrument memory accesses 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: Paolo Bonzini , "Emilio G. Cota" , =?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" XXX: store hostaddr from non-i386 TCG backends (do it in a helper?) XXX: what hostaddr to return for I/O accesses? XXX: what hostaddr to return for cross-page accesses? Here the trickiest feature is passing the host address to memory callbacks that request it. Perhaps it would be more appropriate to pass a "physical" address to plugins, but since in QEMU host addr ~= guest physical, I'm going with that for simplicity. To keep the implementation simple we piggy-back on the TLB fast path, and thus can only provide the host address _after_ memory accesses have occurred. For the slow path, it's a bit tedious because there are many places to update, but it's fairly simple. However, note that cross-page accesses are tricky, since the access might be to non-contiguous host addresses. So I'm punting on that and just passing NULL. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée --- v3 - fixes for cpu_neg() --- accel/tcg/atomic_template.h | 5 +++ accel/tcg/cpu-exec.c | 3 ++ accel/tcg/cputlb.c | 37 +++++++++++++++++---- accel/tcg/plugin-gen.c | 17 +++++----- include/exec/cpu-defs.h | 9 +++++ include/exec/cpu_ldst.h | 9 +++++ include/exec/cpu_ldst_template.h | 40 ++++++++++++++--------- include/exec/cpu_ldst_useronly_template.h | 34 ++++++++++++------- tcg/i386/tcg-target.inc.c | 8 +++++ tcg/tcg-op.c | 40 ++++++++++++++++++----- tcg/tcg.h | 1 + 11 files changed, 153 insertions(+), 50 deletions(-) -- 2.20.1 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 04c4c7b0d2..33ddfd498c 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 @@ -73,6 +74,8 @@ void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint8_t info) static inline void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info | TRACE_MEM_ST); } static inline @@ -84,6 +87,7 @@ void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint8_t info) static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong addr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info); } static inline @@ -95,6 +99,7 @@ void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint8_t info) static inline void atomic_trace_st_post(CPUArchState *env, target_ulong addr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info); } #endif /* ATOMIC_TEMPLATE_COMMON */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6c85c3ee1e..c21353e54f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -272,6 +272,7 @@ void cpu_exec_step_atomic(CPUState *cpu) qemu_mutex_unlock_iothread(); } assert_no_pages_locked(); + qemu_plugin_disable_mem_helpers(cpu); } if (in_exclusive_region) { @@ -705,6 +706,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/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 6a0dc438ff..b39c1f06f7 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -879,9 +879,18 @@ static void tlb_fill(CPUState *cpu, target_ulong addr, int size, assert(ok); } +static inline void set_hostaddr(CPUArchState *env, TCGMemOp mo, void *haddr) +{ +#ifdef CONFIG_PLUGIN + if (mo & MO_HADDR) { + env_tlb(env)->c.hostaddr = haddr; + } +#endif +} + static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, int mmu_idx, target_ulong addr, uintptr_t retaddr, - MMUAccessType access_type, int size) + TCGMemOp mo, MMUAccessType access_type, int size) { CPUState *cpu = env_cpu(env); hwaddr mr_offset; @@ -891,6 +900,9 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, bool locked = false; MemTxResult r; + /* XXX Any sensible choice other than NULL? */ + set_hostaddr(env, mo, NULL); + section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -925,7 +937,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, int mmu_idx, uint64_t val, target_ulong addr, - uintptr_t retaddr, int size) + uintptr_t retaddr, TCGMemOp mo, int size) { CPUState *cpu = env_cpu(env); hwaddr mr_offset; @@ -934,6 +946,8 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, bool locked = false; MemTxResult r; + set_hostaddr(env, mo, NULL); + section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -1264,7 +1278,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, offsetof(CPUTLBEntry, addr_code) : offsetof(CPUTLBEntry, addr_read); const MMUAccessType access_type = code_read ? MMU_INST_FETCH : MMU_DATA_LOAD; - unsigned a_bits = get_alignment_bits(get_memop(oi)); + TCGMemOp mo = get_memop(oi); + unsigned a_bits = get_alignment_bits(mo); void *haddr; uint64_t res; @@ -1313,7 +1328,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, } res = io_readx(env, &env_tlb(env)->d[mmu_idx].iotlb[index], - mmu_idx, addr, retaddr, access_type, size); + mmu_idx, addr, retaddr, mo, access_type, size); return handle_bswap(res, size, big_endian); } @@ -1331,6 +1346,12 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, r2 = full_load(env, addr2, oi, retaddr); shift = (addr & (size - 1)) * 8; + /* + * XXX cross-page accesses would have to be split into separate accesses + * for the host address to make sense. For now, just return NULL. + */ + set_hostaddr(env, mo, NULL); + if (big_endian) { /* Big-endian combine. */ res = (r1 << shift) | (r2 >> ((size * 8) - shift)); @@ -1343,6 +1364,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, do_aligned_access: haddr = (void *)((uintptr_t)addr + entry->addend); + set_hostaddr(env, mo, (void *)haddr); switch (size) { case 1: res = ldub_p(haddr); @@ -1513,7 +1535,8 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr = tlb_addr_write(entry); const size_t tlb_off = offsetof(CPUTLBEntry, addr_write); - unsigned a_bits = get_alignment_bits(get_memop(oi)); + TCGMemOp mo = get_memop(oi); + unsigned a_bits = get_alignment_bits(mo); void *haddr; /* Handle CPU specific unaligned behaviour */ @@ -1562,7 +1585,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, io_writex(env, &env_tlb(env)->d[mmu_idx].iotlb[index], mmu_idx, handle_bswap(val, size, big_endian), - addr, retaddr, size); + addr, retaddr, mo, size); return; } @@ -1607,11 +1630,13 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, } helper_ret_stb_mmu(env, addr + i, val8, oi, retaddr); } + set_hostaddr(env, mo, NULL); return; } do_aligned_access: haddr = (void *)((uintptr_t)addr + entry->addend); + set_hostaddr(env, mo, (void *)haddr); switch (size) { case 1: stb_p(haddr, val); diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 7994819fe6..9d9ec29765 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -95,8 +95,7 @@ static void do_gen_mem_cb(TCGv vaddr, uint8_t info, bool is_haddr) TCGv_ptr udata = tcg_const_ptr(NULL); TCGv_ptr haddr; - tcg_gen_ld_i32(cpu_index, cpu_env, - -ENV_OFFSET + offsetof(CPUState, cpu_index)); + tcg_gen_ld_i32(cpu_index, cpu_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); tcg_gen_extu_tl_i64(vaddr64, vaddr); if (is_haddr) { @@ -106,7 +105,9 @@ static void do_gen_mem_cb(TCGv vaddr, uint8_t info, bool is_haddr) */ #ifdef CONFIG_SOFTMMU haddr = tcg_temp_new_ptr(); - tcg_gen_ld_ptr(haddr, cpu_env, offsetof(CPUArchState, hostaddr)); + tcg_gen_ld_ptr(haddr, cpu_env, + offsetof(ArchCPU, neg.tlb.c.hostaddr) - + offsetof(ArchCPU, env)); #else haddr = tcg_const_ptr(NULL); #endif @@ -128,8 +129,8 @@ 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, - -ENV_OFFSET + offsetof(CPUState, cpu_index)); + 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); @@ -172,8 +173,7 @@ static void gen_empty_mem_helper(void) TCGv_ptr ptr; ptr = tcg_const_ptr(NULL); - tcg_gen_st_ptr(ptr, cpu_env, -ENV_OFFSET + offsetof(CPUState, - plugin_mem_cbs)); + tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs)); tcg_temp_free_ptr(ptr); } @@ -784,8 +784,7 @@ void plugin_gen_disable_mem_helpers(void) return; } ptr = tcg_const_ptr(NULL); - tcg_gen_st_ptr(ptr, cpu_env, -ENV_OFFSET + offsetof(CPUState, - plugin_mem_cbs)); + tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs)); tcg_temp_free_ptr(ptr); tcg_ctx->plugin_insn->mem_helper = false; } diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 9bc713a70b..354788385b 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -207,6 +207,14 @@ typedef struct CPUTLBCommon { size_t full_flush_count; size_t part_flush_count; size_t elide_flush_count; +#ifdef CONFIG_PLUGIN + /* + * TODO: remove and calculate on the fly + * + * Stores the host address of a guest access + */ + void *hostaddr; +#endif } CPUTLBCommon; /* @@ -215,6 +223,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.h b/include/exec/cpu_ldst.h index a08b11bd2c..ac07556d25 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -85,6 +85,15 @@ typedef target_ulong abi_ptr; #define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx #endif +static inline void *read_hostaddr(CPUArchState *env) +{ +#if defined(CONFIG_SOFTMMU) && defined(CONFIG_PLUGIN) + return env_tlb(env)->c.hostaddr; +#else + return NULL; +#endif +} + #if defined(CONFIG_USER_ONLY) extern __thread uintptr_t helper_retaddr; diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h index af7e0b49f2..38df113676 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,10 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + uint8_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -101,10 +101,14 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, oi = make_memop_idx(SHIFT, mmu_idx); res = glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr = (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr = addr + entry->addend; + 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, (void *)hostaddr, meminfo); +#endif return res; } @@ -125,11 +129,10 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + uint8_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -140,10 +143,14 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, oi = make_memop_idx(SHIFT, mmu_idx); res = (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr = (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr = addr + entry->addend; + 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, (void *)hostaddr, meminfo); +#endif return res; } @@ -167,11 +174,10 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + uint8_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif addr = ptr; @@ -182,10 +188,14 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, oi = make_memop_idx(SHIFT, mmu_idx); glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi, retaddr); + hostaddr = (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr = addr + entry->addend; + 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, (void *)hostaddr, meminfo); +#endif } static inline void diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index 42a95237f1..cc625a3da8 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -64,12 +64,18 @@ static inline RES_TYPE glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { + RES_TYPE ret; +#if !defined(CODE_ACCESS) + uint8_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); +#endif + + ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + #if !defined(CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, NULL, meminfo); #endif - return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + return ret; } static inline RES_TYPE @@ -88,12 +94,18 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, static inline int glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { + int ret; +#if !defined(CODE_ACCESS) + uint8_t meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); +#endif + + ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + #if !defined(CODE_ACCESS) - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + qemu_plugin_vcpu_mem_cb(env_cpu(env), ptr, NULL, meminfo); #endif - return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + return ret; } static inline int @@ -114,10 +126,10 @@ static inline void glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, RES_TYPE v) { - trace_guest_mem_before_exec( - env_cpu(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + uint8_t meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true); + 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, NULL, meminfo); } static inline void diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 6ddeebf4bc..8519fd0eb0 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -1775,6 +1775,14 @@ static inline void tcg_out_tlb_load(TCGContext *s, TCGReg addrlo, TCGReg addrhi, /* add addend(r0), r1 */ tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0, offsetof(CPUTLBEntry, addend)); + +#ifdef CONFIG_PLUGIN + if (opc & MO_HADDR) { + tcg_out_st(s, TCG_TYPE_PTR, r1, TCG_AREG0, + offsetof(ArchCPU, neg.tlb.c.hostaddr) - + offsetof(ArchCPU, env)); + } +#endif } /* diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 587d092238..e8094e27d0 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, uint8_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, TCGMemOp memop) { TCGMemOp orig_memop; + uint8_t info = trace_mem_get_info(memop, 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, 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, TCGMemOp 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, TCGMemOp memop) void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) { TCGv_i32 swap = NULL; + uint8_t info = trace_mem_get_info(memop, 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, 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, TCGMemOp 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, TCGMemOp memop) void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) { TCGMemOp orig_memop; + uint8_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, TCGMemOp 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)); + info = trace_mem_get_info(memop, 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, TCGMemOp 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, TCGMemOp memop) void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) { TCGv_i64 swap = NULL; + uint8_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, TCGMemOp 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)); + info = trace_mem_get_info(memop, 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, TCGMemOp 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 966e89104d..0e86e18ccb 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -28,6 +28,7 @@ #include "cpu.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 Fri Jun 14 17:11: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: 166907 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2360816ilk; Fri, 14 Jun 2019 11:03:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxS1e0zdJeKAh+Y+tzrcZ0Cuygk43FAmGP3X9APux3gidKcl9xVayhRkVat4DUSCKoLOzwy X-Received: by 2002:a0c:8af0:: with SMTP id 45mr9757572qvw.111.1560535381403; Fri, 14 Jun 2019 11:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535381; cv=none; d=google.com; s=arc-20160816; b=i4rnGztKphw07nqj+4msZYACGyEZX8G7kUQgJ2Ap1XKIFOJk6r4F1grpDeuAwzP4m7 NzFRHQmfwcL/1i7vKmw9tOPyj9sKzxN8e/jPhRLysDh4EmAbzwn/uEovy2iHBI8pGp86 eVFHByHgNo5wHCsPh274CkzkY7fuEeyjLMJX4CfpxCZcksbzvPJ2HoJt/b2b5s2Udd1T zALbziysiGEvqxPGLEOzw13B0QSuCEPui7P422qYO9DTFrEJUeGxmBJb/yAugR3cxCCn ZsIxh9NEyfE/gMxAhxc8WIBk1/lXMCzRn2NpuO3GWLOO/UHNL8/wxC2Ea8cVeqSoI6Eg LtxQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=w9UhEo/iibTeYQ0N86neImewJmC3U4nMBYOWRfST9lI=; b=WbFAgWLiHohet7p+pN1kwv+UMXXX63hIk/o4RQfCdUXVngRj+2gIy/IlVUinD5aRVz 0rCVPe4c7lLk+LqKnvCfmWcxWeDJbnQXNPaczLTR5CutI9Dwh56Efzc8q1zl/gfJJBD7 AJRirj6tSQmr9j4xMjDRXK7B1tWJdY5KtsB7FORBSZExqpEWyeU5RB/ItQkgf+ll4pzv xly4rQzdZ9mcEdv5lXeKScuN2dlKNv1KlVLX6LH4qIHwpec4QdksQsyEiczYY7DzVC2h pV7zDRwBXmOZB47qzb+17sgEGTXe6HbmoqU0YVLvd47jp9g1R4co1JKgKk+QDDBWQpDJ 7J5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vYeoyf+J; spf=pass (google.com: domain of qemu-devel-bounces+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 s20si88750qve.153.2019.06.14.11.03.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:03: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=vYeoyf+J; spf=pass (google.com: domain of qemu-devel-bounces+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]:53954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqXS-0005RX-No for patch@linaro.org; Fri, 14 Jun 2019 14:02:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58616) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005ax-J0 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00077O-Cd for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38767) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006g1-0C for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x343.google.com with SMTP id s15so3063479wmj.3 for ; Fri, 14 Jun 2019 10:18: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=w9UhEo/iibTeYQ0N86neImewJmC3U4nMBYOWRfST9lI=; b=vYeoyf+Je3L/hoDRbK+6a+zHYFaxfxlOCubTW1gqxQCM7Lgu0kvyfx0v9JrKQJukvy BieKGTy7d84Yx0WzI0aSUoLXXlLH75l9bdaXlaOqVvUkETvcLx5z1yqMTBTl+Kl2fdkZ PDb1xdrCPNleYCpNQYbM5+HYqe0j8Wn+XN2g7fZq2FTpRU/+jH6mglBNABD8ii4yMtHn q+c57Jl/Si3TAmx6Z/WSoXBD6E3tZSnjYbvu7Yw+77bLdhzbvDkDCj6ukfG4J7nwq3pe uZu/EdwylWeQgHZhx7BTZSckumFP4oLXuYJ3jF+cLGDk41Bj0nVbUrCH3KLF435AdeVg 82Vg== 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=w9UhEo/iibTeYQ0N86neImewJmC3U4nMBYOWRfST9lI=; b=RlCBRLl+bcrE5PW6YA9EhTy3kdkwPX74m3pGA7Jr0z98+nY++CdSWlVRcjcExfM2Sk SMQmw8A75Crgu83BbCS2nGq08gQOndbnWgYFkCpQ0ygaIrlQ1OaZlM2MqDnjwRFQQlf6 N3XYEvQO+dByfO5b63YwXvgLU5332M74KtVWEG8R14XCXNhBqo+n1A2cMQh69P1lFjLw 7Y0f+IKsy/XIrsOU9azdRiIK/JxlbScYZsECagl2gVk89alx12O/zuO7CjJiDQGBNpZk bQZ42BLAI6c7qHqrHcid5uYbi4RN5u6BC8DgAmDoZZoWrTgpKVOa+er+/2tGrYsWMOlD v9yw== X-Gm-Message-State: APjAAAU2U9dI2Z8jP/H0m0ig41LnVFewyFgBbBqli3ZcHdpSk5a1rZ2L kN2bkvcK5UwPizejwgaHB5/qRw== X-Received: by 2002:a1c:f001:: with SMTP id a1mr9225447wmb.130.1560532710399; Fri, 14 Jun 2019 10:18:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t12sm1926433wrw.53.2019.06.14.10.18.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5761C1FF87; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:30 +0100 Message-Id: <20190614171200.21078-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 20/50] translate-all: notify plugin code of tb_flush 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: Paolo Bonzini , "Emilio G. Cota" , =?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 --- accel/tcg/translate-all.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 54998e39c6..28a92e6d8b 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 Fri Jun 14 17:11: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: 166853 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2334183ilk; Fri, 14 Jun 2019 10:36:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxItIqTKwSe8B1Jr81D00ApTSk46nlvWA8VJ4jh722RTPd4QQbXF0jArsRQFgX+U8RJw/Wr X-Received: by 2002:aed:3535:: with SMTP id a50mr83765058qte.237.1560533768401; Fri, 14 Jun 2019 10:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533768; cv=none; d=google.com; s=arc-20160816; b=YEEWf0EUYeb3/QbR80nG9V9heHrETTP2r5oUic7N6An64kIVfhgNDXh5Kx9LoUyv6t NmFLU3iXS4i5H2//FE+tCRHZGlpuGwibtjmgSpZeEuky28ql4wkxfMeOC+65zZTSfrUd OD4FpEnZ/NNZbaFQ0dRQFs4d3/2s3xWEFhzSY0TR4EeDhcBjjw9RAJYpEofkgqP7gTjp hA41U7KiAtRFTFP5K/be12qNz6nlbNXCH1BRV5V4/ziyqJ9Edlhzi+2OcI0uepe5gDiM 2e2Z9trdlDqHhCzNvzKjfc/jsiqnbqMFUlYEOPwrjVheKm7UFB8TYp/eCw3IvG8Kq8ZH gNtw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=SFB1HgIcrBt0RkgATkeUJ3aZb9a2tJWQOmU7kxrdIe0=; b=mUzoO2F8NDX1BgWjd3h7450hpGuidnTg1k84hOrGWMrCz9zQlp2HdfDU81NwqWgzBT AbXh5mXMqiI04QN97WPaIvrxQAHjQLtTBFuwilwP2OaCEa4AeywzRuJFPLsq5I3lIFzO nNmEaNkF0v5bfFR4bTjLgYMpf0rpnnjAvdJH2nuVDwxpBxeVRHbfVRiX+5JGqT6yMhTi snwLXAyl/A0PDs5DvYFJkfKH/zeogFpQ0awmBPNsgHrHZiPibbsmekIJAK6MAHv7iMam dJX7FYOpkarniqBzX50JUUeFg1OLkTPgBcMEo2Uu7ahLdku3wcsRIK5+1DxrJy6UkFdm j2Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="l8S3E/Kj"; spf=pass (google.com: domain of qemu-devel-bounces+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 b58si2007899qvb.67.2019.06.14.10.36.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:36: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="l8S3E/Kj"; spf=pass (google.com: domain of qemu-devel-bounces+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]:53820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq7T-0003ui-W7 for patch@linaro.org; Fri, 14 Jun 2019 13:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58589) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005an-1Q for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00076L-2C for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006lK-KH for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so3294445wrw.13 for ; Fri, 14 Jun 2019 10:18: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=SFB1HgIcrBt0RkgATkeUJ3aZb9a2tJWQOmU7kxrdIe0=; b=l8S3E/KjqL5INvVWbMbz5IYnMh00JOjVVAdagGk6gmhn5DWF2R0bC6RzcL4BxAbH+k fbuh75eEUoKiCsVSoyjpbxpvwIPRhTIMbuVJcKWW4DzgsaXtINPf0wv5Dzb3lAZ+d4bv Vtycr/GGM6Iy+44UrlYTPM/s6cPbsA5P2YfRb1JHQ1HBeFHt72F4aI30qRJx3xgR9DUc 38qKJKtyU4JmBBCVYfDpZR9+2xk9i12rugYKwZIHK2oduvP5X39lmqgNtc2iN4U+Jsxf WeCeY0A96w0giXvj9iEOBj8DTS5s1miW3OPKbtpTn4pGy+yMpFoT0PDO6+d61bnR22vB rHWg== 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=SFB1HgIcrBt0RkgATkeUJ3aZb9a2tJWQOmU7kxrdIe0=; b=FzoDP2nVbNiiyoIJSHT+07m1U1wFUFblXP1gTg0WUHo7SzWTaNHq5hDALGtABYj3gg zueX4Br+VWolSQqzu5QJVSTRdPt0KltMmtW13aO+0rFK6ZUvbT7WomaJ/IICsf1NXaXN 2ptLUJFkOaXbu3seQGDy88ZJA5eyK6gmjBRaBxxGRSS69hGjmgV4yXs9sVBOilgN02mj CsZ2NSnP7Q32oV+7iz0FATo1g66JIEth4f2GupwX7K3CdDi2kjzFIzCwTUWOXXYXOGie rS1XaZHMdT2zNvEiDwNsBXqJqB0dTNzGwSiI+Gb1INXewU9avitFkGZ6WvJRkD02tXir CC7Q== X-Gm-Message-State: APjAAAWfP5EsP1hW8dCRZ3SBc0tsAJWvPfZJio+ziEpnG75vDoimVLO2 fHWKrOukZHP6758jvkcIp6DR7A== X-Received: by 2002:a5d:6b52:: with SMTP id x18mr41998034wrw.341.1560532714312; Fri, 14 Jun 2019 10:18:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j7sm4617015wru.54.2019.06.14.10.18.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6B7E01FFA9; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:31 +0100 Message-Id: <20190614171200.21078-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 21/50] *-user: notify plugin of exit 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: Riku Voipio , "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier 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 --- bsd-user/syscall.c | 3 +++ linux-user/exit.c | 1 + 2 files changed, 4 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson 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 Fri Jun 14 17:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166923 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2398801ilk; Fri, 14 Jun 2019 11:41:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzEQIRyNtzL1FRIIjMTXCmXOcVpytso9SWe/79+y/GoM/H3wKJTU72FEikVmZ//15L8E2Q X-Received: by 2002:a37:5444:: with SMTP id i65mr78453375qkb.263.1560537711700; Fri, 14 Jun 2019 11:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537711; cv=none; d=google.com; s=arc-20160816; b=hyG8PNNM8yW7F6OStk1czbDfbFEahcnDSvnGVHYwoh4qI6+fle3+QRhT/q2qDReaxT jRzjwu3TvThrvQHk28cM3stm7CqyT1vBGM9w01WuflDp4Z52I6GPeNuSU0hzHH5roumz ykkefGuaf9eY9fRSNwhZdDzy4uHBb7vF8fcN23Lbc0SfgB0qzYhPm5bId0xV4fOdywUe Yz6DgmE6B6MKUVehHcyC2SwiER0sFF6r6ZBill5WRtoaFBEJrhJxJpjjb32tjkAOEixV gf3Prm5FG6eubJmK4bTUY6kzlafygkrZQgONWJUKW3f7JlJQs6X0FsDqglhEPjBeFtUi owhg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=y/GuCM+htQJxVNj9wpaJsriigpxg4M/lN2SgW++LMIQ=; b=h9xUBa8PJC6gQUM79plriowOLb1T68YpiOZ+W9DhsOh0UJCxZ7cxvmRF1GpZFNLghq oVP0crjGllIspgS40jKd+xSgWXgfikUII6gAESzeArn/XiUzREuL8e24PA+MoyR/TcQD Z3DV/jR3gAFKI1FP+ilRLu4niiHFLN6Aw+E+HyGaMEmfpw4SFxwBTxNaoZewdbYnkR9s r9Y3skAEkYJTXhZfmIwcHOJxrZiaOeQBSUb76YNb62bNxZohUbZTtmSodSiADGS/Fo52 O1rkudbXVPbOIvtS/FZ61PPE0Z0dZOnPM4bgbHORLBhJO7+zvrd4N+FtzuXcBkgK1ri9 2Z7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KIf3qLrd; spf=pass (google.com: domain of qemu-devel-bounces+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 d4si2285693qkc.67.2019.06.14.11.41.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11: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=KIf3qLrd; spf=pass (google.com: domain of qemu-devel-bounces+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]:54210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr95-00017V-BB for patch@linaro.org; Fri, 14 Jun 2019 14:41:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39289) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJb-0004XN-Tz for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbqJZ-0003YI-Lb for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:39 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36555) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbqJX-0003SF-Lg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:35 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so3439356wrs.3 for ; Fri, 14 Jun 2019 10:48: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=y/GuCM+htQJxVNj9wpaJsriigpxg4M/lN2SgW++LMIQ=; b=KIf3qLrdzY/ShAkF8aEn6dNzEELD95uK7Z4JDC2i7SMHzuSLvNu5YNHJQ49bhW9Snb 2S3h0qv6Oarp/pkE981+oH2t67GBS1qDhOQBkMRKS3Kfr/jO9vN2B86PhNt87nIEl+U8 srz45+qEY063XcJrIjsQSWilYFlyqcnxjQAjTKBst5z2wm+upUc/wIrpuHKt2HhKnWeN uEAz6uuQm6f2+wR8dANFVPf/n7UELr87MbJ78H9lrzI1BTCA62dX8NUJ5Lps5IKiL972 4XGT8sY5zJd4dMHAibwOB7TqhEdXF66wrFvMP8yJvt+CiWU6gIgjAHS0tZB0AP0P2ygg ONSw== 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=y/GuCM+htQJxVNj9wpaJsriigpxg4M/lN2SgW++LMIQ=; b=bEDBL5mj1vO6Jw+OJBuEUnBxuYbw6hOeS8mR3M9dsckTCWn2nG/Fhr1cmYEjqt8oqk wCKp74DhhAoCvtfKs8ty0zwyLab9xJVMzX5wTrDkLkpUAkbgIyVcf2slBDBhr7ixqKeO r5SkT5dBQeDDW3LbowXZZuPGLwOvYxBNRoZ0DPE/FiKFtqXEZ0dawTAPr++B0M29FPOj uC6NptFJ+72KZBhWlwKklMCETI27RuXe/OXdIhlkxMBtzSs1lK9rMS/GsdGHFxcLz4Gt L4BnmFxM/yfs4pwEoUeyYF3jHnDoiiJPzBXOjUUeKi5cliRu7dvvzEH5Q1dvhFgzY7Kz DoXg== X-Gm-Message-State: APjAAAX7baljET1DRlA1FSHVwvKNIHIva9SLB1p5n9nTvqq/GMQeRmz0 q7IpsPBWXH34S3dXQ/Y4ofKHWQ== X-Received: by 2002:adf:f951:: with SMTP id q17mr37939614wrr.173.1560534509447; Fri, 14 Jun 2019 10:48:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l12sm9601398wrb.81.2019.06.14.10.48.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:48:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 807721FFAA; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:32 +0100 Message-Id: <20190614171200.21078-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 22/50] *-user: plugin syscalls 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: Riku Voipio , "Emilio G. Cota" , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- bsd-user/syscall.c | 9 +++++++++ linux-user/syscall.c | 3 +++ 2 files changed, 12 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 84a983a9a1..50e47d217c 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -323,6 +323,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, gemu_log("freebsd syscall %d\n", num); #endif 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); if(do_strace) print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -404,6 +406,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, if (do_strace) print_freebsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; @@ -422,6 +425,8 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, gemu_log("netbsd syscall %d\n", num); #endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, + 0); if(do_strace) print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -480,6 +485,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, if (do_strace) print_netbsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; @@ -498,6 +504,8 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, gemu_log("openbsd syscall %d\n", num); #endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, + 0); if(do_strace) print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -556,6 +564,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, if (do_strace) print_openbsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b187c1281d..7f3cfdee84 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11724,6 +11724,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, 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); if (unlikely(do_strace)) { print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -11736,5 +11738,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; } From patchwork Fri Jun 14 17:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166857 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2342516ilk; Fri, 14 Jun 2019 10:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHjNr7j2fqOjWr2Z3uS/54vEEr0UZba2vqk9F1WK7cm4+Imzw99t4uNOrubXub/50/3YOZ X-Received: by 2002:ae9:f20c:: with SMTP id m12mr76958152qkg.58.1560534268377; Fri, 14 Jun 2019 10:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534268; cv=none; d=google.com; s=arc-20160816; b=vPbJyYll0PI7cDk1lR8Sg83zDsVS8FGuKz2kVKmtI3X9rF0YE/Kc+pluMmvqNWt9sB 6OmuqsziJuXYKPph+JHMRmsWGgTBjI644cFTvybf4Bcm6ZroAb9n9GSoeT4mpj0QbdjU Dya+T0eHgddlNMfxR1OG4jXsMqEsODa4djtrI2RFrjVuWQ5SFmcoX0qB09+IeWmx7Vm7 300990b17CJ5bSq0GJs4pQ2k9t2Ma7aK7CHrjQsJr2PevetgLdmredp27aitfbalYWE6 CdwaIuccZvAj/eOoDgGoBABl6flb/2zwig96lT1O1rukIwZidBfXuxhhrLPmIoXND1z9 3UZA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=YncL+aogkxAEp8iPbJPa9DDQqoGQa5c8fOFThE2OZXoYx7CnowV8Odd52BrMFgW908 6HvR42oI8SOUYRusNzu7Y8xibifSlmAFLxao+RdJhuvBur83r74WN+BMrP7NqqIW4Mlm KHUnw1ZXFHDTb6Hk7+dv54ApZlY9ZIp8fAJey5rgJslYrlazEWUL30Ec7+dTpiYxfSB5 IJ9lFQ9trTds49xGg+6ihQsou1K/wDuU7e0xvvoMBJTubG/xH291Kk9CRhlgo4auxQ4n f3Ox9+eTW7Wg02Ja5+u+oyq0yV2gxXx9Q21pSLP0mJyVZ+YR1ge/nhHwx9ccFqy2lXkK 1byA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o3sZ4Pnp; spf=pass (google.com: domain of qemu-devel-bounces+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 o9si2098466qvs.65.2019.06.14.10.44.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:44: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=o3sZ4Pnp; spf=pass (google.com: domain of qemu-devel-bounces+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]:53861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqFX-00021f-W2 for patch@linaro.org; Fri, 14 Jun 2019 13:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58595) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005ap-3b for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00077D-Bx for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006b4-T2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wr1-x441.google.com with SMTP id x4so3333234wrt.6 for ; Fri, 14 Jun 2019 10:18: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=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=o3sZ4PnpU7FHbCcoy45V70DS9r+zSw5ECniTV+Evo0WkDiAXXUAan11CUevOdMEY8n Nai+SerQO/wxlFsTX1Pr5YgRozUk4r9KbBlyEO3VNzQRFQszReDQ93r0H6fTkOzrtPGl XBTDQIvJmwhuL4bPnmk5p3Ri8cPANLkvz1fFcCWZ0AApk4fvr6FwyhJ+N1Q4H5GpZvi1 HqWPCy1XJY+UiQ1BZ0h4Sb6XP82C7rrQ8VWioBrnY28FrFgVfQgvgd53nzGiFQVs8Kdy MJVkRe+HRUOCN9NP6fz5/JO2muJQDyTbKBPs8fgVhTTND0cnKJYiqGt0Rhx/eXMeob0L 6LrQ== 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=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=fMoMXNbzt/1Kkb+BP1A8dRv3yHHEMfbyNgjGflLOGGVBO6F6sABZOgj1opCutxp2M3 5haXsz+dpvbgSveMoXf4jn5OsF3M0dOCqZMOYzbyQr7JKgRF40WqYhe4aLQccg2OkWY3 AL6J/7QiL28GUYv9CPbuvZMHReo6iDE+wgPBlc67isvRDYvFiWu/uV87i4v7CovOAa9q gCF/lbzWpfwzAc33OGLBSWzqU0FRuNTD18eUDfJAQqr3utc4Qv9+c9IYZDsuK0FXJVuV td0CUUAbvHT+jBCB7TK4btf+NajEEYa8E/Jnx3PeIEiuTp+mrOUa/TFtkMBYl5XyU7l0 8hjg== X-Gm-Message-State: APjAAAXSHkAykLCe9J3qoiVtwXbYqs/Qqgs0Dd548HYOSN2cVh2Ostet /P1TJ79jWNswSx8Kqu9RDgwJNw== X-Received: by 2002:a5d:4008:: with SMTP id n8mr6522617wrp.353.1560532707867; Fri, 14 Jun 2019 10:18:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q20sm6518030wra.36.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9594B1FFAB; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:33 +0100 Message-Id: <20190614171200.21078-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 23/50] cpu: hook plugin vcpu events 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: Paolo Bonzini , "Emilio G. Cota" , 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 --- cpus.c | 10 ++++++++++ exec.c | 2 ++ qom/cpu.c | 2 ++ 3 files changed, 14 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/cpus.c b/cpus.c index dde3b7b981..2f86af9a87 100644 --- a/cpus.c +++ b/cpus.c @@ -46,6 +46,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" @@ -1243,9 +1244,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 e7622d1956..4a29471c3d 100644 --- a/exec.c +++ b/exec.c @@ -974,6 +974,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/qom/cpu.c b/qom/cpu.c index f376f782d8..90ebb214bb 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -33,6 +33,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" +#include "qemu/plugin.h" CPUInterruptHandler cpu_interrupt_handler; @@ -354,6 +355,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 Fri Jun 14 17:11:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166915 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2377555ilk; Fri, 14 Jun 2019 11:18:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhUQmA/inZaNQ/S0bXUU3RJtPqwakGxTNdTWk8JeVshuR8ytSW6t6B4LGiGhwbR1nIiz0r X-Received: by 2002:a0c:d066:: with SMTP id d35mr9430242qvh.221.1560536338658; Fri, 14 Jun 2019 11:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536338; cv=none; d=google.com; s=arc-20160816; b=Jv9QryfB03ekDB6Gh/6bQEbJR5sz0SXDKpfGY/mNLmN/eZ8e4miBiEjfwwbRjg/soA 4CDck1lvR3wdCjrGjqbacTBWmLUCiSvmlwX2qlwqAMyGy61JqlRZo6sHNW5snN6D6/sm VNKE6HF6uqvyktMF3cJrZjFzkTIIayHTRstelbNdcFHgf79vFOOE8O8baiYEZqycj5c+ TsayxaKu5ijuDgCc8dS9//v1rWrbL/9xxPZHisVAsnWE6JcLy4UpYs82JHGG6ciOAlHx 3hvzgF7IPyo996rRC8JAbLAZPJde71qROhoWJqmRYrMFO/OrGevlwq21jA3wbe3Iwxgr 98+Q== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=/qvBNA83di35y4TZUh+6AvSJoV82skhcUTraghkKk3o=; b=uScCEElGPvBkQ81rcwtiwPQOU8ZBKCfz70sPzPlU1CaV/nJCiWtG4cN2W6DSv6cLpo IE/YHsTIRpmnqSK4E2II3sKaBEC1q1zKhQrFi3xLsaG1JcARrz46mhS7oWKQf1xrYKkP 7huGV+mMmIci6R67S1nZmSwMH0Acbu2VIpyVuYkOmyrTmFxAR49ZH8iGEpSnSwC56e1O bpzmWA4UEFxizd5JVLLjtRdQuA3s6diTfQI1MBIaNP3WVP1tyjS+uIRl59fNFnxH9FqA dAYlqIcb3jb3r8YHadLdu+Kd1VNKvSeBhtIYDSDdadhSEx9vN4c5itnaxcnt8FbE2IyP TKOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wr8LBQY9; spf=pass (google.com: domain of qemu-devel-bounces+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 n6si1971727qvs.118.2019.06.14.11.18.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:18: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=wr8LBQY9; spf=pass (google.com: domain of qemu-devel-bounces+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]:54056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqmw-0001zk-7C for patch@linaro.org; Fri, 14 Jun 2019 14:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34006) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0F-00075Z-Ba for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0B-0003th-Tc for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:37 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37209) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0A-0003qE-Ik for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:35 -0400 Received: by mail-wr1-x443.google.com with SMTP id v14so3367951wrr.4 for ; Fri, 14 Jun 2019 10:28: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=/qvBNA83di35y4TZUh+6AvSJoV82skhcUTraghkKk3o=; b=wr8LBQY9J71aFkmJqUY1TG3Dnlkt6xg1FiMMSvZuK8QDfSCGxdMxcXQivlSxWae0v6 1n9uaFelgawk2sK2+kldHcbs08eQOD9U8LyVh1ZaHRQb+jtqt6BvxXEGPyDBLKwQzTgo jaDWd0JsLBEqM+OnufpZ4MdiSKwrH8uHyyR2D4W0qKECGWjIoVQX7kQHqWuVUs2hmv9a vlz1Ua+cHLdu8Ci/l8ZoG/Qb+5iEu1G2x95aFUUiLUSMbBwnRQgEbV6V+zj4bu1bcEk4 rca0Rw06GjSupOL8R9yHS7sNDwchVFEPKG6GiQkn2+rMRHU1ovsbBNbXLTKEOnF1MIjP e/+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=/qvBNA83di35y4TZUh+6AvSJoV82skhcUTraghkKk3o=; b=JXY6eIdfsmVWUFT6eCBeOVxiqLxLYQD0TzmdAfNcM/MdCIoHyjIBv1gnmMe6Cu1v5D +UpYcpoG9EZhakRG/0vJu+4vZ1XcsWgD00EgSEWcvbUdF7TVkGWi7qxvP0sihADkkOT4 +1sUMvXyEhc75XKQK5Wv+ZAohSlnwrgOTzaBX9qZn109U0IBb36P87ygF9DxRydHWf74 +VhDlbPhpCMc/6Q86aL7zTuaETSPBmSAfcMlv2RINlTcO9Vf9ySsOeCwo+uiSS/FeyQQ N5ynvzpghtCWgkaGr5VXCovHb1ZLrG2TMh2AXqBkwLdEcwRKab01G+O02UdapLbdLKfR MRwg== X-Gm-Message-State: APjAAAVTuSESRVVX2JDJ5E85CnwkbgOWHWo+tyFILtgjKd1P/er0MX3p d94ylaJWqjDvjQloYzhHa5N7QQ== X-Received: by 2002:a5d:4a0e:: with SMTP id m14mr18674602wrq.91.1560533313452; Fri, 14 Jun 2019 10:28:33 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v15sm3707043wrt.25.2019.06.14.10.28.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A9F851FFAC; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:34 +0100 Message-Id: <20190614171200.21078-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 24/50] plugin-gen: add plugin_insn_append 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: Paolo Bonzini , "Emilio G. Cota" , Richard Henderson 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 --- v3 - use g_byte_array --- accel/tcg/plugin-gen.c | 10 +++++++++- include/exec/plugin-gen.h | 23 ++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 9d9ec29765..758fc5d099 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -60,9 +60,17 @@ /* * plugin_cb_start TCG op args[]: * 0: enum plugin_gen_from - * 1: enum plugin_gen_cb (defined below) + * 1: enum plugin_gen_cb * 2: set to 1 if it's a mem callback and it's 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, diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h index 449ea16034..316638c736 100644 --- a/include/exec/plugin-gen.h +++ b/include/exec/plugin-gen.h @@ -15,15 +15,6 @@ #include "qemu/plugin.h" #include "tcg/tcg.h" -/* used by plugin_callback_start and plugin_callback_end TCG ops */ -enum plugin_gen_from { - PLUGIN_GEN_FROM_TB, - PLUGIN_GEN_FROM_INSN, - PLUGIN_GEN_FROM_MEM, - PLUGIN_GEN_AFTER_INSN, - PLUGIN_GEN_N_FROMS, -}; - struct DisasContextBase; #ifdef CONFIG_PLUGIN @@ -36,6 +27,17 @@ void plugin_gen_insn_end(void); void plugin_gen_disable_mem_helpers(void); void plugin_gen_empty_mem_callback(TCGv addr, uint8_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 @@ -60,6 +62,9 @@ static inline void plugin_gen_disable_mem_helpers(void) static inline void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info) { } +static inline void plugin_insn_append(const void *from, size_t size) +{ } + #endif /* CONFIG_PLUGIN */ #endif /* QEMU_PLUGIN_GEN_H */ From patchwork Fri Jun 14 17:11:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166925 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2399686ilk; Fri, 14 Jun 2019 11:42:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl1HIeipHnZZfhkHre/0c11sIwwZev/3kCS9plg3FDDhZ+c362ajK1lyEhmMOVhalr6daB X-Received: by 2002:a0c:b0c6:: with SMTP id p6mr9248362qvc.225.1560537774252; Fri, 14 Jun 2019 11:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537774; cv=none; d=google.com; s=arc-20160816; b=S3Xj1MpngPdpJKeE8AbkMQD7CgshnvJreg+ecrcwgvA9B/KoDaTGoWm6JNDQzY137C fKJYE9xh3oXDj1Vkfv9g2KBWvcz3cJ5mGbLiUyI/KcgUBW9vQsIpfytPrNnmTcUyYXdl xs4P+6O1EEXQ9uJoQJCvILgmtfczF0eoq+EpDog5DUWVAI5yfchR1LwaLwWMg+5d6Iao AAjwSeTafTZ13fzsafHyI5V9uBE7MTEDUpJcsUQWoV+xBUd81DmFGD3GnGYGYinPA3LG yTzhmnSy1bdAYdRc2qAWNfWyTNwq78nz/RwMesO1N+kfxggYOl18Vp/NJpo6m3Y0mphb 3+FA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=M9pjVZf2vmVt0qPRpyohqMfwA1FkxEKe0Yjf3n3HoWM=; b=zddG+sGwT94N9qU5V8yq1/lOL75TXsShwLuyLas1jAor/ljERoZ6B2Nqdq1Z4g71+d 8uWZF5x7FiHTSz/TyS1mg48hJnw3ZXeeP5ticccjPaHjO0cPHBLdpPxgPh2enuSQBBSb AOThZcyY92bLnht+uxNSqCpfLtCachfNpVpohHI7zDTy/voTa+UEWrrwGlOir1ePTFsW SMcgFtg29zAeZuYMtwrtE4ixk+izwsmXyqAa0Z+sjHHi6qt9jhuZWqMlpxGwtYlnPdsZ QCjYErygsKFWWqEFq9k+JHGO+1cfrl1ngJzfZZwUiLq2sJrEEsjZ8epFZH2BR9MZX9T+ kqkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iedGUINC; spf=pass (google.com: domain of qemu-devel-bounces+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 127si2130350qkm.184.2019.06.14.11.42.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:42: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=iedGUINC; spf=pass (google.com: domain of qemu-devel-bounces+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]:54220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrA5-0001ct-Rj for patch@linaro.org; Fri, 14 Jun 2019 14:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34180) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0Q-0007A0-QK for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0N-00049P-DM for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:49 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:56033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0M-0003up-7F for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:47 -0400 Received: by mail-wm1-x342.google.com with SMTP id a15so3145584wmj.5 for ; Fri, 14 Jun 2019 10:28:37 -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=M9pjVZf2vmVt0qPRpyohqMfwA1FkxEKe0Yjf3n3HoWM=; b=iedGUINCZYuC4fwc28TFy3USZ4JCp6y8qiISt2ZYUhcAu43siybfwyBjoaWfjfTnDN ifHXchm9hegUWABSf9k9xxjf86oFPJ7vNk4+23RZITagCkTLhfA9J0xbwWiJ/Vesa4lB taWaj01xyxOFX/7w4JXJYrMzWxjmPn6TO6EksJAlhwHbRIggla4bhcUQwlJvEtOR/tl9 euxt8g2TwFD5YCeTvNjbukB0ocgmI+2O2aqP2xmDng1EFEbH1dgINFfbN9+hZmSb+RTh RjCRhyZX3slbFfZFxXSb+u4iJRVV14anSpfTYwWp6Pq0AWLiJ8irDIWmnp+QjkD692pI 2zxg== 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=M9pjVZf2vmVt0qPRpyohqMfwA1FkxEKe0Yjf3n3HoWM=; b=PeaJ+Xc12j1LH1mZgqohrGAjcHcoVHDrKsTVihuHwucsh0qM700HXAMJSgvJBWDLV1 Ifh2q97IDaswQqeNU7ApY1CZOIBm6kMEE7BzbyAQPFHm7Vicieg7Z2H8D155Ee/7dfie wtSxijsmrsJJt18BBNQaYMdHcemeccSSgTaPhY1NPXEfhnSEkUJAUpRZOcsDVr9qWILx k+XRJj42v7bw2Gjx3pm8y3T5wq7dj4WfOA0l5FF0lK7OgGZ+2FB35/wXkH3t5vs3O4Ec +JS152pNF5HJhaGdNIpQP7hs2CMTNUGArG+Z3rTxxMjIXfupL3BskuABL/0LoBLSdo0v 0i+A== X-Gm-Message-State: APjAAAWtHhtsFmLBrX2HG0Q67CVcVJFMzxC/gIsI/RhSROs7vdccM+nq pVB6ZOR/r1+Fw6OzGyC/zjAuznTkYos= X-Received: by 2002:a05:600c:2243:: with SMTP id a3mr8531302wmm.83.1560533316231; Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j123sm6629837wmb.32.2019.06.14.10.28.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BBD191FFAE; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:35 +0100 Message-Id: <20190614171200.21078-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 25/50] translator: add translator_ld{ub, sw, uw, l, q} 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: "Emilio G. Cota" , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/translator.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/include/exec/translator.h b/include/exec/translator.h index 180c51d509..33fa709ba6 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,29 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, void translator_loop_temp_check(DisasContextBase *db); -#endif /* EXEC__TRANSLATOR_H */ +#define GEN_TRANSLATOR_LD(fullname, name, type, swap_fn) \ + static inline type \ + fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ + { \ + type ret = cpu_ ## name ## _code(env, pc); \ + \ + 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, ldub, uint8_t, /* no swap needed */) +GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, bswap16) +GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, bswap16) +GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, bswap32) +GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, bswap64) +#undef GEN_TRANSLATOR_LD + +#endif /* EXEC__TRANSLATOR_H */ From patchwork Fri Jun 14 17:11:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166906 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2359996ilk; Fri, 14 Jun 2019 11:02:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0EcnhsbGI4bVSLGfBJeotBsRAGJysCh21fP3NbwT4fiS7AUDmjzBdiKSkny0Vdirok/zr X-Received: by 2002:a0c:d01b:: with SMTP id u27mr9513178qvg.88.1560535341469; Fri, 14 Jun 2019 11:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535341; cv=none; d=google.com; s=arc-20160816; b=uJkkKiU3NlreqnjtMzhmgFXFEmn4fgAnnxENHccK5WQ2Rqv6LB909H4bNV76oKs5ze cHoPeOzou2AvTo+1uWddtTaS9LV1xVM3wCGGjirDb+0KGNRPIMzx/dLkEdfm7V6bRHoI jXzMVIdWIUDdojXAlsOcOkXEM4cSaYNw0ma+oRRsX3HLKXAGSoEzrnTsfBMqZGpFKdWP bM0VDV0Hks+XodDoZX0KR9e8mQQPfgFfeQkJtP90TU0MXzyzMmTcFvyhPBZOVZmXeG8I 5sRGx5V9XUBLDtK4r3ESTOuxJrulZA2Ck1UT3eXTCbfOqFYZSPXB8rqi8xVaXm+KYPcQ sogA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=2raPXKCjQecpuTN9hXy4UgLzVxLUbna9Nio0I94YsC8=; b=oB3F9Dc3yWMgeHMqzt75B8sbLn3Bx4+qQ29pNP3IguKC2n6Sx2lTpZ9cBfx4IMToed odtDYCxIIoh5MhNUgLhBEYbO4OjW3E1qtecw6ApdjnsBS7OCkhKIr9f7tmiWkaQFIc81 qZIjChXvOGqxxj2RNFi3mDFSBiTMpt7OuVOKZDG7AA/O3bi6+gCyqAeIXtyJqPKtI9w3 gxU8TRE0djvUpKvU8daPECV5AjFajZ0sRCgW7TCg9GQXqjB9xs+mt1QLBlIcvS6swAZb PEz+gyCH/+UJcCtA2/UshB6Zch8gOy8O0K9ZkaZfjHpScwqGiX2tBKzaQMYGY1VFuCKd /LGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fHIEQqOl; spf=pass (google.com: domain of qemu-devel-bounces+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 p37si2019594qvc.125.2019.06.14.11.02.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:02: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=fHIEQqOl; spf=pass (google.com: domain of qemu-devel-bounces+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]:53952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqWr-0005Mu-2T for patch@linaro.org; Fri, 14 Jun 2019 14:02:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34066) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0J-00076Y-QM for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0H-0003ys-2l for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:42 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:33823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0F-0003jW-Ks for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: by mail-wr1-x432.google.com with SMTP id k11so3378355wrl.1 for ; Fri, 14 Jun 2019 10:28: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=2raPXKCjQecpuTN9hXy4UgLzVxLUbna9Nio0I94YsC8=; b=fHIEQqOlAsL5rWVjXzym6dN6zDbrXls9Ad0tWpiamMdIHCeBDhehwQM/onGIjLq4m2 YNC6nufwMJcnOj4D5dH+sMeN4GMK7j7mQol6WPeniyBIg7z1so8YsgGTrzJNrMpYbrYN lexy/IINpQf58DDF9AGoWrkwpZXoFwfOGgiS1RL2C1vUutiH9zVuf8MfIrbQVzLmqeIB F4l1x5FZ1EfLFPtSIvdfUBQ/LMHu8/CPngMfbIZN1rZ/6/HgJPsSEP15mMpmVqR2vagX gdn7PN1qZRHGge7SlAXuvEBpmVIAJxjLa+aiB/LkiYjCnGyFEMAQe6p+xupGvFbh7t9L /7ug== 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=2raPXKCjQecpuTN9hXy4UgLzVxLUbna9Nio0I94YsC8=; b=D6/sKpDvjVHJFLLTH7qqY4vSD6JxF0SBNJf78jREg1ysbV/8H+8QybItuic2yO7fTL GB0g/4bIDB8M04MsuUkHRf8dUNh7uJlrZDYBEVP9a58GSDsPF03DvmIRmm5BRr+hibZj Awk9w4MGTtYexmGSTEtHJkw8jgCV+MUKWRcHhsZMGsufckumu5s9EcgRrRz8tn/DXuws UiVOCElY/twah3K6PTybAqXnmhPP5XWZnVvbFWG7IY5hvhKoLqOEOWUawwxHRjF1Q2lR jotzOq6nl5rrDTkvDXKjz5FOMgTNf7lkbbWTMlVumHpB5KiGlO+YIHAodd80gh63kILw 6QxQ== X-Gm-Message-State: APjAAAWInd5rF/X8/6UUrpm1u5Ef0nu/t83k2TDK7yMan5fj19szNmpl 8532ipT+bTUKoIevuhqBy1jBvA== X-Received: by 2002:adf:a201:: with SMTP id p1mr33627107wra.113.1560533307829; Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l19sm2196683wmj.33.2019.06.14.10.28.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D06BC1FFAF; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:36 +0100 Message-Id: <20190614171200.21078-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 Subject: [Qemu-devel] [PATCH v3 26/50] target/arm: call qemu_plugin_insn_append 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 , "Emilio G. Cota" , "open list:ARM TCG CPUs" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" I considered using translator_ld* from arm_ldl_code et al. However, note that there's a helper that also calls arm_ldl_code, so we'd have to change that caller. In thumb's case I'm also calling plugin_insn_append directly, since we can't assume that all instructions are 16 bits long. Signed-off-by: Emilio G. Cota --- target/arm/translate-a64.c | 2 ++ target/arm/translate.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ae739f6575..25dd34a745 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -39,6 +39,7 @@ #include "trace-tcg.h" #include "translate-a64.h" #include "qemu/atomic128.h" +#include "qemu/plugin.h" static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_pc; @@ -14205,6 +14206,7 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) uint32_t insn; insn = arm_ldl_code(env, s->pc, s->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); s->insn = insn; s->pc += 4; diff --git a/target/arm/translate.c b/target/arm/translate.c index c274c8b460..d049844b4a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12122,6 +12122,7 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) } insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); dc->insn = insn; dc->pc += 4; disas_arm_insn(dc, insn); @@ -12192,11 +12193,16 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); is_16bit = thumb_insn_is_16bit(dc, insn); dc->pc += 2; - if (!is_16bit) { + if (is_16bit) { + uint16_t insn16 = insn; + + plugin_insn_append(&insn16, sizeof(insn16)); + } else { uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); insn = insn << 16 | insn2; dc->pc += 2; + plugin_insn_append(&insn, sizeof(insn)); } dc->insn = insn; From patchwork Fri Jun 14 17:11:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166920 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2391625ilk; Fri, 14 Jun 2019 11:34:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyq46zf28T8PBqoT0EO84wywMzYlMV+AqOeRiuU+Qq/xVI1L0675Q/sAFeCQ5Svfj6tfpdm X-Received: by 2002:ac8:1c54:: with SMTP id j20mr55163052qtk.158.1560537247980; Fri, 14 Jun 2019 11:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537247; cv=none; d=google.com; s=arc-20160816; b=SrOwvYt+ysTh6yPhDQHY0n4A8J6jbiGACbjnX/ZbPAQSP/GpQ3Nl9PGyIJYYv9Xuiy bLU4CWs/9Snt7L9/qzgQYwYYz1OFJA/po9OppkyCB80QpD2X1heztVXqutN55iXYJrBX xipjZg+xsCC+fo36BPJyMvGKkxdcBfVu84SCUpz1zR2aYWB2WGx6m9mn95oNN8WAWfDc YPhoxN0APSFlUPfR3VvKlPbOpaPQczJ/SYSvZNY9t4SnMFV2wCS/VXv5lw6zKB7ap48n j+yqb/kJvaUeGTQgf0M/Wdjh5VMabaAJ5q4n3T8Yi/W+bDpIdfVDo2rhwYheka3OEXjX MY2g== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=y+34OeiOJi4hTXE8brxuKPyvEg2ag444W2pbsGyLziY=; b=ABxO6P7H2JwnnCeluU3V9/h4+u23x031aG15KtaAT5QRZmO4cE/bn4k1DWHqz6/bvp /GAJkvUzopy+2BBxv305mGBPqwWEj20flYb+LUlBgzf9BTZRqEe5Rbiw2uqM5Z1EBqZ9 2QDHUz3q0mZtG6kNyQ+zCHPn3STUaQOucHPwZEJnvwX43x0OG+8/W2ChK+U7TBgw92PT 0BWyGNtoGX9g/NLM8DiJe8a661ApLiVVrPcdVxJnyrKj4n5/0Tp35QHtGcOBZZREKIIs f9jfHTd2EW+H6JTRuHc+avJWv4if4jOXjs87tYCJ7OjzAc8zX7DthTWHAneaqwrIFGO/ k7Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qQR8ak4o; spf=pass (google.com: domain of qemu-devel-bounces+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 l6si2005614qvi.51.2019.06.14.11.34.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:34:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qQR8ak4o; spf=pass (google.com: domain of qemu-devel-bounces+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]:54144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr1b-0002Mv-Bf for patch@linaro.org; Fri, 14 Jun 2019 14:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34272) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0c-0007IW-54 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0U-0004K1-RU for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:56 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36525) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0R-0003w3-2w for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:52 -0400 Received: by mail-wm1-x343.google.com with SMTP id u8so3100558wmm.1 for ; Fri, 14 Jun 2019 10:28:38 -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=y+34OeiOJi4hTXE8brxuKPyvEg2ag444W2pbsGyLziY=; b=qQR8ak4o/T0VsAOYgzhfoD323bq7ELePZfhYzGL1qTVJK2Dwk3cZDi7bWJZFYg/fCf jebf/RaGnMzR18mcyasIPnv03a56+LOT+ikoPmZuor3BqrKM9zbmvDDXg4Kf6VjPSXjH hJ4gDReGpyoBFv9GyCHPR1aTNgOBQUL12QSNqiMZr/V9evQs/dBXqz3vemdfuv8LKPkI OoLR8uWQA/6pzBG7XrlEUIgptqltS6IDMQk78jE+4QAS+D6J0FxQrh0MrdJ8ejZutqzq 830a9V3Mgyx4FXI7n54ORixTQdhMlahCS7HrKHnKxNorOpPMzWHocpcYaGbpd0RH/vr/ hMvQ== 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=y+34OeiOJi4hTXE8brxuKPyvEg2ag444W2pbsGyLziY=; b=ESW1XGTk2BmkMMy9itSn7+wVCU+U/bBygK88N5Mwo42WU9mgzToeo6RkT+nFF7P/nh fSs7a4CEKjOk157byGAbrReKol8DIN3A402TfUBigHNxZhabTLwH2EgDDhgqhpx4zjHD RZuwhvxJWU0stbumx1EgXcNcXFAVwJBgKqFhxTlWQhdsIMILtXJspFX8v+UOmIqWcIKv /qle4GUZroM6mroKTGpZOsVbznns1qAgKS9xFeALTm/Jh3GZyoLdjOFabPvaZWA/ClpT i2aqH8sC1uNEBDX39lyqWZWlTAbqRBnidT28AxCdi2+/1Wq9tsbaP5b2HNeCXJ9VojeO Xb0A== X-Gm-Message-State: APjAAAUSazTUEjJs3GWWwpt75rQ+7sHRjyVFQeK/VSAI+lHAZMd0oy2P fDtFojVLqO8LXUVbfKXWr3bliA== X-Received: by 2002:a1c:f20c:: with SMTP id s12mr9399028wmc.151.1560533317329; Fri, 14 Jun 2019 10:28:37 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c11sm2083776wrs.97.2019.06.14.10.28.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E3E951FFB1; Fri, 14 Jun 2019 18:12:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:37 +0100 Message-Id: <20190614171200.21078-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 27/50] target/ppc: fetch code with translator_ld 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: "Emilio G. Cota" , "open list:PowerPC TCG CPUs" , 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 --- target/ppc/translate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson Acked-by: David Gibson diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 4a5de28036..a27b5659f4 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7864,11 +7864,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 Fri Jun 14 17:11: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: 166859 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2346540ilk; Fri, 14 Jun 2019 10:48:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzcpbMIXqOl99Bz/KU3yAIptQm1edxbxF1jIS7cNifk0+o+il0i2zbNoGd0gLbrg5Oway6 X-Received: by 2002:a05:620a:3da:: with SMTP id r26mr59747074qkm.279.1560534518113; Fri, 14 Jun 2019 10:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534518; cv=none; d=google.com; s=arc-20160816; b=s24EwRx4d7DZwx3AiFD2rwBHFXiyYaL25LXX8iURgz2Npn78ywcJTI9bNiq6a15399 1cu0QAGM5nFL3WTlru0euk8jCXtb1Vb7AlmBa0kiqRoN5PSM2MZytEvSs3KxEsV62rNl DxwD14RR0TfyxjQqLXb4uBO4cFjijG+AcDKieU+HTZnGrQGyg8NqTVc9Al/G0Qvve5+8 N9ZgooLZbK893Pwwpx/fQpengBdIf1OCOi6CLml0yv/hZyeayvAqvw0cB/EVToc9aK0T 2n4Pd/qmZ862Dcg+htiUrAV2ftXPWozqbFLAyRC18JmQ3/8PdrAAKe4U0OffR9eGTWwB xoiw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8XTuXWq+xToiDvDobeS2vNcXere9quLdtk1afgwMbsw=; b=iWUjcB0uDoh/2ygq9aW7mhlNKHCRACcbrp6f/NPHIP/cgwnICVGrfv+XtA+WYyzoqI d6e4alWZQ6tQ+8y8Eyhwe4cdN74xznLnAQW1CWhMbmsp2gqAeQwo/IGe22ccQIdmUzkq bQP9qDbIC7iMz6IP4xleIXf1e2JCsyS2U9kF595PjNEpiSnN3mS/hxQavDljV+jsXUi2 UAnNvj8r0635z0eRAmZhgBR37WKtrGwEnJvmDQXqR2GEr8YfvkBPr9CpvbCJfYBXJXvG 9YIfQt42JS/lz7tZfXgUzsHPpinCLRgwr8Y4unTNpynVFHOA6jjU3654Hu8cDcIfZs/I BxQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eUVM8nN6; spf=pass (google.com: domain of qemu-devel-bounces+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 q1si2289089qkd.157.2019.06.14.10.48.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eUVM8nN6; spf=pass (google.com: domain of qemu-devel-bounces+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]:53878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJZ-0004OB-Mv for patch@linaro.org; Fri, 14 Jun 2019 13:48:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58659) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqi-0005b1-WF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00078J-Nj for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36067) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006qu-4Q for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so3355670wrs.3 for ; Fri, 14 Jun 2019 10:18:38 -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=8XTuXWq+xToiDvDobeS2vNcXere9quLdtk1afgwMbsw=; b=eUVM8nN6O/n9aKdS3bQfPIk2EUYVBkSwKKk+0eUD9ncmNkyjrkOl9EqQkQdvQcNika h4wZCvr0t20q9czaW07g3V7pE4zajKot9qW3N5J7oJBlWo0fWdz3sNe4EzGlCvr7rQa9 2qn8BmW79OrGf0NKnGKeYzSuVFM0BJSbrrZKm4fuLD2a28t5D8dxSA7k3MjOPj/uNIrq x4lY14vVitaFllD4HyhrFQW7I+uJPo7PjY7hcJJ++jedSMj67CWWbHj/ajKcDt69RSSQ IvEtWK7FqhawC/2LdSWBr2iiXY+MypOUCYfGMBWo+Z91ozh2XouWt+kQOcfmkOpR27yG ALyQ== 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=8XTuXWq+xToiDvDobeS2vNcXere9quLdtk1afgwMbsw=; b=dsWKwQQpym+QwKTCCq3KH+jaCcaMwUB/Et7nBUzfYtUTJOPwLCc4inNsNGfuEZZw+O QXRnbBqHjZTeVp0HXp2rDMK5yY9yvbiBAT3YHKf/d+oo+Fu49PwSQR6tW/19tO128XOq AyyQIKHU0u2KiBNgeP7q3Slgc/nbClO662lSGmoFIxmZ/6kUuMtYPLBu4rQblhzlf5z0 uvlwDt37+KVhY5ywAknYaVEXlvbPZQHd5MWltN1bK0/Kh+hchYlXNaoVg3bMbgcgd21R Zes5miJHWUKIPJxJ4lPzXd0BleEomGTjxrxLxf143jPx8/vdjcmSpSugna8WrWLS1z6C lWkg== X-Gm-Message-State: APjAAAXPKs750O+xGluvx1Kv3pljrry+YPhlAxmgXlsfhFsUKwCIgAP3 KUq3tRhSQTGfOGwFpRmQY+A/q7ppNdo= X-Received: by 2002:a5d:694a:: with SMTP id r10mr43467409wrw.345.1560532718017; Fri, 14 Jun 2019 10:18:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x11sm5694362wmg.23.2019.06.14.10.18.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:33 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 02CBF1FF8F; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:38 +0100 Message-Id: <20190614171200.21078-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 28/50] target/sh4: fetch code with translator_ld 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: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , 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 Signed-off-by: Alex Bennée --- target/sh4/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson 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 Fri Jun 14 17:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166905 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2359102ilk; Fri, 14 Jun 2019 11:01:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyILDNXw4sfAQ9tZ934pKi2rpuk4B1R+vaceRedpBeHw8ehqMv/4WhvfKMcoKSp1HjmaM3R X-Received: by 2002:a05:620a:5a:: with SMTP id t26mr5153440qkt.201.1560535298349; Fri, 14 Jun 2019 11:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535298; cv=none; d=google.com; s=arc-20160816; b=yd1fn/JMWtj1puAgG6yTs2bxFPDol0iJRvF//Qgj8f3s1AubAeHMxxmiGpOiVIbj7G 6QvI7sdMuISdZzI15WOVpCohqM5f2rAOT9UeDee7bDDv33nxVP72Et0zRz4ZzYF8VLsg VmWMV4cMKq0nuRvPen5F6rz7Uj2vUGvIsLzeI//YBFlWKytyAIvEUPnCKRiqYIs8I/qW 1IuRsTuvlD/gMqtCbXdrEo+Sv80dxzBu899DEMR1xdQTq3xgpmWdrANWuJkqe5k0SbZ4 YEz/iZyWJ0gV3S+H6sxVHq7ftmQIcTjAHyKx1NfclLdUleqzOA7T6U+zXrn2mC8pvQQj LlDw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6P43XFojefi1AlRvRGu6U5nFz+CBkKm3yL3ZJgj6xbU=; b=Wvl7MaSGpXvEJbfxJDxKLHqDnA2H9dXu9rdKk9NOrbKFykLbEJB4KClLegwtcdUvnG aBae50tjGrVYMNR/lTb8CsyDtf4eQrIHTP04hUZBRjEaRkVHmT7Cih9ePH6tedYXsnRY 1fEyAOCQrxdEyy8+9lHFtaBK2pWf4p8/QEuq4LWRdFkX+4fGa21Huz0Tq+aWiMBgGOls r0WlPb/FgWxx+gZAe2TgH5A3KC5p9n610gWofOYxYZpqR6oX3bPWtNCgF1RzucXNBWEX URMVGEzO75mWDw5D1MJ+2rJo8dTRTJvJa8/uVNgpmGz5x51peuhwtAj1G2Eansvmfomb v8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D7sTN8Mz; spf=pass (google.com: domain of qemu-devel-bounces+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 f6si2267148qtd.251.2019.06.14.11.01.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D7sTN8Mz; spf=pass (google.com: domain of qemu-devel-bounces+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]:53948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqW9-0005B7-S7 for patch@linaro.org; Fri, 14 Jun 2019 14:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34064) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0J-00076X-QC for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0H-0003zK-Ak for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:42 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0F-0003jn-LU for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: by mail-wr1-x444.google.com with SMTP id f9so3316794wre.12 for ; Fri, 14 Jun 2019 10:28: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=6P43XFojefi1AlRvRGu6U5nFz+CBkKm3yL3ZJgj6xbU=; b=D7sTN8MzBLAHNKpUlI2YFWHFJcOSeugjwk0VvXAAUxQMfcJ/SPpSKZ3/uLe799EzlA jBtu6vs7Jh0pPB6ZQ2erWrztSE8KVByfVh32lDQNjxc9cQXI7j34FQF2HY63zX5+452G 1JmsUJ8tjFWBLWGQtNSx4u68EKZm4eIiB3H9bmyAtPJCA3tKE15uQIY0XVEvkfoTx3G5 0KhUhvA0UZjgO+WS+T+w56cNkQ6DnYMpva+8LJ6oQqfmaRpTwk+NOdJ122NQuE1kcKMU +zdtWiGRiZcwbFRMcUTBqEyRsXyt6Er90UvJoLjfKoxEb9yMV3uOUJomImiugtLxkgXB QaWg== 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=6P43XFojefi1AlRvRGu6U5nFz+CBkKm3yL3ZJgj6xbU=; b=XP1P7fqO3shiwhNes1ROV77stqKsYuihtDxM2HBANTFyrCyY2bKZfqWcJ6nWxWSosb rtIlKtEn4YfwpiYnJ7S80XfIKF6PiPmnAr71/xDNQl/YZ647UHoPvLsVoVxe+o8zg2Ze PPjfe/l9++lMk7G0k8CrhSGs62XyUcKncx2WRhs3kXWuCqlz5CMUpDMTwaEfssb45+Kv 2VgWV+avvY6NfzuO0WJcqUUksZwu5xjyWAM27QAkuaNCKNOqbVVS1fNgVNRMQyns8N6x nB7y9yB+iu/S8krurQ7wTUaBCbB/HqgIkH/l3LyW2m+nxYsGJtRe3u5IEx8pMhMaKEwK D9kg== X-Gm-Message-State: APjAAAXbtpRGf0KSJFszGBLfxykhxI9nFbOVFZInWzByWkBLG7VXOrd2 TwE12NYmjpHpH0aw2GjSDLxKug== X-Received: by 2002:a5d:63cb:: with SMTP id c11mr65591079wrw.65.1560533308268; Fri, 14 Jun 2019 10:28:28 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u13sm2127233wrq.62.2019.06.14.10.28.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 17B7E1FFB3; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:39 +0100 Message-Id: <20190614171200.21078-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 29/50] target/i386: fetch code with translator_ld 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: Paolo Bonzini , "Emilio G. Cota" , Eduardo Habkost , 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 --- target/i386/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/i386/translate.c b/target/i386/translate.c index 03150a86e2..bf4cd875ab 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 Fri Jun 14 17:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166909 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2367272ilk; Fri, 14 Jun 2019 11:08:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGkyguieRZvLCk0usbCfdAI7/yWYuooCQGZ3Z8V6X8Ty66L44bb7rEqr+E5VcaZnZoPhzn X-Received: by 2002:a37:a343:: with SMTP id m64mr38817120qke.75.1560535730657; Fri, 14 Jun 2019 11:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535730; cv=none; d=google.com; s=arc-20160816; b=jyk6/tJ+wTF62/26ygyMbE/36oIDsd3KxGAmvjw7UATsPrwWYy770KWoW6kG+G4Dzi 9HdkY9f5LUZ00KTX8v2PYzQS0ebuGJj/nY6/aJwF4tI9pmW6JmEJbsmEFcdcWDTKOPTe Ub6P3ECdoJoWSD9n45wglr6nE9IdwzPSY+IoqfkQpnpgNCeOcNFAqDVFzhd2poP1Az1Z WD5oDHr1X42fJ197ZuUWNZxD2xthx2g4C8R+jomjjLRfbSpvtSdtgB1HFfzA0FaeqJ9H RwF5o+TugvWaYD7s3nluoY+j8bl1bwRUUXVEKlw3wBdT6VTi+w3E+1U4edF3v474CuDz 6M6g== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=j/CmdxYOGc9bGjlEPT/VLtkTFw4z76NfPGE78+zNw14=; b=JZ0vPwAwKcRSq5VmhMc4dcgvHUYxg9pxoJVIMthoWZ7vVxiNLM9q4cYWM4X/gQe84H mzYCofZTNuuvCCZrpmJS34PbPUsO0CZ7WTRDm4S6vnJG1qfrRb5iH4+XdoGMShS4N9vF aIaiN9L4RpFV7H3f5ogOm3O6htPawK5hF6FoP950atiL7Aph+B6NxKkSdAwupOd9midk te6c0NWd/xo+VHW59xZw2nJ7ai8zy2va2JBO9/TOMhVfBJS5S5jFTsCHgMAu+xciWRss XQz+FUVn9WU6kj1nolWBP8poRvYpUPGdMNPDda4W9Tb9FgeIfMj9ch8I3RqGBO11lZbW rsiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z3ZbT0GU; spf=pass (google.com: domain of qemu-devel-bounces+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 o32si2274482qtb.402.2019.06.14.11.08.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:08:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z3ZbT0GU; spf=pass (google.com: domain of qemu-devel-bounces+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]:53982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqd7-0001Ob-PN for patch@linaro.org; Fri, 14 Jun 2019 14:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34123) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0N-00076x-A9 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0K-000452-EZ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:45 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:56036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0I-0003yB-Q2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:43 -0400 Received: by mail-wm1-x343.google.com with SMTP id a15so3145708wmj.5 for ; Fri, 14 Jun 2019 10:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j/CmdxYOGc9bGjlEPT/VLtkTFw4z76NfPGE78+zNw14=; b=z3ZbT0GUtX5OwM6uRBuEDG/RTBK15MjFe6skn6MeONPNFc/kyHqOsUUjfAmmPrJvYd SJLF5UWgaWFTO58SKZWBR09r+9JrgIrUlRvuDy4or+DO+vv7FulfQOCZLyS/pH3VsyHo v4pT78XQs0BgSxxurZIMAEEIqQ8BtIO+ob5JTakc+/SPIS4f9pgCxv2XgDxddE8mPW/W i7tw+BPxZVuB9tr/QGpUl310AoT5jJhkYktn6GIocFzhrFNZog44x/SubCkUVX1z679A wPg4D7/cLhLgzIJdjlARvgSA+ZdmUoYVweKKAZhNk4mIG4+LQl13iiQuFothbZDUFN51 8zhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j/CmdxYOGc9bGjlEPT/VLtkTFw4z76NfPGE78+zNw14=; b=a5DJooKlcY/HSYmO5vFwkVhCQVMjAihl58bxWChYhUynotyjl3C+iDtNtvQEj3Fzxh rgjgAIVffDVUQoXMhMa9koTDofST0uFE9GNUVIPuS3X3d2Hu8fPSlG3QwwybbWThtw+7 wKLHkEVUU0Q9pb2oGKgcqXojspIJiYENO7o5THZOZcZod3LxGmwgm1e+B3oAo0clpRFK XHNK23bEBAOqp7ChtIavBllkx5nEABfufIIhUoN4/8GI/a/HKRoBvhCoekMAb9j5Ka91 f9sikwbzHl10Scvq7IicBa5qCZU6yUBVxxxAHGNTm2hq22Vs3zmZRkqFtcpnbJJx/zoD I5bQ== X-Gm-Message-State: APjAAAWP9DQ125zEOGLWHpmFYz+lm7mEagG1qoyHSlall5xQkbLepLGG E5kEYN4QvJAAAnT+tUSI4/5PwbS1RiA= X-Received: by 2002:a1c:968c:: with SMTP id y134mr8267656wmd.122.1560533319750; Fri, 14 Jun 2019 10:28:39 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t14sm2431462wrr.33.2019.06.14.10.28.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2C3EB1FFB4; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:40 +0100 Message-Id: <20190614171200.21078-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 30/50] target/hppa: fetch code with translator_ld 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: "Emilio G. Cota" , 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 --- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 188fe688cb..36a784e293 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4217,7 +4217,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 Fri Jun 14 17:11:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166928 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2410253ilk; Fri, 14 Jun 2019 11:56:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVvUn2BCHhtfQ/tw0N9wtWXZ2TgULduOSRRQKyD42pFpPmEK4sTNscM8TgqOgVCGEUygWg X-Received: by 2002:ac8:303c:: with SMTP id f57mr82225432qte.294.1560538560176; Fri, 14 Jun 2019 11:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538560; cv=none; d=google.com; s=arc-20160816; b=qNJ2H/fB6GXdNbLaBmZLkDudqueQFzksNVDjwefy8bvi4HO0oqwW6cH1YttpXq3UfW ri5R3gFrqPNk2Ea9RgEPXrYUPQgZh+3fmU5GQmgG8usj8HfnYOR0hcGPnFDAyxkCfSK3 LZciBwbKULjW2N0klBdOi07hxuSIvfWHuQeS2t09T3qMJYKXesKhetmzSSQMbOE3mUEs KhGRDQ+tH4qyE3npxjeFHmfrQa8UxzXP0tYIU3qVNq4zNKn6Mf5TeU8Wt8BLzp6hY2kr Ti+5QAD9o5DpHEe2dm2FNb6+37R8IiHN8I/8ornKhtknDlijo9km86FCVP6Ql+De5cjx aqeg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nfJr9+Ou2ey8h7VCuPmwWUBSybcXHQgAvYfUsvi+vzc=; b=z7bNbNAYw2wfrdQxGoQNXyqgkH/kAtDrTojZdl0kvcihRN1Bf3P31VoNXPWapTDT1F NlbE35I822ldADAX6sdjtgMRacLAUBkn3JDn/Q1dYVGdJb6i+r9vGe9T7uU8iCRC9lbX WHUi7VEf9+MRkg2unDhou7TtxfC54BodgvlA5A6XUTWWGwQochBnNLMuEyVTZ0Uuqsj9 P05Qzc41XXq8TZ/c5J0x7DcMBbVqOouNh74P9YPsq7BH3PePLWwKr/grO9jPTYpOGjB/ YbwKCJYFMZyHmRzBTwUlRDuVlfz/yM8NFOW95fsT0mb1ka70G9oGRjIoJg3TWh5yyKVV eCPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ojcGZmQ+; spf=pass (google.com: domain of qemu-devel-bounces+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 x26si2323341qki.218.2019.06.14.11.56.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:56: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=ojcGZmQ+; spf=pass (google.com: domain of qemu-devel-bounces+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]:54362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrMl-0005dp-Og for patch@linaro.org; Fri, 14 Jun 2019 14:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34271) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0c-0007IV-53 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0V-0004KO-AZ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:56 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0S-0003tr-CC for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:53 -0400 Received: by mail-wm1-x343.google.com with SMTP id x15so3158303wmj.3 for ; Fri, 14 Jun 2019 10:28:36 -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=nfJr9+Ou2ey8h7VCuPmwWUBSybcXHQgAvYfUsvi+vzc=; b=ojcGZmQ+xqKKoIbm3N9OkM+GzwOxmfHhXXVr3vxm3+vCLGlUfmGebdPQucdzl1qkYP 7W4mB9d4CxMUdtYs5iyn7RacFKmYHpd2qO9P6WKycnIwmW36ZUMVKJa3OSSpeauO+4+o DlhA6J4jhmsneB2Rl0BJhSWEkiUo85VPRUc/F5dO94KZfzI4EbKh3Dbvj9s7fsPZ7YVe wUkxY+vRk18/WzUS2UK/2IUHGWJs0RZUJUV0g3TWq0WpHpu+hXitlY44cDKo3Acfs3il c6QWU87U6CY+g0pdfl6DIeaTHnTbS96L8kA5GgT1MKZZIRivydezYdsr0NfbCYpCNNJ/ rEDg== 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=nfJr9+Ou2ey8h7VCuPmwWUBSybcXHQgAvYfUsvi+vzc=; b=LEn4rvJr3sueAi0mLLDYB80KX2kWvEQNv4ixjpDHRT1aikuLL9PdcN1aws3OIPwW8x WhOcaZxwP6UbMicSE7rBH/yDh68N9sgjnXAyxUG75lOyjePbVEoTmBhJ6ZVMVsBEtGmE obQzIQmcHzqeEkb6WwDT/TnzCzsBWEddr1OWH9YycRgqGcXvqAVlKBIS49rNHzeb5uFy UFlsyLzQSDDrio4R4PsjhfqdjbcQfTKjZnceGZMb6xxHtCp/+WPDQ7EhquLOd0UgcSaS QIso6cYyB5Qm2bo9pY+QX09rdkaGbI95I6wvHaFCPDehimk/nGcIugn9/ABifzOq6YsW ciFw== X-Gm-Message-State: APjAAAWqFH1y79Z9CCIOVVNko7aJmjFPgoP7g+GirmVrq2OdhEqdxEr1 GztFc+6D66lYReq3tYGu06GAMPzI1Ao= X-Received: by 2002:a1c:b6d4:: with SMTP id g203mr8760124wmf.19.1560533315485; Fri, 14 Jun 2019 10:28:35 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v4sm2752307wmg.22.2019.06.14.10.28.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 415EB1FFB5; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:41 +0100 Message-Id: <20190614171200.21078-32-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 31/50] target/m68k: fetch code with translator_ld 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: "Emilio G. Cota" , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- target/m68k/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 2ae537461f..dc05c0d2ad 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -378,7 +378,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 Fri Jun 14 17:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166913 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2376835ilk; Fri, 14 Jun 2019 11:18:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrLFQ3lOEKsZRyypIaNzQmso74to5SK7NnxZQ1zetcOiMgdY2jkeZnljNFDmLNDG4MOE7D X-Received: by 2002:a37:9c15:: with SMTP id f21mr19912748qke.248.1560536294499; Fri, 14 Jun 2019 11:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536294; cv=none; d=google.com; s=arc-20160816; b=Uj3macQ/UkOmoTFqzs+VZOqaqnQuO8vEZsc1Gc60P6gwk0GDPOs+7Fl244F27aMsgT 8FR7BpWRn1Vwq0cQxr+WCCMaJlUCsDHGN+bRLtLueuO354wQ17A9FtEBGrvJVfFPOokR JI64V8iq//bnQF2catU2YDS4ykhTpL69sybAY5VkZxKDfh3qqGQTItEDvPWuU6G1QOOT gQak/hbIsfUbKqlBBJRUX1EfJqMKYI1vOgL0XJl4cvhwq9SmFHzGCZDW0r+gxmgHktRc GH5dpdrEBBc2KNoqHp1RgZMrtMgY9KrtFVcjvAcGBtuHHwGxBo+7tP97QNRBREH7y8ni k+PQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ITzNLkGufKFpiKfmJVh6vzZ3LsNbeBm40jej1S7JzUY=; b=I5iFqmlYMqTAQo/drsehKs6nChGh3h8C2sMcOpg8duNCyLgVKubaAMEZ0HzFQQmLGa IsseiJCNNP1Ew5BpEu6kLQGH25O0UN4/EmKqjLOsjwqTTI5d0PjWrg/B1Pw+b5giw8Ja Y5bb/UjCFp7E1gZkXPhcpLMFH/KIQNYPP1H7zHiM/VlnBEUQfwM2BDQjaGUtM0E5ZpMt vZm8L7b2EFDkZ/Za5OLaTSmJwaNAYAAg/OU2JYJHXkn6oIDfrcSSvhpq8ax9/FBpNC73 /YRvB7WkOjtf/t7ij4wkrwPGxBAY7V6T7o75I/jZ5ozQwMwhe4UfyARau4zbfNzfesTD yhOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Us/s25z0"; spf=pass (google.com: domain of qemu-devel-bounces+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 o29si2188825qtf.72.2019.06.14.11.18.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Us/s25z0"; spf=pass (google.com: domain of qemu-devel-bounces+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]:54046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqmE-0001G8-3e for patch@linaro.org; Fri, 14 Jun 2019 14:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58662) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005b5-26 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqf-0007Ax-Fx for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006ck-H4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x343.google.com with SMTP id x15so3130739wmj.3 for ; Fri, 14 Jun 2019 10:18: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=ITzNLkGufKFpiKfmJVh6vzZ3LsNbeBm40jej1S7JzUY=; b=Us/s25z0K5nigBSeUH+Yvy1688SNudchk+MgUS+New9ZmBtZ8RSKj8BzrNdDh+Hnp5 pVpm7RcHgcAF5L9rCDfjCFvb1bWqMRUv4f0ITJIyRa+Zz/plQk9ipYPBJUegk8OuXl3X KjMBzMGCuLmjHGKSxavfp7bcfnejBihNrLZLjKklbexep2qA0/qzZjJukTmBFvh3ilzk bxE9nNtrExzMZq2oXjAZ5QxEvFjUjbEtBSCgxfJ6OozVVZuB4nHyZXkzMRjT7+oWfs1K M63+rYYj3Gish0qnUVzKfcqXB18B0yQDBcX1m/IFXkqMKLChV2RzTJ9+ov+WOE1sWLNU 5+pQ== 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=ITzNLkGufKFpiKfmJVh6vzZ3LsNbeBm40jej1S7JzUY=; b=nHF9r/4afqMyuU560D+MgLxYsKFHYMLU5o0O7a/jwikDqQuQkuBcb8XO/jVBn9j0uX 7F5Q07Lws7whBW0T1jOCjCihLchHBSPWQwYDu2m3o/Lr9x4TVsQoO87EO3JMYgU0aBfQ x41mlanRkSfsLnZVpoFX2J2q6/eDwficPVbIMKPcKUbGu+JJRxeykMF+vd1zEmmpn042 5Ou6vTmD4O4D9YGLJeoudCstSfxhqMiz0Dtf+rof5nhtaKH3UB1NoQqgSFdR/1PtS5AX 8aec1qnDf5u8UyBxG/FWJbn/elktS+gTTfQJk+OYbgAtW26+UvtMJOpBFASTSz8sCzaO bRtQ== X-Gm-Message-State: APjAAAUUecKh4qoVJqS4pxcmkPJ7nGmwMMG6fy4r5FmgwBTYPcHjRudh RtEj73J3T8bmdyBfmBdp4TXwJA== X-Received: by 2002:a1c:b684:: with SMTP id g126mr8632045wmf.176.1560532709061; Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 67sm4075045wmd.38.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 558911FFB7; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:42 +0100 Message-Id: <20190614171200.21078-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 32/50] target/alpha: fetch code with translator_ld 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: "Emilio G. Cota" , 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 --- target/alpha/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 2c9cccf6c1..daf1e05cba 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -2989,7 +2989,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 Fri Jun 14 17:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166863 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2350835ilk; Fri, 14 Jun 2019 10:53:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCjZ+QJfXx/aLexdJAL2B3GG9K2MK5FV/B5UOLLvjzBfxdD2u1pUVb01HNUymdcf6ogOQA X-Received: by 2002:ac8:3907:: with SMTP id s7mr36183771qtb.374.1560534788116; Fri, 14 Jun 2019 10:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534788; cv=none; d=google.com; s=arc-20160816; b=H97odgSK9kohZKgVviqEWeHWvDljzFMc9LmT6g/q8ufhSYlAnmvPKjymYOKD59RWPp seMBbJx8kpramYXdpUn2zGPDVrC09Bg+NaVUcmuLbACr2wjOgsV8hQUCUUUqHfj3l5cx bYkaD121OiXtS0Kj2Ftz/0G0MiRgpaShAAL7A665sNk6kBVOFJtnT7V46xdeySUOAHKP DRlOQNljWXitXaEdwLLqArMSxHMtEtLYS9kmbooj8ifix2iNC4I6rTaMvmY2HdWGvGfP xhIcOT2+vtd4YfHY8aCotLRvkohd6WczEbKQzecHg92opL/P6c8XL848ctvQYDo0EkRw /kXg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=qBxTdhQNZtrN8TCgxYqVNYuvZXvpIW53Hq/nYGE1p+s=; b=PAcHlonTbIMBzz5FLrzYTIgtOtRmz2bOnuLAjYnOLnZ/WF8enNU767X+ok6Wr/FUMa Dt/qm35w8CRFg29VNlBW5gb8VsnDd3GHDeAwR226dMqEUUhguasG0SGOXfAZEfNBBmSY 7sdABmx9tJxSi3rfLknnlg7oJF0QdeDWScmKQThUSOTp6qsJxGsAA8OrSDnlBLtroYBn eoZ67C674u0pwG86LMyceFfneF4Gp3fEUq1VUt+POsE77q/O4MIxX70Fl2BQMZTFMvLc pQ2QgD5lN4FBqu1OLOaW4pnr94GSztavgeuw/cjFEA/u2HGsYjOYwdrJOMxOxh7nxVaT jHsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M1DmIUjJ; spf=pass (google.com: domain of qemu-devel-bounces+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 c10si2292749qte.165.2019.06.14.10.53.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:53: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=M1DmIUjJ; spf=pass (google.com: domain of qemu-devel-bounces+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]:53902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqNv-00070w-MD for patch@linaro.org; Fri, 14 Jun 2019 13:53:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58666) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005bE-5a for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00078m-TI for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006hj-7i for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x341.google.com with SMTP id z23so3055013wma.4 for ; Fri, 14 Jun 2019 10:18: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=qBxTdhQNZtrN8TCgxYqVNYuvZXvpIW53Hq/nYGE1p+s=; b=M1DmIUjJySM8HeXdTGllOAnCV5BQWwrV1ZQFtLnDqxSe2LLP/N+uoi7AKRg70JDFSJ oaPMDLXPqfdBoiN2qTzSdyo9HkxQbKz3psNqrDLueGza2A5702DY+6pfV2by6zN+ksVP 8LNHPNSNEF2dKg9M71LyVkLbHN/3FGYzfouiDnEcWwWmmRappMgfb3EIC6ryJL8Mr8Nq IBWf+blPzV7TKFV+e6rYxhAnMFfjBv7HzzC5q6HtwDy4TXrkm+vr01IK1ep6vOgr/jkE 9wvXj4Rxd0C0sYh1G8L7uf3iAO1OTW2z96pfBTT+nTbpauxHivoN4HDFKn2df36b+UeI ymgA== 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=qBxTdhQNZtrN8TCgxYqVNYuvZXvpIW53Hq/nYGE1p+s=; b=VBjlFLY3lHveV1gIWbiIa2xmed/+SfpBPaG416TcsOWZ4KE7Zwm6EbLk/BvLOy6Nni QVJg0z3m/aGpuZykZBNx35l2etGa4BIHtIZECPfr3DYuLXvwjUtFeRSNuF47mNOWFbtb 5pKK6GeH+DFzhXVy9Zgyt4BSu0YZPv0+mxC+zdw587MuEyrbYARXJI1WcVjaJYG1CA4q DpvvWu3uKkYwxJJ9PDB20O6b6FmNzubv/3mUIxJzW2GxRTYv3AYX6A1LH6l8yl+MJSJg QPW74mhpjaxQ9reBF+6e+rR1edvnYavxa8ZpbRh9+a2opDAULBGVAnq1nOetlzMUVb17 l3xw== X-Gm-Message-State: APjAAAUkkKECLmc5t2OaVKrs4mWOiF65cNDYFeFiorX0pjk5Pf4OBfoV XfepiCz3yaG3elpPRLGTGnTaFw== X-Received: by 2002:a1c:c549:: with SMTP id v70mr8517710wmf.135.1560532711546; Fri, 14 Jun 2019 10:18:31 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s188sm4164408wmf.40.2019.06.14.10.18.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 697DA1FFB8; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:43 +0100 Message-Id: <20190614171200.21078-34-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 33/50] target/riscv: fetch code with translator_ld 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 , Palmer Dabbelt , "Emilio G. Cota" , Alistair Francis Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- target/riscv/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 313c27b700..899abf41fa 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -793,7 +793,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 Fri Jun 14 17:11:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166919 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2390302ilk; Fri, 14 Jun 2019 11:32:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQFFgvraC3X1PA9/58ud3K528CULtNnBBnSQe4G6z/ZtjnAsPs6khUiDVhJO22X6Lp+kSQ X-Received: by 2002:a0c:b0e4:: with SMTP id p33mr9735389qvc.208.1560537166651; Fri, 14 Jun 2019 11:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537166; cv=none; d=google.com; s=arc-20160816; b=hPUzamRzEHe5wxfNTrv0HH0GCpaB4XiW1dATS905zOYV4Hkji0PX4Nagx/fRPtkEX7 9Y5LXkHdd5O9RktqghgVu12B4UczRdP6jotCTBTU0fl4DSwQ4ab5Ty7V/dqLpvxry+7L 0f1HaDzX32wupcuHimdGAEPh4opKNqUPG6CLmqVNpwtTUoDzLAYBKFzkA/bwiXp2107L y0nCgFQ3ISZDN8tntNbfEvDuaHaO+xcstokMlP/+jRLHZs9rvwV9Gu3s/veRzuJAUj/7 S37Gl6BafROEFDpoj0pzdVdRgFiuhmuX8n06tWX4cSg6dfqANLo4EjMJWDtZgG7HTaEn MXDw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=HqBVQy6B4RYG2ErzndHduRIrrPjVT1ZXYEPUu/ciMz8=; b=eCLC7zPD2Ku4da+s/uUpaeWgH0QWg3YLCbOlnbWdflLvyPopz31yiYiPRdZLB78UW3 Nmhv9MAOU9EtkyA+wvHBir8RpNaWp4GYnViiBmev0Vo6JXro4K7H+ZcBXbsuzCvV1F34 UBotbQa8uzxpH66HN6xH8yOFFuIFJPTHVkwS6YbBYHFZng6CrghnEF0LQy4lwOg8BdN7 X9G8NY1c7At4S2ywrkfjgaS8P0ARAssK/fUAzj/O1gMnyHsKcDmt7igrazdNxNe7ZQwd kGA7jzheKi0HH+wuGTsiNgY2eiFq3Yigj3hfxsY0PIcFw1aFv3h++Tca9ipPsZP4SBHW rVbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LT8cYFML; spf=pass (google.com: domain of qemu-devel-bounces+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 n32si1979516qvd.214.2019.06.14.11.32.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LT8cYFML; spf=pass (google.com: domain of qemu-devel-bounces+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]:54128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr0I-0001gA-5f for patch@linaro.org; Fri, 14 Jun 2019 14:32:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39245) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJZ-0004Ty-Nf for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbqJX-0003WH-OR for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:37 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:53607) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbqJT-0003RZ-R2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:35 -0400 Received: by mail-wm1-x344.google.com with SMTP id x15so3209805wmj.3 for ; Fri, 14 Jun 2019 10:48: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=HqBVQy6B4RYG2ErzndHduRIrrPjVT1ZXYEPUu/ciMz8=; b=LT8cYFMLNKMTk3dEokm1wL2vbJqCrB5gtaglpgbLMpSqwJHrP752/Bl+w3pA29KTlQ /Aoc0f+RnMt3mjFkspoJdgea0iTDqUlbX72lj6FB+Ir5grgAoY0ov8N0j6Z8g9LPku4G +X1CXB9dj2ogOH1q4OwftL9yi2VI9j/nuAxEawMx13T2irMt90UhXwOLzHjMbf4xhX7d vBfoYALwOunYlTkBCkjKCga6aqqIezKzwXD2ooYjaF8Yn/jmfsiC5atso6pfvbo1/A+d fqilNBYxBMpyU4fiNPhWC+oXN2tK8ovwLydpXdjktev2J51RNOH8bycUoHwfHH4BdpGF WChw== 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=HqBVQy6B4RYG2ErzndHduRIrrPjVT1ZXYEPUu/ciMz8=; b=n5tdzU1vBxKLugnkmpGCoMs6wFU8B1x0aamro0pe6FSKs+WSjBow+dZ4XBMfA8Xna5 3QB77q6i+p4liHob7+uv3UISu7xip1wf34+sRisELPe55rllcvMsnjsRarSZXGmV8gGj Ip1N4FbgI3POHAfu1DoIjRCwABoBlOzIZtj5hQvWxri3HGieQo/hQ03gIk4IgDcgx8g1 bOOOOc7wF+Bw/7pMRA4WHU+wioXwthMxAo9vkNN8ShtmytSSji/OCFidNV8SGhK92V+X GG8Su+2BkRLF8TiIZbvyWBqaXAnLZa3DBMDGEm1VrGpQJ354o5T5hFaolBa6jbfLuaPu 3WJA== X-Gm-Message-State: APjAAAW8Lv68dLydkb2S9arbnQJnMPE1sm5Ngc/rouzbA1sCgI3q2c2v 5WqugwWG6CJ4HtfViFF67c3HDsNODI8= X-Received: by 2002:a1c:cc02:: with SMTP id h2mr8679411wmb.13.1560534508257; Fri, 14 Jun 2019 10:48:28 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o1sm4604546wre.76.2019.06.14.10.48.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:48:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7E5861FFBA; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:44 +0100 Message-Id: <20190614171200.21078-35-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 34/50] target/sparc: fetch code with translator_ld 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: "Emilio G. Cota" , Mark Cave-Ayland , 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 --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 091bab53af..c91ff11809 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5900,7 +5900,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 Fri Jun 14 17:11:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166861 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2349590ilk; Fri, 14 Jun 2019 10:51:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDmRU0fgjLf2SC9ukDsO17QiL2qYRXXT2RQ5cNkac/iMr/mSznN7sKEBkQNWED8JSUPvLj X-Received: by 2002:a0c:bd86:: with SMTP id n6mr9532239qvg.183.1560534700325; Fri, 14 Jun 2019 10:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534700; cv=none; d=google.com; s=arc-20160816; b=y0zRDfuiMtZPZVRlBcqbDSB/wdvqYtw26aY6ptusvgOVsZPkF0RiGdBqma8/whrEBr XqjDbhu24mkJaYJDu9PD/utntTGp/piQJaQ3HCahmXNEhTNhZLxX+3hlDKpE9Zqk72hM joYx+sCb7qgz+MtvTB7aUyi3drVSWExPHvnDzoUElLKtVYm4bhr+D/kfiFrr6NmKJUKp GHeFw+t5sDLBKARaWceMRBMv5lmpe3kz3OfcF1WRaZq6cj3Ax/mO29EacWHt4sICUr2D yZ5FVUaXKbkGIdb8G1LOW0npb86MGFEPs8KbKNk2JtTEWzvG2GUMPalHwb1XOWCZgQEC hcjw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+b63Y9PbLI6+aITJW7vKd87oH1u7+0WksIZYyx+bONM=; b=fJ+/eUyWoLK2XJss23dNQDHscTAl7OKL9CuKUCL/Nfgld0+z6iHdm0cYLKRE+EHCqh D3HxtexQgY4SDnR9bLXnA0Jm8JtfqYl9s3mWJy+D2w83f3oC14m02e/nKn8zbupkkLQ9 OkkzHENzHdinUOVNAaaXcRAlq0LSioJMfyz416Td7TJpGvmM4bPqj5OBHITtQubGcezK vr6TEmyn1TQb6DqOdoYyGEh8h/i2DWJqC2AAyoobMN9jGIlV95u5Dj0oZIpNnmHYwA7q XEJxmPag8vUiv/f8Uczuqr1SX9/gMGcTT8UY/P4keLFlFPIO+C/eFWY9h3II9igDBXtu dW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TJFWFBhS; spf=pass (google.com: domain of qemu-devel-bounces+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 r19si2174242qvj.40.2019.06.14.10.51.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:51: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=TJFWFBhS; spf=pass (google.com: domain of qemu-devel-bounces+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]:53896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqMV-0005tl-TC for patch@linaro.org; Fri, 14 Jun 2019 13:51:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58667) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005bV-61 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqf-0007Ap-Ga for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:34588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006aI-As for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x341.google.com with SMTP id w9so9349677wmd.1 for ; Fri, 14 Jun 2019 10:18: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=+b63Y9PbLI6+aITJW7vKd87oH1u7+0WksIZYyx+bONM=; b=TJFWFBhSps8aAPjD6uLAT0Tj95Vx5KdrHJJEcmLqIKy3NVfeifbGwtWU9ASkxDdHcs S5IdMvLLHIFU0jhX5bHV7uwxlaC33Q3qSVYxeK8KjbNuUmzCX30JZT3MkZ0KilqlQ0UM hv8LHFxDRR9N7rjOyNp8kUBTQUgaJsS87DyuiYza0PKxIqD+QmO2wa9aXPNVduRphSYt 6fLVZtMOK3ZlE9WyWK+MyT/T1HVaWzxtpP/JPIesF9MF91qPjbKxGI+8pbjR3zuGrrgZ 96bKRej71AZMxJggZ3/Ol3O5bv7RJwltepRZrJQ+7n234nBZgZwp7oZrEpbJUtlzmis6 dhTQ== 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=+b63Y9PbLI6+aITJW7vKd87oH1u7+0WksIZYyx+bONM=; b=EqYVE+y0Sqv2IkYGB023FKjJ+n++ms50keGfYrhxDnNYrSFv9SFiSxJdtUf1XjxFoZ glDUAf1P+bbDLWsO7DD4CnTeNudoe85GYA5hy1VVCtVa+sb+mY66pgbpnztKKjJG6LKZ FUC2Ru5fbtsLKC+LDd4rmNqx5zu4/idIliSJDCe8Pa3+7puaWmxKliFKixuQJ6o3mk7Q yo1L78SZWouGe/WjHjWUhMABjC0s8V0DvHiEfils2rQXo/8MiQeZeGDPaTLdNLccdoVl dLW5mU6SOOt6Xh49zygiRMP8h77akQ9kos+xq/vmn/9+jD1NjHBZ6uHdKGJkEKAI5oWr x+bg== X-Gm-Message-State: APjAAAVPFHzX6r66g1ObmSHoheiBIRQvxegGiEBQe13dc5lEljuhzEum 3j0Gl1l0qX4hbxlF8SoY7Sx48Q== X-Received: by 2002:a1c:c003:: with SMTP id q3mr8747990wmf.42.1560532707343; Fri, 14 Jun 2019 10:18:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o126sm7688314wmo.31.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9326C1FFBB; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:45 +0100 Message-Id: <20190614171200.21078-36-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 35/50] target/xtensa: fetch code with translator_ld 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: Max Filippov , "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- target/xtensa/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 6f1da87875..cb849ae2d9 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -863,7 +863,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; @@ -887,7 +887,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 Fri Jun 14 17:11:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166927 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2408560ilk; Fri, 14 Jun 2019 11:53:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKQn4I8PeuucJgT+WRZMqKP17+3rFjq5iDNi+y9bMe//1HW47v/ojj3tAlv4Rh7QH3YF+K X-Received: by 2002:a0c:d4eb:: with SMTP id y40mr9580692qvh.30.1560538423670; Fri, 14 Jun 2019 11:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538423; cv=none; d=google.com; s=arc-20160816; b=hbPMZkT3AKiqTv6YpTnCgeGghEJVorjcdG6w+lJXjeK2dIeYbKEd513TcqtIJRdgUt XDMxvmNAr/mrnbCPvVYx0ekJL5gvtMqTv/aDY5b4dYh9d8qfb30ZsAB+k9PKPvobzTk6 4DpnvLExW5NR2Y6ALwUwUgHWYLmNI3LmKCQmcqrLyP/78HD4P7Gykg21BasYy9rx35eY QfaaLuwyLQ5mMzEYf1iwH5E5L/a9zhqtdW2DLkTmmp1n5Tya3teZw/i330uhswX4uGNn OsPwTHa/M//bKufYvs71kDuhZC6Y09zDXc2drDqv3+B6Yg1Y/SupgIFfkSr1BeO/muin jcFg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sbV6bhfix9ogursybnzoCKTzFmIQ6JokAy/mT287wFE=; b=E/aXjmwFiZ19XgtscUzdHszWYTvl5dBfjtDmddcurzlyIvh0EXXe0b+aizz7a6/ZOw w9cj1NtIxD03i83HJX1W2P0QwG1xJTkrgKRM7qh3fXwsyYDxBfooVOcyaLZeVyfAtX7/ AqU9Qmwz4PgZ35OqPIe1OvKHqd9ijWfE9jPPwveeyo3ZiNdruY20O30z0rvuFxoeWst4 cPfBhF2XavS0g3sPgYGXsqRMqGx6oDME5x6gC1aZKhCiAuIqZHGnT/6UCL0sZjEBbWf4 T6mDQK3IdcxANtnx0l+0gH4c2CrD4QbnA45TClfmc2C4Uoar3mUSlkiFZohbVfMxuFFG j68A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mfXJqv2i; spf=pass (google.com: domain of qemu-devel-bounces+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 y123si2419865qkd.205.2019.06.14.11.53.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:53: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=mfXJqv2i; spf=pass (google.com: domain of qemu-devel-bounces+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]:54328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrKZ-00039t-8C for patch@linaro.org; Fri, 14 Jun 2019 14:53:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34263) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0W-0007Gh-Oh for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:29:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0T-0004Is-Ms for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:54 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54877) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0P-0003pL-Rg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:51 -0400 Received: by mail-wm1-x341.google.com with SMTP id g135so3141217wme.4 for ; Fri, 14 Jun 2019 10:28: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=sbV6bhfix9ogursybnzoCKTzFmIQ6JokAy/mT287wFE=; b=mfXJqv2iDKtSoCK5JpfLwekLTuzQhzmRoOwcpNsgqBTDsQgz1k0XI/Jy7SyZNsWl7X rZ754yFoQDVDymkVwTK6Evf/jnlMn83q+Ha4ZEkChMeU9jF0+HmQ5q/G/FHkjSh19rT5 VLh3cF4K71sYO0Z83vgRBPJ4kAGsjMNoTWCGECreeAs60Ta1ZMKtfksMDiNjJJ9+RDT6 pOCWG5DfdIXprdWbBaeFLmPaISOQdor+KcAEMBmsI9Jn4sKFH+3f7/rSp+jEBBJGRx2C 5k9mllWilp2KJx0jjYBG182A2YaZtZcLj563OlbeitiB+D/2SvTmuJ/45cL1AKoIrmvg Wziw== 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=sbV6bhfix9ogursybnzoCKTzFmIQ6JokAy/mT287wFE=; b=p5EExkBzhEXte9Hc/FYCLs0k2F5aHOpn6KfaZNAHghO1xDVytv4/VTsDmHZarSFCp3 ldJAC3hHM12kJCjcPIkoW6U2iIGRvp6rVNJHp+RGJdP3YyrZaHvxSePE7ya+CQD8cOBj HUeCt1x/jFUnYtH6ZpEozZS/bTewDenCtnRfhagoT9DkLuri0brBNjJOxnTmCnEfMK3v o88tsg5MNwdo6u2jUa4pOUrnyneSOFO18/vmYkJLy1w40l8iwqO+xwxkeA1t2ZP59GsX HYAmFqi81U2RWKfKox3MFhn95xbpPmgyr91T49LelNfnd/fv0oREA+qBs0cA3bm/rn89 k3oA== X-Gm-Message-State: APjAAAX2njRb8ecQocofLNRyJzc7NwVBULuG7BrP8m3Ud0dtqoElS9iT sGGiEBSCWfIifKqGrxSNe5bzJg== X-Received: by 2002:a05:600c:2383:: with SMTP id m3mr8616299wma.20.1560533312982; Fri, 14 Jun 2019 10:28:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o1sm4513463wre.76.2019.06.14.10.28.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A7F481FF90; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:46 +0100 Message-Id: <20190614171200.21078-37-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 36/50] target/openrisc: fetch code with translator_ld 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: Stafford Horne , "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 4360ce4045..7df4c68d15 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1305,7 +1305,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 Fri Jun 14 17:11:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166912 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2376545ilk; Fri, 14 Jun 2019 11:17:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUPKBrfiSyyMxhjulTZHToSE05FQevHfonPuwd3heuX+i1qxbAmxkp8wChWhMYizXnYRYG X-Received: by 2002:a0c:c612:: with SMTP id v18mr9563430qvi.215.1560536274693; Fri, 14 Jun 2019 11:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536274; cv=none; d=google.com; s=arc-20160816; b=EsoCM2i0oUZKU9Ey8ZdurYjWDSkjb8d8GG/EIPFG5S7Ya4tlBzqAbhdCzlm9t3hwXv aB7losJwmTmmBNFQOoVq9GNe21XPngy2cgOTnvjUIPJ/99n1+VA5ZnFYEvjLMSOxb4yN w5P44ZFDVJmwWzmyHmH9G7D66UN/bRIxdj+agXTvxJXV4M/fEjma3uTL1wsINgxRElGt j895mJhJ4xydsIp+f1cPy4jmftSk7iEIiI+w9Ez44Zvo2tmIwPgbA639rjfW/xM3X8MS SczwFNV39W4B0pIywXoaNeRfOp0xkZPTOw8cn3zUXihGf5IEpWbKJRn3N6C65mfXMMEH q5bw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1Ghk3o46eKDRyTTJB5656nYsZZ0fzl1fP3AqjgtBmAI=; b=qJNEZg267iLoMNwygyHYSGAsU0qcROcJwbXv5k7yp+jC2kDjZaDP8KvD5VsrkCmWp2 PfXYUlMnXekzEOfKN7FhjF8Iylr7+JHx/OtaVcA9pZWjWFX2BZdTL+ht3axfvHiRAmIU SrLH4GpJ+mjyoZUs4QzE/EENbkG++fSzAJ3KEjinJFBiUVDBUjZRl4zKBwNok3qQXVKE 6CF46ztXcbS3G+g9VsbO6lw7uno9LmOL4e+Zp1AAQnQCUMHm0ZIvyD6lLtvOTaG6ctCf mcJiawFclDRYY7DJW8qg28aPN8QcWm9Uv5prrdLFnCbR+W0W2LkZcc3hLu1Nfd5/vGUF IriQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VwqLkXGR; spf=pass (google.com: domain of qemu-devel-bounces+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 m18si2215047qtp.253.2019.06.14.11.17.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:17: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=VwqLkXGR; spf=pass (google.com: domain of qemu-devel-bounces+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]:54044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqlu-00019A-AO for patch@linaro.org; Fri, 14 Jun 2019 14:17:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34169) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0P-000799-S6 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0N-00049I-CX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:48 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40095) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0L-0003t7-TX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:46 -0400 Received: by mail-wr1-x444.google.com with SMTP id p11so3359786wre.7 for ; Fri, 14 Jun 2019 10:28: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=1Ghk3o46eKDRyTTJB5656nYsZZ0fzl1fP3AqjgtBmAI=; b=VwqLkXGRUWthSaVtjmb+jBib3TYQEhx3Q5ObYEZ1DabiVFTKIrjtG//tVzbxb7y3QZ 2PVeAGWCFBZX2Er7RmvQ1wLpOOzB1oUkkeR5eaClhp6wllhEkBUrLn99hD6liUL406Iq hftSp4SmKu7ogJI+OEjsPvE7UzA2GANKkn1cGQt9XieD7V6JIgB/kK5NuzHKL0pU6zCy bzokDUlBi756iZHs4+Zw5Rrfnl72hqRkPK9Kw4AZDXLRWfG9COZwvzU0fALvEQLR1hRd AMHH100a9hMiFdOu2pcn3QM+C9upgoeWZrwbHWhbf8zvqm7UBxFbdN2N9bE9VH5cyeqn vrgg== 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=1Ghk3o46eKDRyTTJB5656nYsZZ0fzl1fP3AqjgtBmAI=; b=leOyu1Ekro3Q+XT6lpHW69Oz+2muGY5p6RVvkkWYNZMR5NHstYijAvxYuw28L8xBFQ wkSmWa66RiuW7s6F4YPTQMR49SGZu7J2FoVxQTcD3EFXEW6fI2idjbMXYDZj1deg/7d6 f25J8+CTnRV0JGgaH/OJ0DJeKNElONO/Hz93RG+gi2MbTM1mTx34aXKj9Yc5JbjqOnpM Ap0Hfc8yme4+LQ7D+AnfujIVGMoPzWOUIF0ehi2XLRLP2MY42dukarUkFH7BnfKjnqd9 3r48oOf6svHrQbCH+RgcyaEBts/2Q/Q7YA3+A6Zsrm96uY6vrXtLSu/fblg/cXIH+QqH 9RNg== X-Gm-Message-State: APjAAAVYDkDR7jWpxyyGM1B/C55D0FBD/Y6JJ5/AOKXrLejumdArvdsl 51p36Xjpl9Ka7409RSPq6RnRoA== X-Received: by 2002:a5d:5283:: with SMTP id c3mr35035556wrv.268.1560533314954; Fri, 14 Jun 2019 10:28:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j7sm4655451wru.54.2019.06.14.10.28.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BB9AC1FFBC; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:47 +0100 Message-Id: <20190614171200.21078-38-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 37/50] translator: inject instrumentation from plugins 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: Paolo Bonzini , "Emilio G. Cota" , 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 --- accel/tcg/translator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.20.1 diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 9226a348a3..161b494a54 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))) { @@ -95,6 +103,10 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->translate_insn(db, cpu); } + if (plugin_enabled) { + plugin_gen_insn_end(); + } + /* Stop translation if translate_insn so indicated. */ if (db->is_jmp != DISAS_NEXT) { break; @@ -112,6 +124,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 Fri Jun 14 17:11: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: 166875 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352341ilk; Fri, 14 Jun 2019 10:54:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdPIPPuCqpg07wfdEAokTnnKPFiY9KmxWWOxH04KyJxncXw658OOmev9Yx1raBrttlIF8P X-Received: by 2002:a0c:8aaa:: with SMTP id 39mr9511951qvv.17.1560534884314; Fri, 14 Jun 2019 10:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534884; cv=none; d=google.com; s=arc-20160816; b=ysvmMCa6aF9WaeBsUR7/dfyq74tkllGGLAfBtlrpgnClyPUw/yx6DCrhQ9lKvu0cXu l6gf9j4M9oxX24KmAZ06FvGPTi8lrxbmLwix9iq+5CCIL7JKdtHw9bf+TGY2eCYTB3aD +s3Et9g2fLhzHuYGDyf52D4JaU0QGxrWp9mvIMAcxNEh4YeRIzVJXqQ3uATYqj5qvmPD 4gWlx5eWTpHV22VJM5451vdgEbB0qznVQmXvVhVRAWzx3eT7RdpKrTqUHVqHU4G/Q1bV VpHZFFYoq/28WaUD9J7nMZpfN6VoZbazODEIMiWfIObOgH58JOlUVpP1kZNq2ksA9JG0 L5+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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gsafAaKWWEo4Uo36EmX0kTE77G4d03quI77xyI/6ztg=; b=uk05x5ePO/yuQcH8T5AZYRlzTTlayoKoAQT/yG4KVaRxvOEESQjev3r92OrvBsLB8j WEOZPnbK4LVjz+m3rNLY/QKNgiyBpPHvgLL501N42a9ShofXmr/99gETTice18BDgHIP Cb17sDS0UP4fQqodcqEIkovhUUTY+g7qqB0d0GKBOTk+D9m2c5eO6buLl4OlB0GnWHK7 0PBBP+24VgayNtfDVOM6QlVsUI//GrY7DCnAZmn/jdCMnsz8PusacYiT3XZWUNLXaJAI W3bw+E9e1T4UbAOltCYxas+YR332i6b+RVIBfxbe/O2RQ17qqgXk2XX3iXoxAdkhMibS pVDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zaCNsjX1; spf=pass (google.com: domain of qemu-devel-bounces+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 j7si2206144qtb.118.2019.06.14.10.54.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:54: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=zaCNsjX1; spf=pass (google.com: domain of qemu-devel-bounces+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]:53914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqPT-0000Qo-T2 for patch@linaro.org; Fri, 14 Jun 2019 13:54:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34005) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0F-00075Y-Ba for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0B-0003td-TX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:37 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0A-0003kk-Ib for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:35 -0400 Received: by mail-wr1-x443.google.com with SMTP id n9so3385863wru.0 for ; Fri, 14 Jun 2019 10:28: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=gsafAaKWWEo4Uo36EmX0kTE77G4d03quI77xyI/6ztg=; b=zaCNsjX1Sklh9vJ7E9Ciq6mN5AED+FXPDKin3o4rpH9/iYlUeuUcdmMDAwAfkBPcCD vXTH3tB9meeGKyTLyf36QMweGwyE8CP8wypVMv5b/sgIVy6H6LII1DAniff5POyWPhIf VXyk3E8PQFAgt/85+vfDJHuT36bWIizc+SWn3ZxPdeSPgCnY5nPST/thWVKrZAaWs99b /jsyNFT/qXeeTQa9ZX8//sRsY8VWmjR3PHFn7R0/d2o/bJwbVyXZ4yeEitrqZeij3B1T YPrjft0KgWGk6A0rw6LU5rJJoHnPaz2ZH7KjjRbGe7aDKG7m1YnhGUwBqtlzLX2HE/Vz xcQA== 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=gsafAaKWWEo4Uo36EmX0kTE77G4d03quI77xyI/6ztg=; b=DQ0tSY5JsWuxXhX7nyBKz6pItMIUa6K4lS1HUxic/X8kbNmunnSOpOyQGGgUs2pcGS ZRymssa5o9rUYJk8sDRIBt/O+KLh6mWpHAKDkW3fvyQeHl8iwg01V3Akx5OXgi+aI6dQ LDEcce8NE5o5Lei6rGkhthlZuT2JXuQ+y1uAOSvXNVQ2JTb5DMmwHw+gFaL6Is0Glgfa jNU/mpR8QKS4JpBPCs70VMxdVd206WEPZLftsUKECWbojsg6OcD5qfCqE3/qsDpkTgA3 qCd/5s9cNDrYFzw0VSjy+w6nL1t+r5gJwHB3ELrxYb4eBNoR5IsLMzMAChhwvvsL7TjE Fxng== X-Gm-Message-State: APjAAAX9vQ6zdx2W/bTUcFAxaPKJs/CN7Tg+bVye5e2uyNi/JXRq+wxV QUnwm/fV80ETdhW0sMa6xnz0w2sMvig= X-Received: by 2002:a5d:4b4f:: with SMTP id w15mr8689164wrs.199.1560533309569; Fri, 14 Jun 2019 10:28:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b5sm3951472wru.69.2019.06.14.10.28.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D5B0E1FFBD; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:48 +0100 Message-Id: <20190614171200.21078-39-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 38/50] plugin: add API symbols to qemu-plugins.symbols 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: "Emilio G. Cota" , =?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 [AJB: moved into plugins] Signed-off-by: Alex Bennée --- v3 - moved to plugins/ - include qemu_plugin_reset --- Makefile | 1 + configure | 69 ++++++++++++++++++++++++++++++++++++ plugins/.gitignore | 2 ++ plugins/Makefile.objs | 14 ++++++++ plugins/qemu-plugins.symbols | 35 ++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 plugins/.gitignore create mode 100644 plugins/qemu-plugins.symbols -- 2.20.1 diff --git a/Makefile b/Makefile index 37d396ab88..f3f0c68e85 100644 --- a/Makefile +++ b/Makefile @@ -718,6 +718,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 48f3263e55..d3bf254191 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 @@ -5496,6 +5497,58 @@ if compile_prog "" "" ; then atomic64=yes fi +######################################### +# See if --dynamic-list is supported by the linker + +cat > $TMPTXT < $TMPC < +void foo(void); + +void foo(void) +{ + printf("foo\n"); +} + +int main(void) +{ + foo(); + return 0; +} +EOF + +ld_dynamic_list="no" +if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then + ld_dynamic_list="yes" +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +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..38d47b7922 --- /dev/null +++ b/plugins/qemu-plugins.symbols @@ -0,0 +1,35 @@ +{ + 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_vcpu_for_each; + qemu_plugin_n_vcpus; + qemu_plugin_n_max_vcpus; +}; From patchwork Fri Jun 14 17:11: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: 166916 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2378704ilk; Fri, 14 Jun 2019 11:20:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyeR/HXs4ZBjE4VWw7I3b8OMwfR2/DaqMKVy4MWCypGzjVvBqMczzh7Nh61yoiNIB7ybTQ X-Received: by 2002:aed:2336:: with SMTP id h51mr26678772qtc.125.1560536413643; Fri, 14 Jun 2019 11:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560536413; cv=none; d=google.com; s=arc-20160816; b=x/oeCVDwNL1RsatTHHSvH+tyGNNeMPwQ8SWjyI02ewH1WFvhMwCHlqLerYtKf1oYwn 5p1QvnKZwGbWTy2KOFpGhEjG4TwO5n6x2RQoEbcEn7acK/xXP5UIqYy2kMmN6GvFumBi PMkHGmU78+seXSHy6JsaLeMONy431mT0yctp7YwvGShyCkNlRZ5wyN4yz1KAlubdCWwO wDW7wDECVT6i58x+JHGApL7DPKsEBP0AVKSOZdJfGUO+imF1r3FtnKH5JwU3ogkQXGWU NSjOxKUP/Xc6Vzgwtmh03xSXQ/Q42ejyF6QFaM4eo7FDvAuDvwvkkJhn0fVGdlPK48Kc 2stQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Qg44j1/fmT2WZWQwTd6B39K1u36F6LVDpErcGgO7T1Y=; b=evN3AwnujIvZlhM8cGvY7vpASCRf0GAP0tQKVnyzZ50lXMqcuJFCQJi20/Owd1K/al 4t/YYGG6VapaEtfCCxkQRiBMLd3/4FFfwMfQmBBgCkRIWr85rxaziTueyX2k81ThRrNf 92dsw6bfZwyymGJf2mXsASaB7E9U7gPKhhS+ToJD0ms6vFZDVoTQofymp382kHIHB5Ki Hlw2SrsYvPjI70dt4kWwUa37+9nA34W1MsnTYKfaKqxu5ZQlrmMjCS/mvkWLCh34Wos6 +LD4a04xnHPyz2qVwx4gmjNg5cFOxdBkyrjvYxz1KgfNY+poCtFJL95V8P3LgLAzN/W3 fOGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jPANe3ZR; spf=pass (google.com: domain of qemu-devel-bounces+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 u63si2392120qkc.266.2019.06.14.11.20.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:20: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=jPANe3ZR; spf=pass (google.com: domain of qemu-devel-bounces+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]:54058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqo7-00028h-Gm for patch@linaro.org; Fri, 14 Jun 2019 14:20:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34112) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0M-00076s-BD for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0J-00042r-Er for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:44 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:53325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0H-0003xQ-Q8 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:42 -0400 Received: by mail-wm1-x342.google.com with SMTP id x15so3158427wmj.3 for ; Fri, 14 Jun 2019 10:28:39 -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=Qg44j1/fmT2WZWQwTd6B39K1u36F6LVDpErcGgO7T1Y=; b=jPANe3ZRmE/XYvdJ91iBIjo0AzjtFtvfz2kqeTbd4VE8uTA9DM+g5Q5SdeOKOGMVyW Ral1s4CzaK4ijK90X/2ALR9rWxVxERMcgmy3iwB+J4PyFzeUpCpW93UC/6CUJjiy6z6T YLtI9wktTl8mXA781TPfMZAevztaFPnJq79Ni/2T57/mqslcKH8kPvp25B55C99VprZp fi5l0KqCoi8r0JcuuD2vJZnpeZCuRH/LWavGuyhwvsXILgdwnv2VKEfgRxEZma0MN8ML tEd1iIQOmghgpjFJVWuPTzgtBW0UOT4VE4PtcKtIl8H9PhowfARMBjCiU4DVcF/KZp2c LDbw== 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=Qg44j1/fmT2WZWQwTd6B39K1u36F6LVDpErcGgO7T1Y=; b=N74qB3sBVQ1W+TSt/931fjHBhe/l+H5guGnjCK9vXCJHeY6CY1jT1KlIxhIGJzhBUD cdE5oU2Rd5y19mhupnmsMVoHbD/Pn9RN4NkPJeqEKJWwUk+MniMn5MMrvE4sfaFwUKHJ b5Gq0g321vgLlkbtRCAQJYy8Qq/jwTEcNBh3BXmCNBRFCn2RTZ/2xUuYtlbqraN93VNk EakA1T5LPmCxUbuH4E4zRof8N+1tssaxCSr/DlLYcloK3IwqAg8vwCacDFsqE47YyLbP ItCxHE61HuF0EZu/RSLKWPTgYWY9EN4SXajxo9B1NqnpbvQz/By3afwzV9wdMMDrKqO2 ivYg== X-Gm-Message-State: APjAAAXF8r/TXuIXpPoibZCRvpu9LAna/cHT1hoHhDqZz0mYSd9yO7J/ 6Hd+YTtyS6ROCS516mbqgJfaDQ== X-Received: by 2002:a1c:730d:: with SMTP id d13mr8510608wmb.88.1560533318979; Fri, 14 Jun 2019 10:28:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l8sm9147766wrg.40.2019.06.14.10.28.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E99341FFBE; Fri, 14 Jun 2019 18:12:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:49 +0100 Message-Id: <20190614171200.21078-40-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 39/50] vl: support -plugin option 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: Paolo Bonzini , "Emilio G . Cota" , =?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 --- qemu-options.hx | 17 +++++++++++++++++ vl.c | 11 +++++++++++ 2 files changed, 28 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/qemu-options.hx b/qemu-options.hx index 0d8beb4afd..47bbf358db 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4130,6 +4130,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 005468cbfb..0be9667315 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" @@ -2954,6 +2955,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); error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); @@ -2982,6 +2984,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); @@ -3760,6 +3763,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); @@ -4068,6 +4074,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 Fri Jun 14 17:11: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: 166850 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2323152ilk; Fri, 14 Jun 2019 10:25:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZWIY97y8eqcdM7cg23+5I+ZEgB5OPCjTYJquHSSEnJIRWfMtXQ+FnN5/a1vdff8dRmC46 X-Received: by 2002:ac8:376e:: with SMTP id p43mr82520160qtb.354.1560533115739; Fri, 14 Jun 2019 10:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533115; cv=none; d=google.com; s=arc-20160816; b=ej501rfKVrA6zqgChmMvxW5EVJcmRCbVMzcwDIlQLBKBHxAPfL2u6kbrBNYcUrIwPp 1nj1DxpyYfA6eCKv/rUwNXTc3iaJXsvezY08NGmZMRaMkDuVBun0OkLGJOSrwZ7ob3LF Ojf0O8upv/iY682RJee5rtzRR3bZofWLh8UpGQmGEcb3WLaS9ZggXEHQ/ew87gcLqIq8 29F4fT2+7lsY7Ln0hcO5Iap4Jzlhd5PMMJwFUhpOenSDUcyKYRiz+WySMzBHUfqSio2N H3EPUz7rqYs/Z1GqFh8LAv7DnKRDaBB5MLCEDUOCt5jRdYBTqddMwxOC60H+vOCyko7W Dfyg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=P9bsnv/ggrydM2zdkz7ungy+IkQQkZz8WUvWT7dsGh0=; b=YLiMSWL3Djl6ev8UoWwgaf8+cW8AKaydj7RjBvarPYJ7bHC1r5WvVNddIVXYd8lXhK 4ryQW+SKcL4JilDrfGpL/MmlDKvNUPTt5fSYoYX6PaY9yNdDom5FQ0JEHxk6QsoKJQtc VBPu35AqQ67PG2Mu/8+sZ6zd5wjsl2K9msltQFLamMl+HHs+c5SzTcJb4K+HNGtmcdSh m41tiTICKl0GXhB3A4kzgTPdYs5E3LbqInGnnU8omhQWi/1MpXJTqWUrn3r4leLaat3m QIrcegrk/1nwn85mShUQgsFsrw1acP/hHGvtw+S6FMnpR+jpMuWgrarxNqm1Zk215vCG SRdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pi3oeKyZ; spf=pass (google.com: domain of qemu-devel-bounces+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 y44si2145716qtb.264.2019.06.14.10.25.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pi3oeKyZ; spf=pass (google.com: domain of qemu-devel-bounces+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]:53760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpwx-0003tl-3z for patch@linaro.org; Fri, 14 Jun 2019 13:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58585) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005al-1I for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqd-00075y-W2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:35206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006nJ-Jc for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wr1-x442.google.com with SMTP id m3so3351531wrv.2 for ; Fri, 14 Jun 2019 10:18:37 -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=P9bsnv/ggrydM2zdkz7ungy+IkQQkZz8WUvWT7dsGh0=; b=Pi3oeKyZ6lkA9rSME++oaRwdyK0KNvzRb9FhCxfeql0ZGOHxlDVmX8GwxY6za3KMz2 lO8FQV0iQUmHquHPF5qOIMu9/Wx5i6IDqf7qCOWiUWYWlJ0f7EIzjdJ2hydaN7S7myOo L28d1LDHJUs1p5YQ9qZsuK+anhccmTu7KHIiEee4i7n8rnx2G44J9MMVHq+5O5UnkMEd 4B/bQzWv+BN7dKPeT5xPPigPNltar0EC+TDsLQwh1bVS6dnoZgQflhw0+rVAZx8a+LJr ETJ7ogEjbyYp7mxXF59Dk/JSHRfVf0NUolWLRi9kB2b/uDjBrsU07+acYiUFErvwaSTn sf0A== 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=P9bsnv/ggrydM2zdkz7ungy+IkQQkZz8WUvWT7dsGh0=; b=kuAOXskea8D7TMy0IsJ0FJik6JH7uUE4uckn/I+ShJGcphO58C6/1ztqgqE8cwuc03 q6vHHFO+sTx/D8+wv3FNkTpVV5opVJjAa4V7UwB0eIbzM+f8zrfUG/msuS979nCRtp9E 77byoJs0MDyiknWh0AudBIWEexDLEEDrvkzdpSg3djtmJk4w27RUr+dcUF7VZJltaUGi Q+XSTRCP3wdUoytwEkYI5z3JGsdfRFyNkkDeox1wha1Zl48lhnq+YuXIbeteoDE4waGR y07Th0gTTuoY0nxcUQ3+OZTBgSP11HEnCCG3zzg2Y6GQtdJast7rQca2Bqt0HiD0Lo2c ozkg== X-Gm-Message-State: APjAAAWE7QGMRsVdIj/vHPhnIA62XhNcyWnB60A6gI7N6reA3UlzLmnY 4llY9HXkUqVwieqQgH8n4DNp3A5UkOc= X-Received: by 2002:a5d:4310:: with SMTP id h16mr55726729wrq.331.1560532716118; Fri, 14 Jun 2019 10:18:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c2sm4090092wrf.75.2019.06.14.10.18.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:34 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 08CC01FFBF; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:50 +0100 Message-Id: <20190614171200.21078-41-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 40/50] linux-user: support -plugin option 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: Riku Voipio , "Emilio G . Cota" , =?utf-8?q?Llu=C3=ADs_Vilanova?= , Laurent Vivier 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 --- linux-user/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/linux-user/main.c b/linux-user/main.c index a59ae9439d..1009eab92d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -33,6 +33,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" @@ -387,6 +388,15 @@ static void handle_arg_trace(const char *arg) trace_file = trace_opt_parse(arg); } +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; @@ -438,6 +448,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"}, {NULL, NULL, false, NULL, NULL, NULL} @@ -628,6 +642,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); @@ -635,6 +650,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 Fri Jun 14 17:11:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166930 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2412979ilk; Fri, 14 Jun 2019 11:59:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0MEMTv0dVRERqQbG0nEJw0FxbG5pKlKjvLZyvY+ItfOC1MO1Ej9I4oZ3meS3eYkRXNODu X-Received: by 2002:ac8:70d1:: with SMTP id g17mr38493477qtp.124.1560538774863; Fri, 14 Jun 2019 11:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538774; cv=none; d=google.com; s=arc-20160816; b=Zl5q198kMbiSyJOX7CJ/OCSnfq5s1OJFsYJyq2zNSDT97/dfEs6ufQddA/eq1VUL3a 9ZBXoyd0Fbstv9pdt0/DW8BCpz7r1+vF4fqiTWNucCo/7HtxOKmuFFxKqyu1W2zc6cdp 5SWuWQ49rbMrkJ8+i+gNBu/JwTWwfsIum/mQVWolayysR2EjqrYq/rtBVQ3A5ZzmOOPB ZzFq2QHquXWPTSRcM7afeLLxZzaXROddNT08fTe+d+TvdfBRnKdZ5iYuzGaJj5xiUsMk uOAp3BpO5QLnbS/qckp64uvuNjfwHaXOlYcGH8x6yD9P0ZSy79mAE7WNEXebv7LEBIb8 yenQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VXpK415OMJJqmZ3w36Oxw/kJSG0YBc4gbksES0oJVX8=; b=m6piwdho/Zz8/OfPMcxkJqczPb44ejRV0Kx+OKwyT32C3YFnxBWStUQ5RRc6zP05o3 9AU9LBrdFDP9hArlfAelr40Z9RTAgA++YFyC63LyzY6Bius0bl6N3tSVm7sMEExqGGo5 G0+zKhJzWVSG2eWXOcuv+2u9yCNm5nEJivS4fEfXkS3DNquNGD1thsz5mfDm/7hkmGCy KqvO35fxCJD6alez9urwAwkxIV/7BXSWWmsXH+xDXN/NnAJIv4Wdqbo1leuCWcRdzrg4 eFXsgHUJKL1z/QyyuT73saClmEFYM3zo6AYHGAGdez95WXPMyu25AlJomR+AyWKWapQe JPSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xQbO9Fxe; spf=pass (google.com: domain of qemu-devel-bounces+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 g16si2477276qtg.377.2019.06.14.11.59.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:59: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=xQbO9Fxe; spf=pass (google.com: domain of qemu-devel-bounces+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]:54376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrQE-0007ce-GS for patch@linaro.org; Fri, 14 Jun 2019 14:59:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39288) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJb-0004XL-Ts for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbqJZ-0003Xt-AQ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:39 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:44100) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbqJT-0003S0-Tn for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:35 -0400 Received: by mail-wr1-x42c.google.com with SMTP id r16so3386355wrl.11 for ; Fri, 14 Jun 2019 10:48: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=VXpK415OMJJqmZ3w36Oxw/kJSG0YBc4gbksES0oJVX8=; b=xQbO9FxeBWXSzUk5RTFwKb4C9mLDDfH+MkxTaAut61ZmxEBhRrP4MCI7MJv/Mc1/Gn qDahXRiKHpL54Vs/w3jxE2qA0+zcBwnDqzI8XG230SO4A0383ULxQEb3d8KRzfgHlKQt jul3QLDY8fldQ0BqBLLcGcfY8dFUNPE3upEPnI04jEw8pNzEsgYJtDmi4NtTNQLgnAu7 TjWrZ1OjMnDTyI1xnQyWOyf3iRItfBYgjkyqZw2gDTTLyv47uLSZANHBF+O4uR6xM8kb 1VrENiaA+nEi/OV64t4BO0pjb9TNn8kcHy2/yXzWNp2z0DoOBgE+Mr2kkh6t6xvJFRzD 2bIw== 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=VXpK415OMJJqmZ3w36Oxw/kJSG0YBc4gbksES0oJVX8=; b=aBKQmP3ZqEPXrug/sfvmi/l7kCkraCyIxXq61aVDRWSG2YkXdBO16APip0D4GgOc/D m/XrNOI4u8f9mFTk0fT8INA5jhp/jHqjRe4uBCedE1qQVfg7tY1CNUnxhrgp0xZCUq+f 6U/f/qIuGEa2MlvEdcOuvaiyA498VT/FX0hquD4ZHNfiJ2UKR/PgwLyHGLDx3Y/M0s2v Pco+IqpiHspAow0ZO6lTHqNNR+rC2Y6T67DjWOYl30vYHx60I5DWlsfLif63KH0XRJVe /YMEbI1KPLFFvLGwyIf3xxK+Yt7gY1nRQrOt+yNvum5334mEWKFlOQhsUmU3yGczGrE7 Qi7w== X-Gm-Message-State: APjAAAUy4RFLK+ViZoRLQ7qDYwefQVzbSj71X33VBJuVNv5Fp2Wf1SyW OVSijJ8t/cZljFCTg3yrpAy+eA== X-Received: by 2002:a5d:4302:: with SMTP id h2mr36455054wrq.137.1560534509002; Fri, 14 Jun 2019 10:48:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h84sm5730516wmf.43.2019.06.14.10.48.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:48:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 24B3E1FFC0; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:51 +0100 Message-Id: <20190614171200.21078-42-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PATCH v3 41/50] tests/plugin: add sample plugins 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: "Emilio G. Cota" 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 --- configure | 4 +- tests/plugin/Makefile | 28 +++++++++++++ tests/plugin/bb.c | 66 ++++++++++++++++++++++++++++++ tests/plugin/empty.c | 30 ++++++++++++++ tests/plugin/insn.c | 63 +++++++++++++++++++++++++++++ tests/plugin/mem.c | 93 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 282 insertions(+), 2 deletions(-) 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 d3bf254191..2af8c436f2 100755 --- a/configure +++ b/configure @@ -7995,14 +7995,14 @@ fi # tests might fail. Prefer to keep the relevant files in their own # directory and symlink the directory instead. DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm" -DIRS="$DIRS tests/fp tests/qgraph" +DIRS="$DIRS tests/fp tests/qgraph tests/plugin" DIRS="$DIRS docs docs/interop fsdev scsi" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS="$DIRS roms/seabios roms/vgabios" LINKS="Makefile tests/tcg/Makefile" LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" -LINKS="$LINKS tests/fp/Makefile" +LINKS="$LINKS tests/fp/Makefile tests/plugin/Makefile" LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps" LINKS="$LINKS pc-bios/spapr-rtas/Makefile" LINKS="$LINKS pc-bios/s390-ccw/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..bb868599a9 --- /dev/null +++ b/tests/plugin/bb.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t bb_count; +static uint64_t insn_count; +static int stdout_fd; +static bool do_inline; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "bb's: %" PRIu64", insns: %" PRIu64 "\n", + bb_count, insn_count); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + unsigned long n_insns = (unsigned long)udata; + + insn_count += n_insns; + bb_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + unsigned long n_insns = qemu_plugin_tb_n_insns(tb); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, + &insn_count, n_insns); + } else { + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, + (void *)n_insns); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/empty.c b/tests/plugin/empty.c new file mode 100644 index 0000000000..b2e30bddb2 --- /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, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ } + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + return 0; +} diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c new file mode 100644 index 0000000000..11afe0e8f1 --- /dev/null +++ b/tests/plugin/insn.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static int stdout_fd; +static uint64_t insn_count; +static bool do_inline; + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + insn_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1); + } else { + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL); + } + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && !strcmp(argv[0], "inline")) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c new file mode 100644 index 0000000000..c13c672c91 --- /dev/null +++ b/tests/plugin/mem.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t mem_count; +static int stdout_fd; +static bool do_inline; +static bool do_haddr; +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "accesses: %" PRIu64 "\n", mem_count); +} + +static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + mem_count++; +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *haddr, void *udata) +{ + mem_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + 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 if (do_haddr) { + qemu_plugin_register_vcpu_mem_haddr_cb(insn, vcpu_haddr, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } else { + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc) { + if (argc >= 3) { + if (!strcmp(argv[2], "haddr")) { + do_haddr = true; + } + } + if (argc >= 2) { + const char *str = argv[1]; + + if (!strcmp(str, "r")) { + rw = QEMU_PLUGIN_MEM_R; + } else if (!strcmp(str, "w")) { + rw = QEMU_PLUGIN_MEM_W; + } + } + if (!strcmp(argv[0], "inline")) { + do_inline = true; + } + } + /* plugin_exit might write to stdout after stdout has been closed */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Fri Jun 14 17:11: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: 166860 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2349146ilk; Fri, 14 Jun 2019 10:51:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu4alwcrYaRWMb7FvF2aom6viSQxOaU7i28ELlLrc0Axr8dzECM5mmDpt1RgaIT2INylaI X-Received: by 2002:ae9:c108:: with SMTP id z8mr16369149qki.57.1560534670699; Fri, 14 Jun 2019 10:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534670; cv=none; d=google.com; s=arc-20160816; b=dzgsT/5yasBIUxrE4Xlue5JJnQaytdcLu8Aef7Et99koR/b6t0FgeAK/vuMRvZ2jwb uv+kjHN5DEigAiZvVxV2XTtcrYGRaxgzV07IBYNcI7oaxj4XdPxPAvNGcT/q2gcQ4Xwm dXTgGMO2xJK3ev5baAzo1u2CGIOCz0Ago0gSlhQmTO2Jv7Y/2wIi1NOgKsDHWCmGRh3l sNb6hio2CtcPKyyTs6Od2xl3A9jt1FCwYKWAVpmY3YvgW05TBDf+rHiyjzc/GO1R8xOf CZKaXggf5ksPOkcvuey+FNd+lpbft21rs8Ft55kkYXJ3n9q0a/Gtx8QsuzbQndMqx48m rYQw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AtuxXjdv5rXrTnKR+kY966HW3wPcp99t7mVhH09mMeM=; b=YKqIfbO/WoCKMMnrcjDuWAGSn9MIfwok2yF0EoWh/QIzAlyV2ybuwsSIkRlmTGbDvb DRKS80M+TScljLY8f78pB+7HiFlTwpJXuHKoa0hPbMk/E8ARytSHFQ1JwFxBKy9hqGDr xkr+O9KNPjgqR5f+ySZRzeiGr8yn1BUN/vpJTQ9qH30utxlR2i3GGWKsxW052xeK3Ia2 GDwdQ4d7808VwqwRVwaD508Gy+tFDupcNEaBg47BX4qn0psqkXGnzDMdv1W/HDKZqGac jgCnQxdNAv9LBqhXrw+gQdXIfdOaYz8A5cRK73PU8yfckoveBGGVTQxKZSBK/+ACgobw 98ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ucb28COx; spf=pass (google.com: domain of qemu-devel-bounces+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 k129si2282746qkc.35.2019.06.14.10.51.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:51: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=Ucb28COx; spf=pass (google.com: domain of qemu-devel-bounces+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]:53894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqM2-0005k5-8s for patch@linaro.org; Fri, 14 Jun 2019 13:51:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58664) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005bD-60 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-000790-U9 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:47 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:34591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006jT-9j for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x343.google.com with SMTP id w9so9349805wmd.1 for ; Fri, 14 Jun 2019 10:18: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=AtuxXjdv5rXrTnKR+kY966HW3wPcp99t7mVhH09mMeM=; b=Ucb28COxP9N29+yMdbrQdA8kVqmAcU7/gxDxXTq8Wg5unXy7e46lTP2VZBMTDxPs25 TCC5DRkxaTJpGdp0YAf1P6n53sLM4VNTdU0BAEsHi05rG8aoGULBL+S3VYYwepmRG5Aw Kh3PRKN0UkQ1phFe8VQrLrSaflgWhiD1Bu/R3JhKzAlnP58osihn6EVYYs58MDJIhsKF UBYYPima3IZ5JT2av60y6NUDZGkDfd+bbGRaswGF+d5Y5QGUguJ9DW15LyUuC5q3LRpZ xdIzsA3gyClRJL9K0we/cnDS0hyCgzxqnbV5mY+/aYVj9ZTC/TS58jiZWDIsWCqSp0Bv DAXA== 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=AtuxXjdv5rXrTnKR+kY966HW3wPcp99t7mVhH09mMeM=; b=jKDb+CIRJ18NHkXcux4FM86iA0/aZWIPUPqjxUQIsHoHBM7D8nmdZ7yjFmLeQrNttf Y34rS7z0t9wW68DaKiQOh11Sq6FlSGtQjHwXA98mqBg92zTC1p3fjD6YqPnen4C1jR2Q CM5lnh3HkTeEwkrlAitDXCKDO0jofRtISPGlR4VMomRZSGHnjNpnZJe4b9z7GJ37jeuk R3n4LUH/1ELwDDEqe+FND0XJZWWcm401Gc9ME03CDvdUIdXbuD5oo6uxw6Swr3QSBu6e O6Wpotnsrgh0ExtpplJR1yTh9d5lPmfoqW7m1cB6E7v1kedWbzSHbANmX+Wy6Q3U+Tw5 re5Q== X-Gm-Message-State: APjAAAUuY9fWIrWgPfKxOb67g+g7RUp1+n01l0CPvMOQalGRdeqWzVAD RUPSqxFPE6UL6F0mWTTYdq/TFw== X-Received: by 2002:a7b:c94a:: with SMTP id i10mr8445078wml.97.1560532712975; Fri, 14 Jun 2019 10:18:32 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x129sm5473118wmg.44.2019.06.14.10.18.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3B87D1FFC1; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:52 +0100 Message-Id: <20190614171200.21078-43-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 42/50] tests/tcg: enable plugin testing 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 , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If CONFIG_PLUGINS is enabled then lets enable testing for all our TCG targets. This is a simple smoke test that ensure we don't crash or otherwise barf out by running each plugin against each test. There is a minor knock on effect for additional runners which need specialised QEMU_OPTS which will also need to declare a plugin version of the runner. If this gets onerous we might need to add another helper. Checking the results of the plugins is left for a later exercise. Signed-off-by: Alex Bennée --- tests/Makefile.include | 10 +++++++- tests/tcg/Makefile | 34 +++++++++++++++++++++++++++ tests/tcg/arm/Makefile.softmmu-target | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/tests/Makefile.include b/tests/Makefile.include index db750dd6d0..04b0460262 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -1047,6 +1047,14 @@ check-softfloat: "SKIPPED for non-TCG builds") endif +# Plugins +ifeq ($(CONFIG_PLUGIN),y) +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)) @@ -1061,7 +1069,7 @@ $(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ)))) endif -build-tcg-tests-%: +build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins) $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \ SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \ "BUILD", "TCG tests for $*") diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile index 6fa63cc8d5..9474ab2900 100644 --- a/tests/tcg/Makefile +++ b/tests/tcg/Makefile @@ -116,11 +116,37 @@ all: $(TESTS) # RUN_TESTS=$(patsubst %,run-%, $(TESTS)) + +# If plugins exist also include those in the tests +ifeq ($(CONFIG_PLUGIN),y) +PLUGIN_DIR=../../tests/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_TESTS+=run-plugin-$(t)-with-$(p)))) +endif + +strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1)) +extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1)) + RUN_TESTS+=$(EXTRA_RUNS) ifdef CONFIG_USER_ONLY run-%: % $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<), \ + "$< on $(TARGET_NAME)") else run-%: % $(call run-test, $<, \ @@ -128,6 +154,14 @@ run-%: % -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ $(QEMU_OPTS) $<, \ "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=$@.out$(COMMA)id=output \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(QEMU_OPTS) $(call strip-plugin,$<), \ + "$< on $(TARGET_NAME)") endif gdb-%: % diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target index 49d48d8a1c..cd628306b3 100644 --- a/tests/tcg/arm/Makefile.softmmu-target +++ b/tests/tcg/arm/Makefile.softmmu-target @@ -25,5 +25,6 @@ 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 endif From patchwork Fri Jun 14 17:11: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: 166908 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2361108ilk; Fri, 14 Jun 2019 11:03:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwL4JN2p9yb6dQoGnx68rSdLjSgP5UIoLv3n56wTkFpBE2rokyVJSFeNexojPc3A8wwttUS X-Received: by 2002:ac8:3668:: with SMTP id n37mr36880582qtb.236.1560535396983; Fri, 14 Jun 2019 11:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535396; cv=none; d=google.com; s=arc-20160816; b=eUd96ItotDZNlh4cKGiVCHQJuQ8s3cTHTrSW/IPZ6n51idVB+YVBCVRl/TcONwKrm3 Dt0LYAih+4lI3vkGLjWOakeHUHFqY2Hj611EZLadc3EiNjmmxdKBQQK7ciI27RMH4Cyc OWbvBmCSV6Yc7mQIcBjPpNs1iKyOINR1JqPHeTNIABSs1bveDvr7Xfxh9FyerzQD98uy IlUoMBtrUM6p/8prjBpAQSuVfrw3PFoKCVLYIpfyqUYWZajg4qJw2ma2qL1FQAUTdJ4t 0VQcx+ps9I28YU9Esqz3WwT8ON2gfm2NzxnoRWflRrKaTC/xW5uUXdWq+6s7QKUERSSH VOTQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ePNB7fMxER8fpxE4Yb4C2baLVHXAfUjyVC7rsoU1lSM=; b=Ab2bcES35xSvdvnlbbpsj9v5SBIINMQNAEpeitk9lMHKT1UPSVxBUKTWAJZn37cNt3 AYJ6LDs6nfXburTaGAxhxChTM74hon4xz5uG+5IqBWtIvOLpBp7mlkVCI+rz1GFn6AOg 6VLbVv/j5X7pRjLKxCX/FrKGnDyWH9wit9kZv4QjqMwXXnuojALaYCRvra2AcEw/l+1s gf22GDfkoz70vhfeXgvF01AvpJ0ERPrXuWD45BDzi/bIIR0LQqLIH7oit13CdJuYsx7V 5CFXiOE0/010P/q4H/vpzwvx/b/K42YAV8UFGkJDw7hz9rphu8a+1blXGtW7akVjoW+a o0ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FsDqUtUj; spf=pass (google.com: domain of qemu-devel-bounces+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 y11si2033229qva.106.2019.06.14.11.03.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:03:16 -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=FsDqUtUj; spf=pass (google.com: domain of qemu-devel-bounces+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]:53956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqXd-00063w-Jx for patch@linaro.org; Fri, 14 Jun 2019 14:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58675) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005bu-9i for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-000783-KF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:48 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006fC-3P for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x344.google.com with SMTP id z23so3054935wma.4 for ; Fri, 14 Jun 2019 10:18: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=ePNB7fMxER8fpxE4Yb4C2baLVHXAfUjyVC7rsoU1lSM=; b=FsDqUtUjD4LnyXrNK1AXGYb/CqVAuQ0Y4D2tUE/Wt7OWqWc5QestQaLwg8zAJAp2H3 d+62SsPi6gaVIWTjM4fK/OzOTwpSgz+svCuH0Z1FV9I53hnb33apW8godXC8poFc1dMs 4L4sVVRFlCTOQ8E3u3CfyrU6/SjIrbSoER2rsict6zoQ4uzavJb59LejPQPA1NSs07xd e7yY19EfEDN5YWeYTvhUwTXCdgX/5eCoBJXNqmgAsncenAONg2cmZxj4i3GM6K68wsqP /Ndoo/iYQTAXm0YNDLEFSfssRIJOL9ccZ6+edKpsVKN1w9voW4D6BSeXzMUAjsci8Byh h/Ow== 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=ePNB7fMxER8fpxE4Yb4C2baLVHXAfUjyVC7rsoU1lSM=; b=GWZC/XjTCwokX5STKWTWM9AAAFKirYVn4dBa93bcUGnZPG9PPA0HEzbl+FBTY5wMwu Goe1W3atD6NgyvR68F9MNBMbmZh1yMAZPip6/hha5/3uHnFAfLCtjatzGDjUCDYpgHmt YCcTfNW5TPnkrouyFfDU2bYpEk3z+UqsKxgEOeZxV4F9WmDkki9LAYpORNGWmEDdQZIV gN3XuzVAktZDAzw5EvNgyT+zVwqwvSiFV/yPc21SSyRGcl0MWgJJ6W9gEDfLDbictNJ1 A6CsM6PApRjFliz1NhcZAUvmAaVKR8ZfnL1RA7v4zERJtqcW9eqAJiBfEgWXOllar+2D GcDQ== X-Gm-Message-State: APjAAAX6h+LMkhPO5KEl+Dz9aei0T7BcjbnTtB0ZmY1kW5kKdKetvAU0 LGqCgNR4RKenG282VdWqnqmB5g== X-Received: by 2002:a1c:452:: with SMTP id 79mr9021511wme.149.1560532709802; Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o8sm4744500wrj.71.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5211B1FFC3; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:53 +0100 Message-Id: <20190614171200.21078-44-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 43/50] tests/plugin: add a hotblocks plugin X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- tests/plugin/Makefile | 1 + tests/plugin/hotblocks.c | 145 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 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..acb890e320 --- /dev/null +++ b/tests/plugin/hotblocks.c @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2019, Alex Bennée + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static bool do_inline; +static int stdout_fd; + +/* Plugins need to take care of their own locking */ +static GMutex lock; +static GHashTable *hotblocks; +static guint64 limit = 20; + +/* + * Counting Structure + * + * The internals of the TCG are not exposed to plugins so we can only + * get the starting PC for each block. As a result we will see + * multiple translations at the same PC, we aggregate them here. + */ +typedef struct { + uint64_t start_addr; + uint64_t exec_count; + int trans_count; + unsigned long insns; +} ExecCount; + +static gint cmp_exec_count(gconstpointer a, gconstpointer b) +{ + ExecCount *ea = (ExecCount *) a; + ExecCount *eb = (ExecCount *) b; + return ea->exec_count > eb->exec_count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("collected "); + GList *counts, *it; + int i; + + g_mutex_lock(&lock); + g_string_append_printf(report, "%d entries in the hash table\n", + g_hash_table_size(hotblocks)); + counts = g_hash_table_get_values(hotblocks); + it = g_list_sort(counts, cmp_exec_count); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + ExecCount *rec = (ExecCount *) it->data; + g_string_append_printf(report, " pc: %#" PRIx64 " (%d block%s, %ld insns, %" PRId64" total hits)\n", + rec->start_addr, + rec->trans_count, rec->trans_count < 2 ? "" : "s", + rec->insns, rec->exec_count); + } + + g_mutex_unlock(&lock); + g_list_free(it); + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + hotblocks = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + ExecCount *cnt; + uint64_t cheap_hash = (uint64_t) udata; + + g_mutex_lock(&lock); + cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) cheap_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, unsigned int cpu_index, + 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 cheap_hash = pc ^ insns; + + g_mutex_lock(&lock); + cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) cheap_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) cheap_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 *)cheap_hash); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && strcmp(argv[0], "inline") == 0) { + do_inline = true; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Fri Jun 14 17:11: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: 166856 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2336102ilk; Fri, 14 Jun 2019 10:37:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqWzJbNkoSOjR7eCdVsYyl994DOeuI/5zCuk1F7hLR1KeawnZ5/spNMs7he0YhSP+fhbFW X-Received: by 2002:a37:6086:: with SMTP id u128mr57177502qkb.270.1560533879323; Fri, 14 Jun 2019 10:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533879; cv=none; d=google.com; s=arc-20160816; b=uYPOjZJstVuSe8TXcMWO2nLjFHIAMSeeIpvnBI4bXoVhpQoVKITwbzLBr9HknxYN1U 0GPblg5/RgAj6H0d8HAJGaSLdauK9j+XbvP2g4hmxJl6rmM0hY2jFhRtiDuRQK0kt2yd a6IGheuBW1ErdMjGExh4qxPDmo3RmmVCaO0iMo4bXENY0Sizbk9u8xJx6837QdRuUOiT 9IXeHj/5XuCQJAjmT3IpQAdkz5U9p+bzwbVdG+f7I59LVzwm8Ttx1gOesNrBBIGqDQjF scTbcv6i6XzJnTLBUA2FQEsph4Kui7NSlMA/vPsxMDcaO8lgmK/xkptxHAhkyrLrbKJb Gg1A== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=z1GEGb1AT/jZhECwGmNfmmOk5GT9rSMPb0f35A3hv4U=; b=rmR6Cltv3Pw5sqi6qzxXPZfGuKwMGhjq8zrx9oKgIj7uPywKfJhfxwBg7LLFZy3ll2 5aIK9YW6k8CGpkgt3mtvGQoaMrubMveu/S+5WVZB+feiJ7sBSRIhp5DK3yQDMIWutw2n 3tpHaiiZEi1bWo0irTPbYtHEgEIh+P06f2dkBim7zizJq4lMGXQnu0dt8i0ky1Aot7wg gNPnRjJr+jA+Q38l3qiMcH+P+ilAUHoeq3IkXp/eAjWLM92lrhtQL1hfKVngbxv3e/d8 BzHg0vukVVDCK9Wps/JwPfrJFucP+jAy+jo95NBF0nBqfbl0ijo0qo2HqSOR8dsSSev0 EHSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b4QxVGNm; spf=pass (google.com: domain of qemu-devel-bounces+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 n63si2211318qka.114.2019.06.14.10.37.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b4QxVGNm; spf=pass (google.com: domain of qemu-devel-bounces+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]:53828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq9G-0005Ga-MI for patch@linaro.org; Fri, 14 Jun 2019 13:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58617) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005ay-JG for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqe-00076y-82 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006gy-Rv for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wm1-x341.google.com with SMTP id c6so3074856wml.0 for ; Fri, 14 Jun 2019 10:18: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=z1GEGb1AT/jZhECwGmNfmmOk5GT9rSMPb0f35A3hv4U=; b=b4QxVGNm+6Fj7wKneuYl+McZEVsa+rbuAQzeqkJF2ZMJqsv++7W5AjPv4k6Gczt9rD 0uqDgDSNqVea7ndExQqYgTmbyXwCy9IemmBy7YayqB4cTnudMSItHo5yH8mwVz7tqcEu +XPjLmX6CjZaYIJCjTYQgshcaHR2TTwRiSIGNrzy6wkjRf3YHBGnAUirb6ZTM/jZlU2D U8vr+Xn63JuWl9s6/maMM6g0T5/aK4LLrnyrBfrEznxVRXOBOp4OeC5z4mQ+xi8qAf2k R0QoBLo6Ga3MxgCA6UhddHnjHv0cmCqGvRjJhlvQeBJe6pyt458a2GsxDyxRF5h0HwgH s8GA== 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=z1GEGb1AT/jZhECwGmNfmmOk5GT9rSMPb0f35A3hv4U=; b=B+IqBR2VByBUzcC4Co9lvTs4HHCx2r9p1TRFFEY/E45TdUX1LBoXjZfYSgMqoSqJha ceaLEIZZ0OtY3zvwpf++uo0/CD8djL+35HMdXXp3Srg8qVfadgYda9VwipOPMNvc8P+e VeTlMXUUeEsWPex+jpm0tKfvEOkJJweu4WQ2Lv1cEE3z5dpST2uSOX0KHeGccuiCEjKh T1p6kNcMvDY3hr+852wyDiZTk8iGCAColjSK5k6DCAKHQhERnjDsaz1UtJyxucUrLe1+ 8viknWmiBsxMa45yyCRt0LkLhuKFf51gSsRN1G142cS3NHDSs2kXF4cU1LUiT59pkguO x0/g== X-Gm-Message-State: APjAAAUHhEWhiT9WnrFjLkSH7q6lEu9muSt3Pz5MQPwqHmJy3gImicDd O6eYy0AqcaDU/Kz7dlpXHf0k80TZRFo= X-Received: by 2002:a1c:452:: with SMTP id 79mr9021561wme.149.1560532710963; Fri, 14 Jun 2019 10:18:30 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y133sm5786558wmg.5.2019.06.14.10.18.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:29 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6C74A1FF91; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:54 +0100 Message-Id: <20190614171200.21078-45-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 44/50] plugin: add qemu_plugin_insn_disas helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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. Signed-off-by: Alex Bennée --- disas.c | 103 +++++++++++++++++++++++++++++++++++ include/disas/disas.h | 2 + include/qemu/qemu-plugin.h | 9 +++ plugins/api.c | 7 +++ plugins/qemu-plugins.symbols | 1 + 5 files changed, 122 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/disas.c b/disas.c index 3e2bfa572b..d8b75f0b73 100644 --- a/disas.c +++ b/disas.c @@ -475,6 +475,109 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } } +static 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_printf(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 */ +} + +/* Disassemble a single instruction directly into plugin output */ +static bool plugin_cap_disas_insn(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; +} + +char * plugin_disas(CPUState *cpu, uint64_t addr, size_t size) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + target_ulong pc; + 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 && plugin_cap_disas_insn(&s.info, addr, size)) { + return g_strdup(ds->str); + } + + if (s.info.print_insn == NULL) { + s.info.print_insn = print_insn_od_target; + } + + for (pc = addr; size > 0; pc += count, size -= count) { + count = s.info.print_insn(pc, &s.info); + + if (count < 0) + break; + + g_assert(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 15da511f49..119df9e9bd 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -13,6 +13,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 0db1ef9714..21f056d4ab 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -312,6 +312,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 1c3aa64702..c0a1e98e68 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -40,6 +40,7 @@ #include "sysemu/sysemu.h" #include "tcg/tcg.h" #include "trace/mem-internal.h" /* mem_info macros */ +#include "disas/disas.h" #include "plugin.h" /* Uninstall and Reset handlers */ @@ -218,6 +219,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 38d47b7922..3fd51112b5 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 Fri Jun 14 17:11: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: 166929 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2412680ilk; Fri, 14 Jun 2019 11:59:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpo0cossBI0eiTOLSxzpZYGTbluwdD3sK7OStrHZdeEjdNFS9E+ojH5OGjqJzh1J7jzi21 X-Received: by 2002:ac8:18b2:: with SMTP id s47mr80851096qtj.75.1560538748583; Fri, 14 Jun 2019 11:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538748; cv=none; d=google.com; s=arc-20160816; b=fO50jws4ZcLerGTSCr6iUlsiYueO7feIXK9zC5nUZAkxscYGR8/eiQWgQlQAY+F+La Mj/NmPbs8XH52to10Ni7Mhbc6SwsR+FnLsEsHutdU4SG6F76oo6ecIDe+aGu0qzUZi8X Tn7JnITvXBwzF/S7+Czs30aWpJgH91GwuiZCnllKjH52X8PRyzF+y7lngVA4fXau292T jCdI8blMe9jsXqzw+B3OUhKuDtx33HJ2EtW67QdVtqUcMJsnoErtm2j1M74Che4vKMKB 2wz5MCJ1iv/JEHwpnvLbbm8xs8habQXzs+s34dnet/w7otHlQnnVkNu9s90Q0Q6ajnNM dZLQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=LOtltZHJUqpcmg4ZA8EIX1vMLr1AdiMsA9bSNinYDLI=; b=cHd68APG76eOe9JLjoUgrE7EoS9C2BPDX44/IlTnsO8KD6RcL8LgzRGHAm6kd/W6No rDmKVjNWHF+7IuhbXEoJcmkl2KB8tL4LreVzHZaYz+L+phm9j8RL4/1Cwd0zJTluXOPo qOUFbuP3smh5TbEY9c2HbENrSxTeXMe+Lu/g5rG6T83mQ7CgAmu5c2YSTWI5CF8BnRzq XDPqAdMqGuc0F1bjh5o6wvmFA62ehCe5Dz68XLAL/xTuPbWWH8qcP/ndCt22wrbBOFmP 4webLdY0dJArxIO+d96D58/R+PPIVWWWkW4k63pxClSCk+BZa1J+/chyn4NpBFT52uiO xaBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lo52uWM6; spf=pass (google.com: domain of qemu-devel-bounces+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 e17si2241283qtc.145.2019.06.14.11.59.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:59: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=Lo52uWM6; spf=pass (google.com: domain of qemu-devel-bounces+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]:54372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrPo-0007Xc-5P for patch@linaro.org; Fri, 14 Jun 2019 14:59:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39294) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJb-0004XU-UO for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbqJZ-0003YO-Mg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:39 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:39683) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbqJX-0003RP-L3 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:48:36 -0400 Received: by mail-wm1-x329.google.com with SMTP id z23so3134985wma.4 for ; Fri, 14 Jun 2019 10:48: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=LOtltZHJUqpcmg4ZA8EIX1vMLr1AdiMsA9bSNinYDLI=; b=Lo52uWM6E9RyuykhpnQlXgKUq/sdYmWDePRTZt0dQxUCHimCV50undqx5rOZVmwAI+ +x+AJWYw3i+vTQAnkx2drju8FsVXuGJ2cE/vqNjT22n/u5A8x/i41nVwjloZY5FfwFNS nNARLQUXam/nmAht9AYSyy2p5x3uAY7IUfrFWvr5pE6pQaAo/Zkh8v3wfaZkw83xEC3M Tx6I1jphm5VL2lcMoc47Yh4RNJbmBbjTUQB2Ja3WSTP2rq6DUTfZ+4kTQ6nMLSwb0FBT o9pljRk7A8m6EOwHRQZe2xj/xJWRotRcEHW48tHrfPq3G8WYce1m9rehDqA5VX9pwgeH DYMg== 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=LOtltZHJUqpcmg4ZA8EIX1vMLr1AdiMsA9bSNinYDLI=; b=j67K4+9PNwe8FdIp53ib+L0DSnn3aYicBOnpDuWGhHkEAlUi6gT8UszZEeT+v37wcv CL0TxLiLYTFtMa9DJKN7A60dHBVH2ck2fhVMBL0vtMyLnn0LJEJZ4fBOtTZv0ixg/OaD ZkxFVlEk1iCR+LXRHcxfMJBMIUGhGE7MhQ+Ae0uel7vQ+JvdkyTABQoZnWMhgRksnlfF zopB/FSsTXc0AtOj+OWEjqqUIB8zNQkHpEmTGAhTYwK7sM8ZPXndtFPcWx3/RHRf6CJJ /aWTnd4luTup4CAnGlhB4daIXVkWAe25tiC96GAq4UCxFKlk+g1pQrpkydaKUd5hLUJP uUTg== X-Gm-Message-State: APjAAAUFU/7jXcmM9itCAyz9myO1CorPa5m9WHC5vHlGxjyXf7pEcMGq CeDIWxD1LbmJ47q1JCjctgVZrg== X-Received: by 2002:a7b:cf32:: with SMTP id m18mr9120358wmg.27.1560534507757; Fri, 14 Jun 2019 10:48:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u13sm2154044wrq.62.2019.06.14.10.48.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:48:27 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 81C3D1FFC4; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:55 +0100 Message-Id: <20190614171200.21078-46-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::329 Subject: [Qemu-devel] [PATCH v3 45/50] tests/plugin: add instruction execution breakdown X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= 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 --- tests/plugin/Makefile | 1 + tests/plugin/howvec.c | 297 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 298 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..0796523af3 --- /dev/null +++ b/tests/plugin/howvec.c @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2019, Alex Bennée + * + * How vectorised is this code? + * + * Attempt to measure the amount of vectorisation that has been done + * on some code by counting classes of instruction. This is very much + * ARM specific. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +typedef enum { + COUNT_CLASS, + COUNT_INDIVIDUAL, + COUNT_NONE +} CountType; + +static int limit = 50; +static int stdout_fd; +static bool do_inline; +static bool verbose; + +static GMutex lock; +static GHashTable *insns; + +typedef struct { + const char *class; + const char *opt; + uint32_t mask; + uint32_t pattern; + CountType what; + uint64_t count; +} InsnClassExecCount; + +typedef struct { + char *insn; + uint32_t opcode; + uint64_t count; + InsnClassExecCount *class; +} InsnExecCount; + +/* + * Matchers for classes of instructions, order is important. + * + * Your most precise match must be before looser matches. If no match + * is found in the table we can create an individual entry. + */ +InsnClassExecCount insn_classes[] = { + /* "Reserved"" */ + { " UDEF", "udef", 0xffff0000, 0x00000000, COUNT_NONE}, + { " SVE", "sve", 0x1e000000, 0x04000000, COUNT_CLASS}, + { "Reserved", "res", 0x1e000000, 0x00000000, COUNT_CLASS}, + /* Data Processing Immediate */ + { " PCrel addr", "pcrel", 0x1f000000, 0x10000000, COUNT_CLASS}, + { " Add/Sub (imm,tags)","asit", 0x1f800000, 0x11800000, COUNT_CLASS}, + { " Add/Sub (imm)", "asi", 0x1f000000, 0x11000000, COUNT_CLASS}, + { " Logical (imm)", "logi", 0x1f800000, 0x12000000, COUNT_CLASS}, + { " Move Wide (imm)", "movwi", 0x1f800000, 0x12800000, COUNT_CLASS}, + { " Bitfield", "bitf", 0x1f800000, 0x13000000, COUNT_CLASS}, + { " Extract", "extr", 0x1f800000, 0x13800000, COUNT_CLASS}, + { "Data Proc Imm", "dpri", 0x1c000000, 0x10000000, COUNT_CLASS}, + /* Branches */ + { " Cond Branch (imm)", "cndb", 0xfe000000, 0x54000000, COUNT_CLASS}, + { " Exception Gen", "excp", 0xff000000, 0xd4000000, COUNT_CLASS}, + { " NOP", "nop", 0xffffffff, 0xd503201f, COUNT_NONE}, + { " Hints", "hint", 0xfffff000, 0xd5032000, COUNT_CLASS}, + { " Barriers", "barr", 0xfffff000, 0xd5033000, COUNT_CLASS}, + { " PSTATE", "psta", 0xfff8f000, 0xd5004000, COUNT_CLASS}, + { " System Insn", "sins", 0xffd80000, 0xd5080000, COUNT_CLASS}, + { " System Reg", "sreg", 0xffd00000, 0xd5100000, COUNT_CLASS}, + { " Branch (reg)", "breg", 0xfe000000, 0xd6000000, COUNT_CLASS}, + { " Branch (imm)", "bimm", 0x7c000000, 0x14000000, COUNT_CLASS}, + { " Cmp & Branch", "cmpb", 0x7e000000, 0x34000000, COUNT_CLASS}, + { " Tst & Branch", "tstb", 0x7e000000, 0x36000000, COUNT_CLASS}, + { "Branches", "branch", 0x1c000000, 0x14000000, COUNT_CLASS}, + /* Loads and Stores */ + { " AdvSimd ldstmult", "advlsm", 0xbfbf0000, 0x0c000000, COUNT_CLASS}, + { " AdvSimd ldstmult++","advlsmp",0xbfb00000, 0x0c800000, COUNT_CLASS}, + { " AdvSimd ldst", "advlss", 0xbf9f0000, 0x0d000000, COUNT_CLASS}, + { " AdvSimd ldst++", "advlssp",0xbf800000, 0x0d800000, COUNT_CLASS}, + { " ldst excl", "ldstx", 0x3f000000, 0x08000000, COUNT_CLASS}, + { " Prefetch", "prfm", 0xff000000, 0xd8000000, COUNT_CLASS}, + { " Load Reg (lit)", "ldlit", 0x1b000000, 0x18000000, COUNT_CLASS}, + { " ldst noalloc pair", "ldstnap",0x3b800000, 0x28000000, COUNT_CLASS}, + { " ldst pair", "ldstp", 0x38000000, 0x28000000, COUNT_CLASS}, + { " ldst reg", "ldstr", 0x3b200000, 0x38000000, COUNT_CLASS}, + { " Atomic ldst", "atomic", 0x3b200c00, 0x38200000, COUNT_CLASS}, + { " ldst reg (reg off)","ldstro", 0x3b200b00, 0x38200800, COUNT_CLASS}, + { " ldst reg (pac)", "ldstpa", 0x3b200200, 0x38200800, COUNT_CLASS}, + { " ldst reg (imm)", "ldsti", 0x3b000000, 0x39000000, COUNT_CLASS}, + { "Loads & Stores", "ldst", 0x0a000000, 0x08000000, COUNT_CLASS}, + /* Data Processing Register */ + { "Data Proc Reg", "dprr", 0x0e000000, 0x0a000000, COUNT_CLASS}, + /* Scalar FP */ + { "Scalar FP ", "fpsimd", 0x0e000000, 0x0e000000, COUNT_CLASS}, + /* Unclassified */ + { "Unclassified", "unclas", 0x00000000, 0x00000000, COUNT_CLASS} +}; + +static gint cmp_exec_count(gconstpointer a, gconstpointer b) +{ + InsnExecCount *ea = (InsnExecCount *) a; + InsnExecCount *eb = (InsnExecCount *) b; + return ea->count > eb->count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("Instruction Classes:\n"); + int i; + GList *counts; + + for (i = 0; i < ARRAY_SIZE(insn_classes); i++) { + switch (insn_classes[i].what) { + case COUNT_CLASS: + if (insn_classes[i].count || verbose) { + g_string_append_printf(report,"Class: %-24s\t(%ld hits)\n", + insn_classes[i].class, insn_classes[i].count); + } + break; + case COUNT_INDIVIDUAL: + g_string_append_printf(report,"Class: %-24s\tcounted individually\n", + insn_classes[i].class); + break; + case COUNT_NONE: + g_string_append_printf(report,"Class: %-24s\tnot counted\n", + insn_classes[i].class); + break; + default: + break; + } + } + + counts = g_hash_table_get_values(insns); + if (counts && g_list_next(counts)) { + GList *it; + + g_string_append_printf(report,"Individual Instructions:\n"); + + it = g_list_sort(counts, cmp_exec_count); + + for (i = 0; i < limit && it->next; i++, it = it->next) { + InsnExecCount *rec = (InsnExecCount *) it->data; + g_string_append_printf(report, "Instr: %-24s\t(%ld hits)\t(op=%#08x/%s)\n", + rec->insn, + rec->count, + rec->opcode, + rec->class ? rec->class->class : "un-categorised"); + } + g_list_free(it); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + insns = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + uint64_t *count = (uint64_t *) udata; + (*count)++; +} + +static uint64_t * find_counter(struct qemu_plugin_insn *insn) +{ + int i; + uint64_t *cnt = NULL; + uint32_t opcode; + InsnClassExecCount *class = NULL; + + /* we expect all instructions to by 32 bits for ARM */ + g_assert(qemu_plugin_insn_size(insn) == 4); + opcode = *((uint32_t *)qemu_plugin_insn_data(insn)); + + for (i = 0; !cnt && i < ARRAY_SIZE(insn_classes); i++) { + uint32_t masked_bits = opcode & insn_classes[i].mask; + if (masked_bits == insn_classes[i].pattern) { + class = &insn_classes[i]; + break; + } + } + + g_assert(class); + + switch (class->what) { + case COUNT_NONE: + return NULL; + case COUNT_CLASS: + return &class->count; + case COUNT_INDIVIDUAL: + { + InsnExecCount *icount; + + g_mutex_lock(&lock); + icount = (InsnExecCount *) g_hash_table_lookup(insns, GUINT_TO_POINTER(opcode)); + + if (!icount) { + icount = g_new0(InsnExecCount, 1); + icount->opcode = opcode; + icount->insn = qemu_plugin_insn_disas(insn); + icount->class = class; + + if (verbose) { + dprintf(stdout_fd, "adding instrumentation for %s (%#08x @ %#20lx from %s)\n", + icount->insn, opcode, qemu_plugin_insn_vaddr(insn), class->class); + } + g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); + } + g_mutex_unlock(&lock); + + return &icount->count; + } + default: + g_assert_not_reached(); + } + + return NULL; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + uint64_t *cnt; + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + cnt = find_counter(insn); + + if (cnt) { + if (do_inline) { + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + } else { + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, cnt); + } + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + int i; + + for (i = 0; i < argc; i++) { + char *p = argv[i]; + if (strcmp(p, "inline") == 0) { + do_inline = true; + } else if (strcmp(p, "verbose") == 0) { + verbose = true; + } else { + int j; + CountType type = COUNT_INDIVIDUAL; + if (*p == '!') { + type = COUNT_NONE; + p++; + } + for (j = 0; j < ARRAY_SIZE(insn_classes); j++) { + if (strcmp(p, insn_classes[j].opt) == 0) { + insn_classes[j].what = type; + break; + } + } + } + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Fri Jun 14 17:11: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: 166855 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2335276ilk; Fri, 14 Jun 2019 10:37:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzl+o1CBdTCyS7Nch/o2rS6dP4ynKxnGD3lnJ1liyUgFh9FNLv8CqTCUOC3MKnIrEt/wUTf X-Received: by 2002:a37:e10e:: with SMTP id c14mr59221460qkm.54.1560533830308; Fri, 14 Jun 2019 10:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560533830; cv=none; d=google.com; s=arc-20160816; b=Qi+NBb4Y5QykU2b6PKJFNN6uVWUm6bahTTCCwm53TIQ719l0QYePdfxQfoaeORKWwZ tkB1mWyYPGukgPKjfYfv2X9ObWRxDZDAPg8ydqUIdJMrf910uTjft761HSPf6uQnxyQM xw0CPC54cY9S9+uWu4eoRQ0QPEsG8OO6V6HCwHavWF+j7Yfz8dkcuXbUJXLrdg8fqp3Q EJyWPoT84mTnB5dTTMDkBpaVgVZL/T+XFLxfFPZJ0ymhtjCZoBAxruMS7s5h8ZICZhop j1PLbJqMh91F06WCxFyqR7w3iWu6s0OgmQBy2YgCROwGJbWe4CHCl17UIXoyhJYrpquH NDTA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Q0g+J0COJWGb6iPQMwKOFR9aEmXrXmgB9rcv6IsahSA=; b=oC/quEWvbLqepDkbEoj7q3mtqM1RezhFmW144YwtFN02dS9F38Bwot4URGPAet5ojS VeW07wvZf638554LbQyuDAvXq/Qzem6g2uGrBwFg+4sRhk9Mlv3LB19yOQBATWVURA+S XzGmjenmO3QY2RJadsnYzJII/+DC17c66eh4hY2eNiMPe2m2Krso4DFOa4w2Me7jGqR9 Fx6AfIFZlJzmuV62u7hCV7GYJ80OFpZ+HZDGvnb+IxZJevYcYSQNwyS6b0MV0uy/TZkA r2ig4m5cC3EYAsmKzbhdBX+SaDNdvFPz6ZL9R4oTITTHn44q83pHEOPlOcBGCR7lBuDY CauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=thCBkPLZ; spf=pass (google.com: domain of qemu-devel-bounces+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 n2si2231651qkg.267.2019.06.14.10.37.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:37: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=thCBkPLZ; spf=pass (google.com: domain of qemu-devel-bounces+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]:53824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq8T-00048I-S7 for patch@linaro.org; Fri, 14 Jun 2019 13:37:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58618) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqh-0005az-JX for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqd-00075s-WE for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:46 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:40809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqd-0006c2-Iu for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:43 -0400 Received: by mail-wr1-x42e.google.com with SMTP id p11so3330376wre.7 for ; Fri, 14 Jun 2019 10:18: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=Q0g+J0COJWGb6iPQMwKOFR9aEmXrXmgB9rcv6IsahSA=; b=thCBkPLZn2OyMi7jzH1+rFIWqAmnnlae6qtM3JHYhegd4nIlQyqEfDh5QI0BsQYeHR Xj2fqCdLZGdeTYkzEeN2F1pKjfoMdKctAe0A/Rggke/nxqXRu7XY3uFeh6C70v8ZQpl+ hVo+Sl1mUfSmN54kp3UYDnu8yhlLbCXX5crvoXVxwr9XhAheMc3+5lqUAAgKDX4iXvIM S0JvspdCIQlRIjPzqhu0xkkqy+54ymFoPcvV27eKNi962xBQQqSnt8TjVPkuYfwgKZBJ PtjH3b28PsZCIQKAEs+JBoPOdDd0+KyYwm+nOwrQiLERyfFak4k17+WNtNgp8DSY7HQC f87g== 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=Q0g+J0COJWGb6iPQMwKOFR9aEmXrXmgB9rcv6IsahSA=; b=sf9a1E0A2sae/FgeeAF1zDLggX8b4CnKpAIAxUuKDmowlCUaiXczAIaUZ3n4ECbanx Jgh3PzmQhiKB5gxFEjX7pDsXhqRoqQK71BR36v3ViEIoU2XEbR3O95D+WHK2QMQmwkpi aJgDlz/9DPtJMHVbySOB1CIMmJoXdterMhuoNOZjfxIrrbc2hT+TesSpW+NUc260VmFI /TM397rx7m9F0pzZJvJDZKywNyyuQ0r+gtLyda3SRIFughZqfyNGYVdnvGX37QLY6mjU AYF8Fm6CDxIGwiKxUne3xGdAtqM0qvW+itpLI2914Qu+97lY67a77PwQdYgcVTjo6RWY Kajg== X-Gm-Message-State: APjAAAWmy9xFxsc9TC2KzjRN2hyDUb1cvoO0ssKTOKBJHqWGQT+DwzDI lNxEy4Lf2DM69taUwZIwYh/8svsdWzY= X-Received: by 2002:adf:bac5:: with SMTP id w5mr51292878wrg.124.1560532708568; Fri, 14 Jun 2019 10:18:28 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v204sm5792081wma.20.2019.06.14.10.18.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 975771FFC5; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:56 +0100 Message-Id: <20190614171200.21078-47-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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::42e Subject: [Qemu-devel] [PATCH v3 46/50] tests/plugin: add hotpages plugin to breakdown memory access patterns X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This plugin gives a break down of access patterns grouped into pages. Signed-off-by: Alex Bennée --- tests/plugin/Makefile | 1 + tests/plugin/hotpages.c | 152 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 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..ddeaad077b --- /dev/null +++ b/tests/plugin/hotpages.c @@ -0,0 +1,152 @@ +/* + * 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 bool do_inline; +static uint64_t page_size; +static uint64_t page_mask; +static int stdout_fd; +static int limit = 50; +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_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; + return (ea->reads + ea->writes) > (eb->reads + eb->writes) ? -1 : 1; +} + + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report = g_string_new("Pages:\n"); + int i; + GList *counts; + + counts = g_hash_table_get_values(pages); + if (counts && g_list_next(counts)) { + GList *it; + + g_string_append_printf(report,"Individual Instructions:\n"); + + 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, "Page: %"PRIx64" cpus:%#04x/%#04x %"PRId64"/%"PRId64"\n", + rec->page_address, + rec->cpu_read, rec->cpu_write, + rec->reads, rec->writes); + } + g_list_free(it); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + page_mask = (page_size - 1); + pages = g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *haddr, void *udata) +{ + uint64_t page = (uint64_t) haddr & page_mask; + PageCounters *count; + + 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, unsigned int cpu_index, + 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_haddr_cb(insn, vcpu_haddr, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } +} + +static GOptionEntry entries[] = +{ + { "pagesize", 'r', 0, G_OPTION_ARG_INT, &page_size, "Page Size", "N" }, + { "inline", 'i', 0, G_OPTION_ARG_NONE, &do_inline, "Inline counters", NULL }, + { NULL } +}; + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + GOptionContext *context; + GError *error; + + context = g_option_context_new ("- hot pages tool"); + g_option_context_add_main_entries (context, entries, NULL); + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + dprintf(stdout_fd, "option parsing failed: %s\n", error->message); + return -1; + } + + /* to be used when in the exit hook */ + stdout_fd = dup(STDOUT_FILENO); + assert(stdout_fd); + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} From patchwork Fri Jun 14 17:11: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: 166924 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2399274ilk; Fri, 14 Jun 2019 11:42:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe341/ge3/WJRR4aXjJDhggObN6x623tdAs0VATv4ydAgqQ+lpAT/1UD7c0yIhpw8L/waT X-Received: by 2002:ac8:520e:: with SMTP id r14mr80292338qtn.50.1560537743377; Fri, 14 Jun 2019 11:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537743; cv=none; d=google.com; s=arc-20160816; b=rIA32T0bQWdVBDMhV5DGMqDdWhE7Ez3bkQKjY6Jk9ku8n1e9Mh5BNfGU4AMQJUpqTa UU2Tvgu+c81lz5w/SPWhCBJbFnVNM/Cakx0LggsCxjEP400DZov8/RKApNQbYA9okUUF TPBnRMs/EewFvlJKVTQKtANOsa7RXr+AAEh1e1HUQ8f/lwBwu2tJU999QMxsKUDrHe+J FvZ+ZsqoGkZg1shybRWIdZm/pVOX+vFJmRzcbj111w4Ys7rnNBnu0a2uVCsHzI8MIorn s7TTocQcjnlYcs8U0cBFzycb3Ohk0Ku5F7HqS7uBKQzEQwavSH6eJIq4wSZSfOOZhJxg G7tg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=fvj+WUGANmLFqW2EJSINSwwcAn8sLAyNi/cgHqJTnR8=; b=KnY5zmVhvcPAG5WLZJONza671R+6w3tcHvAraRVfR9IJ3eVO84EJHMUC297E0YfkId tb+/1wbdf2h8TRebJ+lyajNXASAc7jYT7w1bnuAPc4dn0t9yi8NVTFASS4fl9oeDFQ3d O0LKZzNMCA0z3+WLBgBh8tz0uww95KfnLCs4j0CqZTJ8NGTSfqh7FeKzXXg1HEqciADW NNdG+SHgnvVA49b1ay2UzGXuiYfLMtWPiscznOPVHLsf0n8APdcLCM+MP/WLEsA+n/lD UFQudIhwDPl1pFZLVJd+kl+TaW8aC+ELuYQRsEIPSx8LfiOg94B0mww47VlnT+hwIZia vO2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LDLRUGuR; spf=pass (google.com: domain of qemu-devel-bounces+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 q36si2359955qta.74.2019.06.14.11.42.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:42:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LDLRUGuR; spf=pass (google.com: domain of qemu-devel-bounces+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]:54218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr9a-0001U7-Md for patch@linaro.org; Fri, 14 Jun 2019 14:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34086) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0K-00076g-AJ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0H-000401-Qr for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:43 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:35312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0G-0003ms-TE for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:41 -0400 Received: by mail-wr1-x436.google.com with SMTP id m3so3381117wrv.2 for ; Fri, 14 Jun 2019 10:28: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=fvj+WUGANmLFqW2EJSINSwwcAn8sLAyNi/cgHqJTnR8=; b=LDLRUGuRo1k6ccAgdmq4PXLjpEXU1bA74OtyyoAn2v/rzsoR6vBnHY0p5mwIKlEyw1 jTvhICmW2dK0obdWwmS0dpI+bPC7apkvpWKg/j2QNq47JejrjvqxM8FO2hFt29J4UOI9 u2XYHX5v8xxKo0ruXvTEwvhjtGWHFv7ZKmlNEzpCuM074r1VANN6z03PQ+FgDJpnhdQy iJowrWJmlYligEcU44Kv400TMHbJdnkZhji1SS74EMGiweLSPmINL3tzDsj2Zl1wzdFw b+AD3ST+ePK1lTygQwBdfMAQ5EAQU5zOn/cZu7534sWH8sOyKDecHHEuF6YA1UFtBBsz U0Hg== 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=fvj+WUGANmLFqW2EJSINSwwcAn8sLAyNi/cgHqJTnR8=; b=Lr/phDMjf9ewz7FuDrFz7PK8nI7vim/m2h5z5dY9PrdJ8ThNBzdMNzuVmNxr9PL7uV JkJk5rhz9Zkqj2cepqroNP9tQMEckw6AQ4/axlF1t390wxshNxj76E1h3r7qB+FulYJ7 U0U+UVrnranKDXtpmqXbPLkkV1+UHV8yE9GLLuJeg4N0niMaHfFSmW4UKreKepUUsA97 E6XapmIIkHJUU00L+T6NTacNiARJLBXUH1x8B01Otu8i2MjsGlSFiYDCv+NL06C6bD9W ZZgb3/s6nFMRRbqqNSHOHdoABtC1Khz61nhyhpX5BuQFNMsj9A+mutPQ6ff5/80fC3/J 0DYA== X-Gm-Message-State: APjAAAVXJXUmsurtuQkOqSLLkZvA0JZVtXSQo7bgihdwm+IfTDzRa1hF s1ECf15Etlg+1+pCXRuV4yKOLg== X-Received: by 2002:a5d:548e:: with SMTP id h14mr12198151wrv.76.1560533311917; Fri, 14 Jun 2019 10:28:31 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o2sm5672335wrq.56.2019.06.14.10.28.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AAF071FFC6; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:57 +0100 Message-Id: <20190614171200.21078-48-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 47/50] accel/stubs: reduce headers from tcg-stub 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: 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 --- accel/stubs/tcg-stub.c | 3 --- 1 file changed, 3 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 76ae461749..431ec7d7e6 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -11,10 +11,7 @@ */ #include "qemu/osdep.h" -#include "qemu-common.h" #include "cpu.h" -#include "tcg/tcg.h" -#include "exec/cpu-common.h" #include "exec/exec-all.h" void tb_flush(CPUState *cpu) From patchwork Fri Jun 14 17:11: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: 166911 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2369723ilk; Fri, 14 Jun 2019 11:11:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6PsnC0Ka8hUDasPNtd7YNCMUDMzOGsKEKNC3bJWXndx2LmAs/JD+ko2+ok+DE0+XkaxD4 X-Received: by 2002:a37:a98c:: with SMTP id s134mr74902531qke.176.1560535870142; Fri, 14 Jun 2019 11:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535870; cv=none; d=google.com; s=arc-20160816; b=tjO/vLVKKr/nuD5OginZIzqNH67Hd7RHDShYKwa1siqVvOmeShoRU7hge+cMABl0pz zz5w7UbG5llZ60yU2Ywi/hpq/3bxuv+iVHnNkD98aLK4x41GlvW8ra+mvYStuuwDaKeC Kkv8QKvKdXTojSSg95AqwzulH2/tj/gvolkwTpuA8GmFALI1aaBujlGFuMsEKG5wsPVO G+Zq76sOHJcg/mZnBM1eAQrW0dJzQ9AWVm5xL+a++VdONdUjgs60twH2vBj9lrubDtIk y5d4CWSFZisef68InOFtNxA610T4+6u/duL1h7c2ADRiX1uA/FB3FRUDlVGb1xYM7eU+ OzQw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=2ielurtjzGKb7Ob3E21QU+qcFZWaTKQ9JelyDfiWc2c=; b=hKTB2JhxhX9WTgx3tzb9O3FSlAwrBFWh92cITZGfDITBcHb5GWzI0RKWOn5h4oFc3a 5zLQQZx3h67hZNV3zgpqrAEmrSbbLxVb0+pydd6MEYOnr5mvEg7+RSMn5C80EHEm0N9d LeuGi+7aiIBDXLyfpiHXnFIF1Z0DXfdkLsVUZTUX4eKasxWL2aOsCv/JLwoyBgwuiFS0 Vkpo7KXlJZO+JQHgrA9FIBV6hemllJBkf8H09kcC8qJc48QtLIY3Ge1vWskJTcOlPef3 DKub7142JNhrBP5SwtIcfOScLTlt3HY13d+YJiaHID6ANrdBzJ5g5YIptyXVFWg+IdDg ixQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="lphYM1/V"; spf=pass (google.com: domain of qemu-devel-bounces+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 s3si2231816qkj.259.2019.06.14.11.11.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:11: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="lphYM1/V"; spf=pass (google.com: domain of qemu-devel-bounces+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]:53994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqfN-0003Wq-Li for patch@linaro.org; Fri, 14 Jun 2019 14:11:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34033) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0H-00076I-6R for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0F-0003x3-3c for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:40 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0C-0003sD-ER for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:37 -0400 Received: by mail-wm1-x342.google.com with SMTP id g135so3141263wme.4 for ; Fri, 14 Jun 2019 10:28: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=2ielurtjzGKb7Ob3E21QU+qcFZWaTKQ9JelyDfiWc2c=; b=lphYM1/VPBturLVvPuAe4PioAnB50jvTV8shBn2ISbOesQV6pD+lMpq24om+fHsDoa v+duzE5lG7A5F1e10FUPQ3b6v8yHw87v3uViEI6XWth30QeccQQsSNvXJHRaOjdhiZFO LFchlXkYp86Ig0gYDlgcTjN4MblOn6kVDNQ80O6rF9SKnQbqMkMXhcQlNBN7MR6XrMNo EK16GlylIXKVtyQ3cZkwDlHB9XdeyyadAwUr3eS5dJ0j7B5IryX3K5G+ikksX8N7tfAm LQ6brQQ5rxsBeqxyMarG3yG8Tk9vsG/fzPiBFqKNf7a0dcjWGiT/yepaQmX7FvHLVKQo I2lg== 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=2ielurtjzGKb7Ob3E21QU+qcFZWaTKQ9JelyDfiWc2c=; b=VIA5Dh1o+D7XhgsVO8P3jFbKImDQmM0m3izta8ez0uEssPl0oM6V/0fGs96k6cTXHT yd/tKK2UbCG2Ag2LC+cDs6iNIRlsSM/LEgXN+cHZh1ncZU8i1hTiTfJzUYEYnSw2euak S0EcpqfZmyY38A3MoXKPm06X/UWEru7wsaE/8q2kEvVmon4O8ku/04TNiop5qOrOAjI4 AVsYNGl0z5hZWKNTGqu9C2x+EP2DulqwnMqbrH8TMC/Uzl+NFInZEaOGmsaBS/iWwpDr X5iGW/7H7RxT+AQLxq4XUeb10Xs2B+ec8xcGxQ7CQH/sp6stCdyv6K7oHrXKAbNBdTj8 4lig== X-Gm-Message-State: APjAAAW/GO6el/ZdPKZQu/J8RhGVDMkIL0cB0tCZBg7fPUbwdKpx4EK+ y9R6MiyaC6FiGsxE6yQkjBXleg== X-Received: by 2002:a1c:9c8a:: with SMTP id f132mr8766940wme.29.1560533314450; Fri, 14 Jun 2019 10:28:34 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n3sm544040wro.59.2019.06.14.10.28.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:30 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BFEC11FFC9; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:58 +0100 Message-Id: <20190614171200.21078-49-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 48/50] include/exec: wrap cpu_ldst.h in CONFIG_TCG 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: 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 --- 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 90045e77c1..fa4d5b9533 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -21,7 +21,9 @@ #define EXEC_ALL_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 Fri Jun 14 17:11: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: 166910 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2367712ilk; Fri, 14 Jun 2019 11:09:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM5nq9HmCqW/cqO0q3BRuvw0Jpy2pH2NLL0t11idx/J5MvnkDltXB83DKp8yN0RRtMJqDF X-Received: by 2002:aed:2389:: with SMTP id j9mr55858906qtc.244.1560535756722; Fri, 14 Jun 2019 11:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560535756; cv=none; d=google.com; s=arc-20160816; b=rdfi3uLSH6LN3G/aiKCSCgIGm+pkYCYFhyhYmPV7Eb0Uiuxil2qDGRfj/KlWZuTCm/ rzHy9N3B6q/a/SgtEE9wL3gwiB7ebIxFM6iU7g35ns1UDpmYZpsByKIzWnQbsFF3fZ3G wUX/7DHc6yanmJeo8gY4HR+cnSSt4fRGQbD2Fkjv8JSVf6WHchTdcyNiRQaV3pFf8HNg NXdWcWqNQ7S6tUqpvxtRvbJSgf9GpMweHEKikln5UzsN5hL9CTtKdXnM+iozHmQ8qunb rcBXjXSAWvC21KvOOA2geOHkSzm/txbsCFqDCcxMVtia8d5/lperlK/noICjcLD4u2I4 3qpw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=W2oEJPPTu0XotTJyTG/icubFdccUFHMYcxjFSxZmE7E=; b=cdbCXQkMBKdN7iToA+ty3UPoPI/y8GTI358huwWkvOKO4nxomt9byQVRMGDrKTReoZ +3iIab8+PFaRv0I0l8u3S+iP7p16O/QcVcB0slG8BFFib28MA5sxQcYbWgmHrPqBSnF6 zVQsnfOz0POzZvLqrdcaLMdAG8nswXDkSnqsO+pnQEgF4dM9dU25msEESlFIetta6k2u lIkam6i7+oGB+eSEDxBAl0f+yAKbB4raG1KO92Hhj+Fv1Qmel2FFa/miEp0PwFIqx8Fo YY+WF5m/trLmlpH53UtDhcvFbXSMrCWTynrZmp4Vzs8QIGXT3zqKcmu0VOAgJKVqJv6W LGqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zV9KljVm; spf=pass (google.com: domain of qemu-devel-bounces+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 e4si2191427qkg.29.2019.06.14.11.09.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:09:16 -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=zV9KljVm; spf=pass (google.com: domain of qemu-devel-bounces+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]:53984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqdY-0001Y3-95 for patch@linaro.org; Fri, 14 Jun 2019 14:09:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58669) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpqj-0005bZ-71 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbpqf-0007A5-Ac for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:48 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36068) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbpqe-0006o3-AS for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:18:44 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so3355612wrs.3 for ; Fri, 14 Jun 2019 10:18:37 -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=W2oEJPPTu0XotTJyTG/icubFdccUFHMYcxjFSxZmE7E=; b=zV9KljVm7HRXtaa5nQ3r6/hpHMVfa5fDVTakmt+t8rjZR0BRKWZyEbYhLGfmcdhEN9 xXU1hgnVM2SntB/EYjF74Ai8teDFM5m3VneiW+Dm6CaR+1JZmbiCZQmbF7g53BEulpxK /B1UNrQA/eACnE+0TeGJNCpOjijTwgdua/U4aCQzPoM5WNOVLJTvconYfVW1u0tnl/A4 fc5upEoumWoxstCduCLtwNhbxdJO1VijqOlCDJWda4vdsio9qQd0pgp7dHSP607nNeHw VobWLqwpHxdP8aVawH/8U7oGPJVkpQSg5cUzqdzL/BtguJ6bRGfEi7Fu3GxikRR4+F1/ kklA== 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=W2oEJPPTu0XotTJyTG/icubFdccUFHMYcxjFSxZmE7E=; b=Q7uabZkr32tvzF0c5c+JoJu+AKcdc3+CgeBIp52J940XfVOuzpm3aFG+AJUAOT/T/U pSkJoIrR/w+yUACe/bemq+rnkVShYvCI2ChRLYVQUky/leLdbvFrmEiyc8nlamb2QIZa fVtqsaN0pNPXk9ybeD3MhiXbntpPTRq1+z/UGWPDATQjSF99sruXRWh4zGpor0jl5fv5 u93So6At83UeQdnvdUmN+WYbZqejJg6CFgozbYEH07V10aHET0aAWgFxcc8FS9QVejZ4 BhIRrzFUNZzwiymuIJGBK/suN7zwDkPAfP+Z0+fyQad9L0DrsN0aRA7zt5qvngAbW5Ll xbiQ== X-Gm-Message-State: APjAAAXnc+5EYB2AdcVTftvJxEKYKhKbaBVLDqh0/M4qacJ5f9hd5bex Dl7U+blXvf9bwCPnXyRWnW+NSg== X-Received: by 2002:a5d:4e50:: with SMTP id r16mr13474318wrt.227.1560532716650; Fri, 14 Jun 2019 10:18:36 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id i12sm3588188wrs.43.2019.06.14.10.18.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:18:34 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D28DC1FFCA; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:11:59 +0100 Message-Id: <20190614171200.21078-50-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 49/50] include/exec/cpu-defs.h: fix typo 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: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée --- include/exec/cpu-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 354788385b..b529c2013e 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -241,7 +241,7 @@ typedef struct CPUTLB { } CPUTLB; #endif /* !CONFIG_USER_ONLY && CONFIG_TCG */ /* - * This structure must be placed in ArchCPU immedately + * This structure must be placed in ArchCPU immediately * before CPUArchState, as a field named "neg". */ typedef struct CPUNegativeOffsetState { From patchwork Fri Jun 14 17:12:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166926 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2403083ilk; Fri, 14 Jun 2019 11:46:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUmodUpIkHbmPnwcI4vJViWmtOkgFquY4PXA/YZsMnkcLAl/VmRqoPaZnGMYW6+pI575fh X-Received: by 2002:ac8:219d:: with SMTP id 29mr19500047qty.37.1560538016691; Fri, 14 Jun 2019 11:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538016; cv=none; d=google.com; s=arc-20160816; b=elFZndGTSp25/CwhI0DK08ofUyE1j3UV3uQiin4O/orwk35BFhhqCktGsvJk3V2FkT 0DaYAGJoWCSVOj0i9pNi7ql1XYRX5wGkGzG9XaBkMVgpBa24B7i+7JUgVD8nbFiCHJrC DNiXZpOv3zRXztcZgjUjg1KRnBtW75X1MZyacKDpNmaiWuxzBkZjmmL+gMhwgaQJeleX ipciF/ieb5aHzvWduuR21OIc613vMsEpA3B+iEBOips9UG4plIVNEzdgAK5atWDOgXi2 d+w24VLT39Trtm2EoBLYT1+b5gnALjeSKoFWKs3eq1awax92x2PRdxcexMIWVwk9s9en li4Q== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=l+F+1JN97gKyw7kKNWTOxFjpETDNYB39JWHiUo3QTVA=; b=wVKSFpIkCdiX8xru/Bjemn/jTokD3I87lWaBMWf5ugthCL5vkNsnHl4GT3h5ln5Bpl LX9megL9KrBvikmDtawT6dm5EtovHFg1ZwU49+OSWaPHOtbsfK6WELV/iAkO0ni3SVzS xNirSkQunnxmvge5BDezfHn/fArjeXL4mD87oJaRXN/nf0ShcnfKEDc1Re3Mji9XFpb/ JE8lAH3iOShOUyIo6mx9b7OT737EyeGBQWwdRdd8NCK7cxgnUyM1rqXAsfrs+/quI9t5 WZb5i3h57fb9puu7v4Uqd8ubRuozfd6XOiFni8+9TzOLsxf+O4Tls/soQg74wC7UBbSA JYvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sb6Xu5Kp; spf=pass (google.com: domain of qemu-devel-bounces+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 i53si2274399qta.136.2019.06.14.11.46.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 11:46: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=sb6Xu5Kp; spf=pass (google.com: domain of qemu-devel-bounces+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]:54254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrE0-0004ka-7g for patch@linaro.org; Fri, 14 Jun 2019 14:46:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34208) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq0T-0007A9-MY for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbq0P-0004Ca-Dg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:51 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbq0N-0003wR-Bo for qemu-devel@nongnu.org; Fri, 14 Jun 2019 13:28:48 -0400 Received: by mail-wr1-x444.google.com with SMTP id n9so3386221wru.0 for ; Fri, 14 Jun 2019 10:28:38 -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=l+F+1JN97gKyw7kKNWTOxFjpETDNYB39JWHiUo3QTVA=; b=sb6Xu5Kp41Z06TykOvhElWOnU/IGs1hZmd23GE+R+8eET7wGXVqS4I/T6oA76AIkSK 0b+dxWBpr7NOJZ79VVLP8ambmypEN8uW6/WSDPdE3KPdvFTc0d5tT/fDQHljertzxPL0 mRK+wijtp353zjBR18hWt9fd8LGNTMKYl2pcD2/pjAaz2BXaH5NiyzuTIlwFNqw2EMtF lbxQtxBSSfmALXKphpaA2mMbhjkv/WzmSc17qAu9J/HeqAqOsikpbRnGjRLcby40I/im z61WDhl3HyReuCU2dWkOEgZG0bLlzs57RLA3Nv6GaAPSld32ffb0DwL8W2LjNz3/7i6R FryA== 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=l+F+1JN97gKyw7kKNWTOxFjpETDNYB39JWHiUo3QTVA=; b=E88vv6nLS++QKbsNovbk3LncZVEtMJjNzVOIkI/DplHTE3ZbzlwCOyAFtX334xUMOo uqoHpiqnEpcs+TchclWX5+Zo/XRG4VC9YcndmB7DE5tZyVGhIXwgDkdsF5uMrTt2uMAj 3Bdwd4qLshq3BPwk+Z63+SthJI4nUc7OBfMr3WG+SeRJ+gVoyA78doc7tPhLtYZkdT5p 589BeVQiaempM/wsKd/2fBhzGbV3bzuD8+hHYFyIA+soOpmTNmggEauo1cdSb6M+oImy k0CYOXMugtZm/AykM28cUPqWclpanzQL/7KP8mABFsUYoJ/+vMa1Letlp138FgxmlvXf MVfA== X-Gm-Message-State: APjAAAW3nf5LBK3lsZp2yklzsXASlDKVCVhi0DpZXtz/gWS1p2ysPtg6 yUnt2hrXbzxyN4jQhIuhO1FbYw== X-Received: by 2002:a5d:6709:: with SMTP id o9mr52157881wru.301.1560533317777; Fri, 14 Jun 2019 10:28:37 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s188sm4205143wmf.40.2019.06.14.10.28.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 10:28:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E50C71FFCB; Fri, 14 Jun 2019 18:12:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2019 18:12:00 +0100 Message-Id: <20190614171200.21078-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190614171200.21078-1-alex.bennee@linaro.org> References: <20190614171200.21078-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 Subject: [Qemu-devel] [PATCH v3 50/50] TODO: API changes to make? X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" --- include/qemu/qemu-plugin.h | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 21f056d4ab..655640fe54 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -169,6 +169,7 @@ enum qemu_plugin_mem_rw { * callbacks to be triggered when the block or individual instruction * executes. */ +/* ??? - should we expose vcpu_index here? */ typedef void (*qemu_plugin_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, struct qemu_plugin_tb *tb);