From nobody Thu Dec 18 17:52:01 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677031282; cv=none; d=zohomail.com; s=zohoarc; b=AmpILCiEc9GefwpLJTpLxm32gS9NphIrtdO5QYT4kzNZGxae3t9SKaizl52fvYnahR8jm/3uh+c55ZdUjAY6yUzRF04+pw2WyLNlM+bkuOgU9kOhyJ5zoi0g4nls0cG58mII6XwZ4m8qU9VVQc3HJDAI4uq21Hm3ADPe2Cx0Ea8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677031282; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nN1Nd19UG7Ob6HhOyu1ZExnb36Rzel7CeIAQhipYNRY=; b=HHccLbDRhmJTSXtK1MVgsr6sZDtIJOgxuDTySwV8K01WUT78TAFoWxOz4D2Uwa6A707FzaedjquctcnZq1dtGRk4u9Rs1SFng5cgYEMNm6Rlv0Fby2HH8Vt7RjWbtF06csNF+CvGIiJtN0aFcN+MRebgSucaXM3wF5YpdGX6nxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677031282493948.3724817418937; Tue, 21 Feb 2023 18:01:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUeQw-00034j-Dn; Tue, 21 Feb 2023 21:00:38 -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 1pUeQs-00032n-SR for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:00:34 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUeQq-00013t-Qc for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:00:34 -0500 Received: by mail-pj1-x102b.google.com with SMTP id nt5-20020a17090b248500b00237161e33f4so4834792pjb.4 for ; Tue, 21 Feb 2023 18:00:32 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id 2-20020a170902c10200b00189743ed3b6sm91468pli.64.2023.02.21.18.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:00:31 -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=nN1Nd19UG7Ob6HhOyu1ZExnb36Rzel7CeIAQhipYNRY=; b=j9n06ynxaS0F5kR+CHFeJ7ySRkcjI3DdScemCh4CqaPv4cror1TVmjW85Fe3fwnFNH yLXQK3Fj8MBeLQQlSZllrc31ZvC3Ax7xkcU9t8Kc4T+5RIOwBc5KlzJ6ksGi5PdQiVhh 9h6W/+BAJi5rLYw/oDScVo1/HIzp+Uk3b2lsczQ4WqyNfKy+SYLP/k2y9Ut+f25N2K63 1QH3dciqBbgc4OiZArWFLOEB9xGrYOayggFgfAefolEk+0g7zDBOBbHx5paWAWSWcVLU yzgeCMG/2MoGW2qDLHpM/wRQm7tyqEEBQKgmF+OgvKzVhtFHwK5UOUUHzT10KWkrAFKH rneA== 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=nN1Nd19UG7Ob6HhOyu1ZExnb36Rzel7CeIAQhipYNRY=; b=7LACxOH60cdGikvFVXg0ts5NFQ5QfSDABz3MCG0niEy4QlyYKeMsc8AipMtBqeYsBF isXJQytPvfQFSZL9XIskPIWT1agDfGWW92AdcS2MvmmUNtNGykb8cWuUN7aqnCczszOC UufIrVOYFPgPOvIUt/0wJOE8IGaTbhSBI1yni3L010WQy5rqm55XDriKZeyAIj+JGean cXdfI6MRSqnDsBjJIC9EBJJXIpoOQ+VnxEz2/UviRS1nB2zTFT2vX11hpGVeB3kofZw6 L1iD2AMyyjdMLydElvzmUfPuRJ/2f7wja+zx/Tb1uYXInXUrHbxDZl8TFbmkt6ZZI4Kd bpiQ== X-Gm-Message-State: AO0yUKVtywinz5zUkhBjafk1e1xCBtdAE72oUYzcqTp4RevavkpqDgAZ +ogt68cJyRDVEefrPrgSN6incJI4qOvpHQifoJE= X-Google-Smtp-Source: AK7set+PvmvUFyl0Wy0Eysf2WHuSEMGPg3hvGoN6tRoUqhUx7VcEwLjCzEfcjp/iCaGXSbqXN6m54w== X-Received: by 2002:a17:902:c94f:b0:196:88b8:8616 with SMTP id i15-20020a170902c94f00b0019688b88616mr8337734pla.5.1677031231455; Tue, 21 Feb 2023 18:00:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL v2 3/8] linux-user: Always exit from exclusive state in fork_end() Date: Tue, 21 Feb 2023 16:00:18 -1000 Message-Id: <20230222020023.904232-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222020023.904232-1-richard.henderson@linaro.org> References: <20230222020023.904232-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677031283126100001 From: Ilya Leoshkevich fork()ed processes currently start with current_cpu->in_exclusive_context set, which is, strictly speaking, not correct, but does not cause problems (even assertion failures). With one of the next patches, the code begins to rely on this value, so fix it by always calling end_exclusive() in fork_end(). Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Message-Id: <20230214140829.45392-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- linux-user/main.c | 10 ++++++---- linux-user/syscall.c | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 4290651c3c..4ff30ff980 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -161,13 +161,15 @@ void fork_end(int child) } qemu_init_cpu_list(); gdbserver_fork(thread_cpu); - /* qemu_init_cpu_list() takes care of reinitializing the - * exclusive state, so we don't need to end_exclusive() here. - */ } else { cpu_list_unlock(); - end_exclusive(); } + /* + * qemu_init_cpu_list() reinitialized the child exclusive state, but we + * also need to keep current_cpu consistent, so call end_exclusive() f= or + * both child and parent. + */ + end_exclusive(); } =20 __thread CPUState *thread_cpu; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1e868e9b0e..a6c426d73c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6752,6 +6752,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, cpu_clone_regs_parent(env, flags); fork_end(0); } + g_assert(!cpu_in_exclusive_context(cpu)); } return ret; } --=20 2.34.1