From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437598; cv=none; d=zoho.com; s=zohoarc; b=PxLOwlG91OsZUCltd8oVB0w2o89P/3r5zubuX+pPcyGkWmEPDrSI7o89ZtzyVXVq7LpAs8SVPJgcBBgU9s+1tUupKeGZl5hGEAnqBu+n/0G3pc5X5AYc4lv32KeP4sbNHOzBHjOuJTk+Z98UrpZVw9qVjn0i4CGfR8HFNBaY6Rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437598; 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=Q6zTCS3a7jbtaH9NaP7Qy7VX+G/mKKsgVF1UpUR0SU0=; b=LPEao0EQZUWuX8BnwLrDrB8VUuppbIMY+BIw2l3l8/JcUsXsl3Q+cHwP42tNjylgnf7FntmN1s7TUvaDTvVv03GpdbUbXTWlro2YaAYtg7LY8limNZYMRd9DbNjv/IXfu8Ev5l9Kvjd9ByE3SrCjVC5MkW0bxpTr793BOZepG2w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437598150489.39692594709913; Wed, 25 Sep 2019 11:53:18 -0700 (PDT) Received: from localhost ([::1]:56106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCPc-0008GB-75 for importer@patchew.org; Wed, 25 Sep 2019 14:53:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46915) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIV-0001eg-0r for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIT-00049n-Th for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:54 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:44315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIT-00048s-NO for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:53 -0400 Received: by mail-pg1-x52d.google.com with SMTP id i14so142457pgt.11 for ; Wed, 25 Sep 2019 11:45:53 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q6zTCS3a7jbtaH9NaP7Qy7VX+G/mKKsgVF1UpUR0SU0=; b=fu9N3v/CyUj/AF1Jqou+Qwav1uyd1l+Fwy4D4qmEZmi33EKs4W3qnvY3yR9jLD0yU4 veUfrSnFBqm2TZBbmRnZZEm2MPz9c2Ue06agPoeXt2KiXbUAtu28fWtUzuDFBWZsX7Ma mJoOPnpKkM6h4ElbPC4fXcS9Kfe7AIXHmbjT5monn04u+UrEcqxodE0sLirLc2dZ0wt6 j9j6vAGEbVGrkiaqwooATKogVKGaGWMSPKpo3DEFqpzH9zqPL/FoXr9D7TK4ukzRo60h cRvESQKVXnq1PvNdtOO8Yw+FiQPZrlf3IrZXyhLKoPs/Q7gKrbGOKjmw5qEamT8AY/Gi jlOw== 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=Q6zTCS3a7jbtaH9NaP7Qy7VX+G/mKKsgVF1UpUR0SU0=; b=XbFR4VjM2draCp9Fcx+ACTWZsm8CWMCn0gd+XnXDSgKj87OLyQokuqQJCOBjIrrn00 hwpcU2eLLGUsVFya3Hj973F9iZVFg6+sDGDbU7Kd219cltHEpob9jXNRqjwwMdFfnI8L gZwcaoYZjpNX5pNr37M6DdmzMEEP18SBR2OsW3v3J5A6yN4k69vzDarav+e3vmmKsb/f qId3RYxVxUBeICzw6X6e0zjDKav1nodAe8UeHZBQJNBhDS8nnGRGI2IK4dprL/0A8BcU rxBOTtbsX85AzRY9WW8z5y30pOF3nrMeeeZAoRBbmX1wnAbAzf8yeIIyUMs/teyDhVQQ LlvQ== X-Gm-Message-State: APjAAAVFGm3YTyeAiEB/p64oMbJ0801a7xHy/zZYJSszbe0jsegQBoLM FuvNNRapEvPFOEKzbqqrGLlCdn1ltJc= X-Google-Smtp-Source: APXvYqwBtwq69sWjbmzjoL1SWDwe8DNCHdqT2Pdl0lNd4cGMGXqThZuVW+Demfr6rYEWaDZZt1YtRw== X-Received: by 2002:a62:2b51:: with SMTP id r78mr11146723pfr.149.1569437152312; Wed, 25 Sep 2019 11:45:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/16] exec: Use TARGET_PAGE_BITS_MIN for TLB flags Date: Wed, 25 Sep 2019 11:45:33 -0700 Message-Id: <20190925184548.30673-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::52d 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) These bits do not need to vary with the actual page size used by the guest. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d2d443c4f9..e0c8dc540c 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -317,20 +317,24 @@ CPUArchState *cpu_copy(CPUArchState *env); =20 #if !defined(CONFIG_USER_ONLY) =20 -/* Flags stored in the low bits of the TLB virtual address. These are - * defined so that fast path ram access is all zeros. +/* + * Flags stored in the low bits of the TLB virtual address. + * These are defined so that fast path ram access is all zeros. * The flags all must be between TARGET_PAGE_BITS and * maximum address alignment bit. + * + * Use TARGET_PAGE_BITS_MIN so that these bits are constant + * when TARGET_PAGE_BITS_VARY is in effect. */ /* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS - 1)) +#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) /* Set if TLB entry references a clean RAM page. The iotlb entry will contain the page physical address. */ -#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) +#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2)) /* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) +#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) /* Set if TLB entry contains a watchpoint. */ -#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS - 4)) +#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437359; cv=none; d=zoho.com; s=zohoarc; b=XGkvSnmOlSESp6q0wPcAUAf5/nOG2NTBRSgslCc3+gFYeWK7eIMagS0K1a+xzzaF8g3FstodE45OLrAJ1sWlfbK2Sxxxoi80et64Aok4tZ3DheLSQ6ClnIkZ+3Obczoi/5V6Tqayg6fOPDlNNtMtOUBEXEysj+5E+3prTrf8syY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437359; 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=aF7h8rqeF+2t+99M3oN6M4tL53Bil7zhbXJ09PpgfiI=; b=laaeNGEiHflcl22+fl1EkPQA2ief4eMlGOXUpFFPN7B/exbYNRAcIjrJ7lgtyFg3EAfsNhU/WTVllmID0t0lq6tiJ7f7QcKl6oV3od6eJH/QNaJFmeOdqzzT5P3+9VqEwxsUax7cL5jwV9ZlNBh37++/74zDKQ6kG1eQneT4ufc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437359594771.7192136997238; Wed, 25 Sep 2019 11:49:19 -0700 (PDT) Received: from localhost ([::1]:56060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCLb-0003ej-Cp for importer@patchew.org; Wed, 25 Sep 2019 14:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46951) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIW-0001ev-Dv for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIV-0004Bn-B4 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:56 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:38024) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIV-0004AY-5A for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:55 -0400 Received: by mail-pf1-x436.google.com with SMTP id h195so4156831pfe.5 for ; Wed, 25 Sep 2019 11:45:55 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aF7h8rqeF+2t+99M3oN6M4tL53Bil7zhbXJ09PpgfiI=; b=Jr2PYB98n8W4eYtLOfF7FaH9i2h89lfkq5iTuXlXuUruLL7WEKdy7ubbBilpWNmjzc xSXbInx+BbxFhvPrepFdAr+KPswc8JdZyNrlP3cL0t2wxpnD8QmGiewGnmrGnk8e1O9z H1+A/vopzcR5VbtN/+vaDDyGhd+rdGVycOdK0HIJBCsb3KrLZdMTTnJ6cLoV7KWWvu5V C6/42tHAaOuw2Qh+0zUWEUwjRI0mv8LcNTci3QMeXxi6xXI+/BACso7QTBUaMGMVxNVN 6P0V7wYPZzL2y8wCk2s3v9OdsZ010WOkvbOkCkCm6prosn2KZwYwgVvZ13pXovg0Lmb1 ACTw== 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=aF7h8rqeF+2t+99M3oN6M4tL53Bil7zhbXJ09PpgfiI=; b=CM7EM7fUTDuL+de/4NwvUdUeo86j6VqvseTGsH6BHgIRVD63/erZi/l4tFWfHfM364 nLMlsHFgnmxstnSmYtq/nFkjzBas2GT3Xx4ALvkxLsPRbC1mYWshLmT9SoVivtBRcKQT u2kDOveyq2awGzdTP0RR7yCpCAxtQjkMWN1NoMszyKqYw3cPZ92sFphpmczmn1TRicnh tyu3x99q0Tu0k+9IQ8rffoblhVG3o8O/jCakCt+FBWGnkS60uUu3gxIsvM6s692Ln4x0 VwOFZcS10I5LrRevMhW+M2F1/VGj5gRUGJcxBnUIo7LkxWpyRZ8+1LNPiEExLIh4pmoL G9Fg== X-Gm-Message-State: APjAAAXFmbRlPLJPhN63xX7slC7VOqwrbt9CqTFW8RWD8WZOa6xtW+PG nFGHe/wBP1B4yyjdLsixf4u2I+0z3DE= X-Google-Smtp-Source: APXvYqy7hbfP1zi8q5boWgxY4MiapiMBa0dI6Mt7hWL+sIMg4PpcxOONPfi0FkSPrTNIrvmHp2+Gkg== X-Received: by 2002:a62:780c:: with SMTP id t12mr11065326pfc.211.1569437153746; Wed, 25 Sep 2019 11:45:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/16] cputlb: Disable __always_inline__ without optimization Date: Wed, 25 Sep 2019 11:45:34 -0700 Message-Id: <20190925184548.30673-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) This forced inlining can result in missing symbols, which makes a debugging build harder to follow. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Reported-by: Peter Maydell Signed-off-by: Richard Henderson --- include/qemu/compiler.h | 11 +++++++++++ accel/tcg/cputlb.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 09fc44cca4..20780e722d 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -170,6 +170,17 @@ # define QEMU_NONSTRING #endif =20 +/* + * Forced inlining may be desired to encourage constant propagation + * of function parameters. However, it can also make debugging harder, + * so disable it for a non-optimizing build. + */ +#if defined(__OPTIMIZE__) +#define QEMU_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define QEMU_ALWAYS_INLINE +#endif + /* Implement C11 _Generic via GCC builtins. Example: * * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index abae79650c..2222b87764 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1281,7 +1281,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr); =20 -static inline uint64_t __attribute__((always_inline)) +static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read, FullLoadHelper *full_load) @@ -1530,7 +1530,7 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *env= , target_ulong addr, * Store Helpers */ =20 -static inline void __attribute__((always_inline)) +static inline void QEMU_ALWAYS_INLINE store_helper(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op) { --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437355; cv=none; d=zoho.com; s=zohoarc; b=lk/qbBe+KItQ//5sRJuKT0c43HjHE/kmZ7fGCFesHDpU4MntO0QLPwPL3FPaYz2rnm6ZOI0oJhzUf2C7wWpNfIjf59kjwJxg+wMElso1CnBs0ZigGg6Iexb7WuAZdUBPP1d4LnSmg4AWkKfkkwTov0ACOn/XDPEzLBB1ZMYI1To= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437355; 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=Cgi8cwP/kPiakDiYJkRI89bBSyLkz6ovsWz2x/LD2wI=; b=Z/SB+Xrkt6PlQPLuhNIgeu0S9fQJNKuTuq+a9KMYYSeFnMM4sbeZ43cxaeyAvMqBsDDMSMO9bf6zYyWYEfSInCBkja62P8TYGFocKmvStqEMHfYXAolVcHQRdMY99J8xakI3/lWWkSX4X0CWa5SHmlGDunrYsYqcI1ShI2Nh0Q0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437355443195.03399424896793; Wed, 25 Sep 2019 11:49:15 -0700 (PDT) Received: from localhost ([::1]:56064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCLf-0003ix-1B for importer@patchew.org; Wed, 25 Sep 2019 14:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46972) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIX-0001fl-Ey for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIW-0004DL-HY for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:57 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:45504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIW-0004CN-Bu for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:56 -0400 Received: by mail-pf1-x42f.google.com with SMTP id y72so4134536pfb.12 for ; Wed, 25 Sep 2019 11:45:56 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cgi8cwP/kPiakDiYJkRI89bBSyLkz6ovsWz2x/LD2wI=; b=pEfhyXa3LMv/9lv5T4yuYVMwG0mRmtmPtjlMft6HTOfQ6SZaQQKmNcgDXBCGvpyRhY zR6DJxm27kK5KLsB5eEnkJD8js6yPO3Fc8W7PfqB/DGr6nTYf8L/w2kdrloIU8hhrLh9 9Kq8U1vjAUeIgmFWq979TJz3nnkjpxZ9o3fyw7n6Xv8dIJFFG1MGsHF+U4KVuQPWFPlZ kZ3hGKz4X9gR4Jf7fcwNcGXyahW1nLq92gpvRg7FSA91TN9RsBKJtci0/yT5SYqsTloL NYWuTEFNZ8AcgS3BxnnEf9GCdfevnrfGLiAyS3MYCUZ0Ng4WQyVFJDPglySWNL1CJaWb nPqw== 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=Cgi8cwP/kPiakDiYJkRI89bBSyLkz6ovsWz2x/LD2wI=; b=WLuR6pNu1LptV8y8PRxEMHcL+jPsymJ+sSSjhwHEWwDw36dxxauAgCfWHjpjcbpdKm SMLfdYpAV3lgtT6nSKoGZ7bjYKn9SJn4+xoKB93L4Z9ES3rqKQlqb/A48ctTWpdEuJa/ RA4r2XVci4djg3lQtQ7Oy8Uf6NRxPtvgQ3le5cqWr7vlgEtXqD3b2Ei5tl/JBzXGaiMH 1c3GheJGz218ipqBkS9gB38A5HTinx0WcS4NOilkeXHA9EFYkR2+fGZEU6UuqZI6p6Wk eXgV1xP12N08DLwEfXqeHm15FBAimqL1MR7udGCCb5STDYT0JOj5VCv+6gM1PKlm1C3d HvsQ== X-Gm-Message-State: APjAAAX6pCSZTV1zcgFy4m9n6ROcL1Oni4ry3cUEvLtoNDDOTiajq7xl VJhCNb1uUyt6gyk6L3j1RyZioJR2Feo= X-Google-Smtp-Source: APXvYqypjfOipsRqMnLGbbiW+vyiEml/uhtc4kcjhdirt98IFnuhhB3TvFgqkDABy8C72mDEDzv9Aw== X-Received: by 2002:a62:db84:: with SMTP id f126mr11647089pfg.25.1569437154916; Wed, 25 Sep 2019 11:45:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/16] qemu/compiler.h: Add qemu_build_not_reached Date: Wed, 25 Sep 2019 11:45:35 -0700 Message-Id: <20190925184548.30673-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::42f 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Use this as a compile-time assert that a particular code path is not reachable. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/qemu/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 20780e722d..7b93c73340 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -221,4 +221,19 @@ #define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, = __VA_ARGS__)) #define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x,= __VA_ARGS__)) =20 +/** + * qemu_build_not_reached() + * + * The compiler, during optimization, is expected to prove that a call + * to this function cannot be reached and remove it. If the compiler + * supports QEMU_ERROR, this will be reported at compile time; otherwise + * this will be reported at link time due to the missing symbol. + */ +#ifdef __OPTIMIZE__ +extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") + qemu_build_not_reached(void); +#else +#define qemu_build_not_reached() g_assert_not_reached() +#endif + #endif /* COMPILER_H */ --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437606; cv=none; d=zoho.com; s=zohoarc; b=ThrSvNwXSuQ9xGeiXBiYWGyzeyhopZBxnbmlbfGhjKqJexC1ZFUcQx08eSzcyo5rLxJa9UcLquxN0gktli5bTd9V6gJwyQKSn8wmjIfVPLfW7oSYscV7IpFKXp/kIr9X66wmLTjEfFQEwoFzO807ueO2t0d+BTkm726VFdiAle4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437606; 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=tEvO5tw4/suCh+mwvodKHXWtN16PlVfrxqaiSrTER6g=; b=CEKYZ5cRU5IfGWXeAlmuG5KLyczzATt1MNj55L7u/IitsAWnuOs96iZTTe8dq7jR1RqZ1yr/dehwT7EFJGmbDuu4JqWrYTT5pAfDVDgr9BdpUMRj0bLwfpHUS30wGyFg+0dtn3zjajFoa38UTpccpeW5PcnsDuyHSBbzlLUvPFM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437606430503.48437351932876; Wed, 25 Sep 2019 11:53:26 -0700 (PDT) Received: from localhost ([::1]:56114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCPl-0008QJ-7x for importer@patchew.org; Wed, 25 Sep 2019 14:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46987) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIZ-0001h1-2Y for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIY-0004EF-25 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:58 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:37023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIX-0004Dr-TD for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:58 -0400 Received: by mail-pf1-x443.google.com with SMTP id y5so4160998pfo.4 for ; Wed, 25 Sep 2019 11:45:57 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tEvO5tw4/suCh+mwvodKHXWtN16PlVfrxqaiSrTER6g=; b=bbVQHKnFvAbHmLIb7cT7R+nAFllNJtICyzl/XE6Kih9SFhg6LmnrXZHdgDpICNJbHI TloWJcSxR4kNLINaxiblKd1IWStyQ6vI8fJgLp+SFlLzfDaBFlxR7BQlboBeT3JN5dgw TEe/sBHh6MvVT3ckgmtz+x0vtw6KwOqI3RpIqEvt4ZFQdlKLgkmnfRrVAyX44wbVzxDE sLMHT83TWCCkQxDhWBwLFlNEBH/yT0R7BX/tN8NePh90B1SqVe3kF5RlMetgvsFYmA40 aYQomumq1WLkPSd7VOt+5zo1UAQ6DKePMRkVX7uJatJXdlge+elD78gKjdJnxn7LoQ3u GHpA== 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=tEvO5tw4/suCh+mwvodKHXWtN16PlVfrxqaiSrTER6g=; b=hLLT+9I+4TtVuqGsNnyayjPBHX8zh87nC1MA9P5D64OzgBpnllDrzCkykDchUKOE/O YS9puqkTSfjs/jzBGf9b9S6GT81uDEOU5gzhgjakvHXDLTia77dkJLtWDOc5Hg/uwFRe TPaDi6vNTe8czFjcwDz8hE3irXsvuJswtO3w07x1RpkHijJKug1pkNI6Oz2zNAHNlW+i Fwfo7OP0DlLCTd533pYWon3oYVngB99UoMHmT0COcSPa8lF3CqXW2vYMqJGPEZysi+8U Eg7Iha1MLFDAbeAH+AkhumLF87kgkxcm7wrhOAmO9jrORWTCODmgwmgTY3/lNE5BXoS8 Pj+Q== X-Gm-Message-State: APjAAAXy3ZXXVXWXmCAdvC/uV+iHTUDYRB9JaK22YdP+sKWl330N6ZVW 0iax10qlN/OQDfMBu6rwQWGghJbHU9w= X-Google-Smtp-Source: APXvYqxdmw+2pSxaCnR1PDrhfRmbPNDMuw7gl57iR5Zfc5i8EH9+51EcJ5jdl8pgm0ul59oz1joqRw== X-Received: by 2002:a62:7ece:: with SMTP id z197mr18817pfc.78.1569437156411; Wed, 25 Sep 2019 11:45:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/16] cputlb: Use qemu_build_not_reached in load/store_helpers Date: Wed, 25 Sep 2019 11:45:36 -0700 Message-Id: <20190925184548.30673-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Increase the current runtime assert to a compile-time assert. Reviewed-by: David Hildenbrand Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 2222b87764..e31378bce3 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1396,7 +1396,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, res =3D ldq_le_p(haddr); break; default: - g_assert_not_reached(); + qemu_build_not_reached(); } =20 return res; @@ -1680,8 +1680,7 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, stq_le_p(haddr, val); break; default: - g_assert_not_reached(); - break; + qemu_build_not_reached(); } } =20 --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437365; cv=none; d=zoho.com; s=zohoarc; b=iJ3b9zrrhwdDl0nYPCqCLx9IB/HE3fXSuE+ToPy2iRDkL51zrrsb3QAsSq22bIyMxqmP6+BUcCf3NNNAFSeui1Y0yoZ0hFMb7UX0wR+rfj4j5d+07zC7XJXe5VkskhBJlhorUvWrlkHhFMn8y5phon2FeLCpdX4mc6xapxvuijs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437365; 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=dpjQdA7JkkGx46Rli+yrKoXDpXOevLhotnlmbVLP3mg=; b=DUH30g6C4QS9TvtsRTvX9QoGKyWphsVbMdk0tsK44lofSxH2oRdby+zH6aUkjO+j2Ueh0RS2xzhnfJ10QUmI12Fx5WbOm52DrVbBggUma9HOhcLcWiNk2PshM1gqyjI5c6uo2tgfMD2zG4JcOhhP3fui0elaa9qZyBasmqjaivk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437365350583.1040221507575; Wed, 25 Sep 2019 11:49:25 -0700 (PDT) Received: from localhost ([::1]:56068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCLl-0003mc-2T for importer@patchew.org; Wed, 25 Sep 2019 14:49:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIa-0001j1-N9 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIZ-0004Ef-Go for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:00 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:43869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIZ-0004EV-BO for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:45:59 -0400 Received: by mail-pl1-x633.google.com with SMTP id f21so539425plj.10 for ; Wed, 25 Sep 2019 11:45:59 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dpjQdA7JkkGx46Rli+yrKoXDpXOevLhotnlmbVLP3mg=; b=Qjp0JUK4Dp2sjVrTeu15m/JGRzbnlZ6vOzaGsjOFpVbDafFjxvP/+VWwO4qCL6lMpN /f5LTA+VcRpqny0zfq4rV9x0+tOxnecAoVt3CtJjHnn5PAwCYHrn4jwLAmG3NRfgVXHY jr8ceFM59yM+QasTIOdgNkU2cquP2vwnnNIQSESr8l15nwn7T4xJ+IvxSMrnRJTUmYhE TQmr7aQXVHuKlYC2BWthrQkj1qgM2MFhxvMkxNsz5bNr8DWqmtQuGx3Xq4U+WPvPhHfy 1T/G1rDE15TR8RVnqRFc3Of4cEye/gVBUB7PHK0vz+IhMWk5IdKptEdlIQoq4WmxAMQZ 8HoA== 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=dpjQdA7JkkGx46Rli+yrKoXDpXOevLhotnlmbVLP3mg=; b=V7gkPVapJ/tft8/l0Za7tGo94bBmcrT4PWueDWmCnXkQkkZPux4hxQS5xBxIf0EAl9 jai16Iy8QwIwrSrrH9Qbs+f3AhLUDfLV3598jsdbLs6x1CZa/2Qr92TkOGtMQYR8bwNz t4MQsFUpp9YeZCOjqM8zphEF7NgkkQAoyaQfYI2RtRD2zrZM4qgb0kE5II1rJ54jHz1r qd1f8e00tClJ65jurES3i86LKLz83ByqXZ5hnbM7B2YaqK8k1pGvxmio1MBHK5LJqPNS zpbNoz+JiObC885eEneIKjX8eXn16XOUdM1FQ9MREWPzvsMIMzUoykQIn2S5heiDHAoc SpBw== X-Gm-Message-State: APjAAAWrrWfPFbyj38ZGIRf/YnrI+KcxWqmZOrjN/cKSqLJTltloHOGW YH/DXzvpDSldEjkTYYSXJHcISUhbzWY= X-Google-Smtp-Source: APXvYqwZ2XcvxeQ+ATkGKbsyArgQcecB9ChDUhN8ioViVvXEBYGV7iYDRzrkf/PnCwq8b1fqcQGtXg== X-Received: by 2002:a17:902:fe86:: with SMTP id x6mr10925297plm.28.1569437157768; Wed, 25 Sep 2019 11:45:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/16] cputlb: Split out load/store_memop Date: Wed, 25 Sep 2019 11:45:37 -0700 Message-Id: <20190925184548.30673-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::633 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We will shortly be using these more than once. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 107 +++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e31378bce3..eeba8c9847 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1281,6 +1281,29 @@ static void *atomic_mmu_lookup(CPUArchState *env, ta= rget_ulong addr, typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr); =20 +static inline uint64_t QEMU_ALWAYS_INLINE +load_memop(const void *haddr, MemOp op) +{ + switch (op) { + case MO_UB: + return ldub_p(haddr); + case MO_BEUW: + return lduw_be_p(haddr); + case MO_LEUW: + return lduw_le_p(haddr); + case MO_BEUL: + return (uint32_t)ldl_be_p(haddr); + case MO_LEUL: + return (uint32_t)ldl_le_p(haddr); + case MO_BEQ: + return ldq_be_p(haddr); + case MO_LEQ: + return ldq_le_p(haddr); + default: + qemu_build_not_reached(); + } +} + static inline uint64_t QEMU_ALWAYS_INLINE load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op, bool code_read, @@ -1373,33 +1396,7 @@ load_helper(CPUArchState *env, target_ulong addr, TC= GMemOpIdx oi, =20 do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); - switch (op) { - case MO_UB: - res =3D ldub_p(haddr); - break; - case MO_BEUW: - res =3D lduw_be_p(haddr); - break; - case MO_LEUW: - res =3D lduw_le_p(haddr); - break; - case MO_BEUL: - res =3D (uint32_t)ldl_be_p(haddr); - break; - case MO_LEUL: - res =3D (uint32_t)ldl_le_p(haddr); - break; - case MO_BEQ: - res =3D ldq_be_p(haddr); - break; - case MO_LEQ: - res =3D ldq_le_p(haddr); - break; - default: - qemu_build_not_reached(); - } - - return res; + return load_memop(haddr, op); } =20 /* @@ -1530,6 +1527,36 @@ tcg_target_ulong helper_be_ldsl_mmu(CPUArchState *en= v, target_ulong addr, * Store Helpers */ =20 +static inline void QEMU_ALWAYS_INLINE +store_memop(void *haddr, uint64_t val, MemOp op) +{ + switch (op) { + case MO_UB: + stb_p(haddr, val); + break; + case MO_BEUW: + stw_be_p(haddr, val); + break; + case MO_LEUW: + stw_le_p(haddr, val); + break; + case MO_BEUL: + stl_be_p(haddr, val); + break; + case MO_LEUL: + stl_le_p(haddr, val); + break; + case MO_BEQ: + stq_be_p(haddr, val); + break; + case MO_LEQ: + stq_le_p(haddr, val); + break; + default: + qemu_build_not_reached(); + } +} + static inline void QEMU_ALWAYS_INLINE store_helper(CPUArchState *env, target_ulong addr, uint64_t val, TCGMemOpIdx oi, uintptr_t retaddr, MemOp op) @@ -1657,31 +1684,7 @@ store_helper(CPUArchState *env, target_ulong addr, u= int64_t val, =20 do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); - switch (op) { - case MO_UB: - stb_p(haddr, val); - break; - case MO_BEUW: - stw_be_p(haddr, val); - break; - case MO_LEUW: - stw_le_p(haddr, val); - break; - case MO_BEUL: - stl_be_p(haddr, val); - break; - case MO_LEUL: - stl_le_p(haddr, val); - break; - case MO_BEQ: - stq_be_p(haddr, val); - break; - case MO_LEQ: - stq_le_p(haddr, val); - break; - default: - qemu_build_not_reached(); - } + store_memop(haddr, val, op); } =20 void helper_ret_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437864; cv=none; d=zoho.com; s=zohoarc; b=RgGJi7CVUyywc5ZrI/zBB7k5hBuh3e1VN+ikkd31rYNQuWQE3D/NpoAM7D4nI9wQPHX77CajEriAAAHttbogyAk/NtpK7DItPCphj4qYjbOrYkQoZKI/CcGwLi3IdfhLVFJZ62RHUHYdGWDQrZyLWQULtlW+Op6THF1+NrN7wpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437864; 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=VU8gXJ0ha+BxU/auLcZl3iqhGwLSOAQ2I5JEO3/h8Yw=; b=Z96AFdSg5Z6SqRu89QezQppja0xzFo+h+lPASL/IYaTRYBUH6xTbkyBMSvp46cpBqt3C0+La5t69D2SRt/D7RaAB/ks3tKSB2/sAEjqJ/YL8ytnfaFyfuJRMQT1K2UugdN6ii1sNlwc4Q/RxVyuGQDBwY7YL7yfVBnG9F0WUnUA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437864405410.3418208760329; Wed, 25 Sep 2019 11:57:44 -0700 (PDT) Received: from localhost ([::1]:56170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCTq-0003Zo-LN for importer@patchew.org; Wed, 25 Sep 2019 14:57:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47016) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIc-0001ku-IO for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIb-0004FO-13 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:02 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:33419) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIa-0004F1-P7 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:00 -0400 Received: by mail-pl1-x636.google.com with SMTP id d22so2945375pls.0 for ; Wed, 25 Sep 2019 11:46:00 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VU8gXJ0ha+BxU/auLcZl3iqhGwLSOAQ2I5JEO3/h8Yw=; b=yj84Hus4B03MBtSSLlSTLIPbiF7Wmw/YsBAFyO/HFgEdtQYr1YrIeSuJ45AXvu4oZq aEv7huRujb/U3ogGaliSZiU4X3Vh998j7z8VubAfWL+JU7I4SKUgzaqvnyLwNdbwhDWk GqGvnOgWQs20v9VgndldTWVJ4O58kQDrzOsV+z9u8qHpU7C/wn/C+WB3yEWxxYX/Howe bU3IAklyjegUqf7uFylZgAH0fheWQeHaBOTo7+5D30jT0jiAyOYaUqVe+/L2KD8plEdD gRTDdZ2/m1p4eGaB6l+FFwfPEMmpsiMnqJmdBO6YBk0yKQijgo5FNKdKBMr8eCexn8Pf kB5Q== 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=VU8gXJ0ha+BxU/auLcZl3iqhGwLSOAQ2I5JEO3/h8Yw=; b=JFJqbMpp/hRYXE0yyJPt9jWwHEXoS9J7LXCHbP0WRXkj/dyItmsZpGcTsuBMQtTqP8 lvRB+wK8Fe6pKtgp3u7wXOvafgqSA/QkFFICXAJgJQqY/1CiJGyMEJQXQyMEsPjq1Ole aYYGF1bhSUsZCUzfUuzgDoFF2Rr8Zxijr+MiW3M3k7/rTaz+06QMVd6kNYDcFUFSdmmA el0qt0c5H8v6JcV0CBvPyDUZIOhXywXaaXCrnFbX02B3WaN3+kL0RXdlv+sb4NQudt85 R234boosdgLqUFEEJe/svCTc5yG9DwSTgBA4j0Xe3g3aNp+CK+AnvYqCWx6sgF5csRah dcXQ== X-Gm-Message-State: APjAAAUYVpTGhPCeGM8A7dMcR9FCk+W7yjsd9CEdLV0RHB3mZryKA4DM 0a8sAFzy5K9Xfk1tcnkseuUTZgzqSrA= X-Google-Smtp-Source: APXvYqxLAK8/dQM5rZtKi/XzBtf9o3NHYrfASu31YsXs4HtRQuSQuTdXGRV84wm2DqvDg9dAgxV8+w== X-Received: by 2002:a17:902:9a05:: with SMTP id v5mr10778603plp.237.1569437159291; Wed, 25 Sep 2019 11:45:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/16] cputlb: Introduce TLB_BSWAP Date: Wed, 25 Sep 2019 11:45:38 -0700 Message-Id: <20190925184548.30673-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::636 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Handle bswap on ram directly in load/store_helper. This fixes a bug with the previous implementation in that one cannot use the I/O path for RAM. Fixes: a26fc6f5152b47f1 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 4 ++- accel/tcg/cputlb.c | 72 +++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index e0c8dc540c..d148bded35 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -335,12 +335,14 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) /* Set if TLB entry contains a watchpoint. */ #define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) +/* Set if TLB entry requires byte swap. */ +#define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSW= AP) =20 /** * tlb_hit_page: return true if page aligned @addr is a hit against the diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index eeba8c9847..028eebcb44 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -737,8 +737,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, address |=3D TLB_INVALID_MASK; } if (attrs.byte_swap) { - /* Force the access through the I/O slow path. */ - address |=3D TLB_MMIO; + address |=3D TLB_BSWAP; } if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) { @@ -901,10 +900,6 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEn= try *iotlbentry, bool locked =3D false; MemTxResult r; =20 - if (iotlbentry->attrs.byte_swap) { - op ^=3D MO_BSWAP; - } - section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -947,10 +942,6 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry= *iotlbentry, bool locked =3D false; MemTxResult r; =20 - if (iotlbentry->attrs.byte_swap) { - op ^=3D MO_BSWAP; - } - section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -1133,8 +1124,8 @@ void *probe_access(CPUArchState *env, target_ulong ad= dr, int size, wp_access, retaddr); } =20 - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO)) { - /* I/O access */ + /* Reject I/O access, or other required slow-path. */ + if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP)) { return NULL; } =20 @@ -1344,6 +1335,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, /* Handle anything that isn't just a straight memory access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { CPUIOTLBEntry *iotlbentry; + bool need_swap; =20 /* For anything that is unaligned, recurse through full_load. */ if ((addr & (size - 1)) !=3D 0) { @@ -1357,17 +1349,27 @@ load_helper(CPUArchState *env, target_ulong addr, T= CGMemOpIdx oi, /* On watchpoint hit, this will longjmp out. */ cpu_check_watchpoint(env_cpu(env), addr, size, iotlbentry->attrs, BP_MEM_READ, retaddr); - - /* The backing page may or may not require I/O. */ - tlb_addr &=3D ~TLB_WATCHPOINT; - if ((tlb_addr & ~TARGET_PAGE_MASK) =3D=3D 0) { - goto do_aligned_access; - } } =20 + need_swap =3D size > 1 && (tlb_addr & TLB_BSWAP); + /* Handle I/O access. */ - return io_readx(env, iotlbentry, mmu_idx, addr, - retaddr, access_type, op); + if (likely(tlb_addr & TLB_MMIO)) { + return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, + access_type, op ^ (need_swap * MO_BSWAP)); + } + + haddr =3D (void *)((uintptr_t)addr + entry->addend); + + /* + * Keep these two load_memop separate to ensure that the compiler + * is able to fold the entire function to a single instruction. + * There is a build-time assert inside to remind you of this. ;-) + */ + if (unlikely(need_swap)) { + return load_memop(haddr, op ^ MO_BSWAP); + } + return load_memop(haddr, op); } =20 /* Handle slow unaligned access (it spans two pages or IO). */ @@ -1394,7 +1396,6 @@ load_helper(CPUArchState *env, target_ulong addr, TCG= MemOpIdx oi, return res & MAKE_64BIT_MASK(0, size * 8); } =20 - do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); return load_memop(haddr, op); } @@ -1591,6 +1592,7 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, /* Handle anything that isn't just a straight memory access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { CPUIOTLBEntry *iotlbentry; + bool need_swap; =20 /* For anything that is unaligned, recurse through byte stores. */ if ((addr & (size - 1)) !=3D 0) { @@ -1604,16 +1606,29 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, /* On watchpoint hit, this will longjmp out. */ cpu_check_watchpoint(env_cpu(env), addr, size, iotlbentry->attrs, BP_MEM_WRITE, retaddr); - - /* The backing page may or may not require I/O. */ - tlb_addr &=3D ~TLB_WATCHPOINT; - if ((tlb_addr & ~TARGET_PAGE_MASK) =3D=3D 0) { - goto do_aligned_access; - } } =20 + need_swap =3D size > 1 && (tlb_addr & TLB_BSWAP); + /* Handle I/O access. */ - io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, op); + if (likely(tlb_addr & (TLB_MMIO | TLB_NOTDIRTY))) { + io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, + op ^ (need_swap * MO_BSWAP)); + return; + } + + haddr =3D (void *)((uintptr_t)addr + entry->addend); + + /* + * Keep these two store_memop separate to ensure that the compiler + * is able to fold the entire function to a single instruction. + * There is a build-time assert inside to remind you of this. ;-) + */ + if (unlikely(need_swap)) { + store_memop(haddr, val, op ^ MO_BSWAP); + } else { + store_memop(haddr, val, op); + } return; } =20 @@ -1682,7 +1697,6 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, return; } =20 - do_aligned_access: haddr =3D (void *)((uintptr_t)addr + entry->addend); store_memop(haddr, val, op); } --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437602; cv=none; d=zoho.com; s=zohoarc; b=bU3qkNAL0d2O6x9ONZJcc49eydmhf8/YHd10IX81cTozhP4LmlYAgpRV4Yk0aq8TCLMSI1ZyUy5SxGvMHgGQbX6qpsEuVUR+0XdSgHAE5Z2+2Fg7TOkrtm4TznG14EGltDmv1fLKBq9mreViU2+VvKKCAvgUmwRMCUoKTjFvvrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437602; 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=RKAV78KOhwa7cM2YUh+Cq3BXcX5AFdgHACRoOW8XrYE=; b=T3SSdOD5QwgXHC4BnyQfEd2rufvgKItDiPKMOkzzgx9ChItlCVhdSUMggEPmhbtG12Ae9bw5u44DQNYG8NC/tnYeWz4RRqgsoR4LV6qxUR43HmB9geacBLGaY9GoSWFUVUrjqu1EsEUU/uzcNQH5j26JBn98zbzUrEbsedh6URI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437602349651.0219591344006; Wed, 25 Sep 2019 11:53:22 -0700 (PDT) Received: from localhost ([::1]:56110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCPg-0008NV-P5 for importer@patchew.org; Wed, 25 Sep 2019 14:53:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47047) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIe-0001mU-2u for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIc-0004Fu-GV for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:03 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIc-0004Fd-Aw for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:02 -0400 Received: by mail-pl1-x642.google.com with SMTP id u12so2904050pls.12 for ; Wed, 25 Sep 2019 11:46:02 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RKAV78KOhwa7cM2YUh+Cq3BXcX5AFdgHACRoOW8XrYE=; b=tPHRRPv3eAAti8D+Jn2FdazqpxaQ60EJLHJIBqVHuuCicY6JEsHrZKMLxfgQcG7toa lybbdUVwxXwAYsMc7yj9r4rIad9hOiyd9M0oR9yi0feXsNUKy+6s68yweLsAKfhTa0Hg 4UYivvZzHoyKOw1UDCg6FwwGKkCqBGhFUUD4K0fwRh7ir1p4MOa2HM38dYYpwCQVzFeL JTz1CjHGEspuaVNgJvr7SzrKPKjyCUa+BOjF7UjzKO4MH/XMvVlYUgp8qoYKqAZp2PEJ GeHVnlHMEdTWvPdoSvzICE6mT3cwdXgXRcRrZsq+Fuls6I3pQO0jFc/0bTa/4wd/c1Jc 2Kzg== 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=RKAV78KOhwa7cM2YUh+Cq3BXcX5AFdgHACRoOW8XrYE=; b=lufWKTyGJqjWa+0dEeq8/bFfbxZxdCylI/tt/H1B780348rkI/zxrZefZiaJvWpEsv 1NiUb2wORFHWhMS0zmOil4yKRGwbhOB8A9kUEPJgZ22fH71x52iaacXSt+82ESe+aSSi PeyC1Q+KbqM5nq4q3XAWfyx236EBU34+1/gbnZRn4RSDem5FB1LpHLTK60O0WZvJ2DQP HDrgdjOubhQafrlK0pJI8wQz/ixqToU11UVds4pGBPRphVivSSslpsk6JMz+340lsRs5 GzOwrUhAkbQyk9cuPBThCOSUi/Ci6UlSpMM9bziqXZF4cdPwgx+nnZAuwBpau8yLpOyo s8ZQ== X-Gm-Message-State: APjAAAVIGuH5ZKWEzi0qn8KBhNJx+mtEJ6sVeSBQA40sZ8eNWsw5FQ0K HmouFH2fU7l4ay5oq6RPiOrJrmbb3Dk= X-Google-Smtp-Source: APXvYqydEtKyBo7XaPlCv3AfdmbbEPT7PuIm0h7KnqvVlqL/7TKN2MPQXDxoyDA8IYPE0EFVOI5ouA== X-Received: by 2002:a17:902:850b:: with SMTP id bj11mr10890877plb.39.1569437160735; Wed, 25 Sep 2019 11:46:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/16] exec: Adjust notdirty tracing Date: Wed, 25 Sep 2019 11:45:39 -0700 Message-Id: <20190925184548.30673-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::642 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The memory_region_tb_read tracepoint is unreachable, since notdirty is supposed to apply only to writes. The memory_region_tb_write tracepoint is mis-named, because notdirty is not only used for TB invalidation. It is also used for e.g. VGA RAM updates and migration. Replace memory_region_tb_write with memory_notdirty_write_access, and place it in memory_notdirty_write_prepare where it can catch all of the instances. Add memory_notdirty_set_dirty to log when we no longer intercept writes to a page. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- exec.c | 3 +++ memory.c | 4 ---- trace-events | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 8b998974f8..5f2587b621 100644 --- a/exec.c +++ b/exec.c @@ -2755,6 +2755,8 @@ void memory_notdirty_write_prepare(NotDirtyInfo *ndi, ndi->size =3D size; ndi->pages =3D NULL; =20 + trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); + assert(tcg_enabled()); if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { ndi->pages =3D page_collection_lock(ram_addr, ram_addr + size); @@ -2779,6 +2781,7 @@ void memory_notdirty_write_complete(NotDirtyInfo *ndi) /* we remove the notdirty callback only if the code has been flushed */ if (!cpu_physical_memory_is_clean(ndi->ram_addr)) { + trace_memory_notdirty_set_dirty(ndi->mem_vaddr); tlb_set_dirty(ndi->cpu, ndi->mem_vaddr); } } diff --git a/memory.c b/memory.c index b9dd6b94ca..57c44c97db 100644 --- a/memory.c +++ b/memory.c @@ -438,7 +438,6 @@ static MemTxResult memory_region_read_accessor(MemoryR= egion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_read(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -465,7 +464,6 @@ static MemTxResult memory_region_read_with_attrs_access= or(MemoryRegion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_read(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -490,7 +488,6 @@ static MemTxResult memory_region_write_accessor(MemoryR= egion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_write(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); @@ -515,7 +512,6 @@ static MemTxResult memory_region_write_with_attrs_acces= sor(MemoryRegion *mr, /* Accesses to code which has previously been translated into a TB= show * up in the MMIO path, as accesses to the io_mem_notdirty * MemoryRegion. */ - trace_memory_region_tb_write(get_cpu_index(), addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); diff --git a/trace-events b/trace-events index 823a4ae64e..20821ba545 100644 --- a/trace-events +++ b/trace-events @@ -52,14 +52,14 @@ dma_map_wait(void *dbs) "dbs=3D%p" find_ram_offset(uint64_t size, uint64_t offset) "size: 0x%" PRIx64 " @ 0x%= " PRIx64 find_ram_offset_loop(uint64_t size, uint64_t candidate, uint64_t offset, u= int64_t next, uint64_t mingap) "trying size: 0x%" PRIx64 " @ 0x%" PRIx64 ",= offset: 0x%" PRIx64" next: 0x%" PRIx64 " mingap: 0x%" PRIx64 ram_block_discard_range(const char *rbname, void *hva, size_t length, bool= need_madvise, bool need_fallocate, int ret) "%s@%p + 0x%zx: madvise: %d fa= llocate: %d ret: %d" +memory_notdirty_write_access(uint64_t vaddr, uint64_t ram_addr, unsigned s= ize) "0x%" PRIx64 " ram_addr 0x%" PRIx64 " size %u" +memory_notdirty_set_dirty(uint64_t vaddr) "0x%" PRIx64 =20 # memory.c memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t va= lue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %= u" memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t v= alue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size = %u" memory_region_subpage_read(int cpu_index, void *mr, uint64_t offset, uint6= 4_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx64= " size %u" memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint= 64_t value, unsigned size) "cpu %d mr %p offset 0x%"PRIx64" value 0x%"PRIx6= 4" size %u" -memory_region_tb_read(int cpu_index, uint64_t addr, uint64_t value, unsign= ed size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" -memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsig= ned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint= 64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64"= size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uin= t64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64= " size %u" flatview_new(void *view, void *root) "%p (root %p)" --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437608; cv=none; d=zoho.com; s=zohoarc; b=GblCINz91b/eAjZISkSJZ5jDDE2ZEjrSYp4locv9sOYy8yU8a28bcnsVY3DpPXNqDv+xyoVXGFmTsig4RD6W45oAsMmpi+bAHcGnvxcorPlfd78yXpDOMtkxtgR/cM3OVtA8JKJEuuA6dg8GYUvmGB++EHB4AM4OYspB5E1q79s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437608; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+mSQUtExxffwFsuh/c6IBrL9OKLsUbH86Mr3RPL+odM=; b=TXBozD7uiM8YQIBzd+w7q2ip7BTHnI0D8fqtcV7QRqR/cmBaq8FT71j6YVJQZm6nN67xLPA+j0bhDalnkqkuBdTbN5IJF9c7Wbuajw6CbadIHJ+6ReSxg+JIAWJRNn+EyB89OZLgJMWgHswCwl9YkWfLxZHi0Wai8WpYP0yfsuw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437608300963.1689657092311; Wed, 25 Sep 2019 11:53:28 -0700 (PDT) Received: from localhost ([::1]:56118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCPm-0008Sz-RX for importer@patchew.org; Wed, 25 Sep 2019 14:53:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47084) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIf-0001oO-Oc for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCId-0004He-Vd for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:05 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:33890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCId-0004Gd-Na for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:03 -0400 Received: by mail-pl1-x644.google.com with SMTP id k7so2337321pll.1 for ; Wed, 25 Sep 2019 11:46:03 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+mSQUtExxffwFsuh/c6IBrL9OKLsUbH86Mr3RPL+odM=; b=Lyo7E/xo4ojw1cWW9330esFALB35CrtNQq/UIGkmVZuwWy5wR1ww4D5pKPcWiHq4A1 kb7UTIGF6Zr8ZyXFKR0ILXpCAKFBiflzLF2B3omXtWT2wD3q7mJsRcKbZG40i0GDNahN iVZ62aiOcckyA4e8EXg9C5GN/2yvFul8FXY8hS64giuQssbWycKhpTErXDF3nvM3NAaa feOzohU86ckJbrXCpO0XJfSb+/NoRJBrxqCbwgKjVwA8nyd1Jbf5+ajiLLsaU0JSobqk nmYaNLyaSpzn79kW/U59aWr8eUuZF8W5PbtuemIpXMcC2bIofhDnwgXdgxCuw4j+xeP0 gN9A== 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; bh=+mSQUtExxffwFsuh/c6IBrL9OKLsUbH86Mr3RPL+odM=; b=aeiqbJR3QQGmXpCWeOCOGdrNzjt1LZ7vk6ivVFpY8LB8wkUT5huLz0N8VWx9np5Ywk ZIYJeYnUOhWXZwTPEQM6FSnBZUz6DhwMdya4Pybb46tAh0cAKbg/PTKYFQta2d58/zor MKtTJrdg6xxgG4aOv0mA+MmRxqLjMG9D6iZle/M0eUD+xnCa9GezBhkhMqZhf8D3hQ+A BmRFMZoQlm9G35i9FVVFPzUE3yHCxHtXCxQ96Z1D5BaAZgAJXnxS9f+2zZkuZyn4s2GE A5YYkA7QSMPVFpJdrWFbv+7GeY6t6gkFxYigcCDOoN7XzHhibihrwl6m4E6OshqwPiAy YbAA== X-Gm-Message-State: APjAAAU0fYdPAs3s1divx5kyEp1tIb+RWmp9c66DhwsSG66sKXBBmFPu SxaQpn/w5Fwpe3ofl6Z1h6tsKmGat4o= X-Google-Smtp-Source: APXvYqx5gK1ZWZ5UTeBwbS/IxEyO1J80FX4yoBtjBPGpvphLQMa6Sqx6/sV9x1ERHVXySnhDf7vKJw== X-Received: by 2002:a17:902:7595:: with SMTP id j21mr10377950pll.162.1569437162197; Wed, 25 Sep 2019 11:46:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/16] cputlb: Move ROM handling from I/O path to TLB path Date: Wed, 25 Sep 2019 11:45:40 -0700 Message-Id: <20190925184548.30673-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It does not require going through the whole I/O path in order to discard a write. Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 5 ++++- include/exec/cpu-common.h | 1 - accel/tcg/cputlb.c | 36 ++++++++++++++++++++-------------- exec.c | 41 +-------------------------------------- 4 files changed, 26 insertions(+), 57 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d148bded35..ad9ab85eb3 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -337,12 +337,15 @@ CPUArchState *cpu_copy(CPUArchState *env); #define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) /* Set if TLB entry requires byte swap. */ #define TLB_BSWAP (1 << (TARGET_PAGE_BITS_MIN - 5)) +/* Set if TLB entry writes ignored. */ +#define TLB_DISCARD_WRITE (1 << (TARGET_PAGE_BITS_MIN - 6)) =20 /* Use this mask to check interception with an alignment mask * in a TCG backend. */ #define TLB_FLAGS_MASK \ - (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO | TLB_WATCHPOINT | TLB_BSW= AP) + (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ + | TLB_WATCHPOINT | TLB_BSWAP | TLB_DISCARD_WRITE) =20 /** * tlb_hit_page: return true if page aligned @addr is a hit against the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f7dbe75fbc..1c0e03ddc2 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -100,7 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void); =20 void cpu_flush_icache_range(hwaddr start, hwaddr len); =20 -extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_notdirty; =20 typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 028eebcb44..404ec57a4e 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -577,7 +577,8 @@ static void tlb_reset_dirty_range_locked(CPUTLBEntry *t= lb_entry, { uintptr_t addr =3D tlb_entry->addr_write; =20 - if ((addr & (TLB_INVALID_MASK | TLB_MMIO | TLB_NOTDIRTY)) =3D=3D 0) { + if ((addr & (TLB_INVALID_MASK | TLB_MMIO | + TLB_DISCARD_WRITE | TLB_NOTDIRTY)) =3D=3D 0) { addr &=3D TARGET_PAGE_MASK; addr +=3D tlb_entry->addend; if ((addr - start) < length) { @@ -745,7 +746,6 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, address |=3D TLB_MMIO; addend =3D 0; } else { - /* TLB_MMIO for rom/romd handled below */ addend =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + xla= t; } =20 @@ -822,16 +822,17 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, =20 tn.addr_write =3D -1; if (prot & PAGE_WRITE) { - if ((memory_region_is_ram(section->mr) && section->readonly) - || memory_region_is_romd(section->mr)) { - /* Write access calls the I/O callback. */ - tn.addr_write =3D address | TLB_MMIO; - } else if (memory_region_is_ram(section->mr) - && cpu_physical_memory_is_clean( - memory_region_get_ram_addr(section->mr) + xlat)) { - tn.addr_write =3D address | TLB_NOTDIRTY; - } else { - tn.addr_write =3D address; + tn.addr_write =3D address; + if (memory_region_is_romd(section->mr)) { + /* Use the MMIO path so that the device can switch states. */ + tn.addr_write |=3D TLB_MMIO; + } else if (memory_region_is_ram(section->mr)) { + if (section->readonly) { + tn.addr_write |=3D TLB_DISCARD_WRITE; + } else if (cpu_physical_memory_is_clean( + memory_region_get_ram_addr(section->mr) + xlat)) { + tn.addr_write |=3D TLB_NOTDIRTY; + } } if (prot & PAGE_WRITE_INV) { tn.addr_write |=3D TLB_INVALID_MASK; @@ -904,7 +905,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc =3D retaddr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu->can_do_io= ) { + if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } =20 @@ -945,7 +946,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu->can_do_io= ) { + if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } cpu->mem_io_vaddr =3D addr; @@ -1125,7 +1126,7 @@ void *probe_access(CPUArchState *env, target_ulong ad= dr, int size, } =20 /* Reject I/O access, or other required slow-path. */ - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP)) { + if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP | TLB_DISCARD_WRIT= E)) { return NULL; } =20 @@ -1617,6 +1618,11 @@ store_helper(CPUArchState *env, target_ulong addr, u= int64_t val, return; } =20 + /* Ignore writes to ROM. */ + if (unlikely(tlb_addr & TLB_DISCARD_WRITE)) { + return; + } + haddr =3D (void *)((uintptr_t)addr + entry->addend); =20 /* diff --git a/exec.c b/exec.c index 5f2587b621..ea8c0b18ac 100644 --- a/exec.c +++ b/exec.c @@ -88,7 +88,7 @@ static MemoryRegion *system_io; AddressSpace address_space_io; AddressSpace address_space_memory; =20 -MemoryRegion io_mem_rom, io_mem_notdirty; +MemoryRegion io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif =20 @@ -192,7 +192,6 @@ typedef struct subpage_t { =20 #define PHYS_SECTION_UNASSIGNED 0 #define PHYS_SECTION_NOTDIRTY 1 -#define PHYS_SECTION_ROM 2 =20 static void io_mem_init(void); static void memory_map_init(void); @@ -1475,8 +1474,6 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; if (!section->readonly) { iotlb |=3D PHYS_SECTION_NOTDIRTY; - } else { - iotlb |=3D PHYS_SECTION_ROM; } } else { AddressSpaceDispatch *d; @@ -3002,38 +2999,6 @@ static uint16_t dummy_section(PhysPageMap *map, Flat= View *fv, MemoryRegion *mr) return phys_section_add(map, §ion); } =20 -static void readonly_mem_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ - /* Ignore any write to ROM. */ -} - -static bool readonly_mem_accepts(void *opaque, hwaddr addr, - unsigned size, bool is_write, - MemTxAttrs attrs) -{ - return is_write; -} - -/* This will only be used for writes, because reads are special cased - * to directly access the underlying host ram. - */ -static const MemoryRegionOps readonly_mem_ops =3D { - .write =3D readonly_mem_write, - .valid.accepts =3D readonly_mem_accepts, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, -}; - MemoryRegionSection *iotlb_to_section(CPUState *cpu, hwaddr index, MemTxAttrs attrs) { @@ -3047,8 +3012,6 @@ MemoryRegionSection *iotlb_to_section(CPUState *cpu, =20 static void io_mem_init(void) { - memory_region_init_io(&io_mem_rom, NULL, &readonly_mem_ops, - NULL, NULL, UINT64_MAX); memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, N= ULL, NULL, UINT64_MAX); =20 @@ -3069,8 +3032,6 @@ AddressSpaceDispatch *address_space_dispatch_new(Flat= View *fv) assert(n =3D=3D PHYS_SECTION_UNASSIGNED); n =3D dummy_section(&d->map, fv, &io_mem_notdirty); assert(n =3D=3D PHYS_SECTION_NOTDIRTY); - n =3D dummy_section(&d->map, fv, &io_mem_rom); - assert(n =3D=3D PHYS_SECTION_ROM); =20 d->phys_map =3D (PhysPageEntry) { .ptr =3D PHYS_MAP_NODE_NIL, .skip = =3D 1 }; =20 --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438032; cv=none; d=zoho.com; s=zohoarc; b=e2eJnpFR7O/OKsXqZoqU4873Th5mrJxmnl2C411pUhSFB8zBeMzWJ+9zuFg6HDquWMNGFDaiZkIDaPQLNXAJe+OEow6LBvyLBl26aaq02n4D8D8aSnVRKgwbSSAkZ8hsm/6z+QwFbKKyX2pHVTdFQuCqNw/FpuPC1SaAlmRuIGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438032; 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=lX5+tQiTw7pbywR4o4yaxcCikFvv/gVg8TPYVx+VaVQ=; b=chth000pflHH/DW1Xe7rovpCyT5ao8ldQyu8+PZL8xu6QiVVyuBFQNFxIEc6dKtHpvjNnlcOZhAmur8mXyilD5DhOEnFGzzJBQWzH2Q7ZZPT1WgIi38/dtB1T+AkfVxTax9qG79o2xw6+w2as+1JeVVo6P9lQSab08tnGSoqiME= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438032253653.5615932521403; Wed, 25 Sep 2019 12:00:32 -0700 (PDT) Received: from localhost ([::1]:56220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCWZ-0007kc-Dq for importer@patchew.org; Wed, 25 Sep 2019 15:00:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47122) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIh-0001qM-E7 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIf-0004JT-GD for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:07 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIf-0004IR-7j for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:05 -0400 Received: by mail-pl1-x643.google.com with SMTP id u20so2927089plq.4 for ; Wed, 25 Sep 2019 11:46:05 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lX5+tQiTw7pbywR4o4yaxcCikFvv/gVg8TPYVx+VaVQ=; b=jtGcg8nw5dEC11J861lR2ghlPLoj+YU76dkTCAPsVXMqqsGU0EA6BMzVnTCCYIEb2f LXy4JOnJZYnT53MQgMyZrRJegokCmHWOKvFVTHSv2vFcUjV3xpr5vh3CQudBuhasSGLt wCQb/6fnFoR2N+b5nDuFOETb593/fCaEg+bcmUaGVXR1bPKRBJJzHXu/4REwtIqW9g8s +OHijnEYUv32L7mtOy8KVFoQ42XD2D112kUxYSPuiaYutvNZ67CoSxF2/8mJfl1ZnBd4 d/QFegVHHU2IQtoPLEpoONTXaxRgm7JUaZFnN3T0uzBGuSrwtJj1ckS3Mtmzvl2ahhR2 SSDw== 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=lX5+tQiTw7pbywR4o4yaxcCikFvv/gVg8TPYVx+VaVQ=; b=W4MsWK3ZxwWIJ2Hp4Na03rnQAuJsNsX2ShRg/4ZZS/W+/tyOjsrLU4mcvB5SDd1M9M 9z+zRpY7cacZlwr5txF1Pd7MNVk3KPb4NE8viqAVLVC7I6q7wai9uRfxZ32u/oq5zZHs akGvOzytRqGIc13tJ6s0AtIutsKSmscTR7kA6fo7qLtEJ/v2DPDvw1KKX47Xt5bQxGPP u3GfLqLdMrR/jEQFqm/E+1zesvvfsdBTV7oT8lnEqdB57cbyvPJvV08exTXdZC8KosW2 X5OHl3VDvv7pluFHhsBXLNfZYX2ipuTR4KAi/xj8UdyoSQ1X+eQEoeePVrGdbkVeKMfW 9jKg== X-Gm-Message-State: APjAAAWOLbNlv32QKOj6q+571GDm5HU6MbgVtPoEjbGfxMU4suMf74bX toeLIA+gRsgRdiXTT3E3/nZDHSDdMiQ= X-Google-Smtp-Source: APXvYqykX8uBSsO4V6De5CFw8nBxNFQgxUBVynEz1AVJtkioiZdPPs2l7h5G58JIHSfZRVu/y34O4g== X-Received: by 2002:a17:902:a418:: with SMTP id p24mr10551070plq.312.1569437163709; Wed, 25 Sep 2019 11:46:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/16] cputlb: Move NOTDIRTY handling from I/O path to TLB path Date: Wed, 25 Sep 2019 11:45:41 -0700 Message-Id: <20190925184548.30673-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::643 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Pages that we want to track for NOTDIRTY are RAM. We do not really need to go through the I/O path to handle them. Acked-by: David Hildenbrand Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/exec/cpu-common.h | 2 -- accel/tcg/cputlb.c | 26 +++++++++++++++++--- exec.c | 50 --------------------------------------- memory.c | 16 ------------- 4 files changed, 23 insertions(+), 71 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 1c0e03ddc2..81753bbb34 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -100,8 +100,6 @@ void qemu_flush_coalesced_mmio_buffer(void); =20 void cpu_flush_icache_range(hwaddr start, hwaddr len); =20 -extern struct MemoryRegion io_mem_notdirty; - typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque); =20 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 404ec57a4e..7e9a0f7ac8 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -905,7 +905,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc =3D retaddr; - if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { + if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } =20 @@ -946,7 +946,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, section =3D iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr =3D section->mr; mr_offset =3D (iotlbentry->addr & TARGET_PAGE_MASK) + addr; - if (mr !=3D &io_mem_notdirty && !cpu->can_do_io) { + if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } cpu->mem_io_vaddr =3D addr; @@ -1612,7 +1612,7 @@ store_helper(CPUArchState *env, target_ulong addr, ui= nt64_t val, need_swap =3D size > 1 && (tlb_addr & TLB_BSWAP); =20 /* Handle I/O access. */ - if (likely(tlb_addr & (TLB_MMIO | TLB_NOTDIRTY))) { + if (tlb_addr & TLB_MMIO) { io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, op ^ (need_swap * MO_BSWAP)); return; @@ -1625,6 +1625,26 @@ store_helper(CPUArchState *env, target_ulong addr, u= int64_t val, =20 haddr =3D (void *)((uintptr_t)addr + entry->addend); =20 + /* Handle clean RAM pages. */ + if (tlb_addr & TLB_NOTDIRTY) { + NotDirtyInfo ndi; + + /* We require mem_io_pc in tb_invalidate_phys_page_range. */ + env_cpu(env)->mem_io_pc =3D retaddr; + + memory_notdirty_write_prepare(&ndi, env_cpu(env), addr, + addr + iotlbentry->addr, size); + + if (unlikely(need_swap)) { + store_memop(haddr, val, op ^ MO_BSWAP); + } else { + store_memop(haddr, val, op); + } + + memory_notdirty_write_complete(&ndi); + return; + } + /* * Keep these two store_memop separate to ensure that the compiler * is able to fold the entire function to a single instruction. diff --git a/exec.c b/exec.c index ea8c0b18ac..dc7001f115 100644 --- a/exec.c +++ b/exec.c @@ -88,7 +88,6 @@ static MemoryRegion *system_io; AddressSpace address_space_io; AddressSpace address_space_memory; =20 -MemoryRegion io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif =20 @@ -191,7 +190,6 @@ typedef struct subpage_t { } subpage_t; =20 #define PHYS_SECTION_UNASSIGNED 0 -#define PHYS_SECTION_NOTDIRTY 1 =20 static void io_mem_init(void); static void memory_map_init(void); @@ -1472,9 +1470,6 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, if (memory_region_is_ram(section->mr)) { /* Normal RAM. */ iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; - if (!section->readonly) { - iotlb |=3D PHYS_SECTION_NOTDIRTY; - } } else { AddressSpaceDispatch *d; =20 @@ -2783,42 +2778,6 @@ void memory_notdirty_write_complete(NotDirtyInfo *nd= i) } } =20 -/* Called within RCU critical section. */ -static void notdirty_mem_write(void *opaque, hwaddr ram_addr, - uint64_t val, unsigned size) -{ - NotDirtyInfo ndi; - - memory_notdirty_write_prepare(&ndi, current_cpu, current_cpu->mem_io_v= addr, - ram_addr, size); - - stn_p(qemu_map_ram_ptr(NULL, ram_addr), size, val); - memory_notdirty_write_complete(&ndi); -} - -static bool notdirty_mem_accepts(void *opaque, hwaddr addr, - unsigned size, bool is_write, - MemTxAttrs attrs) -{ - return is_write; -} - -static const MemoryRegionOps notdirty_mem_ops =3D { - .write =3D notdirty_mem_write, - .valid.accepts =3D notdirty_mem_accepts, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - .unaligned =3D false, - }, -}; - /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) @@ -3014,13 +2973,6 @@ static void io_mem_init(void) { memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, N= ULL, NULL, UINT64_MAX); - - /* io_mem_notdirty calls tb_invalidate_phys_page_fast, - * which can be called without the iothread mutex. - */ - memory_region_init_io(&io_mem_notdirty, NULL, ¬dirty_mem_ops, NULL, - NULL, UINT64_MAX); - memory_region_clear_global_locking(&io_mem_notdirty); } =20 AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv) @@ -3030,8 +2982,6 @@ AddressSpaceDispatch *address_space_dispatch_new(Flat= View *fv) =20 n =3D dummy_section(&d->map, fv, &io_mem_unassigned); assert(n =3D=3D PHYS_SECTION_UNASSIGNED); - n =3D dummy_section(&d->map, fv, &io_mem_notdirty); - assert(n =3D=3D PHYS_SECTION_NOTDIRTY); =20 d->phys_map =3D (PhysPageEntry) { .ptr =3D PHYS_MAP_NODE_NIL, .skip = =3D 1 }; =20 diff --git a/memory.c b/memory.c index 57c44c97db..a99b8c0767 100644 --- a/memory.c +++ b/memory.c @@ -434,10 +434,6 @@ static MemTxResult memory_region_read_accessor(Memory= Region *mr, tmp =3D mr->ops->read(mr->opaque, addr, size); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -460,10 +456,6 @@ static MemTxResult memory_region_read_with_attrs_acces= sor(MemoryRegion *mr, r =3D mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); @@ -484,10 +476,6 @@ static MemTxResult memory_region_write_accessor(Memory= Region *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); @@ -508,10 +496,6 @@ static MemTxResult memory_region_write_with_attrs_acce= ssor(MemoryRegion *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (mr =3D=3D &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB= show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569437865; cv=none; d=zoho.com; s=zohoarc; b=RRD7aqb8mNEb2MRfKpULbAyg5j188qN5zO4hPjmGsWT3RPkzrLtTp2GyMw0hxUQK5gZFne94mLcNw7IvcmYZg5Gzmw37G04EZnB5m8H1NdSSw2ky7qe9RdhafqWZQ4gDYK51VR013vJgoy6XPP5ukY3SZbziNWWUbaozQZqhBRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437865; 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=thoGiFuad0+sCfOpAMLAT3aKZ6kfKYJYfdagLPNuTGE=; b=Tf71cK0SohmYDZ+3BWo2crsIUxWXWV75Kfm75NkYKqAr0TW81Y9tC7uCkwBh+EE7SbjRbphLN9xQFR54EoVT5e0TY+sEkc1ajYnk9a6mSVihLJQGEIpnBnoJH604dTjneERyxwW/yuQLvefsHFqOrMNvLRtuPdEd/t2VP6OaByc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569437865931739.4232382058581; Wed, 25 Sep 2019 11:57:45 -0700 (PDT) Received: from localhost ([::1]:56178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCTw-0003iq-Mj for importer@patchew.org; Wed, 25 Sep 2019 14:57:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47152) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIi-0001s1-OH for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIg-0004L5-KO for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:08 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:43872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIg-0004K9-BU for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:06 -0400 Received: by mail-pl1-x636.google.com with SMTP id f21so539567plj.10 for ; Wed, 25 Sep 2019 11:46:06 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=thoGiFuad0+sCfOpAMLAT3aKZ6kfKYJYfdagLPNuTGE=; b=obzLGpmus8NXGajsJbBANMPP1Lr9oKl26c9ALC/g3ZVjwdIviv7vHovKTsUKsdr5GX 8UdKcDq2RgoDaJi5E2y8abFH2EtNZf+hGSz5aQOosle62tDMF4+U82BLZ6BlVa5i4r0f symZO6y5FgXpaecoKfYDxWzWdDftRr/NIOsRp9gQTklRBnShR244zyonBxxMv7MQ5cDd d0HczvjrDVGtojvpy9ZMHwd3EgjytwSA8HKUhltokzJOTNkHeWSFXiLzDkMhVIUjgzNE mDAkc7TfHwo+rqDLRwQE15z26wb/wdCqeR8zeEGy2DOPoX3kScAXid2FBmpV6ILNFpMy Pzag== 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=thoGiFuad0+sCfOpAMLAT3aKZ6kfKYJYfdagLPNuTGE=; b=QNXT1DEbvnS6qi0TjUr4GBNvTLc1E1/cQspOCK/q8bEsZuWPmPl8mf5trv53AUAJES DMqu7qjTfz9xm9CzaSDlleq+YpCgoTKhnLSEScpIN16RdyjIcA/fr0X6Dvr2UtZhFzwZ Cj7JERLIZGquDlAhRytzaWe8NvUNdj8t+mRIp/aWA8Gc437eDBZyWZjwBFKzCYaR2LmI qJOPeYfQLN3rc0rAepl0rsbwhaBdnoAkGsiyJgk1rA1qdQwAhbaHx6qJLsdOq+zswv2V fgJZxh7x5Odk62QX8o24aWit9Z9SKB3o/AdgCYv2CIBH9hiHUxd13GWpfA+nTV4OGFxg kuFQ== X-Gm-Message-State: APjAAAWy3zNX3cJdfWKQamWz0DrhEWWCwnVAd4KaD9FO/ewsMlYNnObN BNJAmgFzAOKC4YLjrlj+WFCfAT6+C+w= X-Google-Smtp-Source: APXvYqweOdxqYbMAyFMiZtkmB1Z39fMEdDmQ5pRWCERycYL8+SNLT9ifhNSZX+B34Fi+J+NnsnlB2w== X-Received: by 2002:a17:902:7296:: with SMTP id d22mr10991369pll.41.1569437165034; Wed, 25 Sep 2019 11:46:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/16] cputlb: Partially inline memory_region_section_get_iotlb Date: Wed, 25 Sep 2019 11:45:42 -0700 Message-Id: <20190925184548.30673-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::636 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) There is only one caller, tlb_set_page_with_attrs. We cannot inline the entire function because the AddressSpaceDispatch structure is private to exec.c, and cannot easily be moved to include/exec/memory-internal.h. Compute is_ram and is_romd once within tlb_set_page_with_attrs. Fold the number of tests against these predicates. Compute cpu_physical_memory_is_clean outside of the tlb lock region. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 6 +--- accel/tcg/cputlb.c | 68 ++++++++++++++++++++++++++--------------- exec.c | 22 ++----------- 3 files changed, 47 insertions(+), 49 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 81b02eb2fe..49db07ba0b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -509,11 +509,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int a= sidx, hwaddr addr, hwaddr *xlat, hwaddr *plen, MemTxAttrs attrs, int *prot); hwaddr memory_region_section_get_iotlb(CPUState *cpu, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, hwaddr xlat, - int prot, - target_ulong *address); + MemoryRegionSection *section); #endif =20 /* vl.c */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 7e9a0f7ac8..4f118d2cc9 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -705,13 +705,14 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, MemoryRegionSection *section; unsigned int index; target_ulong address; - target_ulong code_address; + target_ulong write_address; uintptr_t addend; CPUTLBEntry *te, tn; hwaddr iotlb, xlat, sz, paddr_page; target_ulong vaddr_page; int asidx =3D cpu_asidx_from_attrs(cpu, attrs); int wp_flags; + bool is_ram, is_romd; =20 assert_cpu_is_self(cpu); =20 @@ -740,18 +741,46 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, if (attrs.byte_swap) { address |=3D TLB_BSWAP; } - if (!memory_region_is_ram(section->mr) && - !memory_region_is_romd(section->mr)) { - /* IO memory case */ - address |=3D TLB_MMIO; - addend =3D 0; - } else { + + is_ram =3D memory_region_is_ram(section->mr); + is_romd =3D memory_region_is_romd(section->mr); + + if (is_ram || is_romd) { + /* RAM and ROMD both have associated host memory. */ addend =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + xla= t; + } else { + /* I/O does not; force the host address to NULL. */ + addend =3D 0; + } + + write_address =3D address; + if (is_ram) { + iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; + /* + * Computing is_clean is expensive; avoid all that unless + * the page is actually writable. + */ + if (prot & PAGE_WRITE) { + if (section->readonly) { + write_address |=3D TLB_DISCARD_WRITE; + } else if (cpu_physical_memory_is_clean(iotlb)) { + write_address |=3D TLB_NOTDIRTY; + } + } + } else { + /* I/O or ROMD */ + iotlb =3D memory_region_section_get_iotlb(cpu, section) + xlat; + /* + * Writes to romd devices must go through MMIO to enable write. + * Reads to romd devices go through the ram_ptr found above, + * but of course reads to I/O must go through MMIO. + */ + write_address |=3D TLB_MMIO; + if (!is_romd) { + address =3D write_address; + } } =20 - code_address =3D address; - iotlb =3D memory_region_section_get_iotlb(cpu, section, vaddr_page, - paddr_page, xlat, prot, &addre= ss); wp_flags =3D cpu_watchpoint_address_matches(cpu, vaddr_page, TARGET_PAGE_SIZE); =20 @@ -791,8 +820,8 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulon= g vaddr, /* * At this point iotlb contains a physical section number in the lower * TARGET_PAGE_BITS, and either - * + the ram_addr_t of the page base of the target RAM (if NOTDIRTY o= r ROM) - * + the offset within section->mr of the page base (otherwise) + * + the ram_addr_t of the page base of the target RAM (RAM) + * + the offset within section->mr of the page base (I/O, ROMD) * We subtract the vaddr_page (which is page aligned and thus won't * disturb the low bits) to give an offset which can be added to the * (non-page-aligned) vaddr of the eventual memory access to get @@ -815,25 +844,14 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ul= ong vaddr, } =20 if (prot & PAGE_EXEC) { - tn.addr_code =3D code_address; + tn.addr_code =3D address; } else { tn.addr_code =3D -1; } =20 tn.addr_write =3D -1; if (prot & PAGE_WRITE) { - tn.addr_write =3D address; - if (memory_region_is_romd(section->mr)) { - /* Use the MMIO path so that the device can switch states. */ - tn.addr_write |=3D TLB_MMIO; - } else if (memory_region_is_ram(section->mr)) { - if (section->readonly) { - tn.addr_write |=3D TLB_DISCARD_WRITE; - } else if (cpu_physical_memory_is_clean( - memory_region_get_ram_addr(section->mr) + xlat)) { - tn.addr_write |=3D TLB_NOTDIRTY; - } - } + tn.addr_write =3D write_address; if (prot & PAGE_WRITE_INV) { tn.addr_write |=3D TLB_INVALID_MASK; } diff --git a/exec.c b/exec.c index dc7001f115..961d7d6497 100644 --- a/exec.c +++ b/exec.c @@ -1459,26 +1459,10 @@ bool cpu_physical_memory_snapshot_get_dirty(DirtyBi= tmapSnapshot *snap, =20 /* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb(CPUState *cpu, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, hwaddr xlat, - int prot, - target_ulong *address) + MemoryRegionSection *section) { - hwaddr iotlb; - - if (memory_region_is_ram(section->mr)) { - /* Normal RAM. */ - iotlb =3D memory_region_get_ram_addr(section->mr) + xlat; - } else { - AddressSpaceDispatch *d; - - d =3D flatview_to_dispatch(section->fv); - iotlb =3D section - d->map.sections; - iotlb +=3D xlat; - } - - return iotlb; + AddressSpaceDispatch *d =3D flatview_to_dispatch(section->fv); + return section - d->map.sections; } #endif /* defined(CONFIG_USER_ONLY) */ =20 --=20 2.17.1 From nobody Thu May 2 19:21:38 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=1569437864; cv=none; d=zoho.com; s=zohoarc; b=i/z5URPyrHWgusktxyBEJ8aOe8RN4ADVjky22wjn+/ZMXdWz3wE4IrBtlWD7rvUjeslXBY0kVt3x06ClOLXWGAREGlLHOaYxMcqnLxQhPlPirNb27keRWsJOLAaTC5cYirIxLC8a7Jk2Nkb7GI9j8XZY0+C9BYB2qHLC583CiWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569437864; 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=SSIp61nlyQIjm5GOge2E7ScAyXdbAUa4X76UCYWm8z8=; b=IXxUWjV8ASprMz6N0sfmLRr/wZuEvXLLS9DH2ORz8YbWwVpaE7Zoz6/rmaeDj2kBOQL867HI5fI+wxl/++uBpwPiJ2KwyaRKuCwYnPr3uAUJ7Dj082lNsO6mjshMLsVQ1tHhS2ArqGqhM+DbTPWQiSpQY5VdQBA0YMtNOTj+0Q8= 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 1569437864410904.299820558948; Wed, 25 Sep 2019 11:57:44 -0700 (PDT) Received: from localhost ([::1]:56174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCTs-0003a3-RH for importer@patchew.org; Wed, 25 Sep 2019 14:57:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47181) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIj-0001tH-VZ for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIi-0004N4-3C for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:09 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:44313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIh-0004M7-RF for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:08 -0400 Received: by mail-pg1-x52a.google.com with SMTP id i14so142949pgt.11 for ; Wed, 25 Sep 2019 11:46:07 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SSIp61nlyQIjm5GOge2E7ScAyXdbAUa4X76UCYWm8z8=; b=TLp7pkjrgsvLed37Ucz8vhb8EZ1g3IaFtw4atqWaiIQsQ9A5N1WZHD1+m8yt+uaYjK YKIjZy3YveQEpDx56YTAcM4xDtH8nw8QDJ7HcnLGlFWcPtPL1+zzXOdNmP5Aiiaau5xV Jgmvw5lT7EoPNpuV7nBFze3ohmtHBfn4QH8bCSvs1p8pISp8e9/IPwswlLoye7DS86pO 7QBH1BQIDAif/sAsu0Z3FyeymemyUemHYJfYHMT7pDD4knlDSzyZcRz1VQ55aaptPCdP JE1higzFy0+RNrsoduik3YLcxfKfZ0i0mq2JzE08d1H7cb0Dduo8mD2EVjwpTEt6I1XQ G/OA== 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=SSIp61nlyQIjm5GOge2E7ScAyXdbAUa4X76UCYWm8z8=; b=J5T7s4f3CmSArU/DOiuHL9DQbFJaRM2Kgzu0BTadeRvfvf8df3oO/pnpmpe8lHixLf OHq3t24SRvVTXKkOyFxrm7fPN70TNCHxuSrMhkZtrT6CpeFxaiSNcPhO9EQLht28+bue sDEuHvhkWwHXeu0RVmodFIal5NY9cYWm/CZV3fINOtsVloF/jE1NiEmGr37/z+/LAmPa KVs4KnpxjK24tdSqft6k+Aq4pphDaZGY2nBma3ncnqUU+qstxtRzCL7sRSSbiyhI90qb 1zFK8GUINWAMDollf2+n8mCtKmw/1TyJgUDyla+WuQgpe/bN1lchItJ7aHUz0LfwiY5R dcjw== X-Gm-Message-State: APjAAAXr92MUIEQcKMnpd6H6whRxM0O5+WvAPR0pUgSBJyGGRtiQdAlk 7XIplV6ynnvDkqbr+KAe0m+6rWkAQic= X-Google-Smtp-Source: APXvYqzHt7wN3JLTW4lEe6EDn8/n7K5G0fXTA676Z8kbAi0wzIPrFvvQdTah4GxdFPFLI83zLJ0w2Q== X-Received: by 2002:a62:7c4d:: with SMTP id x74mr11307843pfc.95.1569437166398; Wed, 25 Sep 2019 11:46:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/16] cputlb: Merge and move memory_notdirty_write_{prepare, complete} Date: Wed, 25 Sep 2019 11:45:43 -0700 Message-Id: <20190925184548.30673-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::52a 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since 9458a9a1df1a, all readers of the dirty bitmaps wait for the rcu lock, which means that they wait until the end of any executing TranslationBlock. As a consequence, there is no need for the actual access to happen in between the _prepare and _complete. Therefore, we can improve things by merging the two functions into notdirty_write and dropping the NotDirtyInfo structure. In addition, the only users of notdirty_write are in cputlb.c, so move the merged function there. Pass in the CPUIOTLBEntry from which the ram_addr_t may be computed. Reviewed-by: David Hildenbrand Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/exec/memory-internal.h | 65 ----------------------------- accel/tcg/cputlb.c | 76 +++++++++++++++++++--------------- exec.c | 44 -------------------- 3 files changed, 42 insertions(+), 143 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index ef4fb92371..9fcc2af25c 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -49,70 +49,5 @@ void address_space_dispatch_free(AddressSpaceDispatch *d= ); =20 void mtree_print_dispatch(struct AddressSpaceDispatch *d, MemoryRegion *root); - -struct page_collection; - -/* Opaque struct for passing info from memory_notdirty_write_prepare() - * to memory_notdirty_write_complete(). Callers should treat all fields - * as private, with the exception of @active. - * - * @active is a field which is not touched by either the prepare or - * complete functions, but which the caller can use if it wishes to - * track whether it has called prepare for this struct and so needs - * to later call the complete function. - */ -typedef struct { - CPUState *cpu; - struct page_collection *pages; - ram_addr_t ram_addr; - vaddr mem_vaddr; - unsigned size; - bool active; -} NotDirtyInfo; - -/** - * memory_notdirty_write_prepare: call before writing to non-dirty memory - * @ndi: pointer to opaque NotDirtyInfo struct - * @cpu: CPU doing the write - * @mem_vaddr: virtual address of write - * @ram_addr: the ram address of the write - * @size: size of write in bytes - * - * Any code which writes to the host memory corresponding to - * guest RAM which has been marked as NOTDIRTY must wrap those - * writes in calls to memory_notdirty_write_prepare() and - * memory_notdirty_write_complete(): - * - * NotDirtyInfo ndi; - * memory_notdirty_write_prepare(&ndi, ....); - * ... perform write here ... - * memory_notdirty_write_complete(&ndi); - * - * These calls will ensure that we flush any TCG translated code for - * the memory being written, update the dirty bits and (if possible) - * remove the slowpath callback for writing to the memory. - * - * This must only be called if we are using TCG; it will assert otherwise. - * - * We may take locks in the prepare call, so callers must ensure that - * they don't exit (via longjump or otherwise) without calling complete. - * - * This call must only be made inside an RCU critical section. - * (Note that while we're executing a TCG TB we're always in an - * RCU critical section, which is likely to be the case for callers - * of these functions.) - */ -void memory_notdirty_write_prepare(NotDirtyInfo *ndi, - CPUState *cpu, - vaddr mem_vaddr, - ram_addr_t ram_addr, - unsigned size); -/** - * memory_notdirty_write_complete: finish write to non-dirty memory - * @ndi: pointer to the opaque NotDirtyInfo struct which was initialized - * by memory_not_dirty_write_prepare(). - */ -void memory_notdirty_write_complete(NotDirtyInfo *ndi); - #endif #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 4f118d2cc9..3e91838519 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -33,6 +33,7 @@ #include "exec/helper-proto.h" #include "qemu/atomic.h" #include "qemu/atomic128.h" +#include "translate-all.h" =20 /* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ /* #define DEBUG_TLB */ @@ -1085,6 +1086,37 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env,= target_ulong addr) return qemu_ram_addr_from_host_nofail(p); } =20 +static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, + CPUIOTLBEntry *iotlbentry, uintptr_t retaddr) +{ + ram_addr_t ram_addr =3D mem_vaddr + iotlbentry->addr; + + trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); + + if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { + struct page_collection *pages + =3D page_collection_lock(ram_addr, ram_addr + size); + + /* We require mem_io_pc in tb_invalidate_phys_page_range. */ + cpu->mem_io_pc =3D retaddr; + + tb_invalidate_phys_page_fast(pages, ram_addr, size); + page_collection_unlock(pages); + } + + /* + * Set both VGA and migration bits for simplicity and to remove + * the notdirty callback faster. + */ + cpu_physical_memory_set_dirty_range(ram_addr, size, DIRTY_CLIENTS_NOCO= DE); + + /* We remove the notdirty callback only if the code has been flushed. = */ + if (!cpu_physical_memory_is_clean(ram_addr)) { + trace_memory_notdirty_set_dirty(mem_vaddr); + tlb_set_dirty(cpu, mem_vaddr); + } +} + /* * Probe for whether the specified guest access is permitted. If it is not * permitted then an exception will be taken in the same way as if this @@ -1204,8 +1236,7 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr ad= dr, /* Probe for a read-modify-write atomic operation. Do not allow unaligned * operations, or io operations to proceed. Return the host address. */ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, - TCGMemOpIdx oi, uintptr_t retaddr, - NotDirtyInfo *ndi) + TCGMemOpIdx oi, uintptr_t retaddr) { size_t mmu_idx =3D get_mmuidx(oi); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1265,12 +1296,9 @@ static void *atomic_mmu_lookup(CPUArchState *env, ta= rget_ulong addr, =20 hostaddr =3D (void *)((uintptr_t)addr + tlbe->addend); =20 - ndi->active =3D false; if (unlikely(tlb_addr & TLB_NOTDIRTY)) { - ndi->active =3D true; - memory_notdirty_write_prepare(ndi, env_cpu(env), addr, - qemu_ram_addr_from_host_nofail(hosta= ddr), - 1 << s_bits); + notdirty_write(env_cpu(env), addr, 1 << s_bits, + &env_tlb(env)->d[mmu_idx].iotlb[index], retaddr); } =20 return hostaddr; @@ -1641,28 +1669,13 @@ store_helper(CPUArchState *env, target_ulong addr, = uint64_t val, return; } =20 - haddr =3D (void *)((uintptr_t)addr + entry->addend); - /* Handle clean RAM pages. */ if (tlb_addr & TLB_NOTDIRTY) { - NotDirtyInfo ndi; - - /* We require mem_io_pc in tb_invalidate_phys_page_range. */ - env_cpu(env)->mem_io_pc =3D retaddr; - - memory_notdirty_write_prepare(&ndi, env_cpu(env), addr, - addr + iotlbentry->addr, size); - - if (unlikely(need_swap)) { - store_memop(haddr, val, op ^ MO_BSWAP); - } else { - store_memop(haddr, val, op); - } - - memory_notdirty_write_complete(&ndi); - return; + notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); } =20 + haddr =3D (void *)((uintptr_t)addr + entry->addend); + /* * Keep these two store_memop separate to ensure that the compiler * is able to fold the entire function to a single instruction. @@ -1793,14 +1806,9 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulo= ng addr, uint64_t val, #define EXTRA_ARGS , TCGMemOpIdx oi, uintptr_t retaddr #define ATOMIC_NAME(X) \ HELPER(glue(glue(glue(atomic_ ## X, SUFFIX), END), _mmu)) -#define ATOMIC_MMU_DECLS NotDirtyInfo ndi -#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, retaddr, &ndi) -#define ATOMIC_MMU_CLEANUP \ - do { \ - if (unlikely(ndi.active)) { \ - memory_notdirty_write_complete(&ndi); \ - } \ - } while (0) +#define ATOMIC_MMU_DECLS +#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, retaddr) +#define ATOMIC_MMU_CLEANUP =20 #define DATA_SIZE 1 #include "atomic_template.h" @@ -1828,7 +1836,7 @@ void helper_be_stq_mmu(CPUArchState *env, target_ulon= g addr, uint64_t val, #undef ATOMIC_MMU_LOOKUP #define EXTRA_ARGS , TCGMemOpIdx oi #define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END)) -#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, GETPC(), &ndi) +#define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, oi, GETPC()) =20 #define DATA_SIZE 1 #include "atomic_template.h" diff --git a/exec.c b/exec.c index 961d7d6497..7d835b1a2b 100644 --- a/exec.c +++ b/exec.c @@ -2718,50 +2718,6 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr) return block->offset + offset; } =20 -/* Called within RCU critical section. */ -void memory_notdirty_write_prepare(NotDirtyInfo *ndi, - CPUState *cpu, - vaddr mem_vaddr, - ram_addr_t ram_addr, - unsigned size) -{ - ndi->cpu =3D cpu; - ndi->ram_addr =3D ram_addr; - ndi->mem_vaddr =3D mem_vaddr; - ndi->size =3D size; - ndi->pages =3D NULL; - - trace_memory_notdirty_write_access(mem_vaddr, ram_addr, size); - - assert(tcg_enabled()); - if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { - ndi->pages =3D page_collection_lock(ram_addr, ram_addr + size); - tb_invalidate_phys_page_fast(ndi->pages, ram_addr, size); - } -} - -/* Called within RCU critical section. */ -void memory_notdirty_write_complete(NotDirtyInfo *ndi) -{ - if (ndi->pages) { - assert(tcg_enabled()); - page_collection_unlock(ndi->pages); - ndi->pages =3D NULL; - } - - /* Set both VGA and migration bits for simplicity and to remove - * the notdirty callback faster. - */ - cpu_physical_memory_set_dirty_range(ndi->ram_addr, ndi->size, - DIRTY_CLIENTS_NOCODE); - /* we remove the notdirty callback only if the code has been - flushed */ - if (!cpu_physical_memory_is_clean(ndi->ram_addr)) { - trace_memory_notdirty_set_dirty(ndi->mem_vaddr); - tlb_set_dirty(ndi->cpu, ndi->mem_vaddr); - } -} - /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438220; cv=none; d=zoho.com; s=zohoarc; b=MQLrgR+DeXluRBosh+LRCbWym0BGxXE+Csp45Qfsinz5bCpxmTGNxCemuNdfYFMfO7aJAxn7fGvxiTHdkBcTfyzkiWFQqVvCeYw+h+ixnlY/aBlc2HirCWZb3CfV0FI/9wQ2RvZJymgjq838klG4NRKk3bdCoDTN0R4Vg+GagJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438220; 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=yAC6RG3wvhI3H3mXOjF1M8pzwn6maoZxTmCA0mspbiE=; b=LiV4bQGOkqcGjzsIolGXB412l0jeDYYk0xeQOVhlhy2m7otyZ4kJSIS6vSVz6tqBKi7XL8xI0JVQcxfp0spjCo+iQ/TEQgDv1TRH4XpgqqIpzLTYKLlmyTW2cJHZbW8pEorVpe4Lf4TzDNK2XbsXor0FKTqRDnNftleUxUjlKtQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438220799606.9450942166421; Wed, 25 Sep 2019 12:03:40 -0700 (PDT) Received: from localhost ([::1]:56266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCZe-0002P0-7Y for importer@patchew.org; Wed, 25 Sep 2019 15:03:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47196) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIk-0001u2-LN for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIj-0004OP-F0 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:10 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIj-0004NZ-5J for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:09 -0400 Received: by mail-pg1-x542.google.com with SMTP id i14so142992pgt.11 for ; Wed, 25 Sep 2019 11:46:09 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yAC6RG3wvhI3H3mXOjF1M8pzwn6maoZxTmCA0mspbiE=; b=j8sr21E/7b0HcIha4bK+txI5RcHSDB5hgO/mBCmw9C01jPpwe0EJhDMezWYD1nSHxN 45k4cZSLyb5qnB2D2+F4z/1u3LSe5S7AndiUdnxMEKrjyTdlG5tCp/Yrdhf77uk5jpxH brqBILK9azxYj9SPKlfbAuFlWRre3WYTw6usQ1/x8Wf2js9amISDTvgZUxXJznwq85mx 3/3X1VHHAKMoG0PQJ1WNotV2+YxUYqoxFGSbDBISLaqn9fWWb/QiWkJIiKIKQNwIZetf Gsv8xruh1O/yvbYo+zpLlG3FpD42CZsSVvHOasjKL7uNWe/T3G8G3yAmYgwG/zgaGhqG 4KXQ== 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=yAC6RG3wvhI3H3mXOjF1M8pzwn6maoZxTmCA0mspbiE=; b=FPKYXiX8jjAWTEfVgpx86SA2s7obenYhsCuhV3YO6bhyKgT/sk8WDD1f5cVTLD8uzu PkXt+LKaStqKSre88DAq6ANoUbZexrEoJOmVGpeAG2ymIsYtf0CcJx4sz0OAjb9X994j btewq79a/N7DRooTw1yO7EJTy8KeLLdNeWmP2ZbWL+7qF9DRNpBJFXU+0mBCGsW9ZR/0 50VSHvJy6FXcFzidxX/29yx3Qa2lf67WuoNexnub5rCulGJl8nH+Y/tNgnnAKOaEYxWg YnGat2oVLBgKKXaEnKKH6cuYc4eHkgjPgl2nNw0Tx881+uf4C2VFhseSJVXqe54KeSbO TDow== X-Gm-Message-State: APjAAAXAo/iKgaBfRYYKx51koWpaq4EBD7YrMZkAPIRy4gSkv2oOFCpe NwMvkB578fQJo53dmPhEGqq5JUbUcII= X-Google-Smtp-Source: APXvYqwgDeLXGIVJEKyWDA3emsnAE4L5EYU7jYmTQdhJyt2r6ogN1aJgqNkv2VzYln/C4Uj9+a/ZJw== X-Received: by 2002:a17:90a:b385:: with SMTP id e5mr8169741pjr.91.1569437167666; Wed, 25 Sep 2019 11:46:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/16] cputlb: Handle TLB_NOTDIRTY in probe_access Date: Wed, 25 Sep 2019 11:45:44 -0700 Message-Id: <20190925184548.30673-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::542 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We can use notdirty_write for the write and return a valid host pointer for this case. Reviewed-by: David Hildenbrand Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 3e91838519..b56e9ddf8c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1168,16 +1168,24 @@ void *probe_access(CPUArchState *env, target_ulong = addr, int size, return NULL; } =20 - /* Handle watchpoints. */ - if (tlb_addr & TLB_WATCHPOINT) { - cpu_check_watchpoint(env_cpu(env), addr, size, - env_tlb(env)->d[mmu_idx].iotlb[index].attrs, - wp_access, retaddr); - } + if (unlikely(tlb_addr & TLB_FLAGS_MASK)) { + CPUIOTLBEntry *iotlbentry =3D &env_tlb(env)->d[mmu_idx].iotlb[inde= x]; =20 - /* Reject I/O access, or other required slow-path. */ - if (tlb_addr & (TLB_NOTDIRTY | TLB_MMIO | TLB_BSWAP | TLB_DISCARD_WRIT= E)) { - return NULL; + /* Reject I/O access, or other required slow-path. */ + if (tlb_addr & (TLB_MMIO | TLB_BSWAP | TLB_DISCARD_WRITE)) { + return NULL; + } + + /* Handle watchpoints. */ + if (tlb_addr & TLB_WATCHPOINT) { + cpu_check_watchpoint(env_cpu(env), addr, size, + iotlbentry->attrs, wp_access, retaddr); + } + + /* Handle clean RAM pages. */ + if (tlb_addr & TLB_NOTDIRTY) { + notdirty_write(env_cpu(env), addr, size, iotlbentry, retaddr); + } } =20 return (void *)((uintptr_t)addr + entry->addend); --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438043; cv=none; d=zoho.com; s=zohoarc; b=PefSfnpcmZJdDOB5Di7j2becfs4thAw63sj9wdjC5S2jawiBoKES+ipfvI35nYNsphSjIKPaEOgspwXv9+iCMeGIMgDAUy5H48K5gAJhHWRbQkBjxulBMONDR/ynCtR2jkeYdHRg8Ijwbv/1I/fwqsHtzw5TFNy5vE85uI1k22o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438043; 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=fp+IhM5CQTB4UG88fPA7PY7U/XNGkntrALZi2zvKv3E=; b=aZyfW5iS0MDFcprsPw7STa+NdHQQGuHtdvUI4RItOwAsJt7o59LUm+4wOvu/DaIVqsSX4rYHb+hWLF+uhhYG8jM/b8KdNb7WRVuOOIdNOV1OJ2hVfUloAogat9Bax2rOO4TBqJ7Hufp+PSLkfxLnTdbrC2TxPOmLdg9HLW0jrrs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438043769180.0555526328552; Wed, 25 Sep 2019 12:00:43 -0700 (PDT) Received: from localhost ([::1]:56224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCWg-0007tF-7i for importer@patchew.org; Wed, 25 Sep 2019 15:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47244) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIm-0001w9-Ci for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIl-0004QW-0q for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:12 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIk-0004Pf-RR for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:10 -0400 Received: by mail-pf1-x443.google.com with SMTP id q12so4145411pff.9 for ; Wed, 25 Sep 2019 11:46:10 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fp+IhM5CQTB4UG88fPA7PY7U/XNGkntrALZi2zvKv3E=; b=faxW6FtGYTuPX1Z9H1uXQIDVHyVZmJo4OpZK6UyixfJ6RjM1HW5/XzQfdNaPeKPIIy CfqjcD7e1eUpJyEeJPYv2PlXER9rzjbbzpiJX6tFkaB48fGhkLoxhLPp6JFW+57vzsfL SuWuJz8nIuvllc/qXQHX95B2mEfUmQxQvUijyL/ASzhZafMQxio7q9CqP5EfkgLPU8GE Ofp3K7H97Y9f4akCJcMiFeSeqhZTjyF6ZZz+IiNgj9VvxRZIIB5XkC9j5kG+h6IEjFne rkw6dgXdr6uPLcxRXg8oDEHTX0Ec2nHOnt3+zfA0QjRJxagY8vf36vHMyp73yn9CE93g +xHQ== 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=fp+IhM5CQTB4UG88fPA7PY7U/XNGkntrALZi2zvKv3E=; b=RC/3bJ0j+Cxhd9idwl4gbUDpYNPpV+Tr2fRjPb/EX1NH4QpoTrJJwi9fHKEoVUegg+ MujKxVS/elUKO+eGouHAqz83c4Q9xMfmZPZ3aTO5ntcvRmhLHcHxfR8fpVNkFDavMviv KCtfZMDOS7/XRI28Q9e8mjL7b39k5ZPv/P1NnJc7ijXfVYDCv4xHcQO4ZLhF6clOu2yb i6/Hee3su80rnd+Uz1fBBIkznjBZwZ+s1GFhXb2THtcxJBJW9NLhyewqHA5GXqEOIvG9 42gjQWnlMHyct/a2LwZy7dzF4ql10kM66r7cecgeRNpWDuGrVzpKkhVU+JTiqCmIg5Xx uCtQ== X-Gm-Message-State: APjAAAV4LC+dYGH3FbgVB84y5L3rJDCHtL9HbXaKLeqPWv2IBXUWIWgY bDMYkvBPnJ0/O+YJip0f3uk4uRB+Z/Q= X-Google-Smtp-Source: APXvYqz+kcm0pkE1lLoP2brG/MKm9p1SIiUp8IP6Ayj57fuEXyGvKB5YIQpUlZaV9ShdLhFUVKRP6w== X-Received: by 2002:a17:90a:9ca:: with SMTP id 68mr7989502pjo.66.1569437169030; Wed, 25 Sep 2019 11:46:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/16] cputlb: Remove cpu->mem_io_vaddr Date: Wed, 25 Sep 2019 11:45:45 -0700 Message-Id: <20190925184548.30673-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) With the merge of notdirty handling into store_helper, the last user of cpu->mem_io_vaddr was removed. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 2 -- accel/tcg/cputlb.c | 2 -- hw/core/cpu.c | 1 - 3 files changed, 5 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c7cda65c66..031f587e51 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -338,7 +338,6 @@ struct qemu_work_item; * @next_cpu: Next CPU sharing TB cache. * @opaque: User data. * @mem_io_pc: Host Program Counter at which the memory was accessed. - * @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. * @work_mutex: Lock to prevent multiple access to queued_work_*. * @queued_work_first: First asynchronous work pending. @@ -413,7 +412,6 @@ struct CPUState { * we store some rarely used information in the CPU context. */ uintptr_t mem_io_pc; - vaddr mem_io_vaddr; /* * This is only needed for the legacy cpu_unassigned_access() hook; * when all targets using it have been converted to use diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b56e9ddf8c..4b24811ce7 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -928,7 +928,6 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, cpu_io_recompile(cpu, retaddr); } =20 - cpu->mem_io_vaddr =3D addr; cpu->mem_io_access_type =3D access_type; =20 if (mr->global_locking && !qemu_mutex_iothread_locked()) { @@ -968,7 +967,6 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, if (!cpu->can_do_io) { cpu_io_recompile(cpu, retaddr); } - cpu->mem_io_vaddr =3D addr; cpu->mem_io_pc =3D retaddr; =20 if (mr->global_locking && !qemu_mutex_iothread_locked()) { diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 0035845511..73b1ee34d0 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -261,7 +261,6 @@ static void cpu_common_reset(CPUState *cpu) cpu->interrupt_request =3D 0; cpu->halted =3D 0; cpu->mem_io_pc =3D 0; - cpu->mem_io_vaddr =3D 0; cpu->icount_extra =3D 0; atomic_set(&cpu->icount_decr_ptr->u32, 0); cpu->can_do_io =3D 1; --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438228; cv=none; d=zoho.com; s=zohoarc; b=aJJcLu76A7U0fxNR0pkTCf2Z88I0XR+H592E1gjmTnypVrAckQQ07H2ARAud0lDtrAUslHXvN64LxGc/NMDShMNnMNWovd6lWAA63+tmDApL+1AU4S8RFGzAkwTTu9QZHZxBHF2vFwPgt3ybcpH7RF37EVBNDf4FU4JOmv6NxZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438228; 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=60zIbLUAmUNSEgAQIKyqCRl8+f6RWn+eou5eyJkQXA8=; b=ndSSy0E7r7yTNBaK4O02iFkcHzKGCoAVoPfT9Ao1KDtEZBy5/VopixjlZLQr5iHRJplOsaEfGk8kgedHlbi3+sP1/EzBJghZsRjoNcLj8ENx5nWIJRdjb3jnzH8ZrBiP1u7vk432DETPTiy5yHmSMLpeizAWFH8dyAZzAjAMuf0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438228815574.0373438556483; Wed, 25 Sep 2019 12:03:48 -0700 (PDT) Received: from localhost ([::1]:56270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCZn-0002Xt-74 for importer@patchew.org; Wed, 25 Sep 2019 15:03:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47276) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIq-00020L-0u for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIm-0004Sl-F9 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:13 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45561) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIm-0004Rc-98 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:12 -0400 Received: by mail-pg1-x542.google.com with SMTP id 4so360227pgm.12 for ; Wed, 25 Sep 2019 11:46:12 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=60zIbLUAmUNSEgAQIKyqCRl8+f6RWn+eou5eyJkQXA8=; b=xrCPvprifaONXZagZ/fLiCRF0Tp5WX4YVEhS72UkFdTUxPK+uVjcB9kbg934woTf8+ x1dUu7KyBEpkmeOuRycTGdgTIbKZg9ASP3so9ouWNqcb+NU5xCucBbnMqYTbqmo4rWQ5 GuVB5vc4VeXsHaI/kLo5pKRnvfIOblOVZ/rtGxbPVZUrOvI9WGlCL2J0mtBhQcVtwo0J QRSPHhGbFO62lcBncVwXgnkBWQR3L2lfvKU0GMJtOg6X9mbeF5N8uo6xlTcUVSxFUKMS lrKeHsQSSR0akGKVKq2IW4sPcW9bXor6306M8bzd0IfIpfEQ2hGv2IqKn/nrfBLCoonr MqDQ== 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=60zIbLUAmUNSEgAQIKyqCRl8+f6RWn+eou5eyJkQXA8=; b=LFd6ho3whf8NYlIoBy/Uh3D/x/6vZ7rKx1iGNe8EVnuVG6qYzAcOUg1bxfHqRGmhrD J42AJnhTLE2/6OyC5MtGoEQQETNzbb6XM4tk+xsSiPnUWtcnWD7XRzokQmNorrx3uBrh d6lLThbO33i/531dDUjc3htl8YPSBtSbF6fFmMVKHoBZP0TnvVWV7q2bpcPQSvVvap6W WHqYcNylOMtsr9BK1D/fe0u9/eETMik6y3gDydrwXMWQBshTwFiVxXXvcHd2Nln4EsIo LbNLOcZkz4rYzMENrDSYrp4QFRhLGjK5VzcFdJyVDKT+axgi+G95euSfjz14PW29SEXF 2BQA== X-Gm-Message-State: APjAAAUUUI1t6NmngSvTAGx+TsiKFIrlPyTEaLxWUrfuGdhcI7wDUYOj IwHg8SBRHAnwWNlkKYo3qr14cwbcxLk= X-Google-Smtp-Source: APXvYqyN1SicsiA4gerH6TsZ1iZ7ifhN/tw+1MJlS0lG7f1uZ1oa3M96NGEldG5pviFYH8fHLMsZ1w== X-Received: by 2002:a17:90b:946:: with SMTP id dw6mr8133586pjb.48.1569437170739; Wed, 25 Sep 2019 11:46:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/16] cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access Date: Wed, 25 Sep 2019 11:45:46 -0700 Message-Id: <20190925184548.30673-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::542 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) All callers pass false to this argument. Remove it and pass the constant on to tb_invalidate_phys_page_range__locked. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- accel/tcg/translate-all.h | 3 +-- accel/tcg/translate-all.c | 6 ++---- exec.c | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 64f5fd9a05..31f2117188 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -28,8 +28,7 @@ struct page_collection *page_collection_lock(tb_page_addr= _t start, void page_collection_unlock(struct page_collection *set); void tb_invalidate_phys_page_fast(struct page_collection *pages, tb_page_addr_t start, int len); -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d, - int is_cpu_write_access); +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); void tb_check_watchpoint(CPUState *cpu); =20 #ifdef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 5d1e08b169..de4b697163 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1983,8 +1983,7 @@ tb_invalidate_phys_page_range__locked(struct page_col= lection *pages, * * Called with mmap_lock held for user-mode emulation */ -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d, - int is_cpu_write_access) +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d) { struct page_collection *pages; PageDesc *p; @@ -1996,8 +1995,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t sta= rt, tb_page_addr_t end, return; } pages =3D page_collection_lock(start, end); - tb_invalidate_phys_page_range__locked(pages, p, start, end, - is_cpu_write_access); + tb_invalidate_phys_page_range__locked(pages, p, start, end, 0); page_collection_unlock(pages); } =20 diff --git a/exec.c b/exec.c index 7d835b1a2b..b3df826039 100644 --- a/exec.c +++ b/exec.c @@ -1012,7 +1012,7 @@ const char *parse_cpu_option(const char *cpu_option) void tb_invalidate_phys_addr(target_ulong addr) { mmap_lock(); - tb_invalidate_phys_page_range(addr, addr + 1, 0); + tb_invalidate_phys_page_range(addr, addr + 1); mmap_unlock(); } =20 @@ -1039,7 +1039,7 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr= addr, MemTxAttrs attrs) return; } ram_addr =3D memory_region_get_ram_addr(mr) + addr; - tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); + tb_invalidate_phys_page_range(ram_addr, ram_addr + 1); rcu_read_unlock(); } =20 --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438386; cv=none; d=zoho.com; s=zohoarc; b=R2YwxCzfyjGrKazpr0iEIkaWU6VvTto9cGw+c8SY6kE7uGoHV9bjhtXoQ8cnyzL2UW/9LPye6jG/suBRzdH5uh4pn0lC9Tusjb4Zj1WCkzJTIJqG4xzQATBX17rWfTsG/T7u4gVEAo6ANkccZ68vbsHKkY6qLR+hZsfK/SocTEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438386; 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=MGym46ItcVgrFEop1vv6vOBmHP52BveKepQrEUSeRf8=; b=iGixztgrwclO8aWJL+S7iqkJqLlVUXsPw0NPdoGnGr8MCHodH1wL+rE2KnXYjyUFTQEa+xWBXS7OeI0+SG6oIZjEvTC88m4Da7M0XQHsXDpAb05Hf/Z9ZwvrlnmRH9/Q5yLn7s9YXbRlwoyT3izfqbRRbWQsZgVJfBMezzrdjNc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438386915721.36723203635; Wed, 25 Sep 2019 12:06:26 -0700 (PDT) Received: from localhost ([::1]:56304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCcL-0005kI-KG for importer@patchew.org; Wed, 25 Sep 2019 15:06:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47309) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIs-00020u-6y for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIq-0004WW-Qv for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:18 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:33710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIo-0004T7-Sb for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:16 -0400 Received: by mail-pf1-x442.google.com with SMTP id q10so4173653pfl.0 for ; Wed, 25 Sep 2019 11:46:13 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MGym46ItcVgrFEop1vv6vOBmHP52BveKepQrEUSeRf8=; b=F69/UaKN4W2rsE5fVmNSn9hPI1nAh1iHfCIvkiuPnoI6UPuG01lZsNOGl6Ss7X/nEX yul8FhTqwAiztkTzCfmc5J72iK/1kLahPqUnS97vFFFalgfzdAAzxGrRra5gdGR6i5t9 9VyZr+mcKb8bLFfuO85oYXazdC4r1TA0/DMqx9JfaV9NLdl2TiZRJ3FAmyEcQqfesC6O QAOcK63SNaQwWMfKDx4tzgaPt1wX5qgb1yKa20N2KNLcCDynYJOD8V++CozRNSa6erxN XWHqRBXgF/yitzcMq+2urThLkeqdZ3ICM4cEKPzNzLtLDJQ0II4RtD8qB0lCXAe5i0vK y5pA== 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=MGym46ItcVgrFEop1vv6vOBmHP52BveKepQrEUSeRf8=; b=iKhEiJIj1HxGDBSYywvuLgRsmI/PCk6Q8yOUM0azHhsXyZk6slqCODoisUMT81poj9 2J0zW8hB3ldY+MZJm13OkRKzPBf4rl1sCpNUFRXU+ptLwaBuOj9F2lPVONi7RYnTROeQ ahuYwfgKn15+dQd3ygQx7hBGlsH8kb4xltLBTj7RLneMwkl0h4jy8SwEermp7uzu8bxH AEN9WWTDUZRLBQKy05r6C5l1f20P8CIl+IRxlMBJP3TFvFuCcAcr+X4UrgriFWh/5xWn QPZdtvatlEpZkyRu/KCzmw/V49Hv4vx5aXFIDW6vGxnYXX0qXnfVuxlqFpWoQH1kWqHR 6dCQ== X-Gm-Message-State: APjAAAWglx0n0sfes5c/JKkWl8vGsNDREFRq5SaYXUMava9MHGSqMazq m3K23HpPm/kmV/HohJGmFiqODtzb8aI= X-Google-Smtp-Source: APXvYqzCTJsBwhAhcAp2IUcXNQtCHogCjNbiGPKqpL7CBE1uFL7aT3nqfGzrSg1ElCOtKM5Ntv03eQ== X-Received: by 2002:a17:90a:264a:: with SMTP id l68mr8280471pje.74.1569437172186; Wed, 25 Sep 2019 11:46:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/16] cputlb: Pass retaddr to tb_invalidate_phys_page_fast Date: Wed, 25 Sep 2019 11:45:47 -0700 Message-Id: <20190925184548.30673-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Rather than rely on cpu->mem_io_pc, pass retaddr down directly. Within tb_invalidate_phys_page_range__locked, the is_cpu_write_access parameter is non-zero exactly when retaddr would be non-zero, so that is a simple replacement. Recognize that current_tb_not_found is true only when mem_io_pc (and now retaddr) are also non-zero, so remove a redundant test. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- accel/tcg/translate-all.h | 3 ++- accel/tcg/cputlb.c | 6 +----- accel/tcg/translate-all.c | 39 +++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 31f2117188..135c1ea96a 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -27,7 +27,8 @@ struct page_collection *page_collection_lock(tb_page_addr= _t start, tb_page_addr_t end); void page_collection_unlock(struct page_collection *set); void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len); + tb_page_addr_t start, int len, + uintptr_t retaddr); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); void tb_check_watchpoint(CPUState *cpu); =20 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 4b24811ce7..defc8d5929 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1094,11 +1094,7 @@ static void notdirty_write(CPUState *cpu, vaddr mem_= vaddr, unsigned size, if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { struct page_collection *pages =3D page_collection_lock(ram_addr, ram_addr + size); - - /* We require mem_io_pc in tb_invalidate_phys_page_range. */ - cpu->mem_io_pc =3D retaddr; - - tb_invalidate_phys_page_fast(pages, ram_addr, size); + tb_invalidate_phys_page_fast(pages, ram_addr, size, retaddr); page_collection_unlock(pages); } =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index de4b697163..db77fb221b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1889,7 +1889,7 @@ static void tb_invalidate_phys_page_range__locked(struct page_collection *pages, PageDesc *p, tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access) + uintptr_t retaddr) { TranslationBlock *tb; tb_page_addr_t tb_start, tb_end; @@ -1897,9 +1897,9 @@ tb_invalidate_phys_page_range__locked(struct page_col= lection *pages, #ifdef TARGET_HAS_PRECISE_SMC CPUState *cpu =3D current_cpu; CPUArchState *env =3D NULL; - int current_tb_not_found =3D is_cpu_write_access; + bool current_tb_not_found =3D retaddr !=3D 0; + bool current_tb_modified =3D false; TranslationBlock *current_tb =3D NULL; - int current_tb_modified =3D 0; target_ulong current_pc =3D 0; target_ulong current_cs_base =3D 0; uint32_t current_flags =3D 0; @@ -1931,24 +1931,21 @@ tb_invalidate_phys_page_range__locked(struct page_c= ollection *pages, if (!(tb_end <=3D start || tb_start >=3D end)) { #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_not_found) { - current_tb_not_found =3D 0; - current_tb =3D NULL; - if (cpu->mem_io_pc) { - /* now we have a real cpu fault */ - current_tb =3D tcg_tb_lookup(cpu->mem_io_pc); - } + current_tb_not_found =3D false; + /* now we have a real cpu fault */ + current_tb =3D tcg_tb_lookup(retaddr); } if (current_tb =3D=3D tb && (tb_cflags(current_tb) & CF_COUNT_MASK) !=3D 1) { - /* If we are modifying the current TB, we must stop - its execution. We could be more precise by checking - that the modification is after the current PC, but it - would require a specialized function to partially - restore the CPU state */ - - current_tb_modified =3D 1; - cpu_restore_state_from_tb(cpu, current_tb, - cpu->mem_io_pc, true); + /* + * If we are modifying the current TB, we must stop + * its execution. We could be more precise by checking + * that the modification is after the current PC, but it + * would require a specialized function to partially + * restore the CPU state. + */ + current_tb_modified =3D true; + cpu_restore_state_from_tb(cpu, current_tb, retaddr, true); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -2042,7 +2039,8 @@ void tb_invalidate_phys_range(target_ulong start, tar= get_ulong end) * Call with all @pages in the range [@start, @start + len[ locked. */ void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len) + tb_page_addr_t start, int len, + uintptr_t retaddr) { PageDesc *p; =20 @@ -2069,7 +2067,8 @@ void tb_invalidate_phys_page_fast(struct page_collect= ion *pages, } } else { do_invalidate: - tb_invalidate_phys_page_range__locked(pages, p, start, start + len= , 1); + tb_invalidate_phys_page_range__locked(pages, p, start, start + len, + retaddr); } } #else --=20 2.17.1 From nobody Thu May 2 19:21:38 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=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1569438586; cv=none; d=zoho.com; s=zohoarc; b=OR4ADULrWdIN98hKaR+BhHi5hGoNSEgTiz5A2beJDm2Ni+dDh/Xo1hTLmYE36mfUD0py5/T3ieq0uzM6VcpHHiii/2ZVEKAivmqIjBOfBoXIDJHqI3O8yF2LLgqHPmvxNQANYxxwNWd7Olq02TpALg03fj0kRIMeSSZiH8Q2ZB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569438586; 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=Eck7z4xU6rWZDIf+jUdftaZDf15l360hvN4eD+K3cX0=; b=KR7qa7zUn4EsS/Ly0tH74ZCmqXvWHMLix0/pET5LsfA7jerouxAz1bmAtQMe3nFrXq9HBfLE0d5qHd3r1h8hOnA35AfSx8b6scUWLN8dm7xeBJm3b7KOH7TL87FsO6WsSpbcaGO3KZPl6pGLAeou5rc8kvSyQ3Nw+1qe4UNEpwY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass 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 1569438586115261.1204424437474; Wed, 25 Sep 2019 12:09:46 -0700 (PDT) Received: from localhost ([::1]:56340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCfY-0000K6-Oe for importer@patchew.org; Wed, 25 Sep 2019 15:09:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47322) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDCIu-00021d-WC for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDCIs-0004X3-4l for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:20 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:34827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDCIq-0004VA-3D for qemu-devel@nongnu.org; Wed, 25 Sep 2019 14:46:16 -0400 Received: by mail-pl1-x630.google.com with SMTP id y10so2936307plp.2 for ; Wed, 25 Sep 2019 11:46:14 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.61]) by smtp.gmail.com with ESMTPSA id l24sm6133229pff.151.2019.09.25.11.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 11:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eck7z4xU6rWZDIf+jUdftaZDf15l360hvN4eD+K3cX0=; b=S0QUhfurjE0ohyg7NT/RKXb3JlbA3RVowbnV81ytUzRzUMh+Jxu4ilASjWByY9HigY HPySyI2KtyBf9V8sCG0xP3OXjt5qWsNYO69pZ5pM9yUbbd5VSsaBxHHRDZUprFk7Kgfj cqA/GoYK0RAzynx5LlV38k74W4hJ8g5u5Q1M+dsKx8Bri2LtWhkPvb7jg/OaNr0+AHFz 0z1JBZHQ+TzRCJ9oxqxBXQ8kmkdU18lmv1612iqwnejBlMGV4ZmbuA8tMWweJEvVlrZl pBqHtojT2n5dAcSwfBJbFQn8BsSBo+sUk1jxyRv92pKSV2Hb0IwwXqulP+T9HPAHNzuq 9v7g== 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=Eck7z4xU6rWZDIf+jUdftaZDf15l360hvN4eD+K3cX0=; b=FY+gjpLmRL5yRMQY0yKicXU6HGMjIeF4U2KNOryOE+OahOR428Orv2t241oc/fiDOo t5kAAgnBVVzeA2ND/TMyFGO73sOtovkV4OMQkDlM+UfmkNoH+0hixMiAFNu0AYcikZaF VSdDjWCNeCVaIcAnfbVR7j9JMQjyc7GcYXstYW9Pj+zVDNlqrbtnBc18+NS860THr+JH ItRa84qA5e7thyU0YxzqdAxEyprov/XLkOZRnHdJVmpms+5Ny0ixor+XacInQLUJneJo c5RkOfX5Xn7gk7eXGzniTasqxzjh2UHueow7mI+VxNvmGbROV/QvVXRjPRPae/BMesCU p/cA== X-Gm-Message-State: APjAAAUjwKuq9MCs5znhXxI815gPrlPBroFYIfqhUMqDv13FxXsBh8Ww nQv5K7dXhYJizfbRDuy/mxUFY0OXRAs= X-Google-Smtp-Source: APXvYqzXa1RyyUxY3xwA6SKOhSea/TiWF0IPWqBS5YVtCF+0uIG3puPp5LAEsUVnY0hX4rMqXdwg2A== X-Received: by 2002:a17:902:654a:: with SMTP id d10mr10653303pln.199.1569437173816; Wed, 25 Sep 2019 11:46:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/16] cputlb: Pass retaddr to tb_check_watchpoint Date: Wed, 25 Sep 2019 11:45:48 -0700 Message-Id: <20190925184548.30673-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190925184548.30673-1-richard.henderson@linaro.org> References: <20190925184548.30673-1-richard.henderson@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: 2607:f8b0:4864:20::630 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Fixes the previous TLB_WATCHPOINT patches because we are currently failing to set cpu->mem_io_pc with the call to cpu_check_watchpoint. Pass down the retaddr directly because it's readily available. Fixes: 50b107c5d61 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- accel/tcg/translate-all.h | 2 +- accel/tcg/translate-all.c | 6 +++--- exec.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 135c1ea96a..a557b4e2bb 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -30,7 +30,7 @@ void tb_invalidate_phys_page_fast(struct page_collection = *pages, tb_page_addr_t start, int len, uintptr_t retaddr); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d); -void tb_check_watchpoint(CPUState *cpu); +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr); =20 #ifdef CONFIG_USER_ONLY int page_unprotect(target_ulong address, uintptr_t pc); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index db77fb221b..66d4bc4341 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2142,16 +2142,16 @@ static bool tb_invalidate_phys_page(tb_page_addr_t = addr, uintptr_t pc) #endif =20 /* user-mode: call with mmap_lock held */ -void tb_check_watchpoint(CPUState *cpu) +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) { TranslationBlock *tb; =20 assert_memory_lock(); =20 - tb =3D tcg_tb_lookup(cpu->mem_io_pc); + tb =3D tcg_tb_lookup(retaddr); if (tb) { /* We can use retranslation to find the PC. */ - cpu_restore_state_from_tb(cpu, tb, cpu->mem_io_pc, true); + cpu_restore_state_from_tb(cpu, tb, retaddr, true); tb_phys_invalidate(tb, -1); } else { /* The exception probably happened in a helper. The CPU state sho= uld diff --git a/exec.c b/exec.c index b3df826039..8a0a6613b1 100644 --- a/exec.c +++ b/exec.c @@ -2758,7 +2758,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, = vaddr len, cpu->watchpoint_hit =3D wp; =20 mmap_lock(); - tb_check_watchpoint(cpu); + tb_check_watchpoint(cpu, ra); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index =3D EXCP_DEBUG; mmap_unlock(); --=20 2.17.1