From patchwork Tue Sep 3 16:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172853 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp94220ily; Tue, 3 Sep 2019 09:39:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/OIq2egI+K4RYJYtC/dhTSrmSOkLgmSyr7bHbUXs70NQ3QatYUOvUu7f+mHdW5mPirpd2 X-Received: by 2002:a37:a91:: with SMTP id 139mr11887340qkk.418.1567528787054; Tue, 03 Sep 2019 09:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567528787; cv=none; d=google.com; s=arc-20160816; b=AQxtCQJrg1cu/GakvxMdMjbOPSKbvizy+VY3oXgYZtISZiKmHub+cv4WsCS+dIXvFO Uj3tF7uE5TS5+76UXOe0uxB8tTq/UjKIVi8Jn23/CyHTx7C9nw3TkuWaXDBD4yf3I5Zq 0+KZ5CZCW1p8rESLXChR7DbpOupQBcTf706xg5IILrnxCxsXwLtJrO7Z0bsV2LI2Ckws 5oK1LsjDASIvTQ1mF5qOlpPVcvjo+0vs3QCpdJTShhfCLEOYYDGUhRXbMfyY7SqQtpqi PSB+LgtGA2ax31e7eoBXINxHHpD9/agovAdKPuYOu06KOVnpA97LTnHuUgP2DhjpNPbA z50Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7dARXMfy5m/YnyllejYFpw51kHS2wq0N+31r2HBVYEo=; b=zELAc0J0UiqOmui6cpsf2pF2JNqXcmDK5FVEALXAeeN5W48MDr/EpLM+DZY1K7hiHP 7+6x1xxcg3bZg7ARVx6VyYcMY5xeWntBvJgPbaukJYxxwnZuNV0eFyhb2LtARuF/Lr6u utLqp9SPb6Do/jXDbRxF8UcOAdf/+1BNv37aow5ZVemnYdgPtJI/xFfQn5wBwo0hrdsM 03T0quASyL3lPV85VpaYi4WXoq41oEeF/9L/7gLRb73gc8V01c+zQi70O8RMHTN4R2A6 PcUAQXq8fVmFdb6Ekqm2O9MRqRDW74wwWx2f23BkkycLDoDd9lhSjY1NfiNv/GGg8whk dM7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BsfNrrie; 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=fail (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 g27si13613518qte.11.2019.09.03.09.39.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Sep 2019 09:39:47 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=BsfNrrie; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5BqM-0000BY-9Y for patch@linaro.org; Tue, 03 Sep 2019 12:39:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37408) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5BNA-0001aW-7L for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5BN9-0003xb-5Z for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:36 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:42530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5BN9-0003xA-08 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:35 -0400 Received: by mail-pg1-x536.google.com with SMTP id p3so9387936pgb.9 for ; Tue, 03 Sep 2019 09:09:34 -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=7dARXMfy5m/YnyllejYFpw51kHS2wq0N+31r2HBVYEo=; b=BsfNrrieMqEkKeIZJ0S210hTrX2/yOWEJfg3+2Dqj+T6z+6WhORWt2mrf8m9n3XrZs RAYGnwFGskJyXtGWRtA1nyljGUnEe3ILbL+rnK9HH8bvfPCRXy4KRn4hV/MEOkkxky0r dGI/D/EO9zoF2h41VbTpGgkGsjOk8A8vHIGlVOR7m81/NCe7bg9HsJEVffuiW/UDxiOI Gt+wbiAjF+K3TZo8um+nMPT7T4vhnawAJ4M4Kgghoq7NsGp/LWoPAKxYAia6r0Y+ZKar Psqj8zXn22tF9cDvoaCgITZ/855bFhLzmwjbeDfacP23e1WFIfJlOV/gOpa+SQK7GXSK tH5w== 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=7dARXMfy5m/YnyllejYFpw51kHS2wq0N+31r2HBVYEo=; b=BEiMJFwZWuLTWqczQtroMk0IdLR/rAf0HRwOXe78wXD7kEG+Msg8tOZ9vyd9q+pw9w j/zb3Sjkerpi4gANjPcYoWoE5XZU7ohWvjNAZPEay/e5Sdc77N+7gTH2YID2OwVX7J+X s/olUbuUm7wzm32P1p4zIg4iX+W24J8Xzzfjvor3m4TvAOL5f3bVMDuY+xFVupoee/Mz TaEeSJF0SRU2JY/oEgjodKiLDpjgBHUzShVEf/4F4QVfl5MMsSG8BhKQEx50JxbS8vl3 /Na5fTtfydieNVjLUAQfuyYkhNLeYEwAzZOtQZoH4O59S++ZX7h4e5r9wjYzpJ/NGHhk xdsg== X-Gm-Message-State: APjAAAWRxbzNURw5NvASscw8JvrFojU5xc8HjnB02JvYstcLdhU7a6a6 SYDYSiTA2ih66G8tO3/WZWx5fCsJBlM= X-Received: by 2002:aa7:9aa5:: with SMTP id x5mr5209710pfi.16.1567526973716; Tue, 03 Sep 2019 09:09:33 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id 127sm28089711pfy.56.2019.09.03.09.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 09:09:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 09:08:49 -0700 Message-Id: <20190903160858.5296-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903160858.5296-1-richard.henderson@linaro.org> References: <20190903160858.5296-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::536 Subject: [Qemu-devel] [PATCH 27/36] tcg: Check for watchpoints in probe_write() 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, David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let size > 0 indicate a promise to write to those bytes. Check for write watchpoints in the probed range. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand Message-Id: <20190823100741.9621-10-david@redhat.com> [rth: Recompute index after tlb_fill; check TLB_WATCHPOINT.] Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 9a9a626938..010c4c6e3c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1086,13 +1086,24 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, { uintptr_t index = tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + target_ulong tlb_addr = tlb_addr_write(entry); - if (!tlb_hit(tlb_addr_write(entry), addr)) { - /* TLB entry is for a different page */ + if (unlikely(!tlb_hit(tlb_addr, addr))) { if (!VICTIM_TLB_HIT(addr_write, addr)) { tlb_fill(env_cpu(env), addr, size, MMU_DATA_STORE, mmu_idx, retaddr); + /* TLB resize via tlb_fill may have moved the entry. */ + index = tlb_index(env, mmu_idx, addr); + entry = tlb_entry(env, mmu_idx, addr); } + tlb_addr = tlb_addr_write(entry); + } + + /* Handle watchpoints. */ + if ((tlb_addr & TLB_WATCHPOINT) && size > 0) { + cpu_check_watchpoint(env_cpu(env), addr, size, + env_tlb(env)->d[mmu_idx].iotlb[index].attrs, + BP_MEM_WRITE, retaddr); } }