From patchwork Fri May 8 15:43:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186404 Delivered-To: patch@linaro.org Received: by 2002:a92:8d81:0:0:0:0:0 with SMTP id w1csp108506ill; Fri, 8 May 2020 08:56:31 -0700 (PDT) X-Google-Smtp-Source: APiQypJSpotPPucENX5x61DW71Khd55LSWaVBTdVKcm3Qmgd5J5428ll5E3Pd8T5H/JaLN41lEYY X-Received: by 2002:a37:7785:: with SMTP id s127mr3224877qkc.117.1588953391584; Fri, 08 May 2020 08:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588953391; cv=none; d=google.com; s=arc-20160816; b=z3wyudiV7MWyK8lUE/hk6N1080OLcvcDJSnA66RqZZEI3FwDmMiAAJxMdCfhvB/aKT 1CarWEPRyTvdYazpsI1gzcQZks0Opl1b++TB/asa0Y4kINjSx4KjvQD6B+bbyJj/fr86 SKegvSjo3QIwZvCtq2wmf7OGvLgqK+GI34qG0ZP+6TsaMYCCj1plcrkGWS5/WDbg2dcW Gui8rxwzDZSz5e7a7o1gk+RX2Se6qBn3bPRC997Dg6WLqI1B+7igZtvAtuJsUBsedMSI NTc4ddMVJ4G9d5biUq7qpS+BcgLL0A+76gDAew/Jggrm+EsK9GAX5a3pz2S8YifYvMuc oItw== 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=4tSyrjuk3Om51Zcagt3t6yh4FkYKfOOT3yWLv6tJ2Vs=; b=jP/vEOdtHtnYAr5n3Z9PHCFgCHs2EPhJOGNJfGjjgm08x/KtpEFyS8qeCoEPPdEBvK a+9JrJPuqzNsbvm+N6pqCT7ORtQx8pVe/Drkahh5nrWmyM4TCNzIm4eljGuaPLF3nW7f jkFaWwRC+IwhwChEDY6UGK00zGoC85QWE0cEqqYTsfykxBmHt2yL1Ao2JMQ+7iCb0f5A PsWuOjufAFn8FZzEV1Qq4BEpJZ4+XD7CDrUwLvS0IgqRt6YCujIUvstDTnMVX1mJJRKJ 6U8SyPieNfAF2FUUOjEq32y8yczlLjjEeUEBOjy/yqiyfisuXBS/Yjdg82BneuzfBAGa Qorw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRxo0fms; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::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. [2001:470:142::17]) by mx.google.com with ESMTPS id 25si1267646qky.86.2020.05.08.08.56.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 May 2020 08:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::17 as permitted sender) client-ip=2001:470:142::17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRxo0fms; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:470:142::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]:34822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX5MV-0005sp-1l for patch@linaro.org; Fri, 08 May 2020 11:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX5Ap-0007qb-SD for qemu-devel@nongnu.org; Fri, 08 May 2020 11:44:27 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:46381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX5Al-0005cK-TV for qemu-devel@nongnu.org; Fri, 08 May 2020 11:44:27 -0400 Received: by mail-pf1-x441.google.com with SMTP id 145so1109458pfw.13 for ; Fri, 08 May 2020 08:44:23 -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=4tSyrjuk3Om51Zcagt3t6yh4FkYKfOOT3yWLv6tJ2Vs=; b=yRxo0fmsPJZy3pAAxuPuQQ42lBW8toRp/JFfnGF5oG+Z+pDD8/2z44+cDvQEpIE8z3 1zT6iHwfkaoVnrainzpPuxINdCSoao4+pyrSqaIqFMLh1OaaFnIaTxkPybEhts5YTPnW hBhPDaoxtg0FgeO3XW4h7N79DCXmYJut+6ayL2zjRFmIKRnPkPniiQyuhmSzX9QwL+Az 5TrbdRx0KVkzi52NG4BrmnTBFwHY1cQKX1bLrYNf4k0HVMHci1NSIp+W/pOyVKiQeNgq 0SOxO3dB75DSn05X2ry3pvVtEEI/TFZOX8BCn1JIceCoCl3HznBGhbP/hVqEk5FuHodB GJyw== 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=4tSyrjuk3Om51Zcagt3t6yh4FkYKfOOT3yWLv6tJ2Vs=; b=Nj+3P/C0MaFN5HDId3AeRd7tTTiDNTXeoSghRQmxseLeDLUSQzIoLd6YlfaBiY0inS SAfvsprG6BlG57JKMEcx8u6LzK6KU//ls652cGwxEdO3x7xbrcTaHQSNUjAPAZ6I86df 8DEGe2P2uRaBfFqrFh5j0TPbywrkUl0AUAgIEJ2BfVlTLTk2jr6sQXbeumk6AdwxvNtq 3/Bew0ZvEeihhSi2oBu7O1nftB0tVFMs1koIBjtF0MCqt4A0BU+n6izo8C7NE/4h8Yhe 5cK90ngKFzc7hcMS1vdDNH00OhRghOk/ErlR/McOSIFHMzbned45QOsF19DL9dj9YXfV YFAQ== X-Gm-Message-State: AGi0PuY+D3QXc4GFmX1za2bYAkoX+f+BY80Cm9h6tsrbAvu/XSnhIJM1 WuT14CSXfNaExvGkk/waKyfDNbXo+4M= X-Received: by 2002:a63:3c0a:: with SMTP id j10mr2622505pga.373.1588952662227; Fri, 08 May 2020 08:44:22 -0700 (PDT) Received: from localhost.localdomain (174-21-149-226.tukw.qwest.net. [174.21.149.226]) by smtp.gmail.com with ESMTPSA id o99sm2727662pjo.8.2020.05.08.08.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 08:44:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 12/19] target/arm: Handle watchpoints in sve_ld1_r Date: Fri, 8 May 2020 08:43:52 -0700 Message-Id: <20200508154359.7494-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200508154359.7494-1-richard.henderson@linaro.org> References: <20200508154359.7494-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Handle all of the watchpoints for active elements all at once, before we've modified the vector register. This removes the TLB_WATCHPOINT bit from page[].flags, which means that we can use the normal fast path via RAM. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/sve_helper.c | 72 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 6bae342a17..7992a569b0 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -4371,6 +4371,70 @@ static bool sve_cont_ldst_pages(SVEContLdSt *info, SVEContFault fault, return have_work; } +static void sve_cont_ldst_watchpoints(SVEContLdSt *info, CPUARMState *env, + uint64_t *vg, target_ulong addr, + int esize, int msize, int wp_access, + uintptr_t retaddr) +{ +#ifndef CONFIG_USER_ONLY + intptr_t mem_off, reg_off, reg_last; + int flags0 = info->page[0].flags; + int flags1 = info->page[1].flags; + + if (likely(!((flags0 | flags1) & TLB_WATCHPOINT))) { + return; + } + + /* Indicate that watchpoints are handled. */ + info->page[0].flags = flags0 & ~TLB_WATCHPOINT; + info->page[1].flags = flags1 & ~TLB_WATCHPOINT; + + if (flags0 & TLB_WATCHPOINT) { + mem_off = info->mem_off_first[0]; + reg_off = info->reg_off_first[0]; + reg_last = info->reg_off_last[0]; + + while (reg_off <= reg_last) { + uint64_t pg = vg[reg_off >> 6]; + do { + if ((pg >> (reg_off & 63)) & 1) { + cpu_check_watchpoint(env_cpu(env), addr + mem_off, + msize, info->page[0].attrs, + wp_access, retaddr); + } + reg_off += esize; + mem_off += msize; + } while (reg_off <= reg_last && (reg_off & 63)); + } + } + + mem_off = info->mem_off_split; + if (mem_off >= 0) { + cpu_check_watchpoint(env_cpu(env), addr + mem_off, msize, + info->page[0].attrs, wp_access, retaddr); + } + + mem_off = info->mem_off_first[1]; + if ((flags1 & TLB_WATCHPOINT) && mem_off >= 0) { + reg_off = info->reg_off_first[1]; + reg_last = info->reg_off_last[1]; + + do { + uint64_t pg = vg[reg_off >> 6]; + do { + if ((pg >> (reg_off & 63)) & 1) { + cpu_check_watchpoint(env_cpu(env), addr + mem_off, + msize, info->page[1].attrs, + wp_access, retaddr); + } + reg_off += esize; + mem_off += msize; + } while (reg_off & 63); + } while (reg_off <= reg_last); + } +#endif +} + /* * The result of tlb_vaddr_to_host for user-only is just g2h(x), * which is always non-null. Elide the useless test. @@ -4412,13 +4476,19 @@ void sve_ld1_r(CPUARMState *env, uint64_t *vg, const target_ulong addr, /* Probe the page(s). Exit with exception for any invalid page. */ sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, retaddr); + /* Handle watchpoints for all active elements. */ + sve_cont_ldst_watchpoints(&info, env, vg, addr, 1 << esz, 1 << msz, + BP_MEM_READ, retaddr); + + /* TODO: MTE check. */ + flags = info.page[0].flags | info.page[1].flags; if (unlikely(flags != 0)) { #ifdef CONFIG_USER_ONLY g_assert_not_reached(); #else /* - * At least one page includes MMIO (or watchpoints). + * At least one page includes MMIO. * Any bus operation can fail with cpu_transaction_failed, * which for ARM will raise SyncExternal. Perform the load * into scratch memory to preserve register state until the end.