From patchwork Wed Dec 28 12:49:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 637258 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2431531pvb; Wed, 28 Dec 2022 04:53:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXuu4luByb5Cd9rF6IFCCjH2FPqGsj53po1lEj/IE7cfQzVNxqXnx/7E3QXjYKS5qa9cKBbK X-Received: by 2002:a05:622a:991:b0:3a8:724:4a45 with SMTP id bw17-20020a05622a099100b003a807244a45mr42151192qtb.68.1672232030347; Wed, 28 Dec 2022 04:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672232030; cv=none; d=google.com; s=arc-20160816; b=Eld/pkPDL07LtDyfrY6LhaS74vx/BRD4nDqtvOn57AuIT1i//oT73+aK3c0jn3ribm 7kyLuV0qm6aZYhrL7GEIF3dCjX0omX3ymu2DzKjFZiw8xmguz3Siw6zZz4fojVd0k63/ g4Qpt9ix/Seku7wBwD1lyNZgfalwNKLR0GUZDxXrdja1bIK6oFqwwvVkk0jH9xRFByMU h+26NBWgPRUpGKvN5X2vlC1WESO4dJgblx1Bfl96byave0dFWzg8acn8BnBMXdTXnFB0 qGaMS/avoCAexB+ycV5affAnEvTkQNrSuMXWPmOpg9Senry8TCKDx/b2g6DV/Ghq8ITA 2WZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=5cIuqQ4skUeVHmlxcVqLU0zfv7mr6e0LURiFdaTPHd8=; b=LkW1hU9YQEOapq9VaMKDgr9DsjJL3puptaE8ZlpR64TYmVXTSRAhDOhwIV9o0qA/2n 0f/TuAPP9YfHNc16HpWfiVyDiKLz8nt6qP3v5asCn7BEGx0AG62lIjwavWyzZtCmR3nb bZSPMh+mYfzs22wdDq0Q53XJQc/mpqwNuTROKiZiS0NHw1VOivOCZ0K3mVuwpv5DRMm2 xKc68nW4FJr/6KqpFjJi3xWiDoFV7DPXwfrB0dq+8ngHixCs2Aw+/zcGCIdSt6ld3gf0 mBZlyKJlkBQ5RIP/4w9rhKWUxjxOdkuYv2EHLm0R/pFYQWgUIW9aE2akqcBYPzSOvGVI DRKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oOpQVIJq; 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=pass (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 t21-20020ac85315000000b003a57062b8b2si6636187qtn.317.2022.12.28.04.53.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Dec 2022 04:53:50 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=oOpQVIJq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAVsO-0001EP-UU; Wed, 28 Dec 2022 07:49:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAVs9-0000tl-EN for qemu-devel@nongnu.org; Wed, 28 Dec 2022 07:49:31 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAVs7-0002gi-Fy for qemu-devel@nongnu.org; Wed, 28 Dec 2022 07:49:29 -0500 Received: by mail-wm1-x334.google.com with SMTP id m3so2280102wmq.0 for ; Wed, 28 Dec 2022 04:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5cIuqQ4skUeVHmlxcVqLU0zfv7mr6e0LURiFdaTPHd8=; b=oOpQVIJqPSNsWCXIZ2OCQDluc7ruiC0zIb+mrIHIEsNGH1PkBMpFwtHGPct62zFCHS Jd9BByGOVQAE4blBtE8ED48PnQtbxo6IuMGkysAHdgcYcLDDgtQxTBcqJbLE1MshIDIs TTjUhgjKQjSt+x+q9xp/XJoquJw/EkwGd0NHnM+4l1u4smzHmrWDrPG3foY0Om03demt jVRs6Goh6cqQtnaMHpgkRkYggucIOOkD0mZsFg0YOBDKjzMQyP/epNMqPKzTNIoZvPDM 5Le0DXPtOAqxQBoSHibmhx0KAKRJyXYzTfMuPBR48bLzDkUEQbi3yGxFrC4NxD7SUBJc 4Xug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5cIuqQ4skUeVHmlxcVqLU0zfv7mr6e0LURiFdaTPHd8=; b=29F7znPIVUVqjwQUiryM0yr9Qkvjj2SNmt5ZwJIy8Mzv5BMuWPzDUdB74CjfJ9FDHd 0fLambie0LgjSwdqHvpD/yZzMMoFFs7jb5KkRPbOk0cqdrnrkafpnErLnXpqxNNe10Tz wRpKGSTAT8+zHThj6iJA2eUvrDYLz4OVHDCntCP0WSJPh1nuZiMhnELJ4d/G78mhn+0b BsDgoP9QL04Tpb6Cmenoqm2gHxnhXo4acsKQb/YSxRdp9FFI1SqoCF8JvLrdjRCKRlmL 28JlFVjMoBlUqXQ/iFCHXY+nQNa+ryQYdx08tAcE4k/gaSkYvS0hqd8XBxN2LIIPktJ8 6O7g== X-Gm-Message-State: AFqh2kouUSmgwcGrKcf5wYR6AEFr7OU2SlF2wKtptISfeNt0riaCkSGA PF2AHxhdpM4aPAY5aOAyZCV5gGXi1x2Oa1Qb X-Received: by 2002:a05:600c:18a1:b0:3d2:3ec4:7eed with SMTP id x33-20020a05600c18a100b003d23ec47eedmr20549816wmp.10.1672231765814; Wed, 28 Dec 2022 04:49:25 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id h14-20020a05600c314e00b003d237d60318sm22600520wmo.2.2022.12.28.04.49.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 28 Dec 2022 04:49:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1b/4] accel/tcg: Unindent tb_invalidate_phys_page_unwind Date: Wed, 28 Dec 2022 13:49:18 +0100 Message-Id: <20221228124918.80011-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221228124918.80011-1-philmd@linaro.org> References: <20221224151821.464455-2-richard.henderson@linaro.org> <20221228124918.80011-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson [PMD: Split patch in 2] Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tb-maint.c | 53 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index c9b8d3c6c3..b3d6529ae2 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -1024,6 +1024,11 @@ void tb_invalidate_phys_page(tb_page_addr_t addr) */ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) { + TranslationBlock *current_tb; + bool current_tb_modified; + TranslationBlock *tb; + PageForEachNext n; + /* * Without precise smc semantics, or when outside of a TB, * we can skip to invalidate. @@ -1037,36 +1042,32 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) } assert_memory_lock(); - { - TranslationBlock *current_tb = tcg_tb_lookup(pc); - bool current_tb_modified = false; - TranslationBlock *tb; - PageForEachNext n; + current_tb = tcg_tb_lookup(pc); - addr &= TARGET_PAGE_MASK; + addr &= TARGET_PAGE_MASK; + current_tb_modified = false; - PAGE_FOR_EACH_TB(addr, addr + TARGET_PAGE_SIZE, unused, tb, n) { - 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 = true; - cpu_restore_state_from_tb(current_cpu, current_tb, pc); - } - tb_phys_invalidate__locked(tb); + PAGE_FOR_EACH_TB(addr, addr + TARGET_PAGE_SIZE, unused, tb, n) { + 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 = true; + cpu_restore_state_from_tb(current_cpu, current_tb, pc); } + tb_phys_invalidate__locked(tb); + } - if (current_tb_modified) { - /* Force execution of one insn next time. */ - CPUState *cpu = current_cpu; - cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); - return true; - } + if (current_tb_modified) { + /* Force execution of one insn next time. */ + CPUState *cpu = current_cpu; + cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); + return true; } return false; }