From patchwork Tue Jun 9 10:37:56 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: 187642 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp401429ilo; Tue, 9 Jun 2020 03:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDmZJ9ANfo2PjLGp4Uop2rzjvESUFugGqbzjWbO+WzpGzu77mStQSURNfvpWDCDZb9ibR0 X-Received: by 2002:a5b:b49:: with SMTP id b9mr3672ybr.343.1591699270233; Tue, 09 Jun 2020 03:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591699270; cv=none; d=google.com; s=arc-20160816; b=WxP49BLQOQ7QmLpLBvn0ICUWVMQqOoT5rLi0zSzy/O+tObkP0qh0I+oKxMM/2ddCBb Kw7Ujp3lj4fZK2V2RPC3oB+jS6bMx//z7Bmk6u1Ui0mNqQYdLabrz3C0qHrM8yNpjDhH 5NsPoTnEGy2vtGH/bXc1J8avwcMfOXlrjN2szV7VZiK/204xpDFnvmq9NRgBVCOPsn5y E0ad5c/3SikBQ2DQKswKBzfsa+fnOYBeZ+JTMyCSGue3f0PufObCRppp/Uy4WpWt7YKI iquLAHV4u79ba5T+t9snYnyh/K390DAF3QimD/dajfri/A7lvaeijKvAB2b4i9uYsyrh n0sg== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=p4FX53f1uEMaQTO+XmVG4SpfpCIx1tkSo1o781lno5w=; b=Uxidv9pBjSuN/N4b17fvg8IaNcXCdNR56uZEPZVExmiFjXbfupNNiRAxLHdW4Eif3O 6Qs9gzBhwnTYzxlmNWyOvxCzcA1hzwmG3bP0ydgt78Pc3R0SwCQreUAGJAzDjtNEjVKm CLDCsOGXPI/eYob1B0bFAO/NwUB3Z/hPfZYBJplNOT4qgyu5qOpu2b5AywXS6itg7aOR 53OCUWJCuP87TXVItdbpFifL0Iar/fosZP50Y7NyVe+wMnmnNkOQd5t/AHyit5sL9Fyt fxi6whI2sM1/2fYIUXSwd7HMVk8/yIaSoH10nLlclKa50jkdic9ERa/d8e2Aiz2LGcfY 0jAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="wQEW/nUk"; 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 x7si2708344ybg.40.2020.06.09.03.41.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 03:41:10 -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="wQEW/nUk"; 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]:39420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jibgr-0002Ym-Jz for patch@linaro.org; Tue, 09 Jun 2020 06:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jibe7-0007am-BX for qemu-devel@nongnu.org; Tue, 09 Jun 2020 06:38:19 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:54584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jibe4-0004NW-Qt for qemu-devel@nongnu.org; Tue, 09 Jun 2020 06:38:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id g10so2314769wmh.4 for ; Tue, 09 Jun 2020 03:38:16 -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=p4FX53f1uEMaQTO+XmVG4SpfpCIx1tkSo1o781lno5w=; b=wQEW/nUkjh2tW9rSCF5dE1raID99Ho8cPoz/ucxoEFknft0CFH6ILrQOVzaydaadQC oWWRfWh/EJfGUrvJnWhQchnqlc9Jh6YJ18GoQFXNVazcSaxKj6Ojoe0S6WXdsNy4MYOz o+enQH8Jgqn+F5z6tvLIwACxwuL1/6L8jP5lIbXGUAVQzXBKP4UYj+iy2OM5Nzy/PiTt N1ylY6MXBHj6KCAk4FCMh9W3luxlpieVT6P3lz8oxew5wJRDHr9dG/vwAS2gG2Ekn7yR Du1EAiPAreIb0AqSR/awtMOUo7JvPO+qcvExSUI8Mb1+j5zGuoIeo5FXwCdv/0KhmNp5 lf/w== 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=p4FX53f1uEMaQTO+XmVG4SpfpCIx1tkSo1o781lno5w=; b=KwvOTqF+NG5SdB7tYccf2P0Dorgn1Ef67Y7VAONCGi08xoe3KCMcGe3wRL2FP0zi7O yi5T5VpIsBYRgT/wH5btZCw/Pu959yh+XDq/Jw2/uP+sUh/ZhTubfuLmMyv++ELCZqPM lVr9YQFZRM7RfcTAnWQxPRNAxCqbtA6kPNJH5dq6W4k8zkoF5XQv92Y5Dg9A5RH2YOc3 ERd2BeSQ1reuhjj5eFcFZ213jk1a/2ZKo/CP6clgvp2WDxu3Cpt9de3x+XMrXfhX82iN zG6o3UXbCodUOzrxbu8PuLWQY26nJHjHUwDN9Yo0jQ4uRlAkwXuBeXWe8lNeY27UAQPy hyTQ== X-Gm-Message-State: AOAM532H7DLLupxKrDV+eRWiE5pKJvzmvyt/6yBGdX42MS+bjvaBJ0hQ NcpnMflk8W5k1jSHX9qUmY/3BA== X-Received: by 2002:a1c:2044:: with SMTP id g65mr3646039wmg.16.1591699095215; Tue, 09 Jun 2020 03:38:15 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c5sm3092785wrb.72.2020.06.09.03.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:38:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A03191FF90; Tue, 9 Jun 2020 11:38:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 04/17] exec: flush the whole TLB if a watchpoint crosses a page boundary Date: Tue, 9 Jun 2020 11:37:56 +0100 Message-Id: <20200609103809.23443-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200609103809.23443-1-alex.bennee@linaro.org> References: <20200609103809.23443-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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: Richard Henderson , qemu-devel@nongnu.org, Alexander Bulekov , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson 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 Reviewed-by: Richard Henderson Message-Id: <20200605154929.26910-5-alex.bennee@linaro.org> -- 2.20.1 diff --git a/exec.c b/exec.c index be4be2df3a1..a0bf9d61c87 100644 --- a/exec.c +++ b/exec.c @@ -1038,6 +1038,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) { @@ -1058,7 +1059,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;