From patchwork Sun Sep 22 03:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174208 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1314198ill; Sat, 21 Sep 2019 21:10:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxweOc2fNxOraDikmefZl5+s8/GExaqjh83vYOKs4LD/YLz7fiJiVZi59xEZJuL/eAeVde3 X-Received: by 2002:a37:a696:: with SMTP id p144mr11935656qke.435.1569125458120; Sat, 21 Sep 2019 21:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569125458; cv=none; d=google.com; s=arc-20160816; b=sxYQlloLn7bLx9bPb0WYrntK0fp2b8/jpZGbFABRMyMqex2CX9cykQk8ZqEZ/1dffH n9ycpHq6YYgW5UrjhEy3EdKgQxvqEL/jwAE891H6JL5YC+a7x9LfClq9bkQjmxKeoIrm 4gWqumEJ5bq+GeuXrd7+39pr98j6mJ+ZmlOhy3brhG/UeJpx4ZGpsD6/HQzRzePD/ECD K82CJLJvFYIRNQj6umfVEKRuBfWbRiARnPb4FD2CLIQPyglDrl2YGiIPnmD16ab03fyD 3bLEajyJE/oqOlr+79cXdBPht9/BOKlho1qHWBVBh0PqrwY2R8eHqC2Bm58suhCshIlo a3VQ== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=KPC8SHNUPxOyD5nE9eJw1EVJI5wa1gb5+31JaucSTJfrxM2Uu2Apv/aYSNTjKdycRv cT2mOQNvdU/EMoWkgS+CvlX0JTeY+kD4XT+7qIKFG6IIfiP1kyB0K2j8YT4aRM6UaEcR NLnOxpbyEzLbq18/WAoek4BBBaodbF2CCZi0ImNACn0rgXLFSSsrbpfznsn4rbo5PBif QeG7j3aE9OQpk35eudHleeH5nAfB740vHLVhMGIp4uFM0e3qcimKHYjhmefAr68zeddd h4AYwu/GkS6chm32Y7XczpaiVU/qLyrMAJSMxrXjaoJy3pNY7kLsCNJwFr5WeMn1PJpa /cRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DTJ4aK9H; 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 h75si6204925qke.115.2019.09.21.21.10.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Sep 2019 21:10:58 -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=DTJ4aK9H; 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]:45084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBtD7-0000HI-1t for patch@linaro.org; Sun, 22 Sep 2019 00:10:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40998) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBsy8-0001yr-6H for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBsy6-0008Mb-Qd for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:28 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBsy6-0008MK-Jy for qemu-devel@nongnu.org; Sat, 21 Sep 2019 23:55:26 -0400 Received: by mail-pg1-x543.google.com with SMTP id d4so2902118pgd.10 for ; Sat, 21 Sep 2019 20:55:26 -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=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=DTJ4aK9HwfKrjitfJTj/ZwefS8YvEmDtxQuoM2xXoflI9QZegGjQVE4hXF5ZmdQ/Td J0dZuy0n4+h2h+Q6bN+OuzaQhAuuMpLKkdvA2Fu/IzUCmHuHH/XYqVJ5hlE1KYB2PVu9 q9nhn81yGoTXK1MulaPB8q1LtdSmaPTyT0p5f782J4tQO+CpdUN4psvzUU7BxTvCYT7T WgbpTSCLFCzQVcmPyOybGQtZ3kXyEsUSpYqsbi8gWlW/1V/ZAJk/l8WZry4wl8AVxZBc 9qSdbw3fg0kYomqTLghP3WZySkQWnE4QiFNByE4sU5jkeVuX4m7+1BuodMwOwt8oRGfV xFJw== 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=sDuc8EGRNaTml8IZLkfOWC9uf/uHcOoeKSMXRUSHBtA=; b=KmFw1M6uhKdYG9nBvlmJTTKA1qe4ARz1Qbx6DBmRSwpFEF8gdrwHRZXa76dQ5NIbQ+ 8zRK63uK4h315V3/RaCXimWxyt3Q5Ce8snO7pNZN1bYXRIndWhXIu4DhMg1IFBMRsILR LMdQ8ZVlm0XnsL0OND6ZoCWoLJI/GtM4ps5u7rUyuGrQc2r6TufWBpsCFP27hCBoI5P8 S2GCLD56BfhfmwUH8IZDWz7bY2WnvkL0Jn2CZ76GEHMQCeOihlIW2NchSajg0xBvabUP rSC12nAE0ssWIUhfD0UvhJ/ebJNR2J8jjiqxjticOv39e0x6Iyyb+cTASK9thU5RzVSa saZQ== X-Gm-Message-State: APjAAAWnxwuJpmR2LeAty1YOS08AbP6tXUrlfct05dXGY4Ug9Pwa4dvr yDI3cQ8nZi8hgDgUG4xN5gjUaTLFsKQ= X-Received: by 2002:a17:90a:a4c6:: with SMTP id l6mr14235314pjw.15.1569124525054; Sat, 21 Sep 2019 20:55:25 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id z4sm6452921pjt.17.2019.09.21.20.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2019 20:55:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/20] cputlb: Pass retaddr to tb_invalidate_phys_page_fast Date: Sat, 21 Sep 2019 20:54:57 -0700 Message-Id: <20190922035458.14879-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190922035458.14879-1-richard.henderson@linaro.org> References: <20190922035458.14879-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::543 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: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than rely on cpu->mem_io_pc, pass retaddr down directly. Within tb_invalidate_phys_page_range__locked, the is_cpu_write_access parameter is non-zero exactly when retaddr would be non-zero, so that is a simple replacement. Recognize that current_tb_not_found is true only when mem_io_pc (and now retaddr) are also non-zero, so remove a redundant test. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.h | 3 ++- accel/tcg/cputlb.c | 6 +----- accel/tcg/translate-all.c | 39 +++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 26 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/accel/tcg/translate-all.h b/accel/tcg/translate-all.h index 31f2117188..135c1ea96a 100644 --- a/accel/tcg/translate-all.h +++ b/accel/tcg/translate-all.h @@ -27,7 +27,8 @@ struct page_collection *page_collection_lock(tb_page_addr_t start, tb_page_addr_t end); void page_collection_unlock(struct page_collection *set); void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len); + tb_page_addr_t start, int len, + uintptr_t retaddr); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end); void tb_check_watchpoint(CPUState *cpu); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 257c59c08c..eff129447d 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1093,11 +1093,7 @@ static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size, if (!cpu_physical_memory_get_dirty_flag(ram_addr, DIRTY_MEMORY_CODE)) { struct page_collection *pages = page_collection_lock(ram_addr, ram_addr + size); - - /* We require mem_io_pc in tb_invalidate_phys_page_range. */ - cpu->mem_io_pc = retaddr; - - tb_invalidate_phys_page_fast(pages, ram_addr, size); + tb_invalidate_phys_page_fast(pages, ram_addr, size, retaddr); page_collection_unlock(pages); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index de4b697163..db77fb221b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1889,7 +1889,7 @@ static void tb_invalidate_phys_page_range__locked(struct page_collection *pages, PageDesc *p, tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access) + uintptr_t retaddr) { TranslationBlock *tb; tb_page_addr_t tb_start, tb_end; @@ -1897,9 +1897,9 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, #ifdef TARGET_HAS_PRECISE_SMC CPUState *cpu = current_cpu; CPUArchState *env = NULL; - int current_tb_not_found = is_cpu_write_access; + bool current_tb_not_found = retaddr != 0; + bool current_tb_modified = false; TranslationBlock *current_tb = NULL; - int current_tb_modified = 0; target_ulong current_pc = 0; target_ulong current_cs_base = 0; uint32_t current_flags = 0; @@ -1931,24 +1931,21 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, if (!(tb_end <= start || tb_start >= end)) { #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_not_found) { - current_tb_not_found = 0; - current_tb = NULL; - if (cpu->mem_io_pc) { - /* now we have a real cpu fault */ - current_tb = tcg_tb_lookup(cpu->mem_io_pc); - } + current_tb_not_found = false; + /* now we have a real cpu fault */ + current_tb = tcg_tb_lookup(retaddr); } if (current_tb == tb && (tb_cflags(current_tb) & CF_COUNT_MASK) != 1) { - /* If we are modifying the current TB, we must stop - its execution. We could be more precise by checking - that the modification is after the current PC, but it - would require a specialized function to partially - restore the CPU state */ - - current_tb_modified = 1; - cpu_restore_state_from_tb(cpu, current_tb, - cpu->mem_io_pc, true); + /* + * If we are modifying the current TB, we must stop + * its execution. We could be more precise by checking + * that the modification is after the current PC, but it + * would require a specialized function to partially + * restore the CPU state. + */ + current_tb_modified = true; + cpu_restore_state_from_tb(cpu, current_tb, retaddr, true); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -2042,7 +2039,8 @@ void tb_invalidate_phys_range(target_ulong start, target_ulong end) * Call with all @pages in the range [@start, @start + len[ locked. */ void tb_invalidate_phys_page_fast(struct page_collection *pages, - tb_page_addr_t start, int len) + tb_page_addr_t start, int len, + uintptr_t retaddr) { PageDesc *p; @@ -2069,7 +2067,8 @@ void tb_invalidate_phys_page_fast(struct page_collection *pages, } } else { do_invalidate: - tb_invalidate_phys_page_range__locked(pages, p, start, start + len, 1); + tb_invalidate_phys_page_range__locked(pages, p, start, start + len, + retaddr); } } #else