From patchwork Fri Aug 19 03:26:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 598476 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1064134mae; Thu, 18 Aug 2022 20:30:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6YZgOug/x/xYydQNmHLntYULo7L9587zDXwRyDgmq7EW67a475S5NQqpWrVCNv0MB6loXo X-Received: by 2002:ac8:5a91:0:b0:344:69eb:9fa1 with SMTP id c17-20020ac85a91000000b0034469eb9fa1mr5157025qtc.97.1660879805115; Thu, 18 Aug 2022 20:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660879805; cv=none; d=google.com; s=arc-20160816; b=Tboc1vwMl20ZR13W5aGnq+9y5+3u0DItvB9DoFU+kAfh0iuFlN7PUnFDMnOPgam1cf AlzC2LnAJZF20u0FyhGpX0afZRC8jM8XrX19DQWybavyKLhFxW934AaX6VaPWZnXux4g lohnSFrdp54z8dBllo0i+rHuyY1qC/ozLugRhMP0VIBnhtWu8DdMZalaZiW4XeHUxOVl nBK9BUbYRFfHjxbGU8ECgVvaa05AtYOkbRz31XVybN4mE+I3Gtgmv3/HU3kem9+dObuq 9RU8WOPGm45kE8cNS1Fqlzvwo2Qpe4J1CW3R7nUsTEcUKE7QYLb9xFx+RRkNYe6q+pR/ 7/0Q== 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=BkKYzAS+5uJ73OkqVTsICJsmapNm4Yj8Jkt7Pin6sUU=; b=ij0OhABmsSoKvfOk/B/GvxodsXI0wo8UwcL7mfPkauXzvU5JvQPKd7aLwKj8QmPOe4 vOUSDSL9iLVQPUOOc3jdgb2kbMmxldxCZbagaeZTB4cFknFtkIvB2voFCuvbp9jLhoZi bX4WVlm5sFo9mAGJr11W/IjNDHhViAPvrX6vu1vHqMg4XpJHgqXnpndBEcDZaYKpdc89 UJyh8OdDOdEk1EoIxoKiyLxHsLYYsPIvvvf+EM2yBeiel5YAVxQzNI6RJSgDZx9pMJF5 Ij47kBhpMwwjRykjEproefVoLc+3+TP+9+jBKF8FDA2prx3AZhtzjLCqygbGPg56P0xv xVAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C9rxDRGC; 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 y184-20020a3796c1000000b006bb49e8e61dsi1579803qkd.395.2022.08.18.20.30.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Aug 2022 20:30:05 -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=pass header.i=@linaro.org header.s=google header.b=C9rxDRGC; 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]:33646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOshw-0007d5-J2 for patch@linaro.org; Thu, 18 Aug 2022 23:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOseV-0001my-GW for qemu-devel@nongnu.org; Thu, 18 Aug 2022 23:26:31 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:44560) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOseS-0002kl-Uj for qemu-devel@nongnu.org; Thu, 18 Aug 2022 23:26:31 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d16so3082948pll.11 for ; Thu, 18 Aug 2022 20:26:28 -0700 (PDT) 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; bh=BkKYzAS+5uJ73OkqVTsICJsmapNm4Yj8Jkt7Pin6sUU=; b=C9rxDRGCvNgjEL+g59RVPET6/6xCk5/MAHGvriq99Tu9MnJ1ik+lTiOlMc2uUXefkq ufhhv/pESJjRq5w6OKi8o/mSCWw0eSw0B7xiaTOF62LFiuac4M3Le8QgB5dZlbYyFxwi 2/P1fMSyeoWU87e3dutUa2rjL2jFMsmOM6mcKVCkQyrXfmwdanqk+y9glGetZWuRkqxG 0C8jTTnTF4VXCH6tSTBe2IOPiyX1t2j0G+NcEK5ctNZNM5tHXpJXhVC8GDPvJr7OSk37 97619a9dIDMkltGivlLjdQgVEVdXYIZoWRTH5o8689fQDuBXYXGHbFEDffk/A7Oddz/Y BA0g== 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; bh=BkKYzAS+5uJ73OkqVTsICJsmapNm4Yj8Jkt7Pin6sUU=; b=KkWGYXB2mJIPHdy1uKUA28qIpIUdkXK72Vzw+0HK6tU/3EB+no/7iD6KONo9lwfQ0A Y39qoysoX3hOhP2GyyqU8DlxvVEQiMAKsAdW0cVWxrAufOVK5y60T9/8vb0IKa0lUasG NsDmuKFRAT7wvWhAkvtGjtZX8/wSrZsCZFQZXGLbVf05wwvPSZ+pm7sJhW339Ksl/ZdS yCSKcC2OcFRtbjX6LLpjXIK9Sd6Hat2NT3pCMCsHzrTxeOBKf57/QTFbDv1bZDRZLysI PwMdETuDev3pGPORzgpuEhZhq+NFnxpqh6Jx+MqYKau+iSHANl6iDUp/Y9R8S7T6O7Jk eI3g== X-Gm-Message-State: ACgBeo3C9NhIzElysiFDyDCozdwdPGGx1s+VwGjHgTWaUtCaKMwWaIiB fvO61RzC72YZOZbkLJet9gDD5PHUi6koQQ== X-Received: by 2002:a17:90a:9a8a:b0:1fa:b4c1:c94 with SMTP id e10-20020a17090a9a8a00b001fab4c10c94mr11108205pjp.210.1660879587484; Thu, 18 Aug 2022 20:26:27 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:bbf3:9914:aa9c:3b4e]) by smtp.gmail.com with ESMTPSA id g184-20020a6252c1000000b00535d19c46d7sm2199904pfb.203.2022.08.18.20.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 20:26:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, iii@linux.ibm.com, dramforever@live.com, alistair.francis@wdc.com, alex.bennee@linaro.org Subject: [PATCH v6 09/21] accel/tcg: Unlock mmap_lock after longjmp Date: Thu, 18 Aug 2022 20:26:03 -0700 Message-Id: <20220819032615.884847-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819032615.884847-1-richard.henderson@linaro.org> References: <20220819032615.884847-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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, T_SCC_BODY_TEXT_LINE=-0.01 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" The mmap_lock is held around tb_gen_code. While the comment is correct that the lock is dropped when tb_gen_code runs out of memory, the lock is *not* dropped when an exception is raised reading code for translation. Signed-off-by: Richard Henderson Acked-by: Alistair Francis --- accel/tcg/cpu-exec.c | 12 ++++++------ accel/tcg/user-exec.c | 3 --- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index a565a3f8ec..d18081ca6f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -462,13 +462,11 @@ void cpu_exec_step_atomic(CPUState *cpu) cpu_tb_exec(cpu, tb, &tb_exit); cpu_exec_exit(cpu); } else { - /* - * The mmap_lock is dropped by tb_gen_code if it runs out of - * memory. - */ #ifndef CONFIG_SOFTMMU clear_helper_retaddr(); - tcg_debug_assert(!have_mmap_lock()); + if (have_mmap_lock()) { + mmap_unlock(); + } #endif if (qemu_mutex_iothread_locked()) { qemu_mutex_unlock_iothread(); @@ -936,7 +934,9 @@ int cpu_exec(CPUState *cpu) #ifndef CONFIG_SOFTMMU clear_helper_retaddr(); - tcg_debug_assert(!have_mmap_lock()); + if (have_mmap_lock()) { + mmap_unlock(); + } #endif if (qemu_mutex_iothread_locked()) { qemu_mutex_unlock_iothread(); diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index a20234fb02..58edd33896 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -80,10 +80,7 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write) * (and if the translator doesn't handle page boundaries correctly * there's little we can do about that here). Therefore, do not * trigger the unwinder. - * - * Like tb_gen_code, release the memory lock before cpu_loop_exit. */ - mmap_unlock(); *pc = 0; return MMU_INST_FETCH; }