From patchwork Thu Sep 1 06:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 601796 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp249901mae; Thu, 1 Sep 2022 00:04:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6PRM+SicRqOOro0SUzQvDzFmkffBP4CfLhnZHmiBKUCCdUgAa/5MU+ikjbYMLbKd5vcoXv X-Received: by 2002:ac8:5a91:0:b0:344:69eb:9fa1 with SMTP id c17-20020ac85a91000000b0034469eb9fa1mr22169419qtc.97.1662015869300; Thu, 01 Sep 2022 00:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662015869; cv=none; d=google.com; s=arc-20160816; b=MEzmdpZobG+CkufbmFUTRJxJrNYdLyKKPmrN60R1he6oasBhh/F7tloSnkJIjUtFf9 Wj8kITg0V7KZOrkCPrIc1SpQflq0Fx756Dh0GvKaghp9zZpTIhClo1vLghbgY7zlvNuc 8Fb7MqIacpuXXl98AJE6agw6DyVLH3XZ/blx37ikNi/60jAZLKQLFEG+EwZhIT5iwHo/ VfTnS5tZu6CdoFrnYg+4bUkMgBIYzrKTcdPNolBxIFOPygFwTsxW9ye4yUVVqW08Jqca /j5QSW+LckSz55Ru3ujG3QimP9GyFmv2NwRv88GbPAbkCqiN0rI2EIVccGa8MjBO0K4y LtSw== 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=gUYWndQQ8pFmIauaAuMmFCedmEzSZQGaU3WPNExELkk=; b=LTzWP/o1Ik+Y0YBuV+A0CvfQArwZUbZebT1fY8Qmbpna27uvfCgUjWnDr0LhUBQ0FV 2vAjxe/Gh7WxvIcMNVDaxCm/ct69iDwCWoa9byWt2DNVqw46qBqIAZ/nWb8gy232Ifd+ h+8JjCPXPYejAETlJbpb6+JmhGy+xOZzHT6NKC7nXbAmpu0+hNZHZ/C1uJL0ITT4pAtN aL3+WtaJuFVsaaPr6vc9zCFRg9hBYG+2v8Rm6vRYVh4oMO3Rbtd1TQzwrI4K7AgBHLFQ 9EIZWy/mi0pWskICu3YFa6Lo0M+6tD9HCi4gDqCB9lIeCtYU8wYmPaenyJY4cHBkKRk1 ljSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IM7jwaxm; 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 e12-20020a0562141d0c00b00498f50005d4si8996953qvd.76.2022.09.01.00.04.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Sep 2022 00:04:29 -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=IM7jwaxm; 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]:39796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTeFY-0003rI-RI for patch@linaro.org; Thu, 01 Sep 2022 03:04:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe4Q-0005wY-RO for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:03 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe4O-0003Gc-Hu for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:52:58 -0400 Received: by mail-wr1-x436.google.com with SMTP id n17so21009012wrm.4 for ; Wed, 31 Aug 2022 23:52:54 -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=gUYWndQQ8pFmIauaAuMmFCedmEzSZQGaU3WPNExELkk=; b=IM7jwaxmOUDVeG2/cg1ZPLivWqbYBIxS52tq3zFVJtiCLm92JdI/a48MItt0w22vrl JRm1VJz1ke4g/CaU9xaFeRdvXGStdU2gSs9TxuiWzOGA5BmtT+ilRaAIpQyZ5iEY7jyB aSMOHihdKrssF8K20WZPiECt8mm5MkwkECkzjFdIoQ1JD+SfvhaiM6GaESBh2rc30glQ CcwX19XmOrafpoEm9qw3KA3LrfdvdhyM6SyR5H9YegtneUtzzaDES4o8N/xC0ZZyqb8h 8oHi4/uZRljJyDmEOfm/iQWucPQoKQVb1SwuUCIMf3YpQPIXvqzLr5PTVkrPF4Wkk9ON 3ZIA== 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=gUYWndQQ8pFmIauaAuMmFCedmEzSZQGaU3WPNExELkk=; b=j7YvohPk+e+2LB04KIo/nHP74WHeduoKVpxe5vQPKacEuWVuSXFiHYMGD7aclHE498 jOh5jforUBrfCEVQsLfQIWQ734S6Lkkz8h+8ljd84eJsT72QX40QeOa783Ko6qnQieLf bbAm0eBcm8WdLO4bQ1KfLI0AhfNVOiJVLJG/PbMmLX572jqkicaXTo4MOmutjcViDj+7 anDTsWQpRxWMUya1Bmos383Kj5lvNYoOWF0bJcGS2XFPAt6EYcAXd4GLQ7gZIaTMxpRg TdanOR7OabyExDEh8wT23YP5OxDBRZ1c5+MH0cZWQFefHVYv8ofLY++EzJz0pbS54fsH 2VCA== X-Gm-Message-State: ACgBeo2zN1FEM8nNwn67pI1M18gencbF2uHBSocP3UxOcVcoEYA41SeP KKKEMm8pt/Jhnc9qkG2V+XlVECqkwWO5ns15 X-Received: by 2002:adf:e310:0:b0:226:d19c:de22 with SMTP id b16-20020adfe310000000b00226d19cde22mr12826757wrj.314.1662015173733; Wed, 31 Aug 2022 23:52:53 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:52:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Ilya Leoshkevich Subject: [PULL 09/20] accel/tcg: Unlock mmap_lock after longjmp Date: Thu, 1 Sep 2022 07:51:59 +0100 Message-Id: <20220901065210.117081-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x436.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. Acked-by: Alistair Francis Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- 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 2bc4394b80..521aa8b61e 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; }