From nobody Tue Feb 10 14:33:08 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=1564590160; cv=none; d=zoho.com; s=zohoarc; b=oT77RVZgMBhBugAE+ZDOx8Istt8+Awz7nxtjkBYBnnTeVdYg/P18qC60k3Jqo96Jraj0HJpdTSoGryfKHDHLlciIUDHXvUUA7Q6FxciLRV5lM2H1uqhiJc2uWgy0h7np6kSw9/+AU7+FilE77nzKnSgn4GI1Ofnocg+DNYlZVsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564590160; 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=iNk53UNeX1NNAe+JEukLVQQBwgjFTkD+CslUIM9XJKY=; b=gSZHbaUcPhVWnDk8hiQhqwRJAR1PdPRRZ8/N8G01ziwTjLMe0+W60Fx/UBsx3wWDcnQAxZXcYp8t55vxAee9jh77Ng+IPFVKqmxoGyJmKl9UoS/53/hD7w1OtTFyskxqTg652cJR6KOGbg3odZBCy4G9G+yiTpxirsx9hxOnSz8= 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 1564590160876590.9646332623475; Wed, 31 Jul 2019 09:22:40 -0700 (PDT) Received: from localhost ([::1]:42560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsrN9-000577-Rl for importer@patchew.org; Wed, 31 Jul 2019 12:22:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42434) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsrG8-0005yR-6z for qemu-devel@nongnu.org; Wed, 31 Jul 2019 12:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsrG6-0004AM-9U for qemu-devel@nongnu.org; Wed, 31 Jul 2019 12:15:24 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsrG6-00048u-0f for qemu-devel@nongnu.org; Wed, 31 Jul 2019 12:15:22 -0400 Received: by mail-wr1-x442.google.com with SMTP id r1so70310838wrl.7 for ; Wed, 31 Jul 2019 09:15:21 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w67sm89738808wma.24.2019.07.31.09.15.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 09:15:17 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1C5C71FFA3; Wed, 31 Jul 2019 17:07:21 +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=iNk53UNeX1NNAe+JEukLVQQBwgjFTkD+CslUIM9XJKY=; b=CriTWfqh07MbCdF67DxGcRMN6e7Kn9RZy1Mr3l+QOXfFRamsvzGk5h1DluzoWOJJTh Iipcr4LvGa61bd5NstOSXzLny956jJg8TCfj2Q3F1qVPZhh07YxJT4lij3CJMkHMUmfh VwOf0zZc5DPJghjCbEXz8kynKjzXoK4uSxk0vnqMGOI/3IjP/NkNgkToa5y791XNfGDa 7t4lWxMk5lgxeK3Z8k4/oliGCFB5SZ6z7oAfpFEXoJWuLRSn/qzFwghvqirRJLcQS0Lp bBjzJaaYOukVi0gkCcgKSYOccLz83aZVQdulmN77Tu/r9TnjEGufc+fL52djck+3XPpD A1tA== 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=iNk53UNeX1NNAe+JEukLVQQBwgjFTkD+CslUIM9XJKY=; b=TiHL/CsWtWroRq9YM8o6ZiWt0dsAZ6ejCS5TGtqcXOZOgus8o/4EHwA9ujHDnPCu82 lPHb0m3RVH4mr+csOl32wpLphuIzk1nSClsxIqQpcyjEWO6o/cdADc3SBAsR59qAeZjn C6eTya52kxxyepuM+eA8dUxSZTX5dJGXI/BDLLD3yX5+UkoS6vhRkckjmhmvw30mwheC pJTHLgR6I0NGlM5oN3ETITjx5uaPFC3jM1bvLZO2+4Y2lkvKVIWXG1y90VmPKvsyPPge HLtEnegtvRkIPDGpe7hONWy+KDtDEupWlsnNOzBEjDVXr63LefPZY5fNMv9l3BvcRbZb E35A== X-Gm-Message-State: APjAAAWaFI5m1aHInmr/wTupo/NpxzbBccAXJ+DoZGv3Fr5Y9AtchIa6 JYU8v0hjYl+ADAfd1US9iDwsnQ== X-Google-Smtp-Source: APXvYqwEL+HRYl+to53QdI3zzo4Ve/gImLgw1E+ljn4uESILli2/kXFGrrxyMKNO597m9WFExR241Q== X-Received: by 2002:a5d:680d:: with SMTP id w13mr137497767wru.141.1564589720861; Wed, 31 Jul 2019 09:15:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 17:06:43 +0100 Message-Id: <20190731160719.11396-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731160719.11396-1-alex.bennee@linaro.org> References: <20190731160719.11396-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 v4 18/54] 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: aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , bobby.prani@gmail.com, =?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" This will be used by plugins to get the host address of instructions. Signed-off-by: Emilio G. Cota Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- 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 a01e04c5416..21ba71ea9dd 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 8b1c3d5b9db..90045e77c1f 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