From nobody Tue Feb 10 08:03:26 2026 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