From patchwork Tue Nov 22 20:57:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627516 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2723413pvb; Tue, 22 Nov 2022 12:58:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FO7C4DgQX0fp4koG+NtfeDMUD8gdZvVJ/yBcLYxUvNYaCI2CmyluhJyEBXPtp6WSoZPg8 X-Received: by 2002:ad4:43eb:0:b0:4bb:7ad8:deae with SMTP id f11-20020ad443eb000000b004bb7ad8deaemr7185871qvu.92.1669150712956; Tue, 22 Nov 2022 12:58:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150712; cv=none; d=google.com; s=arc-20160816; b=0BdcxltCYoLqw1TSDnKWarfGu+uDVgHeqzyQi1YXfiFoxCyK/9HKGTvnVzw0hdvlFv AgnpgqCVaRH3a2rP9OOfu7QKjIJX0HLNMOB+dd9I/0pVeYDGmRTVOVcx2cZGQ/KJZoF5 XLx+wgSUkB4LyNB2v7oQVJBG4CuECUAufg8mDQa0MaZIcmTwEJZk37kN1XK6ddjEy6NQ 2NgK7qelvGbS8s/zMHhx7I9IcdUD+97hzqAZifg5TU3VMXAToD9lEUErxOe+te+dR5oX fZ1LGRr7e4sP/ZeK0aUJHECPHYRGuzm9eqKTZgxGJJoffWamod2yu9X030wVL+m+EfXc ZK0w== 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=inptdBB5bfU6n6sZF4IxEdTaQ5K/wEiaiS+O8bljutE=; b=wwW0h/f/vsObJDfO6B4Gk73NxiTNg/qPtHIH2iSQ8O6kyZHDt/koEeV6lrC3bI+zbT meJ1eHGTuqnyhiPSOncv53Cb9OnFUiFEIZPF67ry/85je/lPJjZaOSwcG4otXB6EeeW0 +AUKfacavphv1I/QqEWy7KC96BD/F5ohHuJBRi1LoJFBKplxB8+stSo76juzNQReXKsI TzmU6KLnbCcfGkxT85FGDBquJtdH8cYBMfhuFS3TN9GJ+HDe8dv1wHS37ZNkB1WBPW2R sOTIBN7lBsXq9QgwNltTwXY2vwbAuxB5uGEgHCU2LHtdPRx8YAuCz/JW1CRdxuKv423a krRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SrPQz2C4; 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 bz14-20020a05622a1e8e00b00393d93a6675si8685552qtb.241.2022.11.22.12.58.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 12:58:32 -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=SrPQz2C4; 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 1oxaKx-0007I0-NO; Tue, 22 Nov 2022 15:57:47 -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 1oxaKw-0007Fv-EA for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKu-0003T9-UV for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: by mail-pj1-x1032.google.com with SMTP id t17so13558392pjo.3 for ; Tue, 22 Nov 2022 12:57:43 -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=inptdBB5bfU6n6sZF4IxEdTaQ5K/wEiaiS+O8bljutE=; b=SrPQz2C4tokJp0Kcs7tRI81TqlliCEkzhj7h3JyaqxmLvhY3toCZZP0OL6yeUiJSB2 jKBU1IrPhGzEZuqW4+QCFiDOQ/70oArQ+HrXpea/2+kfl/1Pc03xYbb7++iP6lPBuoEX cmHMgyE5RFPrdXBEEi0WNSyuZjNHfpnCAkrrJNCqiP+02FQ0DDbZlW10mVzXjz07SCbI g0yNHK90gq7dEQVt6FGHUHb5APQFfB6YDl4IM1DBBAqami8/2bvzZxTaayIbL4HPIzsb pe0d+dMMEJGxV2DkWpsXksT3wkvG4Bv1CnpVa+IFOs5FY3y0Tj7eEPLBp+NSAYhzpDfT OSdw== 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=inptdBB5bfU6n6sZF4IxEdTaQ5K/wEiaiS+O8bljutE=; b=GOyfRebJjuQRGzrxf/e8nAJkUaxUPLdrRSxqGA3nNnPh0c0MMNJEePfqJzo09TGkKI wvtO2jbT2bCuPO6F+wN9VY1yGyzUDH5c9JYhetmlD1VGFWGtPS65fYSlHk+vkA3fLtj9 AqqPxLX63s1YXFwwXp0AAF1GMHp7Kr0LQeEDmZqo4PQofPQ+SZKvkm0IbX3BZscmQU54 8MT52bHTU2ffqOhik1Q19utv4ABKV54nTaXacbaUdduc0QKcU+1aZdP4OU0tSmzGgE/q 4BQuRsXgQO3GsfyCR2Aveu5IAeKpcSqfN64lWSuVn+AOJFTgsC+kvxWbFgHqY7yCQ3eZ QVFA== X-Gm-Message-State: ANoB5pklZzJ8Ey2VnQz/T0RECoI4m/XBhQNolBcTIoDN+buwZ2EMXo7X mPsEhQi/74tZ7cTCNpYWQF14whPjWS+H7Q== X-Received: by 2002:a17:903:1ce:b0:186:a2ef:7a69 with SMTP id e14-20020a17090301ce00b00186a2ef7a69mr6020609plh.77.1669150662553; Tue, 22 Nov 2022 12:57:42 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v2 1/7] qemu/main-loop: Introduce QEMU_IOTHREAD_LOCK_GUARD, WITH_QEMU_IOTHREAD_LOCK Date: Tue, 22 Nov 2022 12:57:33 -0800 Message-Id: <20221122205739.603510-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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 Create a couple of wrappers for locking/unlocking the iothread lock. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/main-loop.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 3c9a9a982d..73c60a9af4 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -343,6 +343,45 @@ void qemu_mutex_lock_iothread_impl(const char *file, int line); */ void qemu_mutex_unlock_iothread(void); +/** + * QEMU_IOTHREAD_LOCK_GUARD + * WITH_QEMU_IOTHREAD_LOCK + * + * Wrap a block of code in a conditional qemu_mutex_{lock,unlock}_iothread. + */ +typedef struct IOThreadLockAuto { + bool locked; + bool iterate; +} IOThreadLockAuto; + +static inline IOThreadLockAuto qemu_iothread_auto_lock(const char *file, + int line) +{ + bool need = !qemu_mutex_iothread_locked(); + if (need) { + qemu_mutex_lock_iothread_impl(file, line); + } + return (IOThreadLockAuto){ .locked = need, .iterate = true }; +} + +static inline void qemu_iothread_auto_unlock(IOThreadLockAuto *l) +{ + if (l->locked) { + qemu_mutex_unlock_iothread(); + } +} + +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(IOThreadLockAuto, qemu_iothread_auto_unlock) + +#define QEMU_IOTHREAD_LOCK_GUARD() \ + g_auto(IOThreadLockAuto) _iothread_lock_auto \ + = qemu_iothread_auto_lock(__FILE__, __LINE__) \ + +#define WITH_QEMU_IOTHREAD_LOCK() \ + for (QEMU_IOTHREAD_LOCK_GUARD(); \ + _iothread_lock_auto.iterate; \ + _iothread_lock_auto.iterate = false) + /* * qemu_cond_wait_iothread: Wait on condition for the main loop mutex * From patchwork Tue Nov 22 20:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627521 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2724585pvb; Tue, 22 Nov 2022 13:00:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PokmIv7leOdsc0OiC6xAL5fx/TzTA60NlU/+hEZQCwfwADIyFeGi43xyUQMFPy4STikvB X-Received: by 2002:a0c:9b09:0:b0:4c6:10ee:b758 with SMTP id b9-20020a0c9b09000000b004c610eeb758mr23673881qve.130.1669150848908; Tue, 22 Nov 2022 13:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150848; cv=none; d=google.com; s=arc-20160816; b=ZkGSDHdR0P5w1CwQstisFI+QYsGoWQrkv4/asEeRIAqs9xuGbQaTclC9vHH2pRvreS 0K8FKaipz42eMaS1/FSOe3i/xwMF/ex+kLOZWuS/56UfgqtCSo73/rf/kdxELM/bLev6 i8AYLnDFYhZo6aF85BHC6myTWSRDxSY9hFI/ixpa7pioJhyhCB1unN1Mv9hD4RqojHqi Da/VKWYTliooMnn7hGvxECsV8KvdfLglXrQR1JNMSWBj1vCFEYFenu6CiuMJdMfE0b5D Lvl86S98VWayUzFIouH78XTWoVh6QXpr/kVRW4dY/Bf25QlERG6iB0+RLuKwnbF6H8yT +ivg== 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=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=wpSfRbgZi7iWSaeZmWe1WbCm5Wg6xe8neyK4pquPDEC0mMSjQ5P6rkoqP0DDwUPWfp a0xyhOGyT08V6liQ/dou6hVEGKMbfcd/loTGkG54dqK01VDZgpzjv+74AfDSOpGNk5xd DEiUCo+MwBzN2DAG9Iq+SdUbiHNPNP1jVhaKFOTSHCAjMcV3/Nzqfr7MzktdnbrDsMvR hH9jHVH2AWdRUEBq0rVBRfYS4t1se76ausBPpDTlsRmPpDy69TP4s/LEo+mxwX9cYVBT AVqqbYDrLhT2DZgV9LRcADpUYW/En5lzxH2mfPWJnmigPpnvwqoUoNTPo7wu8xpWk1QE E5Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqQ7ViWJ; 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 d17-20020a05620a241100b006ecba5b7b24si8933895qkn.208.2022.11.22.13.00.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 13:00:48 -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=JqQ7ViWJ; 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 1oxaKy-0007Id-2E; Tue, 22 Nov 2022 15:57:48 -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 1oxaKw-0007G2-KP for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKu-0003Tr-Us for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: by mail-pf1-x430.google.com with SMTP id c203so15462553pfc.11 for ; Tue, 22 Nov 2022 12:57:44 -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=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=JqQ7ViWJud6iNe9dYaAMVbyhJoLEulzPMEr24zoWv1vG0rVGL/nJBWMzH4lDC4mZ/D iPWV4Igwi1QpgeGJKgnwia5PhtvoDdlmW7083w6N0hsgr7MiNHAwypowJBmHd3wnSN/G OIe895r5NGzFGTw8vGDHUjA9H74hvAqgjRf0SnWQVnkpskGBgiSb3T9HgnDDHr/X9eos LP8X82TLT582MHGIVyPJXNC0w6R6s0iGX/rjHOH/Z4Buu8LUe4bMH9jeep68qi/Sa3o1 /+75dNrIYrIPf45xkquhJOz/LHEdLft0OLOUF+V3+b2bfFHl6tqC4CY0LLVRULm8tVeq dkOA== 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=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=GgdQ3NKT4Bu5LUEOR0StgvTIWi6C2m7SRYPaXtwgbYc5X6oNqw68GvsZqGTIvchJuj +c8tKi8pnOB4f49tb6RdLVcJQHX5iKG0zFhDF7tD7cYTu2oTmUpkb4bT8xE63Way0dWG QpN4zW7xqaDnRRU/lUBzSINxQRt6X99EBmVpgpTWD7StXNWiK2mXyv2u91I5+1KtN1rO Yk+3UcWLFJKf1+1RdWdbgSRKOAS2Rj5Iodt90iuXUVF9pvafWCZIy+Frj5fhNze9Bym/ 6FOF73UIbaIyOtJsU9ph1x8Sqcd3b9FGjV6WZ59feQwhdfLrVAqetxUanuU0wFBarVm4 l+pQ== X-Gm-Message-State: ANoB5plDeJylT4FQWcOB8HAgz9OFIAz+ngStq5BXtIvWlTZ3aTE9yIhh Ho38ioRZU0qBALqR0aIhnkussiZzUzjlmw== X-Received: by 2002:a05:6a00:1f0f:b0:56e:7424:bc0f with SMTP id be15-20020a056a001f0f00b0056e7424bc0fmr15099952pfb.11.1669150663551; Tue, 22 Nov 2022 12:57:43 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v2 2/7] hw/mips: Use WITH_QEMU_IOTHREAD_LOCK in cpu_mips_irq_request Date: Tue, 22 Nov 2022 12:57:34 -0800 Message-Id: <20221122205739.603510-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- hw/mips/mips_int.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/hw/mips/mips_int.c b/hw/mips/mips_int.c index 2db5e10fe0..c22598d353 100644 --- a/hw/mips/mips_int.c +++ b/hw/mips/mips_int.c @@ -32,36 +32,27 @@ static void cpu_mips_irq_request(void *opaque, int irq, int level) MIPSCPU *cpu = opaque; CPUMIPSState *env = &cpu->env; CPUState *cs = CPU(cpu); - bool locked = false; if (irq < 0 || irq > 7) { return; } - /* Make sure locking works even if BQL is already held by the caller */ - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + WITH_QEMU_IOTHREAD_LOCK() { + if (level) { + env->CP0_Cause |= 1 << (irq + CP0Ca_IP); + } else { + env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP)); + } - if (level) { - env->CP0_Cause |= 1 << (irq + CP0Ca_IP); - } else { - env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP)); - } + if (kvm_enabled() && (irq == 2 || irq == 3)) { + kvm_mips_set_interrupt(cpu, irq, level); + } - if (kvm_enabled() && (irq == 2 || irq == 3)) { - kvm_mips_set_interrupt(cpu, irq, level); - } - - if (env->CP0_Cause & CP0Ca_IP_mask) { - cpu_interrupt(cs, CPU_INTERRUPT_HARD); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - } - - if (locked) { - qemu_mutex_unlock_iothread(); + if (env->CP0_Cause & CP0Ca_IP_mask) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } } } From patchwork Tue Nov 22 20:57:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627515 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2723412pvb; Tue, 22 Nov 2022 12:58:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ufX5llUkyZdmcfK7JxYViywSnPv0VgL3QchM0/Kv6Cgnr532bFlxEibiCgQIFPGos9/fu X-Received: by 2002:ac8:543:0:b0:35a:710a:341d with SMTP id c3-20020ac80543000000b0035a710a341dmr23314769qth.675.1669150712903; Tue, 22 Nov 2022 12:58:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150712; cv=none; d=google.com; s=arc-20160816; b=TDaCcv5dPAJkkoHI9GtoXT1cB5v7I1Mc7aVnnz9OWiG2hBLrG6vHr5Mm31YTcYBxIO FTP4lJ4bkhMrEbzYgoHjlBiR0LB4bjdcz2X5ZueY4p0Nq0Cm3j5ZyOLJkf4Nn0HH81L4 ftxNuK8oqg0A1Na/ML0sKd/9CLfA9ABVyAOoO7Z2VwWfMmmIYHd99lwhT//54i+hjG0u pEVobNGT6PScC8b5jpoXCE+bQgBbIfxgcqGdk/WJj3dM2EpuqUC7OdjAXrzkCoRJs4x1 c0yhriNhq1aRJ71GZjtb3mJfyoWr/xi+91T9iG5vcFqn1LMz2Uk5mP7uko9ueIJS63AU tlwg== 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=H9jFu9uG41whHckncNnQfwXtObMjZa4oIQS9COdwadA=; b=dnmuBFpYjouFCnw304qI1z9zfZwg0pWwC/xLPPy8+Dd8loZiHrB0FHUvQ0HXAZnchK X0Xozk0/zbs2s7UKLsSBwbxjAp2s+SqKP/u/yd0KmFMErHim9xIj6gs7Lf/lBdR9XWjM e3XscP+0wSMe4u4Ilv+4r0xsoO10WlZfhQ+TbOo1KeicXgeqUqEus64fRouoSHxvMyPX Z2jjjhoyHWitdxQJ67G4Dg7Gl6gvYquV673Z7OPt9bzpdZmL1MaPdgzrfDfjPKNGjtDp LrQ0SviVxdHZdPLYP6qVKBUmG4F5NddLcbBLa1RKMwALuIbLcjzH9Q9omo+vpLXnALZU eI4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DhhY/KpJ"; 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 cb5-20020a05622a1f8500b003a528b2621csi9096756qtb.699.2022.11.22.12.58.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 12:58:32 -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="DhhY/KpJ"; 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 1oxaKz-0007Jn-Mg; Tue, 22 Nov 2022 15:57:49 -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 1oxaKx-0007HW-DM for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:47 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKv-0003UI-Ra for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:47 -0500 Received: by mail-pf1-x433.google.com with SMTP id 140so15481306pfz.6 for ; Tue, 22 Nov 2022 12:57:45 -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=H9jFu9uG41whHckncNnQfwXtObMjZa4oIQS9COdwadA=; b=DhhY/KpJvtdCO5i/VsPniYETfljZvdg+k8O6XQuFPrr8Sm33Fzt1JqfS3YOEjkxkkg mIvnPd5WnL+R3yZxYETNnz0ew8nFejLCE8DxDRmaMAAoQwyhtJJCfkg1spCcRZ0FnaXE wI4MtXyQ87hvktRrQu56Ae3UDxyHdl73xR+eE/mvLKIQsWBRPMIjOBEKGbEqgqUqgQSu ol7Jxi7xFX6atGOelABRbAzbAYur7/XSqMeKiqh/x/qU6T13/FpJ7lW0UiVF2ateUdpl J0PVBn/bEzsHxyRtWP573Z0dTSsmB/MUbfU4SmlFWRosq2EM4ZUVDkfKgoWph/rLgue7 FAPQ== 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=H9jFu9uG41whHckncNnQfwXtObMjZa4oIQS9COdwadA=; b=Wj3sclpxeF9R4TTYAF5WLTfULKh+L0u5FOwfXg5vJaSQVFEXE2ZElCZBL/F/e0MFRT /B71EYQDF6aAx+wnYrGHlO4l5H7k2GYHn5yZIp/sP7X3GwMq8oyMyN8Oajv4yltDnkFa WquGYB4mD37EqWogvVuIH46CYwl0H3kDMmtfW2seOSDN5bRXBeLH9TEGlQpYHz/SjMic RXvYVzYVUCOJsaQfoasmNHPeILEgNbhp7KQaNZsss8OX5uPMptuQ9ieYaqqH8Ik533I8 CdHTJPLrvyHG60dq1vZgfmyxpaU2DDGF+OHAOD+i/EIMWi7Nyu7QJjCD2spF+2DKcgqX Ommg== X-Gm-Message-State: ANoB5plHbqttCZNGZp94xg8LoGUL4DQiHXjyMh9/THql91m+dYFJ+nfk oFPW8tZ1PlNRodozge+tCoRvJrbrXlMEtg== X-Received: by 2002:a05:6a00:4c11:b0:56d:93d8:d81a with SMTP id ea17-20020a056a004c1100b0056d93d8d81amr5976984pfb.14.1669150664538; Tue, 22 Nov 2022 12:57:44 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org, Daniel Henrique Barboza Subject: [PATCH v2 3/7] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_maybe_interrupt Date: Tue, 22 Nov 2022 12:57:35 -0800 Message-Id: <20221122205739.603510-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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 Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/excp_helper.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 94adcb766b..8591bb3f73 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2163,22 +2163,13 @@ static int ppc_next_unmasked_interrupt(CPUPPCState *env) void ppc_maybe_interrupt(CPUPPCState *env) { CPUState *cs = env_cpu(env); - bool locked = false; - - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); if (ppc_next_unmasked_interrupt(env)) { cpu_interrupt(cs, CPU_INTERRUPT_HARD); } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } - - if (locked) { - qemu_mutex_unlock_iothread(); - } } #if defined(TARGET_PPC64) From patchwork Tue Nov 22 20:57:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627522 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2724638pvb; Tue, 22 Nov 2022 13:00:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7JQixfHG1Cwc4EJ44VEFTJ8ijmZwDeOn1FifCMlP1AcwkaflSPAaXaZpTmlT+/rjnCo0NA X-Received: by 2002:a0c:c343:0:b0:4b1:79b2:207e with SMTP id j3-20020a0cc343000000b004b179b2207emr5159909qvi.89.1669150853014; Tue, 22 Nov 2022 13:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150853; cv=none; d=google.com; s=arc-20160816; b=wvfatr+dFoUlvWmPDjw36MGiHGuC+7W+J9m6FZJPrpFtDjAW1rTIH6AFe9XOXEpLcw KMGv7dqSN8B4rQc41anqc6rggu0RITJGx159GVJ4JDwOXMrEHs9M/cuwIUsPWuohn0t8 PZaHkWFD5sKp5+tWJ/3KupcBtAMATV4Ns9dRVfwLmIfugV6md9edsflZAT0XCPi/9ci9 mG18LNKbG85jgIyg+08BEwqgwYQreafMCZq2Gojnljz/PA/nAi3Erbn6jCVjI6uMIdP4 4sj1oiP7oKwpNWXlGTpE+aweZozY0yiSrjdj/wlWq+5oB9k23ctTbf+HyH/PZ/OkLpcT HuaQ== 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=07L+bW1+qVSK6zT9bLcsy4Js7Ua88w35lmwPvUxZKNk=; b=04VpbsU5Oo79RpI7KHpFoMEg36Xry1JG++MhrS+Mb1uCPvSj1Y/wRDNwaAwOJYV+19 NZV+xP4EKDL+mDIxQPSJkgVJ4kbFUAIhjAmMwu66WvLuWWEbC5b6YYjBB6dSN7B0+Xqu vJA2pSAI5IvQ0YWPDN8jcpLTawLLGUwToGWKx+s2STbvEPE6f+ngmB48bZ2gZbQbSb1W Locwfuwn5lFrQD7wI5nOeKkQLmJeuqr5YPp/JPf9Mz9XRKqEaGL8RUVgN9PnmDW1NdqP 6v4iQLg+YY2Mmuk3PfULZXwJlRIT8qEhZ0pSCTW2nwFmhFayMdO6ziQVYjCKxVyZgled wOAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Mho/Os4W"; 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 bq27-20020a05622a1c1b00b00397a47f88e4si8504493qtb.783.2022.11.22.13.00.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 13:00:53 -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="Mho/Os4W"; 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 1oxaL5-0007Nx-5b; Tue, 22 Nov 2022 15:57:55 -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 1oxaL1-0007Ld-IT for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:51 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKw-0003UR-W6 for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:51 -0500 Received: by mail-pj1-x1031.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso47680pjt.0 for ; Tue, 22 Nov 2022 12:57:46 -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=07L+bW1+qVSK6zT9bLcsy4Js7Ua88w35lmwPvUxZKNk=; b=Mho/Os4WLtY2b00ZEgDrv8i7nd047aSibqXu8XG7+WgQ8SqDVmeL1Mt8EC3KuK40FB hWbEHc8RylPdFIxJdNiz+TEEAhGXmsYBZsR3Ku088YrUZclqpZYw62gA0z8ZN+ViNX8T 3AbwttU6fVVkZx63rZE2PqoWSMG34USvVOuyLaZr+dK7KTahJehdlIubCiMVXRcUlDrP SHxZEwgAhNSwdZOKnmiXmnEggiH0quAm4JY0tcv/S3r7QljD/jKIIpF8HxB8Ma6vFiTy 7WXRhMjiCbm9ZBoD+N5Vrdk89BJVb9GymfgZpPxyE61TJKwZerVXEIbhW7gV4vA2dBM7 wTWA== 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=07L+bW1+qVSK6zT9bLcsy4Js7Ua88w35lmwPvUxZKNk=; b=1+WdlCuqvGuwQ33DurC/OcGF6gi7QIU+GTH60/UPx5BXkUvZe3AI3OKUJMfGUYXXO1 xqfepPIeU0AUb0lw0mGPWawdA/Yp0Pu9oxRYRpUeNIRYATmnwsWHRyoS6b+qCMXGPQgk 9R7y+0O+qzqvA71ibi/UxZ1mY/BwGBvWDugK6dJlov+kaubc2HdNo7TwSiIDB5Opk703 iMZPVlCluAZqskh6hJOcTjeaXfcpK1A14ctKGB+YfcLtXEf9hw5yFPyTI3B4pYzvlITx L8MH4Rf9XXVgHFrbGF8fVTuu18aIYn+sGrtRc0EqmAknU1J519ok33f4woELfaolzcXS 7CCw== X-Gm-Message-State: ANoB5pk2YCpqgts9S4JC4uChbX00ZtEMG9djtljHgSOYnj2i/P8yWvni X20SexOl5u1rzP+H6+WZPlSfYwdq8QnvRA== X-Received: by 2002:a17:902:6505:b0:189:30f:64d8 with SMTP id b5-20020a170902650500b00189030f64d8mr8574190plk.39.1669150665410; Tue, 22 Nov 2022 12:57:45 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org, Daniel Henrique Barboza Subject: [PATCH v2 4/7] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in cpu_interrupt_exittb Date: Tue, 22 Nov 2022 12:57:36 -0800 Message-Id: <20221122205739.603510-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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, T_SPF_TEMPERROR=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-bounces+patch=linaro.org@nongnu.org In addition, use tcg_enabled instead of !kvm_enabled. Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- target/ppc/helper_regs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index c0aee5855b..779e7db513 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -22,6 +22,7 @@ #include "qemu/main-loop.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" #include "helper_regs.h" #include "power8-pmu.h" #include "cpu-models.h" @@ -203,17 +204,10 @@ void cpu_interrupt_exittb(CPUState *cs) { /* * We don't need to worry about translation blocks - * when running with KVM. + * unless running with TCG. */ - if (kvm_enabled()) { - return; - } - - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); - qemu_mutex_unlock_iothread(); - } else { + if (tcg_enabled()) { + QEMU_IOTHREAD_LOCK_GUARD(); cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); } } From patchwork Tue Nov 22 20:57:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627518 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2723691pvb; Tue, 22 Nov 2022 12:59:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7T8d/ou6PJSKPRKCVM2Dv6LqlH1goZdnuB+RfTKfcgiL0OBW77exBAxdndV5PtkLZjeKM3 X-Received: by 2002:a05:622a:22a8:b0:3a6:3756:c684 with SMTP id ay40-20020a05622a22a800b003a63756c684mr9408865qtb.10.1669150754137; Tue, 22 Nov 2022 12:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150754; cv=none; d=google.com; s=arc-20160816; b=zRGfPyJN1kOm/8mPDuSPHxJelcTrk9eaoYM0+I0OZnjUndvgEwbG4Lh8zofMZ9GDlx F7Rje8cPC4iuVQCk1uoqKqAzJMnXBl7XzcZPYTy1rrudjHBm/XjpqbuFEvObKXgtpWHr GpWGeW+/Rq995YGZ9otGnxycWV+kM0lFMntGSH9zGPOJ6xIoLj30tlz/qlYSWLZ0akr6 RGBVR2V68HB17ODqUd9KHs+U47/nFv4kPpCzR2/mPyl2bmdPYuoFzK4rn8AM8vRIxTEn sN/WsiM9uzALYACEdEw5DdD7cj63+RZjuausm98qiLlq0tXDrPltno98tT4WktoLSNwX MwSA== 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=OQs4PX8mAmo3ud+ztM98k++NoSQ+C6IEic73PWAugco=; b=E2Ps0ptDPIZ+37CyJJMYBneIFI4JS7dZM5v+AEySj7+a2cB41DlQ6oJBtrDmUyBAMn c2Ax3ULyTEaWPHU7q4u+m9zbZCbc8CcAs6Yn0Tvgm0LOGzlt8W0NRBmPWH0wzS0ig5h0 bCblHE6JAIIvrkCg7EGMQB3BHqEVxKSDyCZmfx/nxA+XKj2HzCNvTmZvOJ4qSlcg2l/i yKQ3meisXK888PATEK40T9i+1HEvbtFeitmAPIzXSXHbZALcCchhEJwVeEMDsDrigvGv J5ICFx165d5nnl5x4Nyp2/u6KhBEGjQAyiR8Qa5isFWWNRgnM+0X/Qoh0Tt0q+F5DVMB k1ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqIOfIfr; 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 i6-20020a05620a248600b006f582368e97si9562174qkn.368.2022.11.22.12.59.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 12:59:14 -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=JqIOfIfr; 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 1oxaL2-0007Mm-Li; Tue, 22 Nov 2022 15:57:52 -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 1oxaL0-0007Kq-Kd for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:50 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKz-0003Ul-2i for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:50 -0500 Received: by mail-pg1-x530.google.com with SMTP id q71so15058996pgq.8 for ; Tue, 22 Nov 2022 12:57:48 -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=OQs4PX8mAmo3ud+ztM98k++NoSQ+C6IEic73PWAugco=; b=JqIOfIfrfJ2WYbtWU3dXp6OX1IlvRFsvRgKki8dfBCQRE79I+i5Vm80f0WhyY6GrdR /hoQoPasTJd4ugMH8YFkPmhDhuyCVp4ixv05OT5RpTVp6U46UY06y+n0XkUvnOk2WAFV Vdk3ygSuC1EcSN9MsuTChU8A2c3TqBm7D9eZT3gzsHvnwZOE9Oozbiq/HQElWHXzGj4G RijyK/FkNzQCnNZWm04VAkSn6BRe/SwYIArdbO7zsRqDHF9Zrlud4Db1ndfkamLRe5Nm a2Do176wSZcleMX1JsXxSo14RHhD/XBiNG9lLtzM0gUmdZmkGyE4yd11OcShrrqtn7YK NwIA== 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=OQs4PX8mAmo3ud+ztM98k++NoSQ+C6IEic73PWAugco=; b=t6habXfCLjnCSw99Jyy+Xwt2mW7RmwAoP/AbadPNpzIdiPczHLiKxFCiv7QRkJAtUD d2KlY/V6Ihy1iFpnczSYoW0GsjX4WyPSKRZBR306Ir5DrfUapX3vua2XnYfdQxLe/fB8 VAmzo6TCIG6wEFywfx9MH/6s18vke9LdqpuSDkHnmrhzx3Q38y2TODFJ6XcioBCBTD4V TrKeQg04MsZIycRw4v6tLlEsn9MmFAc0AaqmHAZXYJdxxTBbT6hQHacVkK2qkZ5LpQWL w72T1+zBokpnviB70ydfI1/co3eBEKsoc6+l8xu6PozQp6A8k36BbK2ERwqVnNRCGOWb o0EQ== X-Gm-Message-State: ANoB5pkVjFSEwELoKKjtBBxtQfLajTlrfH8QaMDoIWY/qwsM4ARD+Zpk MrRDeFnTucTr5X9G+RAoBgKOxJpv2tkVwA== X-Received: by 2002:a62:8648:0:b0:56e:cbe8:9353 with SMTP id x69-20020a628648000000b0056ecbe89353mr5598773pfd.5.1669150666263; Tue, 22 Nov 2022 12:57:46 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org, Daniel Henrique Barboza Subject: [PATCH v2 5/7] hw/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_set_irq Date: Tue, 22 Nov 2022 12:57:37 -0800 Message-Id: <20221122205739.603510-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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 Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- hw/ppc/ppc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index dc86c1c7db..4e816c68c7 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -44,13 +44,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) { CPUPPCState *env = &cpu->env; unsigned int old_pending; - bool locked = false; /* We may already have the BQL if coming from the reset path */ - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); old_pending = env->pending_interrupts; @@ -67,10 +63,6 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) trace_ppc_irq_set_exit(env, irq, level, env->pending_interrupts, CPU(cpu)->interrupt_request); - - if (locked) { - qemu_mutex_unlock_iothread(); - } } /* PowerPC 6xx / 7xx internal IRQ controller */ From patchwork Tue Nov 22 20:57:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627519 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2723739pvb; Tue, 22 Nov 2022 12:59:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf78O5qtrz2DEyFjD+mgDZIxmitx0aD+Gz7k56r6PNyJNb7qwe6r5exTLFM0OQAKwtuEaA/4 X-Received: by 2002:a0c:eb89:0:b0:4c6:b959:238c with SMTP id x9-20020a0ceb89000000b004c6b959238cmr4225511qvo.49.1669150761408; Tue, 22 Nov 2022 12:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150761; cv=none; d=google.com; s=arc-20160816; b=TurASDXGvmahy3dBiNUjM0h41wh1z6ZAT3DDXdGKM2WOih4a0Ldbzvi4OxX05Sdg83 VNXgP0zsbDKWshS+rlTG0vSmoDCydEwfmAFpdW31eEIyzRwSgctRhsHQ/f1NsSCwlu9W Skw6Ex2BGINK5QCRDdnEhM1Ov+BOhoHkYsO9cxzdbsFBvNl9ghB6exFF0xLnXRVOkWUZ eu+d3k3EcYLgLmoHjI4tw344VsH30cK00JTgrr73GiYyZrCTHtvaN/WLEsAFul9zp4vN sVP0muyHnmsU3DYOtSAT4YQQyNueMTQrhJZZuvDWLAhoaJY2xVGR2vH5QLa8WD+tunJ3 RISA== 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=BWyV9wO7d+wf3OUu1IWrLDrLspSA8LDsjEbJNoFpi/U=; b=wvhLyK+WEQmvfbVZBDTe38HWt++wwKr+D4uA+HLxCuhEHv+1QF7guOhLFZ6LAFQHXx 4ZXNbv04GXdl81ruA6qLRMx3/bRqyYZnpISrPJWRwDnTVItA56TaMik8259DLEdvbej4 u8Lz3tS7QoAFXoftysFTsMIj2MK0oXPmNTAl/sYAbb7MzaGvZLB676uaitaf87aGKOkd BPtA8FqJ/cAGhWseDwkXZ2W0wweIm4pnzUfADGtFnxygYaj5CAPFAwijyoffZJCzuoQ+ Yl5qn0uVgIFK/DazrlmbRrkjOAsxkmIQDVkbt8zdiy+VywHauKGDhMy4bgTUGCMQ29Bx Hf/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Kh9BSZ/n"; 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 bp44-20020a05622a1bac00b0035d42e1ffc9si8570222qtb.147.2022.11.22.12.59.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 12:59:21 -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="Kh9BSZ/n"; 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 1oxaL1-0007LC-B2; Tue, 22 Nov 2022 15:57:51 -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 1oxaL0-0007KJ-3b for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:50 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKy-0003V1-Kd for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:49 -0500 Received: by mail-pl1-x631.google.com with SMTP id g10so14801151plo.11 for ; Tue, 22 Nov 2022 12:57:48 -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=BWyV9wO7d+wf3OUu1IWrLDrLspSA8LDsjEbJNoFpi/U=; b=Kh9BSZ/nOPwShdtPBfjRSd7EL4UYExRIUZDBMFBLu6BVTcFYi/RoQCGSTxEDKYKisN wCou2k1EQMhU4RkSLkNjqMiyx/S1c4QwJjWfskoGSrVW0ZJPgQSkpKChVSRAEJWf2Zcs lEbMWaTpe68m9TId+JYjRAJY1AsRCZAifu//2G167oYGVn+6qKqp0R6k8N+jmZL8LW// dfv3IU50R6YYoJeLb7TwS+GRbiJilDacos5QUbHr2cRlDAwgRTXePlFIOD9oVbUo19sr RpSVuJlYUQZFGaCestirWZq5hgCy5fr8iEoBNkrZHJ7wX2BoudgJNyAMq+RVIQoz1DZW s2vA== 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=BWyV9wO7d+wf3OUu1IWrLDrLspSA8LDsjEbJNoFpi/U=; b=PmpP4P4mbU1lcrfBw4qaq1LZqRr5MdQHoXGEedf60/5Vf6qjAcyOlntgnqR5Z3+JwH HIOiJuyo0lK190rgOjiyMRg9CVaSZTIS/1HB8yHG7jP/T5CqhleUD+LYI7Jz2Yg7w4F+ npxpoOCWmEZDYpLGcTm2vtNU/GZB+FKeOLFS1hTiiCNm+zcM6waf//rYe8ynyVQxsKH3 8+7VIk3b4jCAKMPJleIH79Yy0cZ3PNlRpBAAf3jWdc9rBDveU/qzXkKN9olGF57G2nqm vLdivrivzqfGw6D2rYmjnlQnmDRM9Asc+tPTd7D7xVCKmOBc/rmkHnl2jZ/29ZihWknx WeBw== X-Gm-Message-State: ANoB5pkGLSbaS2aqaBMOSjglMdI+KZpg6+yvCKiXYAKSGyf3hNUHEX90 tISVc2MNUpVkhL4HYJZ+6pwK6NUL4yfD9Q== X-Received: by 2002:a17:902:cacb:b0:186:9fc8:6688 with SMTP id y11-20020a170902cacb00b001869fc86688mr6033219pld.22.1669150667199; Tue, 22 Nov 2022 12:57:47 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org, Alistair Francis Subject: [PATCH v2 6/7] target/riscv: Use QEMU_IOTHREAD_LOCK_GUARD in riscv_cpu_update_mip Date: Tue, 22 Nov 2022 12:57:38 -0800 Message-Id: <20221122205739.603510-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/cpu_helper.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 278d163803..4c4b404dad 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -610,7 +610,6 @@ uint64_t riscv_cpu_update_mip(RISCVCPU *cpu, uint64_t mask, uint64_t value) CPURISCVState *env = &cpu->env; CPUState *cs = CPU(cpu); uint64_t gein, vsgein = 0, vstip = 0, old = env->mip; - bool locked = false; if (riscv_cpu_virt_enabled(env)) { gein = get_field(env->hstatus, HSTATUS_VGEIN); @@ -621,21 +620,14 @@ uint64_t riscv_cpu_update_mip(RISCVCPU *cpu, uint64_t mask, uint64_t value) mask = ((mask == MIP_VSTIP) && env->vstime_irq) ? 0 : mask; vstip = env->vstime_irq ? MIP_VSTIP : 0; - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + WITH_QEMU_IOTHREAD_LOCK() { + env->mip = (env->mip & ~mask) | (value & mask); - env->mip = (env->mip & ~mask) | (value & mask); - - if (env->mip | vsgein | vstip) { - cpu_interrupt(cs, CPU_INTERRUPT_HARD); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - } - - if (locked) { - qemu_mutex_unlock_iothread(); + if (env->mip | vsgein | vstip) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } } return old; From patchwork Tue Nov 22 20:57:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627517 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2723417pvb; Tue, 22 Nov 2022 12:58:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pc5lJi1MIvzUcDfTtkGjKVLWNXdFbFvwC9JPtuzMQMg8yWHOiQCoPWtzs9Vogvcv5j+RS X-Received: by 2002:a05:622a:4891:b0:3a5:280a:3c9c with SMTP id fc17-20020a05622a489100b003a5280a3c9cmr7931185qtb.282.1669150713197; Tue, 22 Nov 2022 12:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150713; cv=none; d=google.com; s=arc-20160816; b=qIHGnYELj+VxFr0FFMOFO5bkAIKZLXcK6fzMJiQSFezisHU0wzQLts2wTvXU/b+s6w 16bwxQswVPp/kZRheYxNutXERfIynP+O5MFZSl7/g/G0N+t1askcGFMLUSm1Kvts2I00 Z6z1Tl8x78c4Wto9Q8uYEmhhfcZf8S0S0Yf36j5G2d5YGtF+ZuiQn0tXUrSRSS2y/xFm vIGGX2y2NrtXIw9FHi24HfGLzJLvmjxREhZuBRIoOI2VvJszX35THFB4dLZ7eTYl67Ow ILPReUnXbmD6fYX/jh1RlsYm+ao6F0wI9orEEmORsOZoqVqWz0lynwCDM4ct7lqJWLTU OwuQ== 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=jYJr4MboKWNHHDRIY0tG/HwSzvYPNM+yCVJFiR1T/6U=; b=nf1XBYi+kzxcFj7IqFz/j9loFRlaUgR3yAjsSWndp0HLtQF9u9bnjvqMdF5vL7QrDS Y0LlhVbfi5Z81c+8fji4bcsNT0VvVhEWF/f0AeXRYXsmAr2QuzOcRIGT41v+WYC4xMhy 8YUHFpjwu3P0BTl9gO5CjW5I1ZThUxEq2e6DXWKUt1N0SwsBvHbEEwtpIaKZMN0BlW50 z4zmPFvZkTpOikzYHo2zlmrBkKutAF2OISTFIpBQyRkN0eQTfQZsKmDZ6fWTkzg2eNAx H3Rj+BKPXfjaFEzx41YWQprweB8FFNqe4DPguQicbxETaD95lh4THUnTC/JAjIHpu9d1 QShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="yIQweY/x"; 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 y19-20020a05620a44d300b006fa76ffe62esi10087275qkp.340.2022.11.22.12.58.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 12:58:33 -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="yIQweY/x"; 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 1oxaL2-0007N6-V9; Tue, 22 Nov 2022 15:57:52 -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 1oxaL1-0007LS-Da for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:51 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKz-0003VP-Hz for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:51 -0500 Received: by mail-pj1-x102d.google.com with SMTP id ci10so8054981pjb.1 for ; Tue, 22 Nov 2022 12:57:49 -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=jYJr4MboKWNHHDRIY0tG/HwSzvYPNM+yCVJFiR1T/6U=; b=yIQweY/x3WAaQEb3kMCyWN3gVf2imWNtjuaLviMlwsfuJBX9tWdqVjlU2IBqq2E5xP Sq4QXlJE3k3YDxPhn85QE/D6RpY8GnWzk5EPwbOO3gmAlvDWY/SJRbN7irtsrSQUNLLh UO9bM/jMvNU43imhqnQAOUZes8xdqJQEuA/ktkKGqClI6W4Qh+6CHIe8Zs/HHUxx6FYy 52cXWUDt/AyAsEOcrzt5gPyTmt9MSZ+IaHn9oRExnZnVoR/j+F01qCogrkRrZtOoLvdL UQBJi5twe2SuF3tokzVc++mLcLvBMT/o8yLyTjUpgMXl2VvthKOXroh2y86jWYt3MuZN ZKUA== 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=jYJr4MboKWNHHDRIY0tG/HwSzvYPNM+yCVJFiR1T/6U=; b=jFfUduh5Ix0BPiUv2WvGT5ymbeAWoNFcpXPpa30u3FrHhdD/r5ngkSqx7OCkV1ui9m S1ec/0Lce13qMaYv/1cYZp7G524QO9tOiOPeoChV15kMwlkEopvVEdyPSRfVqjJKF8xv 2AACffu3bjOPUGkmD0e/b1XeywsXmUbPUrjM9W6J3L6OyhC5/zK02tZaXh8kaUojfpDu omR+h+AdN080KHvz241SEBrFCDiR02W9+1Hh95+9act4ZML2/Z8voCqqkVmIVbAxMml5 jk5rG5qZjtnkQvuCCd3gcitZFczCOmUwzhIB23APGV9BR1BlS+PAlTGsbgG+LcpxMH9K JYHA== X-Gm-Message-State: ANoB5plHpEsDBYGt4Qiaq8PjutXtE4WFjLziPtjQXY32MbuRYIcpptkO kTVlxnv7KYGwSu73Z63C+GtGSvERWqNpOw== X-Received: by 2002:a17:902:e80f:b0:188:f571:cea2 with SMTP id u15-20020a170902e80f00b00188f571cea2mr8808245plg.146.1669150668241; Tue, 22 Nov 2022 12:57:48 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v2 7/7] accel/tcg: Use WITH_QEMU_IOTHREAD_LOCK in io_readx/io_writex Date: Tue, 22 Nov 2022 12:57:39 -0800 Message-Id: <20221122205739.603510-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 Narrow the scope of the lock to the actual read/write, moving the cpu_transation_failed call outside the lock. Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 6f1c00682b..8b86b70c60 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1356,7 +1356,6 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, MemoryRegionSection *section; MemoryRegion *mr; uint64_t val; - bool locked = false; MemTxResult r; section = iotlb_to_section(cpu, full->xlat_section, full->attrs); @@ -1367,11 +1366,10 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, cpu_io_recompile(cpu, retaddr); } - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - locked = true; + WITH_QEMU_IOTHREAD_LOCK() { + r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs); } - r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs); + if (r != MEMTX_OK) { hwaddr physaddr = mr_offset + section->offset_within_address_space - @@ -1380,10 +1378,6 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), access_type, mmu_idx, full->attrs, r, retaddr); } - if (locked) { - qemu_mutex_unlock_iothread(); - } - return val; } @@ -1410,7 +1404,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, hwaddr mr_offset; MemoryRegionSection *section; MemoryRegion *mr; - bool locked = false; MemTxResult r; section = iotlb_to_section(cpu, full->xlat_section, full->attrs); @@ -1427,11 +1420,10 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, */ save_iotlb_data(cpu, section, mr_offset); - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - locked = true; + WITH_QEMU_IOTHREAD_LOCK() { + r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs); } - r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs); + if (r != MEMTX_OK) { hwaddr physaddr = mr_offset + section->offset_within_address_space - @@ -1441,9 +1433,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, MMU_DATA_STORE, mmu_idx, full->attrs, r, retaddr); } - if (locked) { - qemu_mutex_unlock_iothread(); - } } static inline target_ulong tlb_read_ofs(CPUTLBEntry *entry, size_t ofs)