From patchwork Mon Mar 6 00:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 659170 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1574135wrb; Sun, 5 Mar 2023 16:47:39 -0800 (PST) X-Google-Smtp-Source: AK7set/iRLN10sLq1vqvF2JKnDubiZ0Df9CvsF3sOcT8pMPIrIZ6EK8HQmIXre9EdqY/NjMv5xuN X-Received: by 2002:a05:622a:1988:b0:3b8:4951:57b8 with SMTP id u8-20020a05622a198800b003b8495157b8mr16751086qtc.15.1678063659765; Sun, 05 Mar 2023 16:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678063659; cv=none; d=google.com; s=arc-20160816; b=Nr8Q2OFOVW+nxfeTAbRBw8IOvoEofKa0a0vrEf69qCgebzGPlKulb7611x+4FneAgy Y5SdSojnsQVJ1zexF76DzIEL2NUFseW60ibSFhvhJXQMPrg39Xdckr++8Hlp4eyokwcj Y/5NoYapUVec8eg4Y2pICG6GfT0qvZ6DHAhO2pfMlg8nKMK2726nHgp/ugkwetHPXyn0 ca8Pu2ldNVixLhMNe/zde1Xl2t35ZwJgeXZS83jkV1B5pwBXoxQbLrebhzKO0psC8Xwg jJJR+aeBctZjP/tQHnsp4xomx1qHOmIxvkDV93KIxJWnqdPyWPaNgdE4lFEH1bkzsMWt 6gsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lu/MZw7ErbSjkoIgOh3qSUYCyDOhbQRRQ4HpBsx5cCU=; b=vFFRDAYeOcih+DPjWDBrOOuEsCSH9dbXmONb9JCzFlhT07jg6idZE3oK2KU3l4ihE3 vHAzRMN+UQGnN78uCOtaCk1PqyPT7LDzbmanL3nSttLyohoBHdGD3TuXEcVWXiXGEONs mPT7uhP/2xWvUAzgK8L5lBFnMlnVjozZZSZJkMs1mrdCta2eFbvVD8/3RMm5ON4XplLE PFpOKOE+WbFtplbhw4VsA4kxT0r/dp1EkB7lzO/kRy+/e2irOAGl+Q/zV/8oOEe1nX+O ymCy1ASEDV6XJ/7iywsEHKJ12dK2EvvmApVmvbfMG1Wg6S5YIThEBxac64XXeddNp4Tn 8LpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uNkumGI+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p12-20020ac8408c000000b003b6914d574dsi6041897qtl.157.2023.03.05.16.47.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Mar 2023 16:47:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uNkumGI+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYytc-0004P8-2f; Sun, 05 Mar 2023 19:40:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYyta-0004OJ-Qz for qemu-devel@nongnu.org; Sun, 05 Mar 2023 19:40:07 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pYytY-0006Xr-KG for qemu-devel@nongnu.org; Sun, 05 Mar 2023 19:40:06 -0500 Received: by mail-pl1-x633.google.com with SMTP id n6so8512123plf.5 for ; Sun, 05 Mar 2023 16:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678063203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lu/MZw7ErbSjkoIgOh3qSUYCyDOhbQRRQ4HpBsx5cCU=; b=uNkumGI+scY6P1kw7RNVWOzqHpjzlnIOZI5Ceg+ctZdp4UkdBFL74kbONSfQ3guayd SvXdlUTRNYWPJ2WWgyJqYcFPgH0cnPaMc+4bJid5a5LR4T2sBSeawtuGCV7jDt99+lui gb7A26f7Zs8RgW12ojHPRXdwd3h+3hDNbd2yx9/o4QFB/og5ADwi3Tqri5yaJAV5kjab VoOLnGrZ4/G2k3309aT/IwXOCgJ6BkoK4E/0OnsuFR3pzk/Xx9B0zUxSchSnGyAJDm4f CntgVww3+vYblxZTzX7vn3hYKV828mcHikSpfy+hc5BXbjcbDAyfois5h0iLMW0RBEch gVAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678063203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lu/MZw7ErbSjkoIgOh3qSUYCyDOhbQRRQ4HpBsx5cCU=; b=vKJa0ak2VUSJ2fUP+WJlgnURkB4RTdm+ZO2D6ajT+XZ8Pd29rkE5mt2dfMgR85XGRv bqCWXbFsdEgCDgr2szIcY1MzECW0DT4Q1paCpC8z7fgQXvDeFxJF8P82fkTkiLRy/qy1 kGBs4Wt5rybAfDH6yfGUhQJTE14PiBHf2bRDV/bBNsSEid8gbZqI4qkJPuNO24PI47LZ 4bRYBROWRl6NoOps3IBY+NV4ctKPiRd0a8LnIR5fnoR96L4UwRQ/eh9CKFRCQjJ2Ae6v 7y2PuWMEbRKLhJ+V5FMZF3YSWzc9ZZ/4K5bNf8IfH1Ptx7GlNXayIGVWF3Z94i3vxQPS zCYw== X-Gm-Message-State: AO0yUKWiEG6aR1AaDDZKAeDm53ZLizNViE4mNr9DfdmKM6D1hEJBApWL F6A4ykUwp7S1SHBVkbvIBPflwXRRe5twBUZLuNyTew== X-Received: by 2002:a17:90b:3a88:b0:237:b702:4958 with SMTP id om8-20020a17090b3a8800b00237b7024958mr9678127pjb.38.1678063203139; Sun, 05 Mar 2023 16:40:03 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:87cc:49bb:2900:c08b]) by smtp.gmail.com with ESMTPSA id r13-20020a17090b050d00b002372106a5c2sm6567901pjz.37.2023.03.05.16.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 16:40:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PULL 08/84] accel/tcg: Trigger watchpoints from atomic_mmu_lookup Date: Sun, 5 Mar 2023 16:38:38 -0800 Message-Id: <20230306003954.1866998-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306003954.1866998-1-richard.henderson@linaro.org> References: <20230306003954.1866998-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fixes a bug in that we weren't reporting these changes. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index b49fb0d754..e984a98dc4 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1767,6 +1767,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, CPUTLBEntry *tlbe; target_ulong tlb_addr; void *hostaddr; + CPUTLBEntryFull *full; tcg_debug_assert(mmu_idx < NB_MMU_MODES); @@ -1805,17 +1806,26 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, tlb_addr = tlb_addr_write(tlbe) & ~TLB_INVALID_MASK; } - /* Let the guest notice RMW on a write-only page. */ - if ((prot & PAGE_READ) && - unlikely(tlbe->addr_read != (tlb_addr & ~TLB_NOTDIRTY))) { - tlb_fill(env_cpu(env), addr, size, - MMU_DATA_LOAD, mmu_idx, retaddr); + if (prot & PAGE_READ) { /* - * Since we don't support reads and writes to different addresses, - * and we do have the proper page loaded for write, this shouldn't - * ever return. But just in case, handle via stop-the-world. + * Let the guest notice RMW on a write-only page. + * We have just verified that the page is writable. + * Subpage lookups may have left TLB_INVALID_MASK set, + * but addr_read will only be -1 if PAGE_READ was unset. */ - goto stop_the_world; + if (unlikely(tlbe->addr_read == -1)) { + tlb_fill(env_cpu(env), addr, size, + MMU_DATA_LOAD, mmu_idx, retaddr); + /* + * Since we don't support reads and writes to different + * addresses, and we do have the proper page loaded for + * write, this shouldn't ever return. But just in case, + * handle via stop-the-world. + */ + goto stop_the_world; + } + /* Collect TLB_WATCHPOINT for read. */ + tlb_addr |= tlbe->addr_read; } } else /* if (prot & PAGE_READ) */ { tlb_addr = tlbe->addr_read; @@ -1838,10 +1848,18 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, } hostaddr = (void *)((uintptr_t)addr + tlbe->addend); + full = &env_tlb(env)->d[mmu_idx].fulltlb[index]; if (unlikely(tlb_addr & TLB_NOTDIRTY)) { - notdirty_write(env_cpu(env), addr, size, - &env_tlb(env)->d[mmu_idx].fulltlb[index], retaddr); + notdirty_write(env_cpu(env), addr, size, full, retaddr); + } + + if (unlikely(tlb_addr & TLB_WATCHPOINT)) { + QEMU_BUILD_BUG_ON(PAGE_READ != BP_MEM_READ); + QEMU_BUILD_BUG_ON(PAGE_WRITE != BP_MEM_WRITE); + /* therefore prot == watchpoint bits */ + cpu_check_watchpoint(env_cpu(env), addr, size, + full->attrs, prot, retaddr); } return hostaddr;