From patchwork Wed Jun 17 21:01:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 11610649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C318F912 for ; Wed, 17 Jun 2020 21:25:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A8EE2166E for ; Wed, 17 Jun 2020 21:25:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mvQxS9Ba" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A8EE2166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:60436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlfYS-000692-S3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Jun 2020 17:25:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlfEA-0003M7-Tm for qemu-devel@nongnu.org; Wed, 17 Jun 2020 17:04:10 -0400 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]:38879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlfE0-0008VI-Lt for qemu-devel@nongnu.org; Wed, 17 Jun 2020 17:04:10 -0400 Received: by mail-qv1-xf44.google.com with SMTP id ec10so1759797qvb.5 for ; Wed, 17 Jun 2020 14:04:00 -0700 (PDT) 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=pBQreEfimlo/TeCu0za1hNbEWK5jCOhKGwDICZx6xko=; b=mvQxS9BaVCNlAsDmYqVgirbmHemc9z5WGJbjnkzJv9ld/zyyZnu2xIuYAEslfWbhRH F0UFFmKK9x7rybo2O0NewTwltqm2r1k+4KdIBj/9sJ2/Vmokmyry8qIJaWNKfScDuH63 qyu3ICvzmMwurx+Eoo+8C1+iFvJMGXX11vb+Uwx1e35m/kA8OPODIky6I7YThgaDKUf1 INQtuUChZzhR4ix/qMdLcXTbRXp+kbLvJGjit+ApcHspQ51etdD1mX2UO1kiLgnirtGZ 2rol7lbp1wGZ/6SbHz9PzLVSaJHsNlA0f8a7PFj0QK0f8530JVKEutKjUMfG/qPtMoPP uP4w== 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=pBQreEfimlo/TeCu0za1hNbEWK5jCOhKGwDICZx6xko=; b=OCKk5osMC81pB/ardUXjVUk7urg0QspjIQg8YkYYHYDft6N8ESj4AsjWyNFzez4hVV SSSOr5oe7dtACOhN9PjXZYIlg96wjBYXv0cA9kEY9KaQAWkUK1lWSA9QDi/mhJqigC6E HlDwq11cQsNMUuQYntFkiHqg3JWqdv4PHHRBjo83J326EncwmK1H9MwjUrgsJ11/9YuU 9icILbepu6aIpsSdrowCtORKhv9a6XQ5nCqgOLaeXa+W+5+jJzif2c6Y8/gjCh9pkuZr wDZ0gZJCZl1PKWjsu1Pqxe2TW27Zk//oQkUhjlMiXjRzV0xce0GToDJ4gFUYRfTR7NPv 6wiA== X-Gm-Message-State: AOAM532xGlLBVhoZEDT3+fpHmxB8c0RaQ/TgH+GyUWFBKewU8bvYWFk9 K/pE3PJwImibw+3Ia+ASj7WybTJKKYew7w== X-Google-Smtp-Source: ABdhPJyYrZ1uBKzifJhfGS0O+c6KGeE4xxlb8UUt+Gho5aEbJ3lKBpPux2D/YwwyH87j+UAFFgk2rw== X-Received: by 2002:a0c:d40b:: with SMTP id t11mr623582qvh.0.1592427839478; Wed, 17 Jun 2020 14:03:59 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:fc79:714c:9711:2e9c]) by smtp.gmail.com with ESMTPSA id w13sm997245qkb.91.2020.06.17.14.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 14:03:58 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v10 30/73] cpu-exec: convert to cpu_halted Date: Wed, 17 Jun 2020 17:01:48 -0400 Message-Id: <20200617210231.4393-31-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200617210231.4393-1-robert.foley@linaro.org> References: <20200617210231.4393-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f44; envelope-from=robert.foley@linaro.org; helo=mail-qv1-xf44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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=_AUTOLEARN 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: robert.foley@linaro.org, cota@braap.org, Paolo Bonzini , peter.puhov@linaro.org, alex.bennee@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- accel/tcg/cpu-exec.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d95c4848a4..e296894ea1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -425,14 +425,21 @@ static inline TranslationBlock *tb_find(CPUState *cpu, return tb; } -static inline bool cpu_handle_halt(CPUState *cpu) +static inline bool cpu_handle_halt_locked(CPUState *cpu) { - if (cpu->halted) { + g_assert(cpu_mutex_locked(cpu)); + + if (cpu_halted(cpu)) { #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY) if ((cpu->interrupt_request & CPU_INTERRUPT_POLL) && replay_interrupt()) { X86CPU *x86_cpu = X86_CPU(cpu); + + /* prevent deadlock; cpu_mutex must be acquired _after_ the BQL */ + cpu_mutex_unlock(cpu); qemu_mutex_lock_iothread(); + cpu_mutex_lock(cpu); + apic_poll_irq(x86_cpu->apic_state); cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); qemu_mutex_unlock_iothread(); @@ -442,12 +449,22 @@ static inline bool cpu_handle_halt(CPUState *cpu) return true; } - cpu->halted = 0; + cpu_halted_set(cpu, 0); } return false; } +static inline bool cpu_handle_halt(CPUState *cpu) +{ + bool ret; + + cpu_mutex_lock(cpu); + ret = cpu_handle_halt_locked(cpu); + cpu_mutex_unlock(cpu); + return ret; +} + static inline void cpu_handle_debug_exception(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); @@ -546,7 +563,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } else if (interrupt_request & CPU_INTERRUPT_HALT) { replay_interrupt(); cpu->interrupt_request &= ~CPU_INTERRUPT_HALT; - cpu->halted = 1; + cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; qemu_mutex_unlock_iothread(); return true;