From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534066; cv=none; d=zoho.com; s=zohoarc; b=TwkCzPEijFObUnURr0O++RhswCE+hlIxBfMuIDQt71xeUOIjxlXSFewhoKQgN1VHzXx8Ji2k04qwhvU1EQZFV8wsEPIWaWqknIs2tkTATjnh6FOwC3puR2VPVlkm/iaO66/q8LisE5Cpg5qudnUmK+Scn8iMo3iTBQ2V14xXPgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534066; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Oj/0oPpqLDS/GX/KzCrsGX7DQFLG22FAaJqDHl23Ay4=; b=YrDbnZ1dLhukufqQ7YG7+korpMVovdUytCQCkHjNLvfrih/1LPT9MNXXL5lx8tSBmBuNFDxwYT77RikRRQOHbZ3QAYLRxxsTqEJRy2md5WlnnqPBZEMd1CDaH4+cVlGByJRF5eNXlfmcenO/H0Y/btE8BhU4+jUYTnhcHRkWy50= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156053406637092.2545751328339; Fri, 14 Jun 2019 10:41:06 -0700 (PDT) Received: from localhost ([::1]:53834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqC9-0005p9-8o for importer@patchew.org; Fri, 14 Jun 2019 13:40:57 -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) 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) 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-Google-Smtp-Source: APXvYqyXYaUP5/nsn+/uIdwF80NhYG/ZQOeUsR5r60NGPeGsixupb6MBeBGtKw7kTlCdkACIMYAAEA== X-Received: by 2002:adf:de90:: with SMTP id w16mr33056671wrl.217.1560532321714; Fri, 14 Jun 2019 10:12:01 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" This will allow us to trace 16B-long memory accesses. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560532778; cv=none; d=zoho.com; s=zohoarc; b=c1TLBB00d8u5XaRPF7dlA/c4z7ynLnadf6eaexKmjhammjeY3wyZVh68rFtI2hbStdvAEJTwm310PczDOVj0inraRjgxlqupsZY2y+b+QRjmdp9ElMlgHZLFBSmazTvque/8hMOFZCOJpLNdeCo3AUD4zFpTqGMCZ0mGkOBLy8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560532778; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uuSP1+OO4V0J/TIomTItZc3CIXnPAwyQAIRCHYQETno=; b=AwQcEMy3d1IsyVyIRlNw5PeQ/yQ+CD4jWFwZ8CdycPR7F4qLFAaoiu2CZW41y2efQUX2jdwzrxZfT3Ew56P8H1crvZiJ5Vcf7K/kg5qxoV0yJt5+/6KSjVTL61EeqBmnyY2wh3Smd2s4Xg0igat8Nvc2Oly41qyyL3bMFNDhqXE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15605327783151001.3727051121309; Fri, 14 Jun 2019 10:19:38 -0700 (PDT) Received: from localhost ([::1]:53708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbprV-0005Fs-1V for importer@patchew.org; Fri, 14 Jun 2019 13:19:37 -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) 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) 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-Google-Smtp-Source: APXvYqxd+CILFS88J+V+wzu9kgZ2fli/jH116BhLIXbrKYyil3503Ot7de3KlD+8MWH5hCPViR8+Aw== X-Received: by 2002:a1c:be0a:: with SMTP id o10mr8688679wmf.91.1560532322971; Fri, 14 Jun 2019 10:12:02 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- tcg/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 mod= ifiers: canonical locations before calling the helper. - TCG_CALL_NO_WRITE_GLOBALS means that the helper does not modify any glob= als. They will only be saved to their canonical location before calling helpe= rs, - 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. =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560532541; cv=none; d=zoho.com; s=zohoarc; b=dbtwg4GAH+H7CaQsQSeFYwmhm5/rkylV0FEPXqJxj3KSp659xMgG9tQ3eGTpwZ+fWpeXcTxUC5XYAxZ9XSvqBI4xeRVGDXT0y+eu+p/qB+MyNM54v3paIdgxNb/o4SkouNf1y68dwx3wM0pTXqJe2Up+VZMV3cZSoAIyoKi5NWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560532541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bJlRK12NgWRhW3McWfNYPpf/1E3ddcXa2ZT9Jrrle8U=; b=TLTfLtJiXYADcILRukzdP5eXtlV5tARNW0LmkZCr6zLlRdWX+OUufmtyC4p5iOVUIuYkyWUpe6AjhTsm0gILVUp7Fudt7Mhx35ttkQyVtMO0/24JpwtezCRBepq791Vegr3bfaYj5qY7ImADJuiX5h5fq9CnwElBa/+CNiEo2LM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560532541257563.2847664997227; Fri, 14 Jun 2019 10:15:41 -0700 (PDT) Received: from localhost ([::1]:53672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpnb-0002gb-0K for importer@patchew.org; Fri, 14 Jun 2019 13:15:35 -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) 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) 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-Google-Smtp-Source: APXvYqw0OJnrgeBp6CxmVpNi+pYutlL6v8aJUUfQFIWNpItw/0kqj4OHO2LSNrdfWCdeGYvQIM0pcw== X-Received: by 2002:adf:f186:: with SMTP id h6mr719115wro.274.1560532323665; Fri, 14 Jun 2019 10:12:03 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Suggested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- cpus-common.c | 2 ++ include/qom/cpu.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) 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 =3D true; wi->func(cpu, wi->data); + cpu->in_exclusive_work_context =3D 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 f= unc, run_on_cpu_data data) */ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu= _data data); =20 +/** + * 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. --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534307; cv=none; d=zoho.com; s=zohoarc; b=QbqdlGMV197Zs1pYWc1P9SDJDepBIJIVqlFuudLjq1yn3mgr0PyeL1izXrJ9icaFJCUTk8oZkfrczXu8cl2Bu/p0ZLsTXEf5HiflCbT5c+Du1TbqKbjcrOoteYRRVkzKYmktgtZ237Viy5lR9eh3hE5HDEWv8Rf5IvwRrwipts0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534307; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=08HscLjvD+PkgROa+8EpI2roPOdpCcPPJ5uFR5Az32c=; b=Qdrg6iYljy1b5YeHZ7Yg0KVw4Zk6N1mLSaMSosH3HxPdskN0hGln/1tLSG7YjvjKh72YvLvXrvb8TCVVq9696xQIVaYJTTkpIxULIw4/yMVOjF6IIzkSwffW5eeYmyiaxZWYdY1OZve97gtyr6Ck6pnf1+uN2uq0/KpmhjQHlgg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534307186888.2913698718093; Fri, 14 Jun 2019 10:45:07 -0700 (PDT) Received: from localhost ([::1]:53856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqGA-0001l5-6X for importer@patchew.org; Fri, 14 Jun 2019 13:45:06 -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) 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) 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-Google-Smtp-Source: APXvYqzhA8snmlATmHfzsrQfvqPGr5v/fUWlMygQk+FX17hE35G1ilsEY/O5/ClyK2mBSOqf7a0hFQ== X-Received: by 2002:a1c:305:: with SMTP id 5mr9092711wmd.101.1560532324399; Fri, 14 Jun 2019 10:12:04 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 =3D 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)); + } } } =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560532934; cv=none; d=zoho.com; s=zohoarc; b=RdZkAU7/o6i/FyWWHiIseMDOwRyh30L5i5KENb0Jb6hGMgKK40SN3lPq8u7jJKi3gMr2FVGWvgg3DkrZkN2mSBmLZ013E4vu6P2dMsFUHPV6RL1xUUMFD8E1fTF+a0cohqn5fsnxE28SNbNaEp9fwz0IIBsKABEx4r3vIdPlwkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560532934; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LmI/mBSkUBusQla1865jT/J9Nwa1pt6elfDdpjwViYY=; b=RDlUTmxsbqVcKcf7aAsY/BttDKCcYDUmXA6eSCHjTP5WcpTaWOZSeygd59DBw9puM4IDNzNFSaTKPL2LZkMttofKLO++XxNKSAnD7X+eObkrODW9Y/ZoPTd+7NjykyJfqiyNakoDNfWV1+0yuO4wS5IchEV7ATQz/Ke+v1e4GrM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560532934654932.2620373916034; Fri, 14 Jun 2019 10:22:14 -0700 (PDT) Received: from localhost ([::1]:53720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpu1-0007u1-Jp for importer@patchew.org; Fri, 14 Jun 2019 13:22: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) 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) 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-Google-Smtp-Source: APXvYqwUsrcBj0hO3R1n/BFkgctTyDnI4apXTJ83PUPxly6zkbN5uXcm8Hf7cxjA4qN4TYBDT7iaHg== X-Received: by 2002:a1c:f713:: with SMTP id v19mr8695931wmh.159.1560532325862; Fri, 14 Jun 2019 10:12:05 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is mostly extracted from Emilio's more verbose commit comments with some additional verbiage from me. Signed-off-by: Alex Benn=C3=A9e --- docs/devel/index.rst | 1 + docs/devel/plugins.rst | 99 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 docs/devel/plugins.rst 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=C3=A9e + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +QEMU TCG Plugins +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 +=3D=3D=3D=3D=3D + +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=3Dinline,arg=3Dhint \ + -plugin tests/plugin/libhotblocks.so + +Plugin Life cycle +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 unin= stall +function returns. The plugin isn't completely uninstalled until the +safe work has executed while all vCPUs are quiescent. --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534791; cv=none; d=zoho.com; s=zohoarc; b=kEjPZxde494+HoO24OWGbMNuuGNNXRXcGyOJ+7e2AEOE0pnb3nCIlqMnZPRtk9GaMI0rtbch629j7cVAyIMoSww7/pXTacGqDFjK5XJNJTB+rQZJB5tjYA0BH/5GdjC5ZPC/ncBxcVSNcFNp09jBbpQ50ZGuUatIYd1g+UBYbF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534791; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8bC4Ua5+cmFCH7/z3JbOgJMbpPZnAdyKgQfwrXL9vnQ=; b=QSaQJJVXy47yrim6cMCxTkJY8Ib4IYBKd5LV/oozpFm2PVAIdVpq8aybV5xydD3CKAnsXToVnDJyiM811W/6c8ddHmz0+QfZWfL68ceF+Ju/fSq0c3j57BVweUEWMQ4fXRjtfVtXFyBLKAVgf5s0UXMx1LVjAFjn+x5b4TKV/2c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534791480644.6989211304767; Fri, 14 Jun 2019 10:53:11 -0700 (PDT) Received: from localhost ([::1]:53898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqNv-0006a3-7s for importer@patchew.org; Fri, 14 Jun 2019 13:53:07 -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) 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) 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-Google-Smtp-Source: APXvYqxdaEDeW3Y8t0gEuaqlC2MeHYNd7b/kjp6EC2UQmCyiSQYj/MN5olV0B9/GDPxJz2yGuLPxCg== X-Received: by 2002:a1c:be12:: with SMTP id o18mr8616695wmf.21.1560532325117; Fri, 14 Jun 2019 10:12:05 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure b/configure index b091b82cb3..48f3263e55 100755 --- a/configure +++ b/configure @@ -493,6 +493,7 @@ docker=3D"no" debug_mutex=3D"no" libpmem=3D"" default_devices=3D"yes" +plugins=3D"no" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -1537,6 +1538,10 @@ for opt do ;; --disable-libpmem) libpmem=3Dno ;; + --enable-plugins) plugins=3D"yes" + ;; + --disable-plugins) plugins=3D"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 =20 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" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7296,6 +7304,11 @@ if test "$sheepdog" =3D "yes" ; then echo "CONFIG_SHEEPDOG=3Dy" >> $config_host_mak fi =20 +if test "$plugins" =3D "yes" ; then + echo "CONFIG_PLUGIN=3Dy" >> $config_host_mak + LIBS=3D"-ldl $LIBS" +fi + if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" =3D "sparc64" ; then --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533109; cv=none; d=zoho.com; s=zohoarc; b=UVytVnZTf5JU5mWt05/IK5gbFBeALLCzd+Doj3eaUBRaUnOPbE5ME2s7NNlSHZJViHWfK+YqEtrxITSIWJAhQ+bS49OVACY4tGZMPIyu7ttwdYzg2dqMpjGRpeuTtPUZh8rnsebhMGF9v9dr1xeqbu6wHU+RELp4+6Z4dsdb86Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533109; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+NsNu/fQ72HqiGPytLgCEAG9ztz6pLZ4BO4isDX3okI=; b=HKFZtKIXVLjDD8LNxzrXIVb/NP+QDeIDJZkJXJ47elxLrIOWYHkM3sfTjTL8Zq90ZcpYIfvYQm6/MogzBJ1PMz3jyeuo8MKL7klmv4GDgvGyceuCsOR9/MtiGfbA2wtqcpZTXYW9kBkEcT28FA788ZZrk3R37AUmACgnD3FAugo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533108982279.82753905041466; Fri, 14 Jun 2019 10:25:08 -0700 (PDT) Received: from localhost ([::1]:53750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpwp-0003N6-Uo for importer@patchew.org; Fri, 14 Jun 2019 13:25:07 -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) 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) 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-Google-Smtp-Source: APXvYqx50s14IHdIB7zQexL3mBSrztav3kuTm2g4ETiJsaUXhQwNTWW7F24RPcivVwrfq0/NNDYJVw== X-Received: by 2002:a1c:f21a:: with SMTP id s26mr8512836wmc.163.1560532329097; Fri, 14 Jun 2019 10:12:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Add the API first to ease review. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Benn=C3=A9e --- 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 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=3Dhidden so th= at + * 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__ >=3D 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 r= aise + * 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 receiv= es + * 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 ca= llback + * @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 =3D 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 callb= ack + * @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 flag= s, + 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 *i= nsn, + 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 va= ddr, + 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 flag= s, + 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 *pt= r, + 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_in= dex, + 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 vcp= u_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 *userd= ata); + +/* 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 */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533508; cv=none; d=zoho.com; s=zohoarc; b=Iu1fl3gDAdkObaH9V22uipiibLWOc/BsdSGUrrPRKU9f88jVbkNr7S4QF0OKGn7isxGa7CXRrHUYIO/EEbVw1JNPVgWVhsExEVhdP9JZriu3RUoBpdcG1mhaU7DRWxn0KXEUlpGkIO6RhHXcH7FASkve0kjMGKszMi0uKHygXEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8sZV78BJLDD4zzBRyO2MtNsLdyftsD11BN9/V7IukGo=; b=D2PX+9obqyj3IC2TKPBBljq+wShzgqLBtrLmDY1qvF0vhDJGDFQ4gtFv7siqlExlXi75t2y9VGr2fn9IJVgtKNt4iotQnz9/atNCOM801+Afje1qOS10VzorMv/tKT3pQxCxyagh3JZpuqeYgfi/EiiwX5z1ImUpeRkpO6/84P8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533508714339.6107203756641; Fri, 14 Jun 2019 10:31:48 -0700 (PDT) Received: from localhost ([::1]:53788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq3E-00080g-6C for importer@patchew.org; Fri, 14 Jun 2019 13:31:44 -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) 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) 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-Google-Smtp-Source: APXvYqy6OvqDCfajt3/N3aAt2cdJA/2ZwuwqH/Ycub6YFPqznCXn0rJui6MGKrexyIkQArb0NDHk3w== X-Received: by 2002:a1c:968c:: with SMTP id y134mr8586227wmd.75.1560532328224; Fri, 14 Jun 2019 10:12:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota [AJB: moved directory and merged various fixes] Signed-off-by: Alex Benn=C3=A9e --- 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 diff --git a/Makefile b/Makefile index 8e2fc6624c..37d396ab88 100644 --- a/Makefile +++ b/Makefile @@ -827,8 +827,13 @@ endif =20 ICON_SIZES=3D16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512 =20 -install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-local= statedir \ +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)$(inclu= dedir)/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 +=3D target/$(TARGET_BASE_ARCH)/ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o =20 +obj-$(CONFIG_PLUGIN) +=3D plugins/ + ######################################################### # Linux user emulator target =20 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-tim= e. + * 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 =3D (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 =3D g_new0(struct qemu_plugin_insn, 1); + insn->data =3D g_byte_array_sized_new(4); + + for (i =3D 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j =3D 0; j < PLUGIN_N_CB_SUBTYPES; j++) { + insn->cbs[i][j] =3D 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 =3D=3D tb->insns->len)) { + struct qemu_plugin_insn *new_insn =3D qemu_plugin_insn_alloc(); + g_ptr_array_add(tb->insns, new_insn); + } + insn =3D g_ptr_array_index(tb->insns, tb->n++); + g_byte_array_set_size(insn->data, 0); + insn->calls_helpers =3D false; + insn->mem_helper =3D false; + + for (i =3D 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j =3D 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 a= 5, + 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 a= 6, + 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" =20 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 ch= anges * 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); =20 + 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 +=3D loader.o +obj-y +=3D 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 =3D g_hash_table_lookup(plugin.id_ht, &id); + ctx =3D container_of(id_p, struct qemu_plugin_ctx, id); + if (ctx =3D=3D 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 uda= ta) +{ + CPUState *cpu =3D container_of(k, CPUState, cpu_index); + run_on_cpu_data mask =3D 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 =3D ctx->callbacks[ev]; + + if (cb =3D=3D NULL) { + return; + } + QLIST_REMOVE_RCU(cb, entry); + g_free(cb); + ctx->callbacks[ev] =3D 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, NUL= L); + } +} + +static void plugin_vcpu_cb__simple(CPUState *cpu, enum qemu_plugin_event e= v) +{ + 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 =3D 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 =3D 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 =3D 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 =3D 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 =3D ctx->callbacks[ev]; + + if (cb) { + cb->f.generic =3D func; + cb->udata =3D udata; + } else { + cb =3D g_new(struct qemu_plugin_cb, 1); + cb->ctx =3D ctx; + cb->f.generic =3D func; + cb->udata =3D udata; + ctx->callbacks[ev] =3D 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__loc= ked, + 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 =3D 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 =3D 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 =3D udata; + int cpu_index =3D *(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 =3D=3D NULL) { + return; + } + qemu_rec_mutex_lock(&plugin.lock); + args.ctx =3D plugin_id_to_ctx_locked(id); + args.cb =3D 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 =3D *arr; + + if (!cbs) { + cbs =3D g_array_sized_new(false, false, sizeof(struct qemu_plugin_= dyn_cb), 1); + *arr =3D 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 =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D ptr; + dyn_cb->type =3D PLUGIN_CB_INLINE; + dyn_cb->rw =3D rw; + dyn_cb->inline_insn.op =3D op; + dyn_cb->inline_insn.imm =3D 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 =3D 0; + case QEMU_PLUGIN_CB_R_REGS: + ret =3D TCG_CALL_NO_WG; + break; + case QEMU_PLUGIN_CB_NO_REGS: + default: + ret =3D 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 =3D plugin_get_dyn_cb(arr); + + dyn_cb->userp =3D udata; + dyn_cb->tcg_flags =3D cb_to_tcg_flags(flags); + dyn_cb->f.vcpu_udata =3D cb; + dyn_cb->type =3D 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 =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D udata; + dyn_cb->tcg_flags =3D cb_to_tcg_flags(flags); + dyn_cb->type =3D PLUGIN_CB_REGULAR; + dyn_cb->rw =3D rw; + dyn_cb->mem.haddr =3D haddr; + dyn_cb->f.generic =3D 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 =3D 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 =3D 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 =3D 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 =3D 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 =3D 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 =3D 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 =3D cb->userp; + + switch (cb->inline_insn.op) { + case QEMU_PLUGIN_INLINE_ADD_U64: + *val +=3D 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 =3D cpu->plugin_mem_cbs; + size_t i; + + if (arr =3D=3D NULL) { + return; + } + for (i =3D 0; i < arr->len; i++) { + struct qemu_plugin_dyn_cb *cb =3D + &g_array_index(arr, struct qemu_plugin_dyn_cb, i); + int w =3D !!(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 =3D qemu_ram_addr_from_host(haddr); + if (ram_addr =3D=3D 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 th= at the + * last instruction of a TB might have used helpers, and therefore the + * "disable" instruction will never execute because it ended up as dead co= de. + */ +void qemu_plugin_disable_mem_helpers(CPUState *cpu) +{ + cpu->plugin_mem_cbs =3D NULL; +} + +static bool plugin_dyn_cb_arr_cmp(const void *ap, const void *bp) +{ + return ap =3D=3D bp; +} + +static void __attribute__((__constructor__)) plugin_init(void) +{ + int i; + + for (i =3D 0; i < QEMU_PLUGIN_EV_MAX; i++) { + QLIST_INIT(&plugin.cb_lists[i]); + } + qemu_rec_mutex_init(&plugin.lock); + plugin.id_ht =3D g_hash_table_new(g_int64_hash, g_int64_equal); + plugin.cpu_ht =3D 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 =3D { + .name =3D "plugin", + .implied_opt_name =3D "file", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head), + .desc =3D { + /* 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 =3D qemu_xxhash2((uint64_t)(uintptr_t)arr); + bool inserted; + + inserted =3D 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) =3D=3D 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 =3D opaque; + struct qemu_plugin_desc *p; + + if (strcmp(name, "file") =3D=3D 0) { + if (strcmp(value, "") =3D=3D 0) { + error_setg(errp, "requires a non-empty argument"); + return 1; + } + p =3D plugin_find_desc(arg->head, value); + if (p =3D=3D NULL) { + p =3D g_new0(struct qemu_plugin_desc, 1); + p->path =3D g_strdup(value); + QTAILQ_INSERT_TAIL(arg->head, p, entry); + } + arg->curr =3D p; + } else if (strcmp(name, "arg") =3D=3D 0) { + if (arg->curr =3D=3D NULL) { + error_setg(errp, "missing earlier '-plugin file=3D' option"); + return 1; + } + p =3D arg->curr; + p->argc++; + p->argv =3D g_realloc_n(p->argv, p->argc, sizeof(char *)); + p->argv[p->argc - 1] =3D g_strdup(value); + } else { + error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", na= me); + } + return 0; +} + +void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head) +{ + struct qemu_plugin_parse_arg arg; + QemuOpts *opts; + + opts =3D qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, tru= e); + if (opts =3D=3D NULL) { + exit(1); + } + arg.head =3D head; + arg.curr =3D 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 o= nly + * guaranteed to be >=3D INT_MAX). + */ +static uint64_t xorshift64star(uint64_t x) +{ + x ^=3D x >> 12; /* a */ + x ^=3D x << 25; /* b */ + x ^=3D 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 =3D qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); + ctx->desc =3D desc; + + ctx->handle =3D dlopen(desc->path, RTLD_NOW); + if (ctx->handle =3D=3D NULL) { + error_report("%s: %s", __func__, dlerror()); + goto err_dlopen; + } + + /* clear any previous dlerror, call dlsym, then check dlerror */ + dlerror(); + install =3D dlsym(ctx->handle, "qemu_plugin_install"); + err =3D dlerror(); + if (err) { + error_report("%s: %s", __func__, err); + goto err_symbol; + } + /* symbol was found; it could be NULL though */ + if (install =3D=3D 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 =3D (uint64_t)(uintptr_t)ctx; + for (;;) { + void *existing; + + ctx->id =3D xorshift64star(ctx->id); + existing =3D g_hash_table_lookup(plugin.id_ht, &ctx->id); + if (likely(existing =3D=3D NULL)) { + bool success; + + success =3D g_hash_table_insert(plugin.id_ht, &ctx->id, &ctx->= id); + g_assert(success); + break; + } + } + QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); + ctx->installing =3D true; + rc =3D install(ctx->id, desc->argc, desc->argv); + ctx->installing =3D 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 =3D 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 =3D 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 *da= ta) +{ + struct qemu_plugin_ctx *ctx =3D 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 =3D 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 =3D 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 funct= ion " + "is a bug. Instead, return !0 from the install functi= on."); + abort(); + } + + success =3D 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 =3D 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 =3D plugin_id_to_ctx_locked(id); + if (ctx->uninstalling || (reset && ctx->resetting)) { + qemu_rec_mutex_unlock(&plugin.lock); + return; + } + ctx->resetting =3D reset; + ctx->uninstalling =3D !reset; + qemu_rec_mutex_unlock(&plugin.lock); + + data =3D g_new(struct qemu_plugin_reset_data, 1); + data->ctx =3D ctx; + data->cb =3D cb; + data->reset =3D 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 threa= ds + * 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 =3D=3D v, which saves memor= y 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 h= ave + * 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_ */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533041; cv=none; d=zoho.com; s=zohoarc; b=Bab3QW+vs8NhBBxLM5GyHF1hsQYWClaQzVXPEDW7k9P+8Wm9rAZ890jDHZmLp2F73u8SY1pnjsaG6d5pVOlHX1CpyKVxw7gaAHXM6Mdr2eC8o8eRXNIZhTSIZYbngpoLYKN56Ad4e1YpITM4iuKjdMfThokMERhUE6rgurmpL9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533041; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=92e5w8g18IqDzpvO8b8wKWyc5Ftp9KNxzA8ygeTKv0o=; b=X8eXph+Vxcod1gp6QgAXQUUvywM1AIycsBN+kNoUCu/0bluUb3dX/+N1FLfwKZS0vETzS9w6UmxZD0G+eD2Wg8oBHU6hVs1nUk/i3hrJIsG6aBvxAXpt9wekf5Ybtq5BLK0REZYdd/gNGeUQ1u29Wjr7ghp8i4j3u1aRb3DDKHw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533041837854.0059015579556; Fri, 14 Jun 2019 10:24:01 -0700 (PDT) Received: from localhost ([::1]:53740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpvk-0001xK-Ou for importer@patchew.org; Fri, 14 Jun 2019 13:24:00 -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) 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) 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-Google-Smtp-Source: APXvYqxofbzmMwRvc+NMsVEK0Wbo9ivrjRPa6VBV2taIeozmtOJEFQ+Cog83uzuoztqK82ZgFFd9EQ== X-Received: by 2002:a1c:720e:: with SMTP id n14mr8794084wmc.53.1560532330031; Fri, 14 Jun 2019 10:12:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) [AJB: split from the core code commit] Signed-off-by: Alex Benn=C3=A9e --- plugins/Makefile.objs | 1 + plugins/api.c | 267 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 plugins/api.c 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 @@ =20 obj-y +=3D loader.o obj-y +=3D core.o +obj-y +=3D 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 flag= s, + void *udata) +{ + plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REG= ULAR], + cb, flags, udata); +} + +void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, + 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_REGULA= R], + 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 flag= s, + enum qemu_plugin_mem_rw rw, + void *udata) +{ + plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGU= LAR], + 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 *pt= r, + 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 >=3D 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 +} --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533684; cv=none; d=zoho.com; s=zohoarc; b=Gxpzaeebu9mUgMwU7KU6o7cQSo3xsJkOUOc0vcnGA9R0LyQdlUfpIdNWMu/BWxvyPZgd3kYzO7oeBC6bMOYO9vq81y9m9zFdqmH+PL6/P1PPRZVfZygcFBYw3Q4R79GPCSdNClO7otqfEhnLxNvZ2sjVrni1+oHfVahaZAZjobI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533684; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aaXX3gQaQ+yIC35QS28KS1PNhW44kKO1FarcjHXQujo=; b=bqxtendhDZOy3WGiOIX3MLUkrp5XOVj7tRBPMxiqQ3jkAQHhNzgab81WkfJ8SiQ0XDPo/Dme8STRHLLrg3Tr2TIsq4LvV1zAFA5v0n1jK6JoAlS7m+xsF9rXk06ylgJpbS1alnYUB1E/k5Tb4L5sI9mIz/WMQZkrl8u44Cue8ZI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533684825165.33060107611755; Fri, 14 Jun 2019 10:34:44 -0700 (PDT) Received: from localhost ([::1]:53796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq62-0001cP-K7 for importer@patchew.org; Fri, 14 Jun 2019 13:34:38 -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) 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) 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-Google-Smtp-Source: APXvYqzVc0ERLxe4zVPhF+NdbC2UoHxMn40unJe13UrKbZkUKeIRoRgGgmTsBZszjNO8+sY/dLK2kg== X-Received: by 2002:a5d:484e:: with SMTP id n14mr651654wrs.348.1560532331384; Fri, 14 Jun 2019 10:12:11 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(+) 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 =3D NULL; \ } while (/*CONSTCOND*/0) =20 +/* remove @left, @right and all elements in between from @head */ +#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do { \ + if (((right)->field.tqe_next) !=3D NULL) \ + (right)->field.tqe_next->field.tqe_circ.tql_prev =3D \ + (left)->field.tqe_circ.tql_prev; \ + else \ + (head)->tqh_circ.tql_prev =3D (left)->field.tqe_circ.tql_prev;= \ + (left)->field.tqe_circ.tql_prev->tql_next =3D (right)->field.tqe_n= ext; \ + } while (/*CONSTCOND*/0) + #define QTAILQ_FOREACH(var, head, field) \ for ((var) =3D ((head)->tqh_first); \ (var); \ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535205; cv=none; d=zoho.com; s=zohoarc; b=CqnEcbXkxPOBTjCPdPZ1CaADoj00JBUfbK8CpsGeq4RAZ/hi005cTEfeaZxtVRY/TZx/Zt18iqmM5d9CHQquAxt+IQym3X8s2zY7rwMqIkCRd2Dgg7hHcePsNLqaNLUJQQBdUaUaquId5YJPGULrtEICZlaQYI315Ux7aHGMVsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535205; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=wTzsgKyezzklLe62p3Xhjbs91VZGkyagGHfvJN+obus=; b=GnhPb7aG3y63Rg+eoSa2VD3cT/nRNy1zFtoe6kcamFvmGzovj65cy1d22RcywiiHYqjTxht7Ir9kesGnAnTMPsf7RA5jnJTmnhyulWMEwPquMxcs8SDbYCQQ3ho6BlK0GYpPkV+Cqb7glk3bYJkJ7/HVdeccqu9GLiFVN/ZyIOQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535205836380.6520135050208; Fri, 14 Jun 2019 11:00:05 -0700 (PDT) Received: from localhost ([::1]:53926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqUM-0002d5-Q1 for importer@patchew.org; Fri, 14 Jun 2019 13:59:46 -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) 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) 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-Google-Smtp-Source: APXvYqziac+lJyzXGtAUFBDJvBVk2vyaKTBG46VV6NxopwMWSo6Fxbzg+X6VFt6+f7KLYHHhAiPWeQ== X-Received: by 2002:a5d:4ec1:: with SMTP id s1mr13199824wrv.19.1560532712075; Fri, 14 Jun 2019 10:18:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Suggested-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- accel/tcg/cputlb.c | 5 ----- include/exec/exec-all.h | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) 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) =20 -/* 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 =3D 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); =20 -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(CPUArc= hState *env1, target_ulong static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} =20 -/* 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); =20 void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, target_ulong vaddr); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533251; cv=none; d=zoho.com; s=zohoarc; b=luGRt2j8GZ3edEl6fxynHXFeKZxNXQqyKKH1zcnacymfMw2zEDrnBSM37Uy3k6EFKhxiicWPxxySJ6i77rbbldJaPEv0z7JyzCzHDsH9PkI4gse6D8JnHNbfowBDemRMw499pTCgapmVjEpphRCab8Cra6FD5QrktjSmEOGQBhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533251; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KBrLiVlOKane3sjR6CJw/FTpjNMv1c4o2EyAw7JURhs=; b=Y0vK7vKPdJRb695+9oI4SGFHdRdq+ZFLNJc7PuD3x41cJJnfzrGX2kWy9sLN2jOY7HL7OXAS0iFwegZw2uVjmAwZ65hLLnD5XqoLsZlXhzF/rXDpnoBoK1nS6X/cVxmPcsV4p7vW5TFpQyu1IPZMqBDP3RpSn6qgYmyEQp1ilt8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533251824622.1623204113888; Fri, 14 Jun 2019 10:27:31 -0700 (PDT) Received: from localhost ([::1]:53768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpz3-0005MR-Pn for importer@patchew.org; Fri, 14 Jun 2019 13:27:25 -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) 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) 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-Google-Smtp-Source: APXvYqxP3IrMrkPR3IWWdNzPXFGyP12Z45hHzkyRtYP2JqhuVM5asaIMlQPR5ZqGaJYNE6MdcniX2Q== X-Received: by 2002:a1c:c003:: with SMTP id q3mr8730823wmf.42.1560532328662; Fri, 14 Jun 2019 10:12:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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) =20 -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 ad= dr, + void **hostp) { uintptr_t mmu_idx =3D cpu_mmu_index(env, true); uintptr_t index =3D 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 =3D NULL; + } return -1; } =20 p =3D (void *)((uintptr_t)addr + entry->addend); + if (hostp) { + *hostp =3D p; + } return qemu_ram_addr_from_host_nofail(p); } =20 +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 =20 #include "exec/tb-context.h" +#include "exec/cpu_ldst.h" #include "sysemu/cpus.h" =20 /* allow to see translation results - the slowdown should be negligible, s= o we leave it */ @@ -492,6 +493,26 @@ static inline tb_page_addr_t get_page_addr_code(CPUArc= hState *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 c= ontent + * is kept. + */ +static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, + target_ulong addr, + void **hostp) +{ + if (hostp) { + *hostp =3D 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); =20 +/** + * 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 ad= dr, + 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); =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536541; cv=none; d=zoho.com; s=zohoarc; b=l+A6TB+nIaiBvq6qrNlO57TvMjh2ncd4Qn2tHlg2Uvu2czWl+SoYM5ldzZqTSWX5qCMwVd4dN4pUhl0CuA9hkTaZ3NceLYKOa0gYVEm3/sjBSDZFIEUQY1Bjz+mrF/PtVyCP9GTOy3LV0nUly8GP+r+LRJ40oRrr/Xm7rms9Scw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=X4C4YGVZ3pcwybUGTfe3xxdYoIZorIOdd4k/ZGNzkiA=; b=ChDRUS3wRn+ox/qKfcN8ja+LwTPI7LdVq4tASppfcgW2BQlFvuGwIKF2na68bQuaRe+AHGpLV3OB5+DfoRax/zOm1P6QBi7g2RdABA2FZ8l5AMWQicmCYXSlE0Lm0CHjnC++yxh1ufaUvOUr4cr34zpGcYCtMXQVyQQ9lsTqNAo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536541893795.4463004540651; Fri, 14 Jun 2019 11:22:21 -0700 (PDT) Received: from localhost ([::1]:54062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqqC-0003OM-Ox for importer@patchew.org; Fri, 14 Jun 2019 14:22:20 -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) 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) 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-Google-Smtp-Source: APXvYqyXdueuycr2fhDs9IdLZFDl047DDqJK4I8Ll2oDHdKbZMi5KtOEmeymktAyxRV+K8R85JXj7g== X-Received: by 2002:adf:f64a:: with SMTP id x10mr8598238wrp.287.1560533312471; Fri, 14 Jun 2019 10:28:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- 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 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 +=3D translator.o =20 obj-$(CONFIG_USER_ONLY) +=3D user-exec.o obj-$(call lnot,$(CONFIG_SOFTMMU)) +=3D user-exec-stub.o +obj-$(CONFIG_PLUGIN) +=3D 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 twic= e. + * Instead, during TB translation we add "empty" instrumentation calls for= all + * possible instrumentation events, and then once we collect the instrumen= tation + * 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 co= pies + * of the TCG ops generated for the empty callback, substituting the funct= ion + * pointer that points to the empty helper function with the plugins' desi= red + * callback functions. After that we remove the empty callback's ops. + * + * Note that the location in TCGOp.args[] of the pointer to a helper funct= ion + * varies across different guest and host architectures. Instead of duplic= ating + * 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 prog= ram. + * 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 callba= ck'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, fo= r the + * second and all subsequent callbacks of an event, we do not need to relo= ad 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 =3D tcg_temp_new_i32(); + TCGv_i32 meminfo =3D tcg_const_i32(info); + TCGv_i64 vaddr64 =3D tcg_temp_new_i64(); + TCGv_ptr udata =3D 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 =3D tcg_temp_new_ptr(); + tcg_gen_ld_ptr(haddr, cpu_env, offsetof(CPUArchState, hostaddr)); +#else + haddr =3D 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 =3D tcg_temp_new_i32(); + TCGv_ptr udata =3D 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 =3D tcg_temp_new_i64(); + TCGv_ptr ptr =3D tcg_const_ptr(NULL); /* overwritten later */ + + tcg_gen_ld_i64(val, ptr, 0); + /* pass an immediate !=3D 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 =3D 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 =3D 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 =3D !!(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 =3D gen_empty_mem_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_MEM, &fn, addr, info, true); + + fn.mem_fn =3D gen_empty_haddr_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_HADDR, &fn, addr, info, true); + + fn.inline_fn =3D 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 =3D=3D opc) { + return op; + } + op =3D QTAILQ_NEXT(op, link); + } + return NULL; +} + +static TCGOp *rm_ops_range(TCGOp *begin, TCGOp *end) +{ + TCGOp *ret =3D 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 =3D 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 =3D QTAILQ_NEXT(*begin_op, link); + tcg_debug_assert(*begin_op); + op =3D 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 =3D copy_op_nocheck(begin_op, op); + tcg_debug_assert((*begin_op)->opc =3D=3D opc); + return op; +} + +static TCGOp *copy_extu_i32_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* mov_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + /* movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + } else { + /* extu_i32_i64 */ + op =3D 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 =3D=3D 32) { + /* 2x mov_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + /* mov_i64 */ + op =3D 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 =3D=3D 32) { + /* 2x movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D v; + + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D v >> 32; + } else { + /* movi_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i64); + op->args[1] =3D v; + } + return op; +} + +static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D (uintptr_t)ptr; + } else { + /* movi_i64 */ + op =3D 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 =3D=3D 32) { + /* extu_i32_i64 */ + op =3D copy_extu_i32_i64(begin_op, op); + } else { + /* mov_i64 */ + op =3D copy_mov_i64(begin_op, op); + } + return op; +} + +static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x ld_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *copy_ld_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* ld_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D copy_ld_i64(begin_op, op); + } + return op; +} + +static TCGOp *skip_ld_i64(TCGOp *begin_op) +{ + TCGOp *op; + + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x ld_i32 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + op =3D QTAILQ_NEXT(op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *skip_ld_ptr(TCGOp *begin_op) +{ + TCGOp *op; + + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* ld_i32 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D skip_ld_i64(begin_op); + } + return op; +} + +static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x st_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op =3D 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 =3D=3D 32) { + /* all 32-bit backends must implement add2_i32 */ + g_assert(TCG_TARGET_HAS_add2_i32); + op =3D copy_op(begin_op, op, INDEX_op_add2_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + +static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* st_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op =3D 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 =3D copy_op_nocheck(begin_op, op); + } while (op->opc !=3D INDEX_op_call); + + /* fill in the op call */ + op->param1 =3D (*begin_op)->param1; + op->param2 =3D (*begin_op)->param2; + tcg_debug_assert(op->life =3D=3D 0); + if (*cb_idx =3D=3D -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 =3D 0; i < MAX_OPC_PARAM_ARGS; i++) { + if ((uintptr_t)(*begin_op)->args[i] =3D=3D (uintptr_t)empty_fu= nc) { + *cb_idx =3D i; + break; + } + } + tcg_debug_assert(i < MAX_OPC_PARAM_ARGS); + } + op->args[*cb_idx] =3D (uintptr_t)func; + op->args[*cb_idx + 1] =3D 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 =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); + if (*cb_idx =3D=3D -1) { + op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* call */ + op =3D 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 =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* ld_i64 */ + op =3D copy_ld_i64(&begin_op, op); + + /* const_i64 */ + op =3D copy_const_i64(&begin_op, op, cb->inline_insn.imm); + + /* add_i64 */ + op =3D copy_add_i64(&begin_op, op); + + /* st_i64 */ + op =3D copy_st_i64(&begin_op, op); + + return op; +} + +static void set_memop_haddr_ldst_i32(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS =3D=3D 32) { + idx =3D 2; + } else { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 3 : 2; + } + op->args[idx] |=3D make_memop_idx(MO_HADDR, 0); +} + +static void set_memop_haddr_ldst_i64(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS =3D=3D 32) { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 3 : 2; + } else { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 4 : 2; + } + op->args[idx] |=3D make_memop_idx(MO_HADDR, 0); +} + +static void find_prev_and_set_memop_haddr(TCGOp *op) +{ + while ((op =3D 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 =3D begin_op->args[1]; + + tcg_debug_assert(type =3D=3D PLUGIN_GEN_CB_MEM || type =3D=3D PLUGIN_G= EN_CB_HADDR); + + /* const_i32 =3D=3D movi_i32 ("info", so it remains as is) */ + op =3D copy_op(&begin_op, op, INDEX_op_movi_i32); + + /* const_ptr */ + op =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); + if (*cb_idx =3D=3D -1) { + op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* extu_tl_i64 */ + op =3D copy_extu_tl_i64(&begin_op, op); + + if (type =3D=3D PLUGIN_GEN_CB_MEM) { + /* call */ + op =3D 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 =3D=3D -1) { + op =3D copy_ld_ptr(&begin_op, op); + find_prev_and_set_memop_haddr(begin_op); + } else { + begin_op =3D skip_ld_ptr(begin_op); + } + } else { + /* const_ptr; set it to NULL */ + op =3D copy_const_ptr(&begin_op, op, NULL); + } + /* call */ + op =3D 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 =3D 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 =3D -1; + int i; + + if (!cbs || cbs->len =3D=3D 0) { + rm_ops(begin_op); + return; + } + + end_op =3D find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + op =3D end_op; + for (i =3D 0; i < cbs->len; i++) { + struct qemu_plugin_dyn_cb *cb =3D + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + + if (!ok(begin_op, cb)) { + continue; + } + op =3D 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 =3D begin_op; + TCGOp *end_op; + TCGOp *op; + + end_op =3D find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + /* const ptr */ + op =3D copy_const_ptr(&begin_op, end_op, arr); + + /* st_ptr */ + op =3D 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 descriptor= s, 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] =3D plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs[1] =3D plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + cbs[2] =3D plugin_insn->cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGULAR]; + + n_cbs =3D 0; + for (i =3D 0; i < ARRAY_SIZE(cbs); i++) { + n_cbs +=3D cbs[i]->len; + } + + plugin_insn->mem_helper =3D plugin_insn->calls_helpers && n_cbs; + if (likely(!plugin_insn->mem_helper)) { + rm_ops(begin_op); + return; + } + + arr =3D g_array_sized_new(false, false, + sizeof(struct qemu_plugin_dyn_cb), n_cbs); + + for (i =3D 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 =3D=3D NULL || + !tcg_ctx->plugin_insn->mem_helper)) { + return; + } + ptr =3D 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 =3D 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + + 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + + cbs =3D 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + + cbs =3D 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + 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 =3D g_ptr_array_index(ptb->insns, insn_i= dx); + inject_mem_disable_helper(insn, begin_op); +} + +static void plugin_inject_cb(const struct qemu_plugin_tb *ptb, TCGOp *begi= n_op, + int insn_idx) +{ + enum plugin_gen_from from =3D begin_op->args[0]; + enum plugin_gen_cb type =3D 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 =3D 0; + + QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + const char *name =3D ""; + const char *type =3D ""; + + if (op->opc =3D=3D INDEX_op_plugin_cb_start) { + switch (op->args[0]) { + case PLUGIN_GEN_FROM_TB: + name =3D "tb"; + break; + case PLUGIN_GEN_FROM_INSN: + name =3D "insn"; + break; + case PLUGIN_GEN_FROM_MEM: + name =3D "mem"; + break; + case PLUGIN_GEN_AFTER_INSN: + name =3D "after insn"; + break; + default: + break; + } + switch (op->args[1]) { + case PLUGIN_GEN_CB_UDATA: + type =3D "udata"; + break; + case PLUGIN_GEN_CB_INLINE: + type =3D "inline"; + break; + case PLUGIN_GEN_CB_MEM: + type =3D "mem"; + break; + case PLUGIN_GEN_CB_HADDR: + type =3D "haddr"; + break; + case PLUGIN_GEN_ENABLE_MEM_HELPER: + type =3D "enable mem helper"; + break; + case PLUGIN_GEN_DISABLE_MEM_HELPER: + type =3D "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 =3D -1; + QSIMPLEQ_FOREACH(op, &tcg_ctx->plugin_ops, plugin_link) { + enum plugin_gen_from from =3D op->args[0]; + enum plugin_gen_cb type =3D op->args[1]; + + tcg_debug_assert(op->opc =3D=3D INDEX_op_plugin_cb_start); + /* ENABLE_MEM_HELPER is the first callback of an instruction */ + if (from =3D=3D PLUGIN_GEN_FROM_INSN && + type =3D=3D 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 =3D tcg_ctx->plugin_tb; + bool ret =3D false; + + if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_mask)) { + ret =3D true; + + QSIMPLEQ_INIT(&tcg_ctx->plugin_ops); + ptb->vaddr =3D tb->pc; + ptb->vaddr2 =3D -1; + get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1); + ptb->haddr2 =3D 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 =3D tcg_ctx->plugin_tb; + struct qemu_plugin_insn *pinsn; + + pinsn =3D qemu_plugin_tb_insn_get(ptb); + tcg_ctx->plugin_insn =3D pinsn; + pinsn->vaddr =3D 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 =3D=3D NULL, e.g. when we're + * fetching instructions from a region not backed by RAM. + */ + if (likely(ptb->haddr1 !=3D NULL && ptb->vaddr2 =3D=3D -1) && + unlikely((db->pc_next & TARGET_PAGE_MASK) !=3D + (db->pc_first & TARGET_PAGE_MASK))) { + get_page_addr_code_hostp(cpu->env_ptr, db->pc_next, + &ptb->haddr2); + ptb->vaddr2 =3D db->pc_next; + } + if (likely(ptb->vaddr2 =3D=3D -1)) { + pinsn->haddr =3D ptb->haddr1 + pinsn->vaddr - ptb->vaddr; + } else { + pinsn->haddr =3D 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 =3D 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 =3D 0; i < PLUGIN_N_CB_SUBTYPES; i++) { + if (ptb->cbs[i]) { + g_array_set_size(ptb->cbs[i], 0); + } + } + ptb->n =3D 0; + tcg_ctx->plugin_insn =3D 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" =20 #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), d= h_ctype(t3), \ #include "helper.h" #include "trace/generated-helpers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" =20 #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" =20 #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 *d= b); +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 *d= b) +{ } + +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); =20 +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 =3D=3D 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)) =20 +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 } =20 +static void alloc_tcg_plugin_context(TCGContext *s) +{ +#ifdef CONFIG_PLUGIN + s->plugin_tb =3D g_new0(struct qemu_plugin_tb, 1); + s->plugin_tb->insns =3D + 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 functi= on @@ -772,6 +781,10 @@ void tcg_register_thread(void) g_assert(n < max_cpus); atomic_set(&tcg_ctxs[n], s); =20 + if (n > 0) { + alloc_tcg_plugin_context(s); + } + tcg_ctx =3D s; qemu_mutex_lock(®ion.lock); err =3D tcg_region_initial_alloc__locked(tcg_ctx); @@ -968,6 +981,8 @@ void tcg_context_init(TCGContext *s) indirect_reg_alloc_order[i] =3D tcg_target_reg_alloc_order[i]; } =20 + alloc_tcg_plugin_context(s); + tcg_ctx =3D 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 nar= gs, TCGTemp **args) flags =3D info->flags; sizemask =3D info->sizemask; =20 +#ifdef CONFIG_PLUGIN + /* detect non-plugin helpers */ + if (tcg_ctx->plugin_insn && unlikely(strncmp(info->name, "plugin_", 7)= )) { + tcg_ctx->plugin_insn->calls_helpers =3D 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 { =20 /* Next and previous opcodes. */ QTAILQ_ENTRY(TCGOp) link; +#ifdef CONFIG_PLUGIN + QSIMPLEQ_ENTRY(TCGOp) plugin_link; +#endif =20 /* Arguments for the opcode. */ TCGArg args[MAX_OPC_PARAM]; @@ -726,6 +729,23 @@ struct TCGContext { =20 TCGLabel *exitreq_label; =20 +#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 mo= re + * 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 */ =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560532789; cv=none; d=zoho.com; s=zohoarc; b=n5Rgz7WvNG4XMrVMcHTHtfX4k9ERVCCpleqUlBt2RVhxeoZh/PhTzyjvZClad/DBwrDEUn+qtON1QoyWGo9wCm/QeurS/a0MfihAlkzMK0gSys2zy09slyd4DvijSgiW7lT0nrRP86VapYo6V6fhfQ0YubKhs8zwAqzEq8KdLrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560532789; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZGytCy7dk/rtAnR0c8LWL1u/jXw6ywf1Xd8f/B0+XIs=; b=EFkfqPoPAAXqKaMF6KQJH/l2ChbQf/iosi89gZX37hxAx2tZa0qI3v6YF7BEfgBNH/6MEBBtyi4JKjtjkZRF4xQQ0niQQwamtectBrXMOpocOhR3mtQVg458AELaDcH8TSHNgGgMdf5W/GQZo2v/DGiTcXf2h8m/6HHt3Du5qQM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560532789432561.4103858810166; Fri, 14 Jun 2019 10:19:49 -0700 (PDT) Received: from localhost ([::1]:53712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbprg-0005hU-Aa for importer@patchew.org; Fri, 14 Jun 2019 13:19:48 -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) 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) 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-Google-Smtp-Source: APXvYqwynb8NZtUK5NtDBM3eDufFX+apCyNMFDI1h4I/cTv5ZVlV8uSDif5HIwmqA2z660sT8kv5tA== X-Received: by 2002:a5d:4a8d:: with SMTP id o13mr31265800wrq.350.1560532330517; Fri, 14 Jun 2019 10:12:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Will gain a user soon. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- tcg/tcg-op.h | 5 +++++ 1 file changed, 5 insertions(+) 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_p= tr a, intptr_t o) glue(tcg_gen_ld_,PTR)((NAT)r, a, o); } =20 +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); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537192; cv=none; d=zoho.com; s=zohoarc; b=B1B4FJMHRa+K6Vg//11CbqxeHj7ZtEpUHfBGiDA1cEJDXaqHtCxkytiy3fLev7R0HklE2B/UURuBLHUJqXN+JCh/ZP/ThiSbhRK21H0GKmDnKdiO329ayfjZi2Mg8dmPvT4RA1ZrYl4KXfycGwbEU86eC5328mtVovuufM3mu48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537192; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aDs2dqXGIEF28FBqcTkP/2L64OJ8gLbRaNrMScFtO/w=; b=kURHObF25EIJKvmg522mcHO7Wk7bYBwCO1szbvWiPXQJ1Y1AN/q9OBrm77+ENLriIZLdL5th2T/J6O6gy4DRzN+WiHkjU3cRtM6huI2hXy3fDebZzT5uKa891TE/DX1SqOf5ogVDU59gGOnCXwTzvlJj4rvO752Z5E0v23ZbZ/k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560537192763610.7418391697031; Fri, 14 Jun 2019 11:33:12 -0700 (PDT) Received: from localhost ([::1]:54124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr0h-0000sJ-ML for importer@patchew.org; Fri, 14 Jun 2019 14:33:11 -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) 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) 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-Google-Smtp-Source: APXvYqzco7nNUfYr1iu+cc4QpsTc4Tr8Rt3RnNz/LIPV0+espOLlKE8A4IPihgBcusMYPLkV30tK1A== X-Received: by 2002:adf:e301:: with SMTP id b1mr14118389wrj.304.1560533310627; Fri, 14 Jun 2019 10:28:30 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(+) 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 =3D 5 << MO_ASHIFT, MO_ALIGN_64 =3D 6 << MO_ASHIFT, =20 + /* + * SoftMMU-only: if set, the TCG backend puts the corresponding host a= ddress + * in CPUArchState.hostaddr. + */ + MO_HSHIFT =3D MO_ASHIFT + 3, + MO_HADDR =3D 1 << MO_HSHIFT, + /* Combinations of the above, for ease of use. */ MO_UB =3D MO_8, MO_UW =3D MO_16, --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537569; cv=none; d=zoho.com; s=zohoarc; b=E90nE9PQ4DAD9eCmp3/gYmuOExBTmMSWEuRYB5/AvGrCqdk25Nzp6fNpev+eqMs8pA/HNLTZv1tEtSmcYqPcBrjhJerzxFxlZvmvdjZsrD34y6uq3iCt1UTEbNnvCGvDh2aKelvQl35UJl0GRg1zr+xVmFDsbAnBSSRHUh6ClCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537569; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7LkO/RwU961CsHjb/1835Cx9O+zFCubxVzSPwrwohBY=; b=dbtGNySF58hSd7pCjOZEmAoDubl0LwGOZMRD6WFbkvUnYcKTj6haoG8i3jUSMyqYkCD5cn9ehd3Qz3LpLJIPALS9i0wS5Nv4a6j3Lzfn/65NuEjsHNS2hwlkuETk7o9GFIc5tHTPMQJVVg5Egaj0bUsk5OA9GNLYPQvAu7LUt1g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560537568978154.65591322896148; Fri, 14 Jun 2019 11:39:28 -0700 (PDT) Received: from localhost ([::1]:54178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr6m-0005IU-12 for importer@patchew.org; Fri, 14 Jun 2019 14:39:28 -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) 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) 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-Google-Smtp-Source: APXvYqwAjbuiS8A1DyMpf1MGsaDY4dHNCCPSRo1/xfeOfnoq/QYoURplMUi6TxMkTqAi92AsWAMPRg== X-Received: by 2002:a7b:c057:: with SMTP id u23mr8968631wmc.29.1560533318513; Fri, 14 Jun 2019 10:28:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- accel/tcg/atomic_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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_ul= ong addr, =20 #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 =3D ATOMIC_MMU_LOOKUP; \ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536539; cv=none; d=zoho.com; s=zohoarc; b=C1Cb9KCcKwXNhqmVyJDGQd9wpsD8Dteblzl6ilDpnADj628mtsGOMvnM3Z/qmC0X7tGUaLE1qvPDu07wl7NXQJqRS6a/fAYOjfqhKuHAMReTNFuWsZrouQkCOF+vwM+dn5kEPIZ+7sbUNUkczWefn83sIYJwGBvkGbRAAjYpVe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536539; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=il3aOSQFRSZJ2/99Y43bBqgnwxHoXzOMQ0saAfzkh+I=; b=JyfZUcIwruvKixk8ir1rSVgkIfPYPS3JzDJ1wZZUzBG+zHc6WhxO0P5Nsrvu0wrn/Jl2u0t2ghb9zU3tyO1yUGRE6dQsOlwFDZOmw7ArssDQcSzE4uufDbi+xDpfxQ3K0cb4R/8NSExL57bY5NSKg0BPLOQwfK5+h6XBfHfR9oU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536539890822.9487350464315; Fri, 14 Jun 2019 11:22:19 -0700 (PDT) Received: from localhost ([::1]:54064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqqA-0003RC-NE for importer@patchew.org; Fri, 14 Jun 2019 14:22:18 -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) 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) 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-Google-Smtp-Source: APXvYqwTTWLBDQVCvgr7ufM5l5WLP+qVadJvzLop27KTPAFDvmpkG9btqgtyumm2aIzxjeSC0DD+cw== X-Received: by 2002:a05:6000:110:: with SMTP id o16mr62393959wrx.200.1560532718511; Fri, 14 Jun 2019 10:18:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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 =20 -#define ATOMIC_TRACE_RMW do { \ - uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, fal= se); \ - \ - 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 =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, fal= se); \ - \ - trace_guest_mem_before_exec(env_cpu(env), addr, info); \ - } while (0) - -# define ATOMIC_TRACE_ST do { \ - uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, tru= e); \ - \ - 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 in= fo) +{ + CPUState *cpu =3D 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 a= ddr, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint8_t inf= o) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong ad= dr, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint8_t inf= o) +{ + trace_guest_mem_before_exec(env_cpu(env), addr, info); +} + +static inline void atomic_trace_st_post(CPUArchState *env, target_ulong ad= dr, + void *haddr, uint8_t info) +{ +} +#endif /* ATOMIC_TEMPLATE_COMMON */ =20 /* 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, targe= t_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE =3D=3D 16 ret =3D atomic16_cmpxchg(haddr, cmpv, newv); #else ret =3D atomic_cmpxchg__nocheck(haddr, cmpv, newv); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return ret; } =20 @@ -115,10 +136,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ul= ong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val =3D atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return val; } =20 @@ -127,10 +150,12 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong = addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); =20 - 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 =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret =3D atomic_xchg__nocheck(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return ret; } =20 @@ -154,10 +181,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulo= ng addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret =3D atomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return ret; \ } =20 @@ -186,8 +215,9 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ XDATA_TYPE cmp, old, new, val =3D xval; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ cmp =3D atomic_read__nocheck(haddr); \ do { \ @@ -195,6 +225,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ cmp =3D atomic_cmpxchg__nocheck(haddr, old, new); \ } while (cmp !=3D old); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return RET; \ } =20 @@ -232,14 +263,16 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, targ= et_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE =3D=3D 16 ret =3D atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv)); #else ret =3D atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return BSWAP(ret); } =20 @@ -249,10 +282,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ul= ong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val =3D atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return BSWAP(val); } =20 @@ -261,11 +296,14 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong = addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); =20 - ATOMIC_TRACE_ST; + val =3D BSWAP(val); + atomic_trace_st_pre(env, addr, info); val =3D 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 =3D ATOMIC_MMU_LOOKUP; ABI_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret =3D atomic_xchg__nocheck(haddr, BSWAP(val)); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return BSWAP(ret); } =20 @@ -289,10 +329,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulo= ng addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret =3D atomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return BSWAP(ret); \ } =20 @@ -319,8 +361,9 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ XDATA_TYPE ldo, ldn, old, new, val =3D xval; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ ldn =3D atomic_read__nocheck(haddr); \ do { \ @@ -328,6 +371,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ldn =3D atomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ } while (ldo !=3D ldn); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return RET; \ } =20 @@ -355,10 +399,6 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef MEND #endif /* DATA_SIZE > 1 */ =20 -#undef ATOMIC_TRACE_ST -#undef ATOMIC_TRACE_LD -#undef ATOMIC_TRACE_RMW - #undef BSWAP #undef ABI_TYPE #undef DATA_TYPE --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534665; cv=none; d=zoho.com; s=zohoarc; b=Sja9QSRGBBeOX1Q0ZRG7l9P8bS3UVVEx2lgrqWfroTCuHAjAGeRYUIycoxPCACs6I9/uh4nvMSUyZjuDcXv1y5jtXZXK2wN0z/MzcRhKByh35JBZr85GUEjqlC6MD/2YXCebQNdhMxnwQtgGvWP2zFhZyh+zaPx4W48pI7S8Pp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534665; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kv2IwrRCWvjl90KLYznRzS05j6rVbW2oPC3nXpHDO7s=; b=c+Z52ZXgqfEQypzSTbaIMvPxnqv+qa+bbqJ/pL8ZXJ10KRE25QYunScoD3mq9qNUawWxGoS51VJ1kb4k8m7JAPNJHBN9swkCxkxH0fgS2nc6RaMj8IMzUei3mTZ6N729QUp04AMqxaCyV5GdESqsq/fcsJfFEbcJbwYrwMkX5YQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534665715539.3052064897574; Fri, 14 Jun 2019 10:51:05 -0700 (PDT) Received: from localhost ([::1]:53882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqLw-0004c3-OT for importer@patchew.org; Fri, 14 Jun 2019 13:51:04 -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) 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) 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-Google-Smtp-Source: APXvYqzRN4YWYVOtX3VJd2uI+WTTSvkI9gj6pRxBQrqvRe8MAln2Q6CQdq2pcOA9LLXkR9T4bEau5g== X-Received: by 2002:a1c:b189:: with SMTP id a131mr9145569wmf.7.1560532713548; Fri, 14 Jun 2019 10:18:33 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" This function is already under #ifndef CODE_ACCESS. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- include/exec/cpu_ldst_useronly_template.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_l= dst_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); } =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536354; cv=none; d=zoho.com; s=zohoarc; b=VduQhhkZZsQfOaEdxZRYOAouGurARsfnxg/LDk+U6Fwysw0K0hCT4aOIYG7knSCKyfOleuXPOh6J31Hi22wTUJtLUZYEfSkseKgF1swQ8Ta3SYrRdUi/ehlyaaSHfhVw3N3yEl2r23KnUsQig22gnwf+Vzo2MqUbyUtasCtNWqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536354; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0Pim99RaJoGz7KvkA/uPJ/GgI2y9KeaVPRnEwtwD6pM=; b=k0yx+amZaB6HVx9QUulhqWMea2jTp6rn963zIWkMWNWZFoyXjwccOuvodDAwQb74kLsjcKME2HouzsrYqrJ/n7bYW0vgTahbfgkRcoP+MQt45z/PT3WL+lZpoDDogaciXhD3xEoCkb7TYvMq5ua5wou3jVOcb4F1BxGgpWeLd3s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536353993676.9529805138187; Fri, 14 Jun 2019 11:19:13 -0700 (PDT) Received: from localhost ([::1]:54052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqn7-0001Oy-Vp for importer@patchew.org; Fri, 14 Jun 2019 14:19:10 -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) 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) 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-Google-Smtp-Source: APXvYqxjKA9EICeQ50IOfRJRzozVgJIRQBf9mSeMv60s8hfqY8QYeXKaFrfrzEZXdkYwMgcp7oSK1A== X-Received: by 2002:a1c:c747:: with SMTP id x68mr8912858wmf.138.1560533309075; Fri, 14 Jun 2019 10:28:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 ~=3D 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=C3=A9e --- 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(-) 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 . */ =20 +#include "qemu/plugin.h" #include "trace/mem.h" =20 #if DATA_SIZE =3D=3D 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 a= ddr, 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= ); } =20 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 ad= dr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info); } =20 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 ad= dr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, haddr, info); } #endif /* ATOMIC_TEMPLATE_COMMON */ =20 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); } =20 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(); } =20 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); } =20 +static inline void set_hostaddr(CPUArchState *env, TCGMemOp mo, void *hadd= r) +{ +#ifdef CONFIG_PLUGIN + if (mo & MO_HADDR) { + env_tlb(env)->c.hostaddr =3D 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 =3D env_cpu(env); hwaddr mr_offset; @@ -891,6 +900,9 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, bool locked =3D false; MemTxResult r; =20 + /* XXX Any sensible choice other than NULL? */ + set_hostaddr(env, mo, NULL); + section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -925,7 +937,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, =20 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 =3D env_cpu(env); hwaddr mr_offset; @@ -934,6 +946,8 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, bool locked =3D false; MemTxResult r; =20 + set_hostaddr(env, mo, NULL); + section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -1264,7 +1278,8 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, offsetof(CPUTLBEntry, addr_code) : offsetof(CPUTLBEntry, addr_read= ); const MMUAccessType access_type =3D code_read ? MMU_INST_FETCH : MMU_DATA_LOAD; - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); void *haddr; uint64_t res; =20 @@ -1313,7 +1328,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, } =20 res =3D 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); } =20 @@ -1331,6 +1346,12 @@ load_helper(CPUArchState *env, target_ulong addr, TC= GMemOpIdx oi, r2 =3D full_load(env, addr2, oi, retaddr); shift =3D (addr & (size - 1)) * 8; =20 + /* + * XXX cross-page accesses would have to be split into separate ac= cesses + * for the host address to make sense. For now, just return NULL. + */ + set_hostaddr(env, mo, NULL); + if (big_endian) { /* Big-endian combine. */ res =3D (r1 << shift) | (r2 >> ((size * 8) - shift)); @@ -1343,6 +1364,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, =20 do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); + set_hostaddr(env, mo, (void *)haddr); switch (size) { case 1: res =3D ldub_p(haddr); @@ -1513,7 +1535,8 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_addr_write(entry); const size_t tlb_off =3D offsetof(CPUTLBEntry, addr_write); - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); void *haddr; =20 /* Handle CPU specific unaligned behaviour */ @@ -1562,7 +1585,7 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, =20 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; } =20 @@ -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; } =20 do_aligned_access: haddr =3D (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 =3D tcg_const_ptr(NULL); TCGv_ptr haddr; =20 - 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); =20 if (is_haddr) { @@ -106,7 +105,9 @@ static void do_gen_mem_cb(TCGv vaddr, uint8_t info, boo= l is_haddr) */ #ifdef CONFIG_SOFTMMU haddr =3D 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 =3D tcg_const_ptr(NULL); #endif @@ -128,8 +129,8 @@ static void gen_empty_udata_cb(void) TCGv_i32 cpu_index =3D tcg_temp_new_i32(); TCGv_ptr udata =3D tcg_const_ptr(NULL); /* will be overwritten later */ =20 - 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); =20 tcg_temp_free_ptr(udata); @@ -172,8 +173,7 @@ static void gen_empty_mem_helper(void) TCGv_ptr ptr; =20 ptr =3D 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); } =20 @@ -784,8 +784,7 @@ void plugin_gen_disable_mem_helpers(void) return; } ptr =3D 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 =3D 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; =20 /* @@ -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 =20 +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) =20 extern __thread uintptr_t helper_retaddr; diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_templ= ate.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 =20 +#include "qemu/plugin.h" #include "trace/mem.h" =20 #if DATA_SIZE =3D=3D 8 @@ -86,11 +87,10 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUAr= chState *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 =3D trace_mem_build_info(SHIFT, false, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -101,10 +101,14 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); res =3D glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D addr + entry->addend; res =3D 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; } =20 @@ -125,11 +129,10 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *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 =3D trace_mem_build_info(SHIFT, true, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -140,10 +143,14 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); res =3D (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D addr + entry->addend; res =3D 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; } =20 @@ -167,11 +174,10 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUA= rchState *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 =3D trace_mem_build_info(SHIFT, false, MO_TE, true); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -182,10 +188,14 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUA= rchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D 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 } =20 static inline void diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_l= dst_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 =3D trace_mem_build_info(SHIFT, false, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); +#endif + + ret =3D 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; } =20 static inline RES_TYPE @@ -88,12 +94,18 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUAr= chState *env, static inline int glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { + int ret; +#if !defined(CODE_ACCESS) + uint8_t meminfo =3D trace_mem_build_info(SHIFT, true, MO_TE, false); + trace_guest_mem_before_exec(env_cpu(env), ptr, meminfo); +#endif + + ret =3D 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; } =20 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 =3D 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); } =20 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, T= CGReg 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 } =20 /* 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" =20 /* 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 i= dx) tcg_debug_assert(idx =3D=3D TB_EXIT_REQUESTED); } =20 + plugin_gen_disable_mem_helpers(); tcg_gen_op1i(INDEX_op_exit_tb, val); } =20 @@ -2696,6 +2698,7 @@ void tcg_gen_goto_tb(unsigned idx) tcg_debug_assert((tcg_ctx->goto_tb_issue_mask & (1 << idx)) =3D=3D 0); tcg_ctx->goto_tb_issue_mask |=3D 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 =3D tcg_temp_new_ptr(); + TCGv_ptr ptr; + + plugin_gen_disable_mem_helpers(); + ptr =3D 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) } } =20 +static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint8_t info) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn =3D=3D NULL) { + return; + } + plugin_gen_empty_mem_callback(vaddr, info); +#endif +} + void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { TCGMemOp orig_memop; + uint8_t info =3D trace_mem_get_info(memop, 0); =20 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop =3D 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); =20 orig_memop =3D 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, TCG= Arg idx, TCGMemOp memop) } =20 gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); =20 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, T= CGArg idx, TCGMemOp memop) void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { TCGv_i32 swap =3D NULL; + uint8_t info =3D trace_mem_get_info(memop, 1); =20 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop =3D 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); =20 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap =3D tcg_temp_new_i32(); @@ -2852,6 +2869,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCG= Arg idx, TCGMemOp memop) } =20 gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); =20 if (swap) { tcg_temp_free_i32(swap); @@ -2861,6 +2879,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCG= Arg idx, TCGMemOp memop) void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { TCGMemOp orig_memop; + uint8_t info; =20 if (TCG_TARGET_REG_BITS =3D=3D 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, TCG= Arg idx, TCGMemOp memop) =20 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop =3D tcg_canonicalize_memop(memop, 1, 0); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 0)); + info =3D trace_mem_get_info(memop, 0); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); =20 orig_memop =3D 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, TCG= Arg idx, TCGMemOp memop) } =20 gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); =20 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, TCG= Arg idx, TCGMemOp memop) void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { TCGv_i64 swap =3D NULL; + uint8_t info; =20 if (TCG_TARGET_REG_BITS =3D=3D 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, TCG= Arg idx, TCGMemOp memop) =20 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop =3D tcg_canonicalize_memop(memop, 1, 1); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 1)); + info =3D trace_mem_get_info(memop, 1); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); =20 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { swap =3D tcg_temp_new_i64(); @@ -2947,6 +2968,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCG= Arg idx, TCGMemOp memop) } =20 gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); =20 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" --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535639; cv=none; d=zoho.com; s=zohoarc; b=Td6VQJ4A1ppljwB2v6CBG/bO8obeXY8EqpxOLw/UsM9bRPcKAYcKchI3FU3IlWQORJapT+yLtyRbDFhwQPZNuR1tIrDQF9PmgYiioGWS55g/USDCUOJSBqnBYG9kzrtdA3OPgQ0LEmo7KHB6qm0vdhunbw/UWVaU9JZyVml3ZhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535639; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=w9UhEo/iibTeYQ0N86neImewJmC3U4nMBYOWRfST9lI=; b=VWRTDpAqNz5d8ijslbqYsZCI+iWTjnGPH7hG4fNX8vUQ8M5rqOlgK7e4OAnHstZhqfkusKgdZHY8sVpm/pEx1At/kByaH08SMi/0JMJ3ynz4puANg5e1Su4zEek0UISu5HiMd10cjgspmy11ZZPnQHEuLZF1vjvd9dyfKUsrY+k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535639522563.3310134869355; Fri, 14 Jun 2019 11:07:19 -0700 (PDT) Received: from localhost ([::1]:53972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqbc-0007mh-H9 for importer@patchew.org; Fri, 14 Jun 2019 14:07:16 -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) 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) 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-Google-Smtp-Source: APXvYqxn/fgR0GmUjvPWixrrnjMCLx0pfOVBrvBvjkTfto2xbydlrS5AQT0yrPdSpFackBxiG8rbJg== X-Received: by 2002:a1c:f001:: with SMTP id a1mr9225447wmb.130.1560532710399; Fri, 14 Jun 2019 10:18:30 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- accel/tcg/translate-all.c | 6 ++++++ 1 file changed, 6 insertions(+) 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, gpoin= ter 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 =3D 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_dat= a tb_flush_count) if (tb_ctx.tb_flush_count !=3D tb_flush_count.host_int) { goto done; } + did_flush =3D true; =20 if (DEBUG_TB_FLUSH_GATE) { size_t nb_tbs =3D tcg_nb_tbs(); @@ -1262,6 +1265,9 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_dat= a tb_flush_count) =20 done: mmap_unlock(); + if (did_flush) { + qemu_plugin_flush_cb(); + } } =20 void tb_flush(CPUState *cpu) --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533723; cv=none; d=zoho.com; s=zohoarc; b=B+TOOEZmBq8XixWGgtJ6XVl4bBogIhY0wqB/YW4CqcaL4KADptaKgciBNQzTvdbwLba0Y9tUPJVmNiBm6BymnxjMPQLIiR5Rn3kvuhvfPpbKpJflB84prAYgtLQTWjLe+T578WzK/mcP7R0xSRhn9sTS9Z4iIfdzoAE+fvtrT9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533723; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SFB1HgIcrBt0RkgATkeUJ3aZb9a2tJWQOmU7kxrdIe0=; b=YWFFuIC+V6u3mWWHthMlGCFnUkfhDNk+lw5y9O/PCbKUIZbVyLXtPebXEwTVdhIn0aIeyRb+/+aJZxiT1ziG+wh0l1qMe4ZvUcdjGuX2OlgUmU3OX5dvNoPxq9QBDPWqPDgUfAx5uS+oNuY1wC3uFK6Dcbx6wMCvgio9EM4chJU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560533723466614.1995800688322; Fri, 14 Jun 2019 10:35:23 -0700 (PDT) Received: from localhost ([::1]:53808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbq6h-0001zR-7i for importer@patchew.org; Fri, 14 Jun 2019 13:35:19 -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) 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) 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-Google-Smtp-Source: APXvYqyAz1Gz5gpkj41geb6NiTLQDJcGS7+JEZA3h73+iBD7JdShC/Xgt8ZhrpYgBfpS165Spmlu3A== X-Received: by 2002:a5d:6b52:: with SMTP id x18mr41998034wrw.341.1560532714312; Fri, 14 Jun 2019 10:18:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- bsd-user/syscall.c | 3 +++ linux-user/exit.c | 1 + 2 files changed, 4 insertions(+) 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 =3D 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 =3D 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 =3D 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(); } --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537693; cv=none; d=zoho.com; s=zohoarc; b=CFByIP7FO36+n3UOe590er1b8ZH7kRDDK6D3h5/U2sQ/EE/YxuObRL4L47iX4mUoo7pIg2yokr4VuV2XMLt62VN1DP9PFuzOrmpZ7PrYnfjQhIMxHHWMh+hAsnJsWcVdnzdzz2qsc/WefrsVmMRJ8HsdXh7wbP5TllRLxlEB6UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=y/GuCM+htQJxVNj9wpaJsriigpxg4M/lN2SgW++LMIQ=; b=U/fuHv6NQ73lEjzYi3f8+aZXJuSr/44XFjs6YpmTMKAkEoro/DQkXfa8+QjxCBW2jVYc6+gllItXls4R5ywQcKgoweER38ymeNoA7Qa1Fg+sI+gOQBHQuKJqtEXc4VJdMdc35fw0estEEZQvc9EPEPrdkyeGzoP/bZibRzTTbGg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560537693830752.1440116924291; Fri, 14 Jun 2019 11:41:33 -0700 (PDT) Received: from localhost ([::1]:54202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr8j-0008I0-SV for importer@patchew.org; Fri, 14 Jun 2019 14:41:29 -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) 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) 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-Google-Smtp-Source: APXvYqxVUf6JvHOanL8dF2IVjKwd1oGeV3pXYF+V2mgjUB/SYLQakIn++C4cuZoumvcJchN68wNaiQ== X-Received: by 2002:adf:f951:: with SMTP id q17mr37939614wrr.173.1560534509447; Fri, 14 Jun 2019 10:48:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- bsd-user/syscall.c | 9 +++++++++ linux-user/syscall.c | 3 +++ 2 files changed, 12 insertions(+) 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); =20 @@ -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 =3D -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); =20 @@ -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 =3D -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); =20 @@ -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 =3D -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_lon= g arg1, =20 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); =20 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_lon= g arg1, } =20 trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; } --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534204; cv=none; d=zoho.com; s=zohoarc; b=U37n7HDblt6m62048GBxlV4/GgCgBVJ9z3lqdJjHF0OrWyHV/QPrPfekylxy1w+ALdMZwjm+MZFFPt9+BAkF0hYN64Jn2ubAVJWPwysVhgrTCrfcc1vm1WR+ajwJtxiJFjbT2y032VDOp1br/vZMRSzIy7JQO44ZdMD2R76mHX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534204; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IwZdpz8vUj//qW3TG8z9CwKHzzC4bqX+Vltp43bJ1yk=; b=AqQPPhqVY5oFm9fU+oEoYfxM2v3ob7VNwao1rtj7i5IttYTikQsrMJLctutbJ241ktEUGiRCh1c+BAs04wHtkMt/XS2iRjdkC8k4+7B1hHtObave84AOndLHF33LjHuFSBYXNlo1F1ldA5RLyNVgrqPYHOUlVcZGAaO0mZSEedc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534204666364.46126105902067; Fri, 14 Jun 2019 10:43:24 -0700 (PDT) Received: from localhost ([::1]:53850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqEV-00007R-N7 for importer@patchew.org; Fri, 14 Jun 2019 13:43:23 -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) 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) 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-Google-Smtp-Source: APXvYqz31UqvKCNHZO9xGIlxVAazLGxYSQHiG8W5YLcZ8elMnr2BWRfeaX9+8IOYzyTN3T7LSPGzig== X-Received: by 2002:a5d:4008:: with SMTP id n8mr6522617wrp.353.1560532707867; Fri, 14 Jun 2019 10:18:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- cpus.c | 10 ++++++++++ exec.c | 2 ++ qom/cpu.c | 2 ++ 3 files changed, 14 insertions(+) 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" =20 #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) =20 static void qemu_wait_io_event(CPUState *cpu) { + bool slept =3D false; + while (cpu_thread_is_idle(cpu)) { + if (!slept) { + slept =3D true; + qemu_plugin_vcpu_idle_cb(cpu); + } qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } + if (slept) { + qemu_plugin_vcpu_resume_cb(cpu); + } =20 #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); =20 + qemu_plugin_vcpu_init_hook(cpu); + #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D 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" =20 CPUInterruptHandler cpu_interrupt_handler; =20 @@ -354,6 +355,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Er= ror **errp) CPUState *cpu =3D 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); } =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536269; cv=none; d=zoho.com; s=zohoarc; b=OyTFglwPAE92Gm3WktsQ7QQ0GK71OfSWo6OwExJFN2YDyWlk1A6ySbH7GSDUvHOgeEwRGPfcQjidOQdxUBCdowirkAh0Z4J1PlxbRIgK1ue0opRnukhpJX3nxgJ3e0Pj2jdt+Yx3wskrHclmG8kRXAZOkdYFNWBD/dHMpaXcKSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536269; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/qvBNA83di35y4TZUh+6AvSJoV82skhcUTraghkKk3o=; b=NW6atG2Top8l4DP8Pr0Ad4MynpLuohIxJWXWYVLvfmwdDNjRcL1+3Z9x8rffVgiL+7Gtgd9Ppfv6GBFEpYddD3o1W8ulENAlETywNswBP6InTozp5lmVzwry434CUV8sgwEER0l0wpDZXCKdOU218B4eMBZOl3+VvtIQWX32AYI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536269660446.76420829895164; Fri, 14 Jun 2019 11:17:49 -0700 (PDT) Received: from localhost ([::1]:54042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqlo-0000Cd-LY for importer@patchew.org; Fri, 14 Jun 2019 14:17:48 -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) 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) 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-Google-Smtp-Source: APXvYqywQjJoGsY3i0aGL8CTmgU6BHffN2Jap7gZz86sU/O0N8avlhA6ki7Z4nSBR3MYLaX4PzON7A== X-Received: by 2002:a5d:4a0e:: with SMTP id m14mr18674602wrq.91.1560533313452; Fri, 14 Jun 2019 10:28:33 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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" =20 -/* 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; =20 #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); =20 +static inline void plugin_insn_append(const void *from, size_t size) +{ + struct qemu_plugin_insn *insn =3D tcg_ctx->plugin_insn; + + if (insn =3D=3D NULL) { + return; + } + + insn->data =3D g_byte_array_append(insn->data, from, size); +} + #else /* !CONFIG_PLUGIN */ =20 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) { } =20 +static inline void plugin_insn_append(const void *from, size_t size) +{ } + #endif /* CONFIG_PLUGIN */ =20 #endif /* QEMU_PLUGIN_GEN_H */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537903; cv=none; d=zoho.com; s=zohoarc; b=GHYVOHY7YKsQMEmQw2UphiKPjDtbyLYbcBS5u0UaI1ta8yFfPCNLt+CjUCcwvvA22a8Ko2sSHMxdacQXTNqtm7pQB+FcMu6KGBHyDXrungMDkyLtu76o5sPZ+QL+bVQnULZyMzgWREDegAGkAfNkcg0MbvTr5CBBySdLf4Wl23M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537903; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=M9pjVZf2vmVt0qPRpyohqMfwA1FkxEKe0Yjf3n3HoWM=; b=etXAk9CCNTS0gTfGKlU3VoEbDF00H54UifDQetMDh8VVOjFLfBgrildnppWXWfCS4FA09ntFl+wx2mJ1ez7+0sWLsIlMz+jTLMMVx3n9g2gnxseaUnt2eUz5y5FYpdb2kYoWDJeAxwBZ27yeE78O1qASJdFIRNHwCBxuAPLybTM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560537903912121.91835620684333; Fri, 14 Jun 2019 11:45:03 -0700 (PDT) Received: from localhost ([::1]:54234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrCA-0002vU-P1 for importer@patchew.org; Fri, 14 Jun 2019 14:45:02 -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) 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) 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-Google-Smtp-Source: APXvYqyelPlKrgmQBwFBI7WLeymq9VOP+8CbOBoe3Q/SvtGzaUaP9+x+Au2xgUtRg3fXhWc5inhlzQ== X-Received: by 2002:a05:600c:2243:: with SMTP id a3mr8531302wmm.83.1560533316231; Fri, 14 Jun 2019 10:28:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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 @@ */ =20 =20 +#include "qemu/bswap.h" #include "exec/exec-all.h" +#include "exec/cpu_ldst.h" +#include "exec/plugin-gen.h" #include "tcg/tcg.h" =20 =20 @@ -142,4 +145,29 @@ void translator_loop(const TranslatorOps *ops, DisasCo= ntextBase *db, =20 void translator_loop_temp_check(DisasContextBase *db); =20 -#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 =3D cpu_ ## name ## _code(env, pc); \ + \ + if (do_swap) { \ + ret =3D 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 */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535635; cv=none; d=zoho.com; s=zohoarc; b=drWQdBO/sChxZDKQ7oVn4N6wXSqA/IOho7eQEThpOPdFp+smYnp5Rn444iO+Ui1Lr7tUpiXEkCPGskb7s7WZ0LQnr0RURUaMDQRYd+jVGpc5TQZKhjhaMKipWwf5OtPs9BAtpxAKRo1zAog4qohI6uJa5YISqVGC59VOuRDm5Lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535635; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2raPXKCjQecpuTN9hXy4UgLzVxLUbna9Nio0I94YsC8=; b=eg8xiInSHx97pmSLsSGo75rZcc/XZKiWge5if2AEryNNvIP9tenCYCT6m+UnP7pwMqqh+UGYvTdvZnVvmuq1cBIqPoBGDOJZyhqEsSSFUqegMlCtoYMPBKJf3Y6maBOmLNMBDiw+AXT+ybCemvarYTYEe1c1v/MA8tlxXzw/d30= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535635570245.07450064371528; Fri, 14 Jun 2019 11:07:15 -0700 (PDT) Received: from localhost ([::1]:53966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqba-0007hZ-J7 for importer@patchew.org; Fri, 14 Jun 2019 14:07:14 -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) 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) 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-Google-Smtp-Source: APXvYqwnaio8xVQcNsHUv+78CcU6eKcEB8NBS8/nX+NRzLijLQJSNwdA/EcA/aoTP6K7C0NLtVWaeA== X-Received: by 2002:adf:a201:: with SMTP id p1mr33627107wra.113.1560533307829; Fri, 14 Jun 2019 10:28:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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" =20 static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_pc; @@ -14205,6 +14206,7 @@ static void disas_a64_insn(CPUARMState *env, DisasC= ontext *s) uint32_t insn; =20 insn =3D arm_ldl_code(env, s->pc, s->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); s->insn =3D insn; s->pc +=3D 4; =20 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) } =20 insn =3D arm_ldl_code(env, dc->pc, dc->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); dc->insn =3D insn; dc->pc +=3D 4; disas_arm_insn(dc, insn); @@ -12192,11 +12193,16 @@ static void thumb_tr_translate_insn(DisasContextB= ase *dcbase, CPUState *cpu) insn =3D arm_lduw_code(env, dc->pc, dc->sctlr_b); is_16bit =3D thumb_insn_is_16bit(dc, insn); dc->pc +=3D 2; - if (!is_16bit) { + if (is_16bit) { + uint16_t insn16 =3D insn; + + plugin_insn_append(&insn16, sizeof(insn16)); + } else { uint32_t insn2 =3D arm_lduw_code(env, dc->pc, dc->sctlr_b); =20 insn =3D insn << 16 | insn2; dc->pc +=3D 2; + plugin_insn_append(&insn, sizeof(insn)); } dc->insn =3D insn; =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537138; cv=none; d=zoho.com; s=zohoarc; b=OJx+anaFuly3HfLeYc2I91snrqccMqS9x19fas9Zo9S+grIamSM4t235PmINlxDwtVmsz+veDExP+DJ+zkKzG4KCgKCA5DHgG92uPy3DYRG/uPnKHTzvZq8P2AtbvxSYzbAaI5pAD7V+MgjmATo2s7zjoj6Su7nJkOrze4hIXG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537138; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=y+34OeiOJi4hTXE8brxuKPyvEg2ag444W2pbsGyLziY=; b=Usdx3QV190Tu4XuOEhNftkfykx403etLsWii6V0C0SctI/7SbsmAjlH6MH9ozZOKco7iOJI0Ch4oSm3DwMOvb5kxHsQCJ2Bjx+HpYgdQ6drxcykwVYhe8C988Ui2vXEk4TGxlEIqcNadp1NUu0rhldJwq2YsqPprX1QrHJdpQWM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15605371388157.104568791602901; Fri, 14 Jun 2019 11:32:18 -0700 (PDT) Received: from localhost ([::1]:54114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqzm-0008NN-QB for importer@patchew.org; Fri, 14 Jun 2019 14:32:14 -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) 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) 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-Google-Smtp-Source: APXvYqzIWddpxQxn5iSaxqlDYzs2Bf139Pb6u1FWGZIHq1LEifCmiAToHYtQbZ0FGYuVz4bFKb6LYw== X-Received: by 2002:a1c:f20c:: with SMTP id s12mr9399028wmc.151.1560533317329; Fri, 14 Jun 2019 10:28:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Acked-by: David Gibson Reviewed-by: Richard Henderson --- target/ppc/translate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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=3D" TARGET_FMT_lx " super=3D%d ir=3D%d\n", ctx->base.pc_next, ctx->mem_idx, (int)msr_ir); =20 - if (unlikely(need_byteswap(ctx))) { - ctx->opcode =3D bswap32(cpu_ldl_code(env, ctx->base.pc_next)); - } else { - ctx->opcode =3D cpu_ldl_code(env, ctx->base.pc_next); - } + ctx->opcode =3D 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), --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534311; cv=none; d=zoho.com; s=zohoarc; b=YMWIPZYr+fMY+SDoqx2/JJnABZ1pQfg4W37MmD++8QHwheXXu9BkgYpH8o2RdOclbooZW7aoNaycIpYbZ602cVUS2x8wPfgc4ZiG4ur8RNbonkl00aqUul7ZZ1lOf2sMR9SzlBaL1Ll2FzAnG+kQGrcnPOuz7XMRKgO3kXSmwjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8XTuXWq+xToiDvDobeS2vNcXere9quLdtk1afgwMbsw=; b=DhPz+E8bcToJMY/Y3zsIp4wRkz+gogPAODLZFHbHEfL3rN+K79DHezDETAL8CeWIT7+MLR8iTqBHD8sQBZ+/jhkZh+zIQW4BDuo8JjBSgnmKjzbcKSV/ox7AfY8qWTt3yISRbk1JV2hsGa10SpOW8Y2JIE0EpIcTrvxxpcDHF5M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534311566297.09318310773654; Fri, 14 Jun 2019 10:45:11 -0700 (PDT) Received: from localhost ([::1]:53858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqGE-00021R-GI for importer@patchew.org; Fri, 14 Jun 2019 13:45:10 -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) 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) 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-Google-Smtp-Source: APXvYqxQnb+GMlSOfJaxv7q8G0FO0bNsheabfgos+iNcRgSwxgtwQD3J6/3B5Kr+Kd+sRTBlP7sHsw== X-Received: by 2002:a5d:694a:: with SMTP id r10mr43467409wrw.345.1560532718017; Fri, 14 Jun 2019 10:18:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Reviewed-by: Richard Henderson --- target/sh4/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, CPUSH4Stat= e *env) =20 /* Read all of the insns for the region. */ for (i =3D 0; i < max_insns; ++i) { - insns[i] =3D cpu_lduw_code(env, pc + i * 2); + insns[i] =3D translator_lduw(env, pc + i * 2); } =20 ld_adr =3D ld_dst =3D ld_mop =3D -1; @@ -2332,7 +2332,7 @@ static void sh4_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) } #endif =20 - ctx->opcode =3D cpu_lduw_code(env, ctx->base.pc_next); + ctx->opcode =3D translator_lduw(env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next +=3D 2; } --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535203; cv=none; d=zoho.com; s=zohoarc; b=Az5RV2ovmBezvPiE9smRIfORaUKJYrWrB9pnfc35mgE0/3mD6ay1FqDYWBBaHY6hH3yn0lmTKc+a9sQJH2NuuMMb5+DlSYKek68mH67iaES/ZAsTJ8Es0YBQLHPjLj6+szlSGZLCyXH0n22u7XxLNdN17JGN2xDpHxmczN8Z8HY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535203; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6P43XFojefi1AlRvRGu6U5nFz+CBkKm3yL3ZJgj6xbU=; b=gEQZKRpoVechtO3Si2MFgSSzKMatga3k30GrvffX8UanXbrQDbZYtJ6QGbwN+OlgiFabUVCI5WzGpMAqOGi5pgBuoTSMHsjmKC5sVqmmr05vHmU4nqAseihfovbrStWneeT4+g7Lv7PyNx3h+DHYd+CTLjWbivkg1oaVc42yV/g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535203691202.10522402284653; Fri, 14 Jun 2019 11:00:03 -0700 (PDT) Received: from localhost ([::1]:53932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqUU-0002zm-O3 for importer@patchew.org; Fri, 14 Jun 2019 13:59:54 -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) 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) 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-Google-Smtp-Source: APXvYqxl6mL7tTz7X7KEtG2vqgQMbj67v6Cc1Rl4iudjG1CUlvN3GaFe4IW9bcSP3mAkcN1XqsCGkA== X-Received: by 2002:a5d:63cb:: with SMTP id c11mr65591079wrw.65.1560533308268; Fri, 14 Jun 2019 10:28:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/i386/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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, DisasC= ontext *s, int num_bytes) =20 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)); } =20 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)); } =20 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)); } =20 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)); } =20 #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 =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535875; cv=none; d=zoho.com; s=zohoarc; b=jBYvfTVf8kdG0a/tafF6CX1z6jPXxlUDQvdjHIVKK5rTrH/cmQ5qlr9+yE5BZ/SHIY+kBSFJYlU03MJ9lEOCXvA4rU3p7We9zkr9ViXgBUw27il4hCXCKpEZ4bvPrTiM9z3zoTc8/jP+x86NuSKCyJ92iQcA2TcdjFNWaYwhHug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535875; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=j/CmdxYOGc9bGjlEPT/VLtkTFw4z76NfPGE78+zNw14=; b=a+W6eJ3stQtEGsp6xaRQnGnRW6j/OQQ6MEvZzyHF8GizSDsoYBWNeG+rzF94S8N/l1QMjbEqxkcNsILBl7PpN12aUMSMWc7+pJV2a/ooPXe8ICEP2DNQjVwNkJS3QjjAwzcNvol6QVI26615GyLTruVfk/O+GITXh3N9lRpTxgs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535875699837.9417176767715; Fri, 14 Jun 2019 11:11:15 -0700 (PDT) Received: from localhost ([::1]:53988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqfR-0003M5-AF for importer@patchew.org; Fri, 14 Jun 2019 14:11:13 -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) 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) 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-Google-Smtp-Source: APXvYqytXUg2PDOj/GmEuDip87jfeD5HQVRvfx2+JYKWbbWtyzfOgQ6dVy361Uwdswbvi4DEnBwVLQ== X-Received: by 2002:a1c:968c:: with SMTP id y134mr8267656wmd.122.1560533319750; Fri, 14 Jun 2019 10:28:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 =3D cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn =3D translator_ldl(env, ctx->base.pc_next); =20 /* Set up the IA queue for the next insn. This will be overwritten by a branch. */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560538518; cv=none; d=zoho.com; s=zohoarc; b=i8oFeSAZmqb2JtVwk9X/ksDBi8hvbk8sPl3XR3nZbzuh7V0V3co6XGRQdxkCx/HOagZzjDfOvTHPwJlsvH6bPEYWNy0moNhvDkNOSseQlZ10KUqtmfbF01TEydOvBWs/BfDszyy2Epiry/houriuH7i8JpLTq69XHYziBnHIB5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560538518; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nfJr9+Ou2ey8h7VCuPmwWUBSybcXHQgAvYfUsvi+vzc=; b=HhZ+WEnGtKAV5BOnF90tLaleb4VfAuhxUKD31gKulzodXFUZ6Xw+8VHTX3/EmwjrhJdrBF8U0zUvEMdApYasvtgsmzZ7g2BgNSbMM9MDHfPHMX3Ys8wCwESrptC19bufKxW+ICZ057EiH/9VBBzNy7uKKeIp8tM1bLRZwBEf1J0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560538518566735.4261074091653; Fri, 14 Jun 2019 11:55:18 -0700 (PDT) Received: from localhost ([::1]:54350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrM5-0004OA-L2 for importer@patchew.org; Fri, 14 Jun 2019 14:55:17 -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) 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) 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-Google-Smtp-Source: APXvYqxxiV0ayX1I1rzd0LpLB+cwEgtfOWrsymBAUYDB6e0iBPMhXmhzTY10DuM1eEjDnWBBm2+twA== X-Received: by 2002:a1c:b6d4:: with SMTP id g203mr8760124wmf.19.1560533315485; Fri, 14 Jun 2019 10:28:35 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/m68k/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 =3D cpu_lduw_code(env, s->pc); + im =3D translator_lduw(env, s->pc); s->pc +=3D 2; return im; } --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536205; cv=none; d=zoho.com; s=zohoarc; b=h7DCBxL2bHSH+lGihFs+j2DhYE/5GhI92KmELzwCaHfywpZnm8DPI8JP07NkS/GyXh1coKkZV3yL8MMD9S2LZqVQEB8eS8e4skDUMs517OJz1JQAamAf5X7SZ6xVXpALCoA6+rdprFbmURZX/ZEZuUOYI+NvXRTdVvYiy8YxD/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536205; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ITzNLkGufKFpiKfmJVh6vzZ3LsNbeBm40jej1S7JzUY=; b=HvnWaAhxhYl4DjNcdrC5Ug4pV5V8dci3p51Fb1XMfr4OC72R8C7flo+tCqYisxFsxQMFLnwSyrEmAY9J6npY4Vi37IpucnnD7UVMm9e32/sOEmxANZom+hPN++X2V0Ssff9Iu+6oabXBynG6en9L7ib/IKNsjkcY7yYl/8CMK7k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536205373586.3527562511578; Fri, 14 Jun 2019 11:16:45 -0700 (PDT) Received: from localhost ([::1]:54032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqkg-0007R7-8d for importer@patchew.org; Fri, 14 Jun 2019 14:16:38 -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) 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) 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-Google-Smtp-Source: APXvYqwscFUsmLzmfKBI+1R+Cp/VFQNmAmOY4wureejtvZptyFOqsTfE5uhagkzmItu0+I9n6W06Hw== X-Received: by 2002:a1c:b684:: with SMTP id g126mr8632045wmf.176.1560532709061; Fri, 14 Jun 2019 10:18:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/alpha/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 =3D container_of(dcbase, DisasContext, base); CPUAlphaState *env =3D cpu->env_ptr; - uint32_t insn =3D cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn =3D translator_ldl(env, ctx->base.pc_next); =20 ctx->base.pc_next +=3D 4; ctx->base.is_jmp =3D translate_one(ctx, insn); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535042; cv=none; d=zoho.com; s=zohoarc; b=lk/T0DxNn51MGnyHpMhbzKkhLJQWroQvFkx40CIxM3PHEMMsCkHeFuOQlfUz56Bp13ktudht1XLpkT25RL7rhwIEnKqjTzL/xS03qGCREitrxtdfS1IQmaEu/92Sg3W9hPUJR72Ma7V3YLtBde0yICKNQYyNhHV0CGlY/VolQ7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535042; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qBxTdhQNZtrN8TCgxYqVNYuvZXvpIW53Hq/nYGE1p+s=; b=j6lejz7RKjYNAZ9qBOa8+dqQIgmM6aCo7iKV5khdV/9ECPppEHzeAy5d6UgI22x82tPRxPSGrv6t/FegJOvhxNLBJU5COsle6ZHJkVNBX+Bgvd83vcEjCVj9aporHnwQX5dDZqK/ncH9eHwRroy1oj5S1jzlG2YBZz4j0h5PZ2g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535042749320.8703649950112; Fri, 14 Jun 2019 10:57:22 -0700 (PDT) Received: from localhost ([::1]:53912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqS1-0000P2-LX for importer@patchew.org; Fri, 14 Jun 2019 13:57:21 -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) 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) 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-Google-Smtp-Source: APXvYqzVzcy/lNHpdyTqDBQUqPXBwnbG4otD543eQwqA42aI8vWZ7Xz/YgCZ6NYSB2WR8ltP7bX9mQ== X-Received: by 2002:a1c:c549:: with SMTP id v70mr8517710wmf.135.1560532711546; Fri, 14 Jun 2019 10:18:31 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/riscv/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 *d= cbase, CPUState *cpu) DisasContext *ctx =3D container_of(dcbase, DisasContext, base); CPURISCVState *env =3D cpu->env_ptr; =20 - ctx->opcode =3D cpu_ldl_code(env, ctx->base.pc_next); + ctx->opcode =3D translator_ldl(env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next =3D ctx->pc_succ_insn; =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536997; cv=none; d=zoho.com; s=zohoarc; b=hAXO5apC90r2wMuZhqw8Jwbd6H8IFdvfBbvGyib+8mlvTqumxHFYZIvr70qXaDbBwCG36hx1qljotvoN6BZT90ZLcloyHGIWPq1DoMUT/2XJt1JIsjSH9odZfLh4xTxEwu8Ps8WwstQSmFEFl/1HpkCK9HcKq36/H4nnfJDtdhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536997; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HqBVQy6B4RYG2ErzndHduRIrrPjVT1ZXYEPUu/ciMz8=; b=kA+cnvgFbQ/JY4SbGMs/HlgaOpXg3CKesVBnZn0X2nVUzK4qq7IArkzvjWMalS5Cc+Rz0mtmBHU8YexTISSi4bvsoTGdHTXnInGWHH+WRdr5uc7yE9hp2wzfKiHwfHsl05BRTKj2VNTakSVaSzipR83xQqyFF2bvCSFYzq8Pcm8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536997578741.4396922410671; Fri, 14 Jun 2019 11:29:57 -0700 (PDT) Received: from localhost ([::1]:54112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqxO-00073D-26 for importer@patchew.org; Fri, 14 Jun 2019 14:29: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) 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) 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-Google-Smtp-Source: APXvYqw3oLvR6oVr3vcjA0xVXdU0dy0o8hSs9B5kenQCGyk2LKrqxObs2NVsprv/Ucd00P7ogb+5jA== X-Received: by 2002:a1c:cc02:: with SMTP id h2mr8679411wmb.13.1560534508257; Fri, 14 Jun 2019 10:48:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 =3D cs->env_ptr; unsigned int insn; =20 - insn =3D cpu_ldl_code(env, dc->pc); + insn =3D translator_ldl(env, dc->pc); dc->base.pc_next +=3D 4; disas_sparc_insn(dc, insn); =20 --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534886; cv=none; d=zoho.com; s=zohoarc; b=WrxZf/6Q0AUmj6WRPrRzEvtDUJYLGJwWfAPtOljhz6qLPvc8bwGJTnSc5Au7nyl23GGM8gsKKgqrTQzxu4LrXjFrA4TkGKCnsRjjNPx8byadZQfZu0Jds3xjtYMiYJ8HaiFnb/lsfIaZ8xqth55EbjjDWEWOXxlX2ekLBL3373I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534886; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+b63Y9PbLI6+aITJW7vKd87oH1u7+0WksIZYyx+bONM=; b=Hrb+O3KJbNliIMFlTcwsraPM9sUS2WEmn/jCqYWE0+PqozLpIr9tpYMUbjNveTszauZq5SklA3NWyz8GWsTWol/n+f/+Xp3F/WqG4VLTkNkGPRCQVE4RxKa8UA5WLlBjJwZ0A4IMfn/ryUacbIhKn7hUpuV/OKyzTSE2PrBhao8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534886521992.5918240758383; Fri, 14 Jun 2019 10:54:46 -0700 (PDT) Received: from localhost ([::1]:53906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqPN-0007y4-Fy for importer@patchew.org; Fri, 14 Jun 2019 13:54:37 -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) 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) 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-Google-Smtp-Source: APXvYqyv51qiQ/pFBZohY4DFImbVbgkL3DVlA2KqBrZdHJq18ShK2TIbSHtfIlQ6AwIVXXvrZ2hYYw== X-Received: by 2002:a1c:c003:: with SMTP id q3mr8747990wmf.42.1560532707343; Fri, 14 Jun 2019 10:18:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/xtensa/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 =3D dc->config->isa; - unsigned char b[MAX_INSN_LENGTH] =3D {cpu_ldub_code(env, dc->pc)}; + unsigned char b[MAX_INSN_LENGTH] =3D {translator_ldub(env, dc->pc)}; unsigned len =3D xtensa_op0_insn_len(dc, b[0]); xtensa_format fmt; int slot, slots; @@ -887,7 +887,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) =20 dc->base.pc_next =3D dc->pc + len; for (i =3D 1; i < len; ++i) { - b[i] =3D cpu_ldub_code(env, dc->pc + i); + b[i] =3D translator_ldub(env, dc->pc + i); } xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len); fmt =3D xtensa_format_decode(isa, dc->insnbuf); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560538401; cv=none; d=zoho.com; s=zohoarc; b=gofaG5cJv/EiWd1DqK8U4ofyK0+F1ysmV7xV6m08HeHW5aX6T/f3ujR1v1TPkV0ps7CZz14yTxkgJPJPVMWHkKYrkxUFnNpYcxm2PqxU0hOXfie8KAovltQZs31X5emm38z10XlmJUSel7yUt1gc0vN2UXB2flb9xw2yABZ93LQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560538401; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sbV6bhfix9ogursybnzoCKTzFmIQ6JokAy/mT287wFE=; b=j1BlQc0ydooYvJoJmKIltfZdRQQCj3wgsqz/ADXTxvqjRveL/VfDYL8/aynZ7hqezR+OqZDHsVFpSNRaSOoUttcK8a4qfr6hth/jYnU6DQemvEGZT8//kk61JRElep2nTfCZKDbn1caPb2/XVHM3NlB9U5V/5SsxiSXkS7x3Bho= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156053840167152.61235522995821; Fri, 14 Jun 2019 11:53:21 -0700 (PDT) Received: from localhost ([::1]:54320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrKC-0001mD-Nd for importer@patchew.org; Fri, 14 Jun 2019 14:53:20 -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) 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) 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-Google-Smtp-Source: APXvYqw2mEZdlvTBSoFYPr3sTDIzPskNfUQBwlQteDOGw/Er33YzAaE0fynFyS6QGWQIqO+/fUrMkQ== X-Received: by 2002:a05:600c:2383:: with SMTP id m3mr8616299wma.20.1560533312982; Fri, 14 Jun 2019 10:28:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(DisasContextBa= se *dcbase, CPUState *cs) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - uint32_t insn =3D cpu_ldl_code(&cpu->env, dc->base.pc_next); + uint32_t insn =3D translator_ldl(&cpu->env, dc->base.pc_next); =20 if (!decode(dc, insn)) { gen_illegal_exception(dc); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536205; cv=none; d=zoho.com; s=zohoarc; b=nvY8i7sMHaaBEGETJnDVwC9edfHNchUb7iKSppeabc/VWdxAy/1eITRKRFiHbkU+ywgoecpcCvkAz1+VOdDZsIMo/hJa5f7+9tINzeMOl4prIjpq2uNXjhvuQ2I9rSrq8NkpzlrlXIdVd1JoHOb5rGeu7oCd+6U7hxzRSRglp4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536205; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1Ghk3o46eKDRyTTJB5656nYsZZ0fzl1fP3AqjgtBmAI=; b=h0c9wJVcVXrnyliWR07w37xgOummgUwJ5L3L61w5sDXeq4Zv7MTrWDEanQhwFvmaHnRKP7shJPSJovy4FjUj4kVZO/OxJUoNL3UqvGuvuHo5lbmraSr1H5XlRSC+6YrecyljEjHyXmsxXZEIGYRM15eI9dL+/xEUDhhgHzek1Iw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536205327602.0515005005137; Fri, 14 Jun 2019 11:16:45 -0700 (PDT) Received: from localhost ([::1]:54028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqka-0007IO-4b for importer@patchew.org; Fri, 14 Jun 2019 14:16:32 -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) 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) 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-Google-Smtp-Source: APXvYqzzQ7cXCS4nXhvB5Qq3IMEDWXfcw67SDCbLhV4Ypg0poPRwTgouammHwcQ1KCHecq62LJaQ1w== X-Received: by 2002:a5d:5283:: with SMTP id c3mr35035556wrv.268.1560533314954; Fri, 14 Jun 2019 10:28:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota --- accel/tcg/translator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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" =20 /* 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, DisasConte= xtBase *db, CPUState *cpu, TranslationBlock *tb, int max_insns) { int bp_insn =3D 0; + bool plugin_enabled; =20 /* Initialize DisasContext */ db->tb =3D tb; @@ -55,11 +57,17 @@ void translator_loop(const TranslatorOps *ops, DisasCon= textBase *db, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 + plugin_enabled =3D plugin_gen_tb_start(cpu, tb); + while (true) { db->num_insns++; ops->insn_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit = */ =20 + 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, DisasCon= textBase *db, ops->translate_insn(db, cpu); } =20 + if (plugin_enabled) { + plugin_gen_insn_end(); + } + /* Stop translation if translate_insn so indicated. */ if (db->is_jmp !=3D DISAS_NEXT) { break; @@ -112,6 +124,10 @@ void translator_loop(const TranslatorOps *ops, DisasCo= ntextBase *db, ops->tb_stop(db, cpu); gen_tb_end(db->tb, db->num_insns - bp_insn); =20 + if (plugin_enabled) { + plugin_gen_tb_end(cpu); + } + /* The disas_log hook may use these values rather than recompute. */ db->tb->size =3D db->pc_next - db->pc_first; db->tb->icount =3D db->num_insns; --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534797; cv=none; d=zoho.com; s=zohoarc; b=eWWxZ6Ddms9/IyfhouGqUx2HTSo4tkVUQxvBVSLEelPgMWs7v+AW2ZvV1ZneoA1txHW1Z+PpgntbXm4/2pJIuv5G2lmKR7hfbqRNhrTv1LycRJUzveYcHX0lp1bZIBfysU+gfE8/NbFRpuah8cBWS6DeT8n3mP3dV58ST6OZG3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gsafAaKWWEo4Uo36EmX0kTE77G4d03quI77xyI/6ztg=; b=ddFHGWLSmhtowORP4aiMywgW1SnOV/vYbfKWGKV8denDCixCxyy8hgFrVavw4SvOY+HQXAjMUdF8+CRn9FOEz/4cQmymBIm1I6WjIhJ+DgKez6sKi4dTpoztIZ1hs+w0qajp32nth96c+0Tv7wii7/QYun4rVmhCYNMDD67HlFE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534797731408.93762898031775; Fri, 14 Jun 2019 10:53:17 -0700 (PDT) Received: from localhost ([::1]:53904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqO4-00072G-MC for importer@patchew.org; Fri, 14 Jun 2019 13:53:16 -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) 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) 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-Google-Smtp-Source: APXvYqzShaMTBTlWtca3XdE385bmHNBYE1HD2AUHWAB14uht18erwzmYwVRIHvACmmk+HHUVFTtD7A== X-Received: by 2002:a5d:4b4f:: with SMTP id w15mr8689164wrs.199.1560533309569; Fri, 14 Jun 2019 10:28:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota [AJB: moved into plugins] Signed-off-by: Alex Benn=C3=A9e --- 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 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=3D"${TMPDIR1}/${TMPB}.o" TMPCXX=3D"${TMPDIR1}/${TMPB}.cxx" TMPE=3D"${TMPDIR1}/${TMPB}.exe" TMPMO=3D"${TMPDIR1}/${TMPB}.mo" +TMPTXT=3D"${TMPDIR1}/${TMPB}.txt" =20 rm -f config.log =20 @@ -5496,6 +5497,58 @@ if compile_prog "" "" ; then atomic64=3Dyes fi =20 +######################################### +# 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=3D"no" +if compile_prog "" "-Wl,--dynamic-list=3D$TMPTXT" ; then + ld_dynamic_list=3D"yes" +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +cat > $TMPTXT <> $config_host_mak LIBS=3D"-ldl $LIBS" + # Copy the export object list to the build dir + if test "$ld_dynamic_list" =3D "yes" ; then + echo "CONFIG_HAS_LD_DYNAMIC_LIST=3Dyes" >> $config_host_mak + ld_symbols=3Dqemu-plugins-ld.symbols + cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols + elif test "$ld_exported_symbols_list" =3D "yes" ; then + echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=3Dyes" >> $config_host_mak + ld64_symbols=3Dqemu-plugins-ld64.symbols + echo "# Automatically generated by configure - do not modify" > $ld64_sym= bols + grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' |= \ + sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols + else + error_exit \ + "If \$plugins=3Dyes, either \$ld_dynamic_list or " \ + "\$ld_exported_symbols_list should have been set to 'yes'." + fi fi =20 if test "$tcg_interpreter" =3D "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 +=3D loader.o obj-y +=3D core.o obj-y +=3D api.o + +# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_li= st +# 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 :=3D -Wl,--dynamic-list=3D$(BUILD_DIR)/qemu-plugins-ld.symbols +else +ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST +api.o-libs :=3D -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; +}; --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536615; cv=none; d=zoho.com; s=zohoarc; b=aw5SOWTFQeieESVqyCbd7z3vplwM5AinwzK9kJwWg6plhYQkj9LsUZaiaQ47wrb/8vK6izvtSBrwo8VlB5HGPy/cYkJMtB5A8k+wKXGwUSfcjcnbi/psOxjmXr/g8AnJpQVWna0toINfWIuCdXrm9UQpGg/IOBeJKLVjOcHmZ3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536615; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Qg44j1/fmT2WZWQwTd6B39K1u36F6LVDpErcGgO7T1Y=; b=JtCEStywfZFHHeh4bhnast5VzhmjFHmfjAS3XwtXKa1T3vNT0iaLDjmIaQtMTq8dcvFy1DPSatC4cnSz4yinwQatji6HWPRKK/li6AIwltIUJ9JtgpfiQ7YXU6/pv6Xg01GasX+zNsvsTZa9OxndTtH0b5t4GLdhxqysQ6T1nws= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156053661585211.739115270594084; Fri, 14 Jun 2019 11:23:35 -0700 (PDT) Received: from localhost ([::1]:54076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqrM-00048T-PV for importer@patchew.org; Fri, 14 Jun 2019 14:23:32 -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) 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) 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-Google-Smtp-Source: APXvYqwwNF2M+YYJZsJMY/VEd12uNEYgIdt/dZg0hAEOwxtUSHVcWh9xXXMqaCtX65dWo1r7QZxz/A== X-Received: by 2002:a1c:730d:: with SMTP id d13mr8510608wmb.88.1560533318979; Fri, 14 Jun 2019 10:28:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Vilanova?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Llu=C3=ADs Vilanova Signed-off-by: Llu=C3=ADs Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- qemu-options.hx | 17 +++++++++++++++++ vl.c | 11 +++++++++++ 2 files changed, 28 insertions(+) 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 o= f text. @findex -trace @include qemu-option-trace.texi ETEXI +DEF("plugin", HAS_ARG, QEMU_OPTION_plugin, + "-plugin [file=3D][,arg=3D]\n" + " load a plugin\n", + QEMU_ARCH_ALL) +STEXI +@item -plugin file=3D@var{file}[,arg=3D@var{string}] +@findex -plugin + +Load a plugin. + +@table @option +@item file=3D@var{file} +Load the given plugin from a shared library file. +@item arg=3D@var{string} +Argument string passed to the plugin. (Can be given multiple times.) +@end table +ETEXI =20 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) =20 #include "trace-root.h" #include "trace/control.h" +#include "qemu/plugin.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" =20 @@ -2954,6 +2955,7 @@ int main(int argc, char **argv, char **envp) bool list_data_dirs =3D false; char *dir, **dirs; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); + QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); =20 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 =3D trace_opt_parse(optarg); break; + case QEMU_OPTION_plugin: + qemu_plugin_opt_parse(optarg, &plugin_list); + break; case QEMU_OPTION_readconfig: { int ret =3D qemu_read_config_file(optarg); @@ -4068,6 +4074,11 @@ int main(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } =20 + /* process plugin before CPUs are created, but once -smp has been pars= ed */ + 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"), --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560533259; cv=none; d=zoho.com; s=zohoarc; b=QLXJZiewmKTmH0pLh0NUPpOi/RCE5oBGdCEXXXzNHm8sj31mCd/K0xk0o0Gw+1LkT7Yc4ejyTzDXbGcpqYzrHwcurZAbqANWh+XRYfOPc7R3LNtEjJoTOVH0ZSlIzOYvA6QCMXX/LSKUmlJNk89zft57vRbtSykaVRk7NfJ0ogQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560533259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=P9bsnv/ggrydM2zdkz7ungy+IkQQkZz8WUvWT7dsGh0=; b=BnDmwbHEkEAMY7vx7MycEpzxAeS5tY2LzCoB5eoBKD9H2t9owcr6JYvSyDY3nVJF6IuIc6FwyrjcpjZfTIqCJhKCwG8E4qj+Z+E7sl4r9uXgDZL+GSvw3ddJSL/CYW+915vyCtvIBEvqvZ2D5agZMhBZPoX6MMdrQ8t0YBUPgk8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15605332591181004.8032698778003; Fri, 14 Jun 2019 10:27:39 -0700 (PDT) Received: from localhost ([::1]:53774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbpzD-0005lB-3E for importer@patchew.org; Fri, 14 Jun 2019 13:27:35 -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) 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) 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-Google-Smtp-Source: APXvYqzIn8CV4RvLu2tBmZWNPNVejfhi7H7xUjzkM2OPPybFYx53HxEbuIKhND7dS+IllAWDexX30Q== X-Received: by 2002:a5d:4310:: with SMTP id h16mr55726729wrq.331.1560532716118; Fri, 14 Jun 2019 10:18:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Vilanova?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Llu=C3=ADs Vilanova Signed-off-by: Llu=C3=ADs Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson --- linux-user/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 =3D trace_opt_parse(arg); } =20 +static QemuPluginList plugins =3D 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[] =3D { "", "Seed for pseudo-random number generator"}, {"trace", "QEMU_TRACE", true, handle_arg_trace, "", "[[enable=3D]][,events=3D][,file=3D]"}, +#ifdef CONFIG_PLUGIN + {"plugin", "QEMU_PLUGIN", true, handle_arg_plugin, + "", "[file=3D][,arg=3D]"}, +#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 =3D NULL; =20 qemu_add_opts(&qemu_trace_opts); + qemu_plugin_add_opts(); =20 optind =3D parse_args(argc, argv); =20 @@ -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); + } =20 /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560538865; cv=none; d=zoho.com; s=zohoarc; b=Plp8CvqTJ9SaIyYb7dLsqfOxYVUl0V/mu3oWqrWCsjiTTr/Sovqo4i4vIJkt448hNbigqDuBEP6656yVEuxZLxA9jqu2npGW881a3DAYf9w7L/4bpdyYNYciqVc6klxG5dxJS7hR+papwkal5hQ6XQW2AhA8gOkBlWzI6ZlJdss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560538865; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VXpK415OMJJqmZ3w36Oxw/kJSG0YBc4gbksES0oJVX8=; b=ESlWF4gIkNZYBePbmY9ZgIYFq6rEZfPzlxre4AlGnaBZlOzHuugsRRnbXQq7jj39AvJhPuTFSdXIiXtCl2lKd3Jtmn4A+v6QrrtWpue+zoin0DeWG9kYH8wna2vKpI+euld6mYPtkgqcIYW00nUWToAuOjYFZvBlu+XvvZ3QDK8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560538864932858.7059213213909; Fri, 14 Jun 2019 12:01:04 -0700 (PDT) Received: from localhost ([::1]:54382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrRa-0000Ip-JN for importer@patchew.org; Fri, 14 Jun 2019 15:00:58 -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) 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) 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-Google-Smtp-Source: APXvYqwzVELrPux0c6U0ZsBBsmjubvRsPsv4uWGLUMQpraPiD/TfJooSwaP7KGEeNylKrfDOYKwxRQ== X-Received: by 2002:a5d:4302:: with SMTP id h2mr36455054wrq.137.1560534509002; Fri, 14 Jun 2019 10:48:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Pass arguments with -plugin=3Dlibfoo.so,arg=3Dbar,arg=3Dbaz 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 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=3D"tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/q= api-schema tests/tcg/xtensa tests/qemu-iotests tests/vm" -DIRS=3D"$DIRS tests/fp tests/qgraph" +DIRS=3D"$DIRS tests/fp tests/qgraph tests/plugin" DIRS=3D"$DIRS docs docs/interop fsdev scsi" DIRS=3D"$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS=3D"$DIRS roms/seabios roms/vgabios" LINKS=3D"Makefile tests/tcg/Makefile" LINKS=3D"$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" LINKS=3D"$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makef= ile" -LINKS=3D"$LINKS tests/fp/Makefile" +LINKS=3D"$LINKS tests/fp/Makefile tests/plugin/Makefile" LINKS=3D"$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps" LINKS=3D"$LINKS pc-bios/spapr-rtas/Makefile" LINKS=3D"$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 :=3D $(CURDIR)/../.. + +include $(BUILD_DIR)/config-host.mak +include $(SRC_PATH)/rules.mak + +$(call set-vpath, $(SRC_PATH)/tests/plugin) + +NAMES :=3D +NAMES +=3D bb +NAMES +=3D empty +NAMES +=3D insn +NAMES +=3D mem + +SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) + +QEMU_CFLAGS +=3D -fPIC +QEMU_CFLAGS +=3D -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 =3D (unsigned long)udata; + + insn_count +=3D 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 =3D qemu_plugin_tb_n_insns(tb); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, + &bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_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") =3D=3D 0) { + do_inline =3D true; + } + + /* to be used when in the exit hook */ + stdout_fd =3D 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 =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + struct qemu_plugin_insn *insn =3D 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 =3D true; + } + + /* to be used when in the exit hook */ + stdout_fd =3D 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 =3D 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 memin= fo, + 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 =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_mem_inline(insn, rw, + QEMU_PLUGIN_INLINE_ADD_U6= 4, + &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 >=3D 3) { + if (!strcmp(argv[2], "haddr")) { + do_haddr =3D true; + } + } + if (argc >=3D 2) { + const char *str =3D argv[1]; + + if (!strcmp(str, "r")) { + rw =3D QEMU_PLUGIN_MEM_R; + } else if (!strcmp(str, "w")) { + rw =3D QEMU_PLUGIN_MEM_W; + } + } + if (!strcmp(argv[0], "inline")) { + do_inline =3D true; + } + } + /* plugin_exit might write to stdout after stdout has been closed */ + stdout_fd =3D 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; +} --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534525; cv=none; d=zoho.com; s=zohoarc; b=aL8dNoPMEOTAum8mmRzcxKKaB1ZGqvrAQvhic0f6OMM1+neQn1zTs/ZlV6PaEVhorPTbXbDRwqm290/IE4Mn6EAIAVmH9a9UA6DKXnsqufBvaYCWGC5hod/pCoBppfmAajbdSk94sqY9XzurhZZZzm0rryJQBG8TDZWjWUHWWJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534525; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AtuxXjdv5rXrTnKR+kY966HW3wPcp99t7mVhH09mMeM=; b=VzqLxI/1pkuUAnWF7w1DotmJSNbcbzl5A9wLetVSrgNyaZfeuunmC59KZE0Q9GJlqkUVz1n/07quUi12whGPoaPjGWUXqDH37db/JChpHF1y2Hqo5wqv8je8xNUNHhx3E2RK5/Qgm+dWduTkSZEpHmrsWQHJWkl80w8/rCWb8VQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534525938915.2993693090083; Fri, 14 Jun 2019 10:48:45 -0700 (PDT) Received: from localhost ([::1]:53874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqJZ-0003Om-P1 for importer@patchew.org; Fri, 14 Jun 2019 13:48:37 -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) 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) 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-Google-Smtp-Source: APXvYqw6zw6RiTxGhinm8wxWiITqeOci37oKCHRT75bc/xo6UZLh6n5d9dfL9DXvBYvTILTScO5J0Q== X-Received: by 2002:a7b:c94a:: with SMTP id i10mr8445078wml.97.1560532712975; Fri, 14 Jun 2019 10:18:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- tests/Makefile.include | 10 +++++++- tests/tcg/Makefile | 34 +++++++++++++++++++++++++++ tests/tcg/arm/Makefile.softmmu-target | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) 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 =20 +# Plugins +ifeq ($(CONFIG_PLUGIN),y) +plugins: + $(call quiet-command,\ + $(MAKE) $(SUBDIR_MAKEFLAGS) -C tests/plugin V=3D"$(V)", \ + "BUILD", "plugins") +endif + # Per guest TCG tests =20 BUILD_TCG_TARGET_RULES=3D$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS)) @@ -1061,7 +1069,7 @@ $(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ)))) endif =20 -build-tcg-tests-%: +build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins) $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V=3D"$(V)" \ SKIP_DOCKER_BUILD=3D1 TARGET_DIR=3D"$*/" 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) # =20 RUN_TESTS=3D$(patsubst %,run-%, $(TESTS)) + +# If plugins exist also include those in the tests +ifeq ($(CONFIG_PLUGIN),y) +PLUGIN_DIR=3D../../tests/plugin +VPATH+=3D$(PLUGIN_DIR) +PLUGINS=3D$(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+=3Drun-plugin-$(t)-with-$(p)))) +endif + +strip-plugin =3D $(wordlist 1, 1, $(subst -with-, ,$1)) +extract-plugin =3D $(wordlist 2, 2, $(subst -with-, ,$1)) + RUN_TESTS+=3D$(EXTRA_RUNS) =20 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=3D$<.out$(COMMA)id=3Doutput \ $(QEMU_OPTS) $<, \ "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=3D$@.out$(COMMA)id=3Doutput \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(QEMU_OPTS) $(call strip-plugin,$<), \ + "$< on $(TARGET_NAME)") endif =20 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+=3D-nostdlib -N -static test-armv6m-undef: EXTRA_CFLAGS+=3D-mcpu=3Dcortex-m0 =20 run-test-armv6m-undef: QEMU_OPTS+=3D-semihosting -M microbit -kernel +run-plugin-test-armv6m-undef-%: QEMU_OPTS+=3D-semihosting -M microbit -ker= nel =20 endif --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535260; cv=none; d=zoho.com; s=zohoarc; b=CRGH7Fu5bRWjK2rFUtrsX1rBCS+tyZvjB3NAdSjlkPev2e3Tm1xuAb08MAKwviInV0KBckFuimSMw2fdo5lj6MawVf2lGsG11E+m7TirmL9y1y483rlaoYX4i6MNW0w9neMd80x6dYyZUlDupgMNSjZOnyG8MPLiOa+uDLQjdBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535260; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ePNB7fMxER8fpxE4Yb4C2baLVHXAfUjyVC7rsoU1lSM=; b=da/QWXRHKgN4o/HaE3Zty0FI2kFkgimUuu1O0v1mgonNz7HuU94Np9ZjM4uSZVJQvfzAH01phZZ2WND2lSAvofooYLxfMYlsK2RCY6hQIw0ybqtL7aExeJUqqOG6IyPIcff2tgEbBlefgl+vVsOwcN/CZnKwPlcgpOkNL3jzzd0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535259986903.3837357697043; Fri, 14 Jun 2019 11:00:59 -0700 (PDT) Received: from localhost ([::1]:53936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqVV-0003tD-MG for importer@patchew.org; Fri, 14 Jun 2019 14:00:58 -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) 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) 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-Google-Smtp-Source: APXvYqw8gwtsGMuDacw+jESeSyhKn2bpfqd0YYL9O+VE0Y/Lfe1WcVRT62k5Vi8nr5+MZlwmrpfLGA== X-Received: by 2002:a1c:452:: with SMTP id 79mr9021511wme.149.1560532709802; Fri, 14 Jun 2019 10:18:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- tests/plugin/Makefile | 1 + tests/plugin/hotblocks.c | 145 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 tests/plugin/hotblocks.c 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 +=3D bb NAMES +=3D empty NAMES +=3D insn NAMES +=3D mem +NAMES +=3D hotblocks =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 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=C3=A9e + * + * 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 =3D 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 =3D (ExecCount *) a; + ExecCount *eb =3D (ExecCount *) b; + return ea->exec_count > eb->exec_count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report =3D 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 =3D g_hash_table_get_values(hotblocks); + it =3D g_list_sort(counts, cmp_exec_count); + + for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { + ExecCount *rec =3D (ExecCount *) it->data; + g_string_append_printf(report, " pc: %#" PRIx64 " (%d block%s, %l= d 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 =3D 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 =3D (uint64_t) udata; + + g_mutex_lock(&lock); + cnt =3D (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) c= heap_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 =3D qemu_plugin_tb_vaddr(tb); + unsigned long insns =3D qemu_plugin_tb_n_insns(tb); + uint64_t cheap_hash =3D pc ^ insns; + + g_mutex_lock(&lock); + cnt =3D (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) c= heap_hash); + if (cnt) { + cnt->trans_count++; + } else { + cnt =3D g_new0(ExecCount, 1); + cnt->start_addr =3D pc; + cnt->trans_count =3D 1; + cnt->insns =3D insns; + g_hash_table_insert(hotblocks, (gpointer) cheap_hash, (gpointer) c= nt); + } + + g_mutex_unlock(&lock); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_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") =3D=3D 0) { + do_inline =3D true; + } + + /* to be used when in the exit hook */ + stdout_fd =3D 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; +} --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534184; cv=none; d=zoho.com; s=zohoarc; b=G2VS8ger8lv7jJLjJQEB6Sh3FN4l8kIGBlGnUk3dk53+Knr+gkYV53XBtjgV9qZLnvX4N2gq0GKo+JWeTmZn1rfLo/bgLHGXXQRrHtWeTfot889MZxexUGRvHxyVEJpMjB46tbNZT8c9GnaN9K7jTQ6bVZ68Z3M/2lrlgYcDq/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534184; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=z1GEGb1AT/jZhECwGmNfmmOk5GT9rSMPb0f35A3hv4U=; b=bwurHhTktviIKjoXOuLzQvVu08eKVzhg/KyahKRnzrm+VepkpW0ED8tq8qKzNlNfSDyPSEVVz4wHnREZCilHeMllYrTDv1959k+TdE3m9PZPbQpGqf0qr6LhHqo9fDLeGKBfwoQvpbZdahgBkaXjrfFl5VIlmaa/ijH7+kfzNqM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534184356695.9723066802376; Fri, 14 Jun 2019 10:43:04 -0700 (PDT) Received: from localhost ([::1]:53840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqE8-0007iC-9J for importer@patchew.org; Fri, 14 Jun 2019 13:43:00 -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) 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) 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-Google-Smtp-Source: APXvYqzgZQ5Z+g+Ud4extfvydZF0eChZKD9acTtshsuYsoYM7sGlUrb4SZbJMRck2kNClA/gh8pxzg== X-Received: by 2002:a1c:452:: with SMTP id 79mr9021561wme.149.1560532710963; Fri, 14 Jun 2019 10:18:30 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Give the plugins access to the QEMU dissasembler so they don't have to re-invent the wheel. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- 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(+) 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_ul= ong code, } } =20 +static GString plugin_disas_output; + +static int plugin_printf(FILE *stream, const char *fmt, ...) +{ + va_list va; + GString *s =3D &plugin_disas_output; + int initial_len =3D 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 *i= nfo) +{ + /* does nothing */ +} + +/* Disassemble a single instruction directly into plugin output */ +static bool plugin_cap_disas_insn(disassemble_info *info, uint64_t pc, siz= e_t size) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize =3D 0; + int count; + GString *s =3D &plugin_disas_output; + + if (cap_disas_start(info, &handle) !=3D CS_ERR_OK) { + return false; + } + insn =3D cap_insn; + + size_t tsize =3D MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf =3D cap_buf; + target_read_memory(pc, cap_buf, tsize, info); + + count =3D 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 =3D CPU_GET_CLASS(cpu); + target_ulong pc; + int count; + CPUDebug s; + GString *ds =3D g_string_set_size(&plugin_disas_output, 0); + + g_assert(ds =3D=3D &plugin_disas_output); + + INIT_DISASSEMBLE_INFO(s.info, NULL, plugin_printf); + + s.cpu =3D cpu; + s.info.read_memory_func =3D target_read_memory; + s.info.buffer_vma =3D addr; + s.info.buffer_length =3D size; + s.info.print_address_func =3D plugin_print_address; + s.info.cap_arch =3D -1; + s.info.cap_mode =3D 0; + s.info.cap_insn_unit =3D 4; + s.info.cap_insn_split =3D 4; + +#ifdef TARGET_WORDS_BIGENDIAN + s.info.endian =3D BFD_ENDIAN_BIG; +#else + s.info.endian =3D BFD_ENDIAN_LITTLE; +#endif + + if (cc->disas_set_info) { + cc->disas_set_info(cpu, &s.info); + } + + if (s.info.cap_arch >=3D 0 && plugin_cap_disas_insn(&s.info, addr, siz= e)) { + return g_strdup(ds->str); + } + + if (s.info.print_insn =3D=3D NULL) { + s.info.print_insn =3D print_insn_od_target; + } + + for (pc =3D addr; size > 0; pc +=3D count, size -=3D count) { + count =3D s.info.print_insn(pc, &s.info); + + if (count < 0) + break; + + g_assert(size >=3D 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); =20 +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_i= d_t id, qemu_plugin_vcpu_syscall_ret_cb_t= cb); =20 =20 +/** + * 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" =20 /* Uninstall and Reset handlers */ @@ -218,6 +219,12 @@ void *qemu_plugin_insn_haddr(const struct qemu_plugin_= insn *insn) return insn->haddr; } =20 +char *qemu_plugin_insn_disas(const struct qemu_plugin_insn *insn) +{ + CPUState *cpu =3D 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; --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560538730; cv=none; d=zoho.com; s=zohoarc; b=FUn75vsXnPUvfOjesOmh/gIKQxmXdvykqV0JhN3arQakUcltyAhxa8fS1iKNewzhZNuX27jKIWCKJa9aUid14cEn8wKScpNybWumEZupAO5UMm9PZoxL2j5wPfjgGvO9vV6hbtXEJoE/l/6GWP+H7bvUfI9ECaJryKhqi/aqMLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560538730; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LOtltZHJUqpcmg4ZA8EIX1vMLr1AdiMsA9bSNinYDLI=; b=SK44niW71v8VCrwXkBh3KYHBuPdIh9Rpg7XtyO/Lw9/UQ4f6AZA/f4qqpuOCsEYjSkxxqC/YyE98B5+vVuzL4dXRgF+wJGjeNun/gGo9ysQ0WsN7W+9LyoiEeZZsozSANzFH5IFntp/KAp0kJZl5Y+KpGhRG0GpEoLmsqDsPPdA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560538730016177.6545072140193; Fri, 14 Jun 2019 11:58:50 -0700 (PDT) Received: from localhost ([::1]:54366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrPM-0006Yt-M8 for importer@patchew.org; Fri, 14 Jun 2019 14:58:40 -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) 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) 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-Google-Smtp-Source: APXvYqwK4FxwBEqQwgmDCdQnPEGmg0WggSxmHYqoP7/FwSqkyvh1Fk9CdpCJxVGDH8JRoK4ZHuEhng== X-Received: by 2002:a7b:cf32:: with SMTP id m18mr9120358wmg.27.1560534507757; Fri, 14 Jun 2019 10:48:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This gives a break down of instruction classes and individual instruction types. Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/Makefile | 1 + tests/plugin/howvec.c | 297 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 tests/plugin/howvec.c 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 +=3D empty NAMES +=3D insn NAMES +=3D mem NAMES +=3D hotblocks +NAMES +=3D howvec =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 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=C3=A9e + * + * 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 =3D 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[] =3D { + /* "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 =3D (InsnExecCount *) a; + InsnExecCount *eb =3D (InsnExecCount *) b; + return ea->count > eb->count ? -1 : 1; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + GString *report =3D g_string_new("Instruction Classes:\n"); + int i; + GList *counts; + + for (i =3D 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 individua= lly\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 =3D g_hash_table_get_values(insns); + if (counts && g_list_next(counts)) { + GList *it; + + g_string_append_printf(report,"Individual Instructions:\n"); + + it =3D g_list_sort(counts, cmp_exec_count); + + for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { + InsnExecCount *rec =3D (InsnExecCount *) it->data; + g_string_append_printf(report, "Instr: %-24s\t(%ld hits)\t(op= =3D%#08x/%s)\n", + rec->insn, + rec->count, + rec->opcode, + rec->class ? rec->class->class : "un-ca= tegorised"); + } + g_list_free(it); + } + + dprintf(stdout_fd, "%s", report->str); + g_string_free(report, true); +} + +static void plugin_init(void) +{ + insns =3D g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + uint64_t *count =3D (uint64_t *) udata; + (*count)++; +} + +static uint64_t * find_counter(struct qemu_plugin_insn *insn) +{ + int i; + uint64_t *cnt =3D NULL; + uint32_t opcode; + InsnClassExecCount *class =3D NULL; + + /* we expect all instructions to by 32 bits for ARM */ + g_assert(qemu_plugin_insn_size(insn) =3D=3D 4); + opcode =3D *((uint32_t *)qemu_plugin_insn_data(insn)); + + for (i =3D 0; !cnt && i < ARRAY_SIZE(insn_classes); i++) { + uint32_t masked_bits =3D opcode & insn_classes[i].mask; + if (masked_bits =3D=3D insn_classes[i].pattern) { + class =3D &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 =3D (InsnExecCount *) g_hash_table_lookup(insns, GUINT_TO_P= OINTER(opcode)); + + if (!icount) { + icount =3D g_new0(InsnExecCount, 1); + icount->opcode =3D opcode; + icount->insn =3D qemu_plugin_insn_disas(insn); + icount->class =3D 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 =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + uint64_t *cnt; + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + cnt =3D 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, c= nt); + } + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + int i; + + for (i =3D 0; i < argc; i++) { + char *p =3D argv[i]; + if (strcmp(p, "inline") =3D=3D 0) { + do_inline =3D true; + } else if (strcmp(p, "verbose") =3D=3D 0) { + verbose =3D true; + } else { + int j; + CountType type =3D COUNT_INDIVIDUAL; + if (*p =3D=3D '!') { + type =3D COUNT_NONE; + p++; + } + for (j =3D 0; j < ARRAY_SIZE(insn_classes); j++) { + if (strcmp(p, insn_classes[j].opt) =3D=3D 0) { + insn_classes[j].what =3D type; + break; + } + } + } + } + + /* to be used when in the exit hook */ + stdout_fd =3D 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; +} --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560534065; cv=none; d=zoho.com; s=zohoarc; b=i1dHkeciAa+pfpWKuL3P9+/Xu+XLb6Vv1QRRyQWl1IMhZRiQPM5IVKuoPGSTG7fLko/zKFZ6zTkufHia521W+rDoslXz+zUxwDA3gNtppKyjOJZQMd0fTUdRU7MCRx6cD5d3rFngkh3QHNRe6Jqjh+F5/mi5xYrIWpJ3z+JW4sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560534065; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Q0g+J0COJWGb6iPQMwKOFR9aEmXrXmgB9rcv6IsahSA=; b=P3kRwpGYaFg0hs9DQdNDL6uaUqFRK3CtHM17a1ITfYKQ6MjTxsl3yM3mwss6KLODGAGesaJTHpq0FOq4PSlnhAgdZEWRf4G6jr2mX2zb0TsgNuO43Ws7s8KoHAwL3EvwtfWbxFQLVBFrOQ7/4Axq//LWlDOuvA81iv8w2Pl817w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560534065727183.4048147823214; Fri, 14 Jun 2019 10:41:05 -0700 (PDT) Received: from localhost ([::1]:53836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqCB-0005uV-PP for importer@patchew.org; Fri, 14 Jun 2019 13:40:59 -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) 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) 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-Google-Smtp-Source: APXvYqzake6QIVTv4bpS0cBgTdnAxv3DGFGNBUmfdmaidi5Zq2a3/dMizsC1Nh4af4tY2LhsDdl1ew== X-Received: by 2002:adf:bac5:: with SMTP id w5mr51292878wrg.124.1560532708568; Fri, 14 Jun 2019 10:18:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This plugin gives a break down of access patterns grouped into pages. Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/Makefile | 1 + tests/plugin/hotpages.c | 152 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 tests/plugin/hotpages.c 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 +=3D insn NAMES +=3D mem NAMES +=3D hotblocks NAMES +=3D howvec +NAMES +=3D hotpages =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 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=C3=A9e + * + * 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 =3D 50; +static enum qemu_plugin_mem_rw rw =3D 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 =3D (PageCounters *) a; + PageCounters *eb =3D (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 =3D g_string_new("Pages:\n"); + int i; + GList *counts; + + counts =3D g_hash_table_get_values(pages); + if (counts && g_list_next(counts)) { + GList *it; + + g_string_append_printf(report,"Individual Instructions:\n"); + + it =3D g_list_sort(counts, cmp_access_count); + + for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { + PageCounters *rec =3D (PageCounters *) it->data; + g_string_append_printf(report, "Page: %"PRIx64" cpus:%#04x/%#0= 4x %"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 =3D (page_size - 1); + pages =3D g_hash_table_new(NULL, g_direct_equal); +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t memin= fo, + uint64_t vaddr, void *haddr, void *udata) +{ + uint64_t page =3D (uint64_t) haddr & page_mask; + PageCounters *count; + + g_mutex_lock(&lock); + count =3D (PageCounters *) g_hash_table_lookup(pages, GUINT_TO_POINTER= (page)); + + if (!count) { + count =3D g_new0(PageCounters, 1); + count->page_address =3D page; + g_hash_table_insert(pages, GUINT_TO_POINTER(page), (gpointer) coun= t); + } + if (qemu_plugin_mem_is_store(meminfo)) { + count->writes++; + count->cpu_write |=3D (1 << cpu_index); + } else { + count->reads++; + count->cpu_read |=3D (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 =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + struct qemu_plugin_insn *insn =3D 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[] =3D +{ + { "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 =3D 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 =3D 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; +} --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560537699; cv=none; d=zoho.com; s=zohoarc; b=XynO0VliZOOnsLor7310Q0orK+8DaSUjp7MQZ9/v/pZ3nPLwhigA6uSjl1Am4P9oRhlbQGPk8McN7PjVvaoSMB2mlH/gvDZ02spH+PpPFGC6UMFdf4yo4qkJD9iW6AprGyVJ6qoBYGJM5ZBkeLVVi4hlwLWuiWbesm7s+/tDzrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560537699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fvj+WUGANmLFqW2EJSINSwwcAn8sLAyNi/cgHqJTnR8=; b=WljMfxscsQN6oXScPs02agzyhD9bLIRdugtFHLyqLs3JaN74tVK/u6IxJSnPQunwvY1SJof/Bpb/hh119k3mxyLFMjmVf0iIQTblZzVBLUH9Mc+mqSjb6h6wBhXOJ7SWdC+3uq/geWVBTvq5Bh79dNAbBrSSYcIGp5InjN8A3js= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156053769905669.93382907857153; Fri, 14 Jun 2019 11:41:39 -0700 (PDT) Received: from localhost ([::1]:54208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbr8s-000079-2q for importer@patchew.org; Fri, 14 Jun 2019 14:41:38 -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) 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) 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-Google-Smtp-Source: APXvYqxuD3a0pD9ZYdthvGwCJzuOkmP1GyY2kDx8kJ8s512Pu3NpRPYp3mZIWNsjszVYbr7M4+uwSA== X-Received: by 2002:a5d:548e:: with SMTP id h14mr12198151wrv.76.1560533311917; Fri, 14 Jun 2019 10:28:31 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Reviewed-by: Richard Henderson --- accel/stubs/tcg-stub.c | 3 --- 1 file changed, 3 deletions(-) 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 @@ */ =20 #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" =20 void tb_flush(CPUState *cpu) --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560536050; cv=none; d=zoho.com; s=zohoarc; b=SSYJHPAo+hr0xGYYLlCDYTy/a7vp9D8QFsm5H3tg5P9sq83wUeKt8/sL9ONdbT+2tzdQQc8kX7FSY5WhgMeEsO22yBg5mgXMWC15Zowb5IXeGYvRKY9WbhjvjBwjm1kiXCxAYAzszutRj348Noybfoddd+fmUNU1UEkqhO3EyhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560536050; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2ielurtjzGKb7Ob3E21QU+qcFZWaTKQ9JelyDfiWc2c=; b=QHuQuU0ppFwAVkzHqwsdX+xAN0YLbUzMh0xfI+Rj4caR+pdlLC3NGn8QAaJPtWW2hvuEtYTgwspHVp1F7hRpaTKlxMDnaEN8eWZ/9LKYGRMbpVUTlfedylZwRvKMOPsult8ySealM9InAVETWRN0FhKnewCtFLT2EIaIqOHF2s0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560536049985557.6415566751303; Fri, 14 Jun 2019 11:14:09 -0700 (PDT) Received: from localhost ([::1]:54012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqiD-0005Xc-RH for importer@patchew.org; Fri, 14 Jun 2019 14:14:05 -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) 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) 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-Google-Smtp-Source: APXvYqxpePc3nsmS7MKNkLz24NNxFVOv6SYmzINEFKa2dDrC01r1/W8nZCgxG6p3I9xoOjY3z93Xpw== X-Received: by 2002:a1c:9c8a:: with SMTP id f132mr8766940wme.29.1560533314450; Fri, 14 Jun 2019 10:28:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This gets around a build problem with --disable-tcg. Signed-off-by: Alex Benn=C3=A9e --- include/exec/exec-all.h | 2 ++ 1 file changed, 2 insertions(+) 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 =20 #include "exec/tb-context.h" +#ifdef CONFIG_TCG #include "exec/cpu_ldst.h" +#endif #include "sysemu/cpus.h" =20 /* allow to see translation results - the slowdown should be negligible, s= o we leave it */ --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560535899; cv=none; d=zoho.com; s=zohoarc; b=gNkqKRBV4I1yPL2nr9T+dIgEmpjtUgS8nq7AAGLDF3YJ6E/b+9h8VyAZMHt0Yo7uSp1+FbvQsD2CVwA/CuhDoh1EylFyfBQY0/IxznsohM64RLhjqnvIKZsjGakfvbfvBgxK54IewaKZ9CtzR1oW8hjbIn0fc/CjNF58MExZo1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560535899; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=W2oEJPPTu0XotTJyTG/icubFdccUFHMYcxjFSxZmE7E=; b=Ux0O+sNWHpdO8lwrPe7LKNbY8XA3EMnCFAI8XWfciw6DIliEBkMtwGchSYSuM0Nw2b1O7CyMXcWJanb3J/ia4oIDoTDBLgqBBHUKkSatY9b2OP20zBU88vY38fu0vEHYE+bcJd+YuI126V28TqSqW3po/xz/p4q6lKOOKoeQ2LY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560535899073463.37880023833156; Fri, 14 Jun 2019 11:11:39 -0700 (PDT) Received: from localhost ([::1]:53992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbqfp-0003Ta-Tv for importer@patchew.org; Fri, 14 Jun 2019 14:11:37 -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) 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) 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-Google-Smtp-Source: APXvYqwJNWKxqA9UsjX/FQ+SgmC03tf1hyTlBPzQju3SBUCxIhlsRWlQQjNy0RNYGEkhgWM13n5qBQ== X-Received: by 2002:a5d:4e50:: with SMTP id r16mr13474318wrt.227.1560532716650; Fri, 14 Jun 2019 10:18:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/exec/cpu-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ =20 /* - * 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 { --=20 2.20.1 From nobody Mon May 6 23:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1560538175; cv=none; d=zoho.com; s=zohoarc; b=IlM62QXOWBPBPi8k6KwmwNh0tfhDBrxmQaMSAuzb3I2wAQn77pDLmqsitNDS72Smi+7HTkN+2Btd4pL6zfMGVsIBE/I5KlG8+QyKUGWKBTNCw6RQDkwwqDz6m6uUHNVd68s2weu4YsDMklPpn/5T2Gwg3CBIWrcsPJJrGA3jfO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560538175; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=l+F+1JN97gKyw7kKNWTOxFjpETDNYB39JWHiUo3QTVA=; b=JneoD1G+LErfUC7+hV1CYWehF+0A57V7dDioECsikAVrU43Iw31mlIfhSAIaB3BXhxJP6rz4mAu3ppz8CTQf2Ti0HeptE1hdlICsrvzGPzVqMX5Yorp3XXOBwI1Kbvm7Yy16ZGK6sDpBY9VAZosi5SzcBjf6Q48D6kgVXIJzojo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560538175787976.6408532687699; Fri, 14 Jun 2019 11:49:35 -0700 (PDT) Received: from localhost ([::1]:54270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbrGW-0006wL-LK for importer@patchew.org; Fri, 14 Jun 2019 14:49:32 -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) 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) 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-Google-Smtp-Source: APXvYqzMLSK7+SkT+doycWqokAFfRgXvilXEqEabHPNK31DKuQzeai/z248Q1ZETdDcZvs/q+IljJA== X-Received: by 2002:a5d:6709:: with SMTP id o9mr52157881wru.301.1560533317777; Fri, 14 Jun 2019 10:28:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=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 Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" --- include/qemu/qemu-plugin.h | 1 + 1 file changed, 1 insertion(+) 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); --=20 2.20.1