From patchwork Sat Jan 23 18:50:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 369450 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2592176jam; Sat, 23 Jan 2021 10:54:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0AY4saI+C6O4hZ1t1Hm1KjA1cgY+8MpBYYBu2ILauust2ce8eibFXR9wbOiDDCDse4aot X-Received: by 2002:a25:f02:: with SMTP id 2mr14383782ybp.190.1611428083227; Sat, 23 Jan 2021 10:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611428083; cv=none; d=google.com; s=arc-20160816; b=zIs4/RujiFxm81y6yq5COk0+llCAWLgcajgGWFWXdeVh8vwEGON61rynC5nXbBLIR/ ZP1p2KZJqcQ5FG/Ud3M2tZ1DLc6se3qS3kVTVLiQMPVIM+rjtJ9xIx05i4shuAFNQ7WH EZ6X56P0Qluld1LIHIOpJEm3e2I0isrzrYrG8fLvp6plGQU30bH17FvK6PGyiGWlUNsO IH2mYa/USWW6SAB9ScyRPgXsTPL169aIpNE/8f7Msve//m4G2dgdXAUMBmDeHrxP4vQi VWJR0t0Q+qja93iARr/TmRGnp5BYWsyNcVI5PSy7Q0bv1Qwp56ezvbeavmmVVYovk0MY t5ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=wdBJyG9pvdbY/tWrWdbknFMnMMlRkyr0IIdSlApvTpw=; b=elz/P+i0I6bN/io0R66yRwiYo7+FlvY7TcUE2XolPAIhokkQRb4Dn0UdkYxihDaVJ5 2+wl0k/X70tYLyjEWPohY9gaswK2NUl2GxStnG5A9HWjiYxsEqnxPEQ7hL9BukLB2hNA fBy0OygJMYdJjDTyank5OvFZ6GUFJ3qyW0Ef4sQtuk/ZlJUiKACLK7pFrNKkoerWCdS5 6oksN1a4mUrcWpWyJdqMeUaSFuxB2NSrIcbR+1lyIEPtMPUdyF2V2YF9JuhIHyf4z32i defaVws3yoQqovp7KRtpYIFIocx3ggNb8XCqKG0DzkHuy2B+elNe6Iwh7uy139ISgkF/ C4kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ymwZOQfH; 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 e8si13728077ybp.331.2021.01.23.10.54.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 23 Jan 2021 10:54:43 -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=ymwZOQfH; 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]:36368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3O3W-0001w3-NQ for patch@linaro.org; Sat, 23 Jan 2021 13:54:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3NzT-0005Ag-BL for qemu-devel@nongnu.org; Sat, 23 Jan 2021 13:50:31 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l3NzP-0008E3-7F for qemu-devel@nongnu.org; Sat, 23 Jan 2021 13:50:31 -0500 Received: by mail-pl1-x633.google.com with SMTP id j21so547445pls.7 for ; Sat, 23 Jan 2021 10:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wdBJyG9pvdbY/tWrWdbknFMnMMlRkyr0IIdSlApvTpw=; b=ymwZOQfHld7DCBVukldRcdmdz9p7bX9JMNNYxbCglSEhb+BcI4dgf10ud6SrBA5StU 8zfvAMcuY9UTz0ieOm0vBRxwlak282Om6Aa25XizmeEqmlRY7c/115qmJoPUv4DlJAOD CvzamhDgJOl/o1XK2/Qe5mnDa28zFiAi8U34d3CSXl+Ru1E+FNIWW2Ko8DC8FBdOb+Ye P/+7dRfpcpkI6EQPkDsFWgYeH3WS5QhpDoLBcTfwSfN5RSRCRor9qOv3t0RyGY8kMoY/ T3oLzNW5C5nEOb9/OOwvXNuyWSHvTfe7CkgXPOR0Z73Own5DPfjzfbrO6c1vvRpFcS76 XjMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wdBJyG9pvdbY/tWrWdbknFMnMMlRkyr0IIdSlApvTpw=; b=FfWe71XCZuKOrZCUFH4m43+SW+L8C+ldnJArAyTviibMsd+AwF12yd3F0+EfUpiapj 3xFGbENesJbHtydUJ4vQfqxKdVFt4k5zj33U0U48PhjUZMQCDQB/mx50vbbYqa/79Jfs pLXHGaVUwB9EHQKicPdqt+5AWHlWx7XZaVKKMrfd+wB0//PeRcDDi7ygs7XLEgpK9LiZ AHeNk26mJibpQpaWKw6x1lFtcb+lPUVDy/q6NrJpVVc4v5OqC7xdAObgiGSps2CFAH7E K1e8ZmKm1YbekJvHjfnhfdaG9tXuuXMbv44evtLjVx43TFAVp3OqklSgxxmS0kt+b1D5 wSlg== X-Gm-Message-State: AOAM530wP5JgHeqZp9FiWhfTll5340oNrYJAgz4X2ZfXvwRNYqDAgv0e yJ6+x7WvBpFMn/JxMl2bX8DhpOkPFYwQDg== X-Received: by 2002:a17:90a:db50:: with SMTP id u16mr12958389pjx.39.1611427825225; Sat, 23 Jan 2021 10:50:25 -0800 (PST) Received: from localhost.localdomain (cpe-66-75-72-126.hawaii.res.rr.com. [66.75.72.126]) by smtp.gmail.com with ESMTPSA id j19sm5018614pfn.14.2021.01.23.10.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 10:50:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/10] tcg: update the cpu running flag in cpu_exec_step_atomic Date: Sat, 23 Jan 2021 08:50:11 -1000 Message-Id: <20210123185020.1766324-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210123185020.1766324-1-richard.henderson@linaro.org> References: <20210123185020.1766324-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Douglas Crosher Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Douglas Crosher The cpu_exec_step_atomic() function is called with the cpu->running clear and proceeds to run target code without setting this flag. If this target code generates an exception then handle_cpu_signal() will unnecessarily abort. For example if atomic code generates a memory protection fault. This patch at least sets and clears this running flag, and adds some assertions to help detect other cases. Signed-off-by: Douglas Crosher Message-Id: Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.25.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e0df9b6a1d..8053aa3f11 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -285,6 +285,9 @@ void cpu_exec_step_atomic(CPUState *cpu) if (sigsetjmp(cpu->jmp_env, 0) == 0) { start_exclusive(); + g_assert(cpu == current_cpu); + g_assert(!cpu->running); + cpu->running = true; tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb == NULL) { @@ -323,6 +326,7 @@ void cpu_exec_step_atomic(CPUState *cpu) */ g_assert(cpu_in_exclusive_context(cpu)); parallel_cpus = true; + cpu->running = false; end_exclusive(); }