From patchwork Thu May 21 16:39:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 187034 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1720384ilb; Thu, 21 May 2020 09:55:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQjstEnZYfYR2xwOrjVM+itDI8TDQY3X3Ud1ailyHlUvv98i7tYMBhovGYo5pwmHAigVRu X-Received: by 2002:a25:148b:: with SMTP id 133mr16536356ybu.38.1590080156832; Thu, 21 May 2020 09:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590080156; cv=none; d=google.com; s=arc-20160816; b=BsI7v44V/vjLtIGhNecQz5kdohj3Yyl60F6FRQKJy0tJ6R9uj8tqcZt27ggLyG27Jt LkqXc/AabaZ7BolXlePatNzNJ3BwvNVwBll49BA6m1J25OPKgMc0ovbg1qv1Uufwlmbh np2jhi1BJKBN6S7DUtKNwaisNf0ONHh1Ibw2JRfDnQJjD9qIyZGpwYN2Tb/Owu7v4ww9 anr0bo6FWJL0vH8VHPt37TR0P7iZ2Nrk3WuP87yfsAZnqLirk9B9IAuK3rZyd3sIW54s H5rcOVOGMIF6Cst6OzbxfmHpvIuGq99PyWLWkFqNnH7doLa4KOTMn1JYhtSTVwaUqu+S IFpA== 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=pBQreEfimlo/TeCu0za1hNbEWK5jCOhKGwDICZx6xko=; b=Se2e0+uO6tFzA9hYL73m/GnLc+8/x4pKlJBXy/MClbhGJGY/oubTh2REwau/PuCXhr PMVRINKHAX2iouEUjbN8DsE9So6Nnf4MU/9Ozc1y8i61b9K2DqGZtv8rCxv+Gi2meQEV DHEBS+2PFt0PlMqT7J5be+naCPu9hAMVSbObOquwykQnL1mEVKpwkLJK0K7voHkqXiRg AjzzEL7AtZsDg28MVfTXkBQKWAQnhJVrgd2WlORGxvY8qhJFKaSa2FoE4PlYt2kkbp+O HlYNHxfyaehV+QjzfLo44QQ4t/yAwR3rME8QQ4BLw0iaV7cSArLbwLhniLAo1otfmeEE X0Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IzbY8sNs; 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=fail (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 e189si5350477ybe.281.2020.05.21.09.55.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 09:55:56 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=IzbY8sNs; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jboU8-0002Cg-84 for patch@linaro.org; Thu, 21 May 2020 12:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jboIY-0003Dn-GY for qemu-devel@nongnu.org; Thu, 21 May 2020 12:43:58 -0400 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]:44595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jboIX-0006ZU-Gx for qemu-devel@nongnu.org; Thu, 21 May 2020 12:43:58 -0400 Received: by mail-qv1-xf42.google.com with SMTP id ee19so3342776qvb.11 for ; Thu, 21 May 2020 09:43:57 -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=IzbY8sNsFCCG7RUPWdXm/GGEFVHfY3p59He/vZwaEPAQf9w6cTazD+Pzt4hJ5nhN6c qJfuJEjJjlOYIklwyaKoRbThan844MI2O1m/oqpQIdQprCnzxLM+wqzqVfpwnrHJdexw 99axPxXW77bY2l2Od7t0JPMWSX9vftYb8xNjtDFFRpAcADxJNk4sAvkiLOiOc5IE0ogC +JmUfSJcGRoEk86Es0ZNZgjd01siy+6azz3JWGhit9c8jey3E9jbu0kkDIHmnHgIn/C+ sAYJiJX9aGS9GyDfiwzsPScSxKwXxHWZePb3Fo0tZzK5x6ieUUBSBmXPMr8++sQAlYaq UsLw== 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=pZWCDD4GdUU4L/DO24Jfs2GZmIjaOGZvxriRqXd4OHTQ3uscclxSVg7Zn/6gkOrsz7 93Dha/8TtdobhWO2QZCTZ55w7iTmaPqjbiinDTVWZ/7lXOX+vI5nriAUFWw3kXpMFXvd bDew6GnvLziWaOMoCaec6uCQU1Ip4TXRHUB1EMAZFTpu42LG18ULi5eIJkw5owdpeBtE RIjkQPG1yjJISRu+N/FPSq2ctTK48nhLUOCYbSIoLbV3n/ylYuzAt1U/DFtznLyk2zfJ 1kHgeJ4FyxKHjVkeLnq8CNkljjWNynBvRqvQQ/DFQsIpsGiM0/VN8aFzYznHRTPdzm7m aoqQ== X-Gm-Message-State: AOAM530OoURYh+TGVVBnoFNw9EKv8kTBcJ2NmEcsvRTuGLcAhA9EVsaU 9xS1UKDySfOKBoVJDjZkE4GLcz7kjta7HA== X-Received: by 2002:a0c:b259:: with SMTP id k25mr3834404qve.111.1590079436348; Thu, 21 May 2020 09:43:56 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:1944:c530:655c:5583]) by smtp.gmail.com with ESMTPSA id x24sm5923829qth.57.2020.05.21.09.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 09:43:55 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v9 31/74] cpu-exec: convert to cpu_halted Date: Thu, 21 May 2020 12:39:28 -0400 Message-Id: <20200521164011.638-32-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200521164011.638-1-robert.foley@linaro.org> References: <20200521164011.638-1-robert.foley@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f42; envelope-from=robert.foley@linaro.org; helo=mail-qv1-xf42.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_PASS=-0.001, URIBL_BLOCKED=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: richard.henderson@linaro.org, cota@braap.org, alex.bennee@linaro.org, robert.foley@linaro.org, peter.puhov@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.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(-) -- 2.17.1 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;