From patchwork Tue Jun 2 16:49:11 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: 187378 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp4136139ilb; Tue, 2 Jun 2020 09:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMcbNEsEf4oLckuNa6UZ2BWbw8XxU6MJIQv5j6yNnKk4zGHuDLxbanNrZq+aDs7TMVBPWE X-Received: by 2002:a25:9387:: with SMTP id a7mr40950886ybm.1.1591116593934; Tue, 02 Jun 2020 09:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591116593; cv=none; d=google.com; s=arc-20160816; b=Zek+B0k7T2I8AXHPSA3EntTt/7SU+g/XxFFCjJV9GDifAWwaVRV9FQQlNr63jDeKeA OEl/B8IEWi68LqTlGZ+NhH3Ufxf9ZJB67ercBe460mluUXPSMRZWWVbvnzFl4wVDn5la yUJMIIX2ZfVwDRLn6zcWM7exVcYXQIzQhBGp5UhUu7bfAMtutkO/wR8s1kfhlACx49N1 QcYHs/8ZxF+V1/WY3aUQVw1AcJv+l5iL6APwjyf3ZBzxefOwTRS7mx6OVvdKxPp/UM4J c1XKRWEt/goch93QxbLe3RVItjzXVRFpZf941xhsybKI7Kv+c3wLMgcO0uCx2XFbh7uc 7law== 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=Qu7tvER0IKqrMliw7MGPzBrrSEYyVxBvPs7B5vkCjKg=; b=CT3RLm3Li8qwuSedc2KGYb3Ms5pDMaIHdoRE3v76gnhrBArhVGisAidFR8dcNfu8rf 8cUEWzS6figfASsA0iXe0RtYAekkHTft7h8sKXM97d28CV7ttylimIltHor2mgOuCRNN CeYuQZVq5JrLWEa9fZ5FqL2RVF3xqnjHjwbcymx0LguEVX3G75v48GTGgxa8U6tQ3aVA m71e7VWsQqo/HLigCDLEp4z3B8X1cqwB/g8eqoGXj2yEWf9QVzhMtSJaJJ6EV5UQWlWq s7LKeRFPL2fDXnmAvS1bw1D2vQhpBZePZO4KxszM/9KW1n2Of79oDqkt8Kttcx4RPxff 3Wig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fl1x2PKz; 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 v203si2381404ybv.150.2020.06.02.09.49.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 09:49:53 -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=fl1x2PKz; 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]:57480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgA6r-0007mG-EA for patch@linaro.org; Tue, 02 Jun 2020 12:49:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgA6P-0007jx-O7 for qemu-devel@nongnu.org; Tue, 02 Jun 2020 12:49:25 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:53823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgA6O-0005OE-Jz for qemu-devel@nongnu.org; Tue, 02 Jun 2020 12:49:25 -0400 Received: by mail-wm1-x342.google.com with SMTP id l26so3598564wme.3 for ; Tue, 02 Jun 2020 09:49:24 -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=Qu7tvER0IKqrMliw7MGPzBrrSEYyVxBvPs7B5vkCjKg=; b=fl1x2PKz2dTddLBPBFB5XbLaJGvQ9SmsOZzb5qgeFiEEXdakwPbTMB8a29GYTl74WY 1ubZI+rYf8lLmToekeGLra0JYd7JPoh/FwJKE3yd1vFJpEm9KopWatpKKkKKA8ncZt/k sWXQ2lCoIl8UXl7sC0oP0ub27z60AckFkg+TDm+7bXENrwDCV/vti18oIjg6h05MKoSi t+d6aNCPR6D6WIiynC6gRpDMd3inHB1LQOrwqL5B+Cre6Bekgw7ABOzwI45YB49jLqFp xw7QBCxeykfgueLYPiQQJwLFXhvt3Qj0ur1RkAqUnfXa2tFTCSsZG+nM7Rb6pv4K3k3L k4Qw== 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=Qu7tvER0IKqrMliw7MGPzBrrSEYyVxBvPs7B5vkCjKg=; b=pbQ6GgZbl4ARb4WK3bcpJPXrCgZiAL13H0825ysIv8ggNLDhYhEskvNA7esbsAYmlX NRfBdePQx87Uqw9s3cGfoY5cqjp3+tqoI//b/rQePzvLBjt3Og9cyJ2J2+1uzrqp9NgS y8ukK6BITaI36OdH3ZxSxhpIdhQZcC3jEqQysw6lBXN7yg5bm//LfZVePHsmDesEH+y5 B9xeiNfwWOm5Yw7GBsYjwiZiAWwME6u2ooWQqr4rYIEp5e5dCsFDD9TFe4B2/zc9yF50 kHcb3dbRo3s7BsOOraHSmfqfQhMK1LLQPV+nKUhdz3K4zDEXnd8E4iJMuNTEKHsnnx9q IS7g== X-Gm-Message-State: AOAM530+aTxRYl89iIAUN26kt1AROVnA++MnwIWYTrzMduzwWmu6aTYx p7RwnXc8X2zM8wsNO6CLIa/Wkg== X-Received: by 2002:a7b:c0cc:: with SMTP id s12mr5061846wmh.111.1591116562723; Tue, 02 Jun 2020 09:49:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x18sm346902wmi.35.2020.06.02.09.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 09:49:21 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B9F521FF7E; Tue, 2 Jun 2020 17:49:20 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [RFC PATCH] exec: flush the whole TLB if a watchpoint crosses a page boundary Date: Tue, 2 Jun 2020 17:49:11 +0100 Message-Id: <20200602164911.5706-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 --- exec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/exec.c b/exec.c index 5162f0d12f9..851ac180fe7 100644 --- a/exec.c +++ b/exec.c @@ -1056,7 +1056,11 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, QTAILQ_INSERT_TAIL(&cpu->watchpoints, wp, entry); } - tlb_flush_page(cpu, addr); + if (((addr + len) & TARGET_PAGE_MASK) != (addr & TARGET_PAGE_MASK)) { + tlb_flush(cpu); + } else { + tlb_flush_page(cpu, addr); + } if (watchpoint) *watchpoint = wp;