From patchwork Wed Feb 22 02:00:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655648 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp443989wrb; Tue, 21 Feb 2023 18:01:22 -0800 (PST) X-Google-Smtp-Source: AK7set+AxQQ/GPOEQygXo7ZYqE/S+RxAtnDVC6Jae7mU79T8LDtLRqoCkTF5d9f+wvXDolYrMeaR X-Received: by 2002:ac2:5984:0:b0:4b9:f5e5:8fbc with SMTP id w4-20020ac25984000000b004b9f5e58fbcmr2229790lfn.30.1677031282465; Tue, 21 Feb 2023 18:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677031282; cv=none; d=google.com; s=arc-20160816; b=agOt/bVHByHoVbVDu1Pkle0DDDwYMc5VMdNXuIUa8D6BTXU9nXnVscq28HRdu2sfnh w+fO8SK6InJn94+RrTBV3DAFS3lwNjqUspIDcr6DxGFjNSOpBF6Oi6suy3JdT0YHwlB6 MaW1mYp77fQN2Hv4i4mA9DXgQibEa3ErB9e2pUJeBvMp/YDc3DXzAHPP1dfKrvUpThNH SV1AAgoezizL3PfXTIMWiq5xStR0TLzLpjesi1b2VwF/wxlcoOv1cZXQrGMVtD/ZGU9l Cku2CykCiyQsr1EteVvZujuLxDcNjDYYu418B82GGfcRffJzgLlKfkk4bI+b+YcucN96 f0YQ== 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=nN1Nd19UG7Ob6HhOyu1ZExnb36Rzel7CeIAQhipYNRY=; b=pMzcXxNC3IXvgZmcjzK++SrtHbrQkwgE5vMF0EDqRPVZkJgBAEenJz7bE8nyOfRMYB 2DqpKRBEdmCX+JDudVaVk2D+jWqWADkWsKhp6X1120xyHzBQ1DI0lIG87Wa7LZJzKhMw qGkKgbGz27Miz/3WlcLiqKdjQoju43H11Qa92daMTjPX+Yjbw7k8iJiWygHORRyq2LZE C1TMLUHD/alfKTWT1VtdUVn9j0PzDALLghmDuqhzSSDBpxZGx2ZyEyllsksebdFKRWJC SyJbrpsbLiigYh7TY8iZ/sDJZGqt0cIDyDn7ZFGy78+K5VAXxG2LLt8QczUIFsdLHw6o G9pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j9n06ynx; 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 g13-20020ac2538d000000b004cc7fe5bf55si1936767lfh.160.2023.02.21.18.01.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 18:01:22 -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=j9n06ynx; 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 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich , =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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() for + * both child and parent. + */ + end_exclusive(); } __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 flags, abi_ulong newsp, cpu_clone_regs_parent(env, flags); fork_end(0); } + g_assert(!cpu_in_exclusive_context(cpu)); } return ret; }