From patchwork Thu Mar 26 19:30:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 184878 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp455755ilr; Thu, 26 Mar 2020 12:48:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuU5PA4fbX55Yj4EUcsWgNmWpwj4WbOdI2nw9dmWC8VlwOm7S+AF0Mw2W8nzcRh3ZgSPcxV X-Received: by 2002:a37:6215:: with SMTP id w21mr1765572qkb.149.1585252101628; Thu, 26 Mar 2020 12:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585252101; cv=none; d=google.com; s=arc-20160816; b=MFky0FClrUkCHUHGW0kUnJxV3mJyVcTOa+kpyQYZIFbJGDfbB3R138nB+5fHAPH2RM Wq2p7IH5FEwP10maxzU2264+XqoELXACmNwCdJLa6mskw0sJY7Gmg0HzbaudGcNFkqq+ JluNwAwnqs58XtoVfBrf++PsLMuSlo41p4QXtmcODec+arNAhDUUArxs+bTRdtGM2p3/ XxnYU/WewCkiKqCaLhOnLMsfPEe6MQU9vhyLOPGy5xeZbICl6CiEejREm+TpZPpZqrwE VlOL9GF1mAiUHvV+bT9TCWTjAULxM9tw6GY0HoklGeI3QgQ3C7xM/UYgRiMynyZDe4e1 OjBw== 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=eDLiMVv+D2ZXvXpFAK7V65+ch4hZt+k/wLuboxFFAO0=; b=SQn84htiBLgagT/p26FrNlRJt33jOQVhfluFcnKJPjbJlaiFcUiKBuSTKLrDao7h+E CJBq2PjO1BZujF2LkdNe2rE26uZiFn8RlTGWg4g3ViBm4Sph/SCGK+Ls3GG5OQvICQA4 bXTlGyM6oAzZuyvGHUsH+/M/GVYi0XjoIbVlNeLI+fm1Qsn1R5VI5Ib6TYJmUd9+Yp7u CRP5aPz4gmrg9mTUqlNTiH7xgkSMgzfapRm6/IR6phhcC3am1b7oHTsramhhIZtKgFzz pa7vPwLDh/dDqgZzqjcVpEx8OXonpGB/h5Zp8acBzImmUCdqxbOpqibJH5P7qJ6KbDn0 n3SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YYT9Pp6W; 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 q28si2073393qkq.284.2020.03.26.12.48.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Mar 2020 12:48:21 -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=YYT9Pp6W; 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]:58898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYUH-0008PS-3b for patch@linaro.org; Thu, 26 Mar 2020 15:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHYKB-0006WM-Nw for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHYKA-0001Uh-Cg for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:55 -0400 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]:37204) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHYKA-0001UK-8e for qemu-devel@nongnu.org; Thu, 26 Mar 2020 15:37:54 -0400 Received: by mail-qv1-xf43.google.com with SMTP id n1so3709465qvz.4 for ; Thu, 26 Mar 2020 12:37:53 -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=eDLiMVv+D2ZXvXpFAK7V65+ch4hZt+k/wLuboxFFAO0=; b=YYT9Pp6WMOUvmhMslR+1NSHC6ths3u+8qk/dHvbW3+zTnssXCynpiZdh98+9/qhJeq IdkYE8WvLEKXlQovJgJR4hKGx+6nIeZmxFKtJxMbc+vdPnTMTDgxmREqqhIihU73t1Y6 OYUXga1Xoa/4H+VrkjhJyhn4CKWxUDI7jgte6L8/mZXANZRBKh3TLhUUAFqgyOhDTVa+ MCJF2KlXMVFeX26c23+DI7gEmrQUhX4iReaV0KbZ4/IiU58hkop4I5oogKvhGXcL19wr eSUTShcXIh9Uw2yJEGNSXc8AaQOQIv6bvnjfMvwOnbJBPEqShjnZfyPVkh/WojLqntNP bIQg== 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=eDLiMVv+D2ZXvXpFAK7V65+ch4hZt+k/wLuboxFFAO0=; b=Jw9rkkBZUvYsBqnrzBBBIBG7dxQXtDg8DDC9FqCxLbg7GmXcCmwkjSLEjgh3VNVH71 twvKlJIEyXcy18soOcLHb+fkQpxZxuzJpbOONzbOeTJ5eVLKh1cxUl72o1jOaqlbND48 3rdzRY5avsrE6Cs0LZRRU0BgpYsY7f2LgXxXzvdQJ6dyIYhh/kXATe6Pc0F+0mJroPOn 7C5DK59ODnMn/nDwOpZ7AB6igQ3dmA/bcS0w1gyQUOAdnHOG/Q4AJt3KifNJx+Tpczeo uCqbMNluESaLLdH8zGE4m+CIePnDNpo2GrX86VHVqiYXXlT2KnaSlRAS3b8GVlpN1v6j 54ew== X-Gm-Message-State: ANhLgQ2wjiulb8l4KTZ7fNc0st0TmLlY7HER+kHKF+Sxo5/FjuUZfR8y bMSXiyZGqwoSfb0L7Bh2k/9VOXNPudwfUA== X-Received: by 2002:a0c:ee28:: with SMTP id l8mr10065622qvs.196.1585251472299; Thu, 26 Mar 2020 12:37:52 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:fd55:4e67:1038:8302]) by smtp.gmail.com with ESMTPSA id u51sm2161916qth.46.2020.03.26.12.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 12:37:51 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v8 15/74] cpu: define cpu_halted helpers Date: Thu, 26 Mar 2020 15:30:57 -0400 Message-Id: <20200326193156.4322-16-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326193156.4322-1-robert.foley@linaro.org> References: <20200326193156.4322-1-robert.foley@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::f43 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, "Emilio G. Cota" , 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" cpu->halted will soon be protected by cpu->lock. We will use these helpers to ease the transition, since right now cpu->halted has many direct callers. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Robert Foley --- include/hw/core/cpu.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 2.17.1 diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 3f7727ec70..48b46c90ed 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -498,6 +498,30 @@ void cpu_mutex_destroy(CPUState *cpu); */ bool no_cpu_mutex_locked(void); +static inline uint32_t cpu_halted(CPUState *cpu) +{ + uint32_t ret; + + if (cpu_mutex_locked(cpu)) { + return cpu->halted; + } + cpu_mutex_lock(cpu); + ret = cpu->halted; + cpu_mutex_unlock(cpu); + return ret; +} + +static inline void cpu_halted_set(CPUState *cpu, uint32_t val) +{ + if (cpu_mutex_locked(cpu)) { + cpu->halted = val; + return; + } + cpu_mutex_lock(cpu); + cpu->halted = val; + cpu_mutex_unlock(cpu); +} + static inline void cpu_tb_jmp_cache_clear(CPUState *cpu) { unsigned int i;