From patchwork Mon Mar 20 10:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 665186 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp1036795wrv; Mon, 20 Mar 2023 03:11:48 -0700 (PDT) X-Google-Smtp-Source: AK7set/Qc8I5duhLHJsDA2nCvWIWdmkhlU2Rg+s1K35Q9ul7uQoRG78ZDJn17/D67T3gnZ9zSLVN X-Received: by 2002:a05:6214:d07:b0:5c2:b08a:3b9e with SMTP id 7-20020a0562140d0700b005c2b08a3b9emr11359290qvh.29.1679307108784; Mon, 20 Mar 2023 03:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679307108; cv=none; d=google.com; s=arc-20160816; b=ubkrmSrhn0lcRle43qtkHdXOT6ctwVubalc3+VE5kxy0ZCOQrQWnGWC4UcibtCajum oNtGRmxcvAzi2fuuM6HeacOH4luiCaV7EWjkyXVOWAPmYIeOJZ2PbZ2lJxi3W1w8Qp0n 9ux3Gbe5A0jvzOWUZtRBKpL8SoLvMFJg5hZcGv5/+1g48FSdFk2cNse4MQSbxhWvftKW KvWs8/pmxVBdvVWZMiAAEpV0s3Yui1b2qFsdOiZboQ2j44xTth/b9zbXCJmqlnWLiTOG wmFQy+FHdvCYHtzderCT6eo01tO8/3/nFQDbpS9/BOJ3iMsgjSKsUKstkSy+jk1mzZUc jd4g== 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=4kskGeJQrf9Cxcn5vNzrmuB/lHaeNa1KLZhaRS/P5FA=; b=KmtoqF7ut6kEgKDDwg9zY3eyPGmqoICNaFfm97maviBhWmlcPREWfaQ+5YiIn4vlWx GnznSsXFZxoAI9VE+sfipF89i4TEB8ulO4qLLWmizfSpjPO8kef1IwPYFGEAR8tLNeqe 7IoTTPTxfL0w/qYmur6XIctCh7YgLvpLML2tvj8OTrvhYwIm9wNRzLUdXmxd7QUfcMYa 65jPsCZ9yUtZwc6U8x0pxwhRLRn6vI1Z9Y+rTU2QhLLKg0l252CW+eRKvq/geLqbxW7P tvMEcxRk1hh63YplVBHgsphkv0SQsSgQs55l/QH9hTellwJsfi7L+okGJ/a0lDBgKjF2 P1MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tVTfBFQe; 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 y15-20020a37640f000000b007468f260261si506905qkb.294.2023.03.20.03.11.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Mar 2023 03:11:48 -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=tVTfBFQe; 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 1peCTf-0003oS-AI; Mon, 20 Mar 2023 06:10:55 -0400 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 1peCTT-0003l2-EH for qemu-devel@nongnu.org; Mon, 20 Mar 2023 06:10:44 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peCTR-0000D9-6k for qemu-devel@nongnu.org; Mon, 20 Mar 2023 06:10:43 -0400 Received: by mail-wm1-x331.google.com with SMTP id i5-20020a05600c354500b003edd24054e0so2024372wmq.4 for ; Mon, 20 Mar 2023 03:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679307040; 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=4kskGeJQrf9Cxcn5vNzrmuB/lHaeNa1KLZhaRS/P5FA=; b=tVTfBFQe7Sr0LP39/RjEGZK8aR/R4trqGKJMo7w/nuXxEgYRWEQWUG5wtWPORLpejv UlBZzE/17C8FCh9Ys5BHHRbrMexpQetN/bRd1kyU6iPi3NCZKcyT+m/JcvQ2TB6bgppT onvtmiQozBvdnMw+0QgrSED0wuFgz2sQMou7KJsNVqRhZ41wWWkG6vhEKVZFqkbrB6IW 8VAKRIsLt/MHQawn3y7C3waDU5HQHY74qqZwfAbZZbO9r7D+0S6AfgE2TRMJFoax9+5P LtYKn0dydklvLcjkU/+hDMhHmtHoxfQZaErhfhI+mMgHTI3V2gI3LP09eGzWyTqSoWy4 j/4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679307040; 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=4kskGeJQrf9Cxcn5vNzrmuB/lHaeNa1KLZhaRS/P5FA=; b=LcYMXBJUKsaF0LXzm6roahSIwDIBb6BQ4FMCE9kDRMfmt95RS4HTDdF/hfr5eutMB4 p3uSCROyFlTr3mYK43t1tIhxB0ctlf9/HZCNalPHP8vsThNyFoRwdaPKiA9fPn+oO+Nm IYoAAe6/WBBN5z0LqG2PfT55qOC+gknztvap1UEzvy+1hkJC4mWIqChJsv4Xgll/mu9A HN6xXcD4zTh4b1ayNFl/bW0qUoCoHtKjtfW12hLcqms1f9MCzc3/c9lgfajRnV3atERV h71yogRDibISORYxR5rJY+jQSQWT7Nqvsu6vKJKiNW/AWlMthvO+FZ6knlykkKnix27w RwQQ== X-Gm-Message-State: AO0yUKVX4O5Hg5a2OiEGokm+ihRtOGiIrr8vISgj9+vFQXqwzbhPofdC CzmtkSArRtahY0EnIIC8ENTXyg== X-Received: by 2002:a1c:4c05:0:b0:3ed:6a32:d792 with SMTP id z5-20020a1c4c05000000b003ed6a32d792mr11410851wmf.7.1679307039854; Mon, 20 Mar 2023 03:10:39 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i26-20020a1c541a000000b003ed246f76a2sm16364366wmb.1.2023.03.20.03.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 03:10:38 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8A80B1FFBF; Mon, 20 Mar 2023 10:10:36 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: Alessandro Di Federico , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 07/10] accel/tcg: use QEMU_IOTHREAD_LOCK_GUARD to cover the exit Date: Mon, 20 Mar 2023 10:10:32 +0000 Message-Id: <20230320101035.2214196-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230320101035.2214196-1-alex.bennee@linaro.org> References: <20230320101035.2214196-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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 This avoids us having to make sure each exit path does an unlock. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/tcg/cpu-exec.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index ea2e7004fe..daa6e24daf 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -774,7 +774,9 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(qatomic_read(&cpu->interrupt_request))) { int interrupt_request; - qemu_mutex_lock_iothread(); + /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ + QEMU_IOTHREAD_LOCK_GUARD(); + interrupt_request = cpu->interrupt_request; if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -783,7 +785,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG; cpu->exception_index = EXCP_DEBUG; - qemu_mutex_unlock_iothread(); return true; } #if !defined(CONFIG_USER_ONLY) @@ -794,7 +795,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu->interrupt_request &= ~CPU_INTERRUPT_HALT; cpu->halted = 1; cpu->exception_index = EXCP_HLT; - qemu_mutex_unlock_iothread(); return true; } #if defined(TARGET_I386) @@ -805,14 +805,12 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); cpu->exception_index = EXCP_HALTED; - qemu_mutex_unlock_iothread(); return true; } #else else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - qemu_mutex_unlock_iothread(); return true; } #endif /* !TARGET_I386 */ @@ -835,7 +833,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, */ if (unlikely(cpu->singlestep_enabled)) { cpu->exception_index = EXCP_DEBUG; - qemu_mutex_unlock_iothread(); return true; } cpu->exception_index = -1; @@ -852,9 +849,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, the program flow was changed */ *last_tb = NULL; } - - /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ - qemu_mutex_unlock_iothread(); } /* Finally, check if we need to exit to the main loop. */