From patchwork Wed Jun 3 11:24:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 187447 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp429723ilo; Wed, 3 Jun 2020 04:25:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkTPwJ104yDbEUgM0wL57nXET8ERxUnsbjpQIMvcopt39CrOaZvqq/jwBdkv2hoEh1Pt66 X-Received: by 2002:a25:dfd6:: with SMTP id w205mr9160079ybg.216.1591183522331; Wed, 03 Jun 2020 04:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591183522; cv=none; d=google.com; s=arc-20160816; b=LKVoBk66C4JXj/6WJWRSepEDmP4r2P25vjBKESt2krdcy983nt2AB3iQTr1XHhYGHD 5WaJz7w8lLBlPi5MbeYTR7GHl0CwOUrRw9fVILe+3RittUBlCZiH4KEVbIKMdDFBzUbw Ikbyt80FLJ0Seaf7SQ7rzKqSvt8jntU60Il+Z7bZI3xBWTDepA/nfYhdwJFqQonlpkGR EcENwhDbG/kRBDpzwvtDWtwPwio4nmyBadyex0w3eHd9+asdLXGk0fsBg2/p7fpulMVv YyGqxjjdpLjJ55DYgkHEtSH/+pvvkAhFE56YR6hPanWbbqS2Tzp8AULbkzkLHqM3bC/M A53w== 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:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=jnj2c7tchtxxtkXbmzqQYHYZ9zjghpz3ssXi/A1ffqE=; b=nsfcRsQvzXQMx2vXz7wfio8EL7XThlDKqDnm9gS68qBFvCntzJk5BSQjAv0qaYe5YG pK83A/q1DYG/MYuxELl0ZTJudxM91+W2uvNykM5XgeZ6b2b7yO/yFcSuQrEvElFMecFX TYIYPd6ll0zttt87maxXuZGX48M2F55hZyBsDzUcDQfgLsDQgjQEupjSYJTeEp7kykLb FT4bbkZvXf//4h09C43H/m9D242hNsNz9cvTqge+1oM8u8rQltCC1rCW4/Bf+XcCOHBP bVHVSrRa2E/sgBXY3OZZ+ChS8fPi9LUDa2xc4xuuGfWv5CZlA9/MY1Lmfta0GBFgWWPE NY4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Odh7tpqH; 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 s46si1562358ybi.263.2020.06.03.04.25.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jun 2020 04:25:22 -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=Odh7tpqH; 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]:43416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgRWL-00072c-Sf for patch@linaro.org; Wed, 03 Jun 2020 07:25:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgRVt-00072U-8N for qemu-devel@nongnu.org; Wed, 03 Jun 2020 07:24:53 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgRVs-0006GM-24 for qemu-devel@nongnu.org; Wed, 03 Jun 2020 07:24:52 -0400 Received: by mail-wm1-x342.google.com with SMTP id g10so1539343wmh.4 for ; Wed, 03 Jun 2020 04:24: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:mime-version :content-transfer-encoding; bh=jnj2c7tchtxxtkXbmzqQYHYZ9zjghpz3ssXi/A1ffqE=; b=Odh7tpqHxLvJfH9MW37FvMQcSwov0UQyawvJ/ioRoMEhZ3JuLVWhwq5mAHx8+G5gew 9sXZhe4sw/eDJUHIW8L9Tjsdj5yQP8EGV+aDLC3Q8+qVh8V9MZ6JdJ0iESX5m9gT1wgm PP2Cqt3UFVfiL+GRzeitHLV7IrV5g1Vdi5DYhpL1R7cu7ecaagFOvbHHcWoLO9ObZ989 zfSpfzebbSEGqbmR0T8Z8F0+LfKvjCfRMlP6V68jdEriX6GhTijGed6DWkPyyqm1XhSZ KnogbgZBCZbXTP+vlVmbtT3kaHTtPGPGYonq1jsw3tSwpwjyVUidkDjzws7ubHpU2nrU U6fQ== 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:mime-version :content-transfer-encoding; bh=jnj2c7tchtxxtkXbmzqQYHYZ9zjghpz3ssXi/A1ffqE=; b=LqsOAw9zNdBcDV9/4Nqj3AjvHmEr8aVqApFjxXxDk0vA9ogFBkFwRsWygB4YfQ6eZI l6VHh6p26YJWGwGGelcNT19kDJTuhKTwV8TXMziuhtbFxsnRacn3vii4ViC4Jqme8UCW UHoiD26Zm8UFVlJfNNxIQ2U7+w4Oea8MoNZILCgvSXXF/KnDhsEohePaLnIjKAVO5CfW WCBYvQ1JPYHIznIJbd2xm8xz4kh6rlEkEsyPdxpjVtb+H+J00coV1tH33l3/9pfkYgQf QA9kNMLoa6vtyND8X9vj5p6X2LoPPo5mUE2rivGyTraOhzAc5ZrW9bnT8GJL09CDoPw8 zjxQ== X-Gm-Message-State: AOAM531M23YFFw5CHDLOCh8nVV2PukZdN2s2OakJE7vMdu9Ha48F4h2l tzQlOI3eYg1nnrDN8oZP7DMjng== X-Received: by 2002:a1c:2e4d:: with SMTP id u74mr8640854wmu.145.1591183490216; Wed, 03 Jun 2020 04:24:50 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i10sm2886446wrw.51.2020.06.03.04.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 04:24:48 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C221C1FF7E; Wed, 3 Jun 2020 12:24:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2] exec: flush the whole TLB if a watchpoint crosses a page boundary Date: Wed, 3 Jun 2020 12:24:42 +0100 Message-Id: <20200603112442.22833-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Alexander Bulekov , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no particular reason why you can't have a watchpoint in TCG that covers a large chunk of the address space. We could be clever about it but these cases are pretty rare and we can assume the user will expect a little performance degradation. NB: In my testing gdb will silently squash a watchpoint like: watch (char[0x7fffffffff]) *0x0 to a 4 byte watchpoint. Practically it will limit the maximum size based on max-value-size. However given enough of a tweak the sky is the limit. Reported-by: Alexander Bulekov Signed-off-by: Alex Bennée --- v2 - use cleaner in_page = -(addr | TARGET_PAGE_MASK) logic per rth --- exec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/exec.c b/exec.c index 5162f0d12f9..65a4376df37 100644 --- a/exec.c +++ b/exec.c @@ -1036,6 +1036,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, int flags, CPUWatchpoint **watchpoint) { CPUWatchpoint *wp; + vaddr in_page; /* forbid ranges which are empty or run off the end of the address space */ if (len == 0 || (addr + len - 1) < addr) { @@ -1056,7 +1057,12 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, QTAILQ_INSERT_TAIL(&cpu->watchpoints, wp, entry); } - tlb_flush_page(cpu, addr); + in_page = -(addr | TARGET_PAGE_MASK); + if (len <= in_page) { + tlb_flush_page(cpu, addr); + } else { + tlb_flush(cpu); + } if (watchpoint) *watchpoint = wp;