From patchwork Wed Jun 17 21:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 190901 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp798400ilo; Wed, 17 Jun 2020 14:05:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUBHHJTJuQDp4jXld1KlsdaS5N0J3lYMrulL82HxoDaKNYco7znGiF6THTtWXbqWL9U5vA X-Received: by 2002:a25:2313:: with SMTP id j19mr1474163ybj.144.1592427909411; Wed, 17 Jun 2020 14:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592427909; cv=none; d=google.com; s=arc-20160816; b=QNyCPdJ/ogrKC7z+C6or3dRe1v2PqJ4+zxJ/rxK8qKXGd1NAU7JEUXpkymwk5kvxlV oEthkUZs3ZF2jRryWSquBBey2T6b26FhrPeFgTJNNnH6oqlKEQenPeC+vAbpZxHxBB0o zHHRLgQA7/VtqV6xsn83ENKxDSNtdAKmr4EsV6Pw0E6vlwrheEC1JjKSekgxiLQtOx1O LiGiftjtoLgVWpyUpJSwTSFjKOQMg+6XN7kgJqAUwO45VsTvHpG7EranHtWUrCNwRBFl Q5z4DNTWtQAK9Ur8DWbxjm97U7nxnjRUWWhpgWZ5On/RmHM1zshqvGhpGw05JUOmSMVO bwEw== 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=38XOeCAg8eirTLUPmY4XSVCYcrFE+9q7Dk1aEtr2HSc=; b=NgbvGq7uljbPwvNXXMhRNIevEfhIsPSh1e2aBdwnva4EwR6vJSmJWu/oDdwy6CfDOu eodtfnnY0dmg9MYiochP4ZeGdgiF1pBtnnHqaemWbXcGZTILsEFjpGKnVqUt3/ik1JlC Q3ndUlwu7MRcYKsRpOx+cRJCi0JBoLoJRTwjl/ujC7K+KjoM5G4CMf+5ucFSWtxsf37q Jv5WoDcRaGoxeEvdT/576mLGlmbt+5n/6ymSDOiB+/Xo+iK5HUa8PQVcRqyRbZNCqLuX y+i6tm5zXziqh2EruLYYTeq/ENUzAy+erOLB9wOgyLeJCMrv+rfpin3K8089/YvDYm++ MDaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QtqWXwkH; 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 b204si596154ybg.181.2020.06.17.14.05.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jun 2020 14:05:09 -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=QtqWXwkH; 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]:34522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlfF6-0002yj-SG for patch@linaro.org; Wed, 17 Jun 2020 17:05:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlfDf-0002q1-Og for qemu-devel@nongnu.org; Wed, 17 Jun 2020 17:03:39 -0400 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]:41385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlfDd-0008Rp-0R for qemu-devel@nongnu.org; Wed, 17 Jun 2020 17:03:39 -0400 Received: by mail-qv1-xf42.google.com with SMTP id er17so1755317qvb.8 for ; Wed, 17 Jun 2020 14:03:36 -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=38XOeCAg8eirTLUPmY4XSVCYcrFE+9q7Dk1aEtr2HSc=; b=QtqWXwkH/gGVezhhKpEW7oEkU6PGrLgNCGeRarDoft3Nbw73bQO9gWAlCHjQ+tnSjA gGEElf8eJJuOkr8OBu+CYGdCWGpmcXKHZ38H6o5bCRwVcoguXDME9xVmDK83DIodCZo/ LF2uHOF2Dfkqs18U9flgZVn36PuvcEV01wNFSb7E5kdN7QRg6QmH35K1NB2hfqClGP7p 0rdGigepcWmzigRNdNFz8SjNz8+xQsdCV96rf7yfr3BFRVDFx5i/yj27gtIGVzGqE/+n rMWG4T6+OA87VReCwXhhn19Wtkh0szfEOjH3DRH2OirA6etWTxzq7H/U5NLbmUfJ/VBA q/Bg== 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=38XOeCAg8eirTLUPmY4XSVCYcrFE+9q7Dk1aEtr2HSc=; b=f9ILX8p+mTeRd+IwEcqfKKjW7Nymmvus3o2B3QRykG8YzP0qJbRIDu8Id7EL8GLqtw GNanjWra8xBygxqOysw0HD8U7iKzVsmzfvtg48Kc/9drmANwgw+H3XoK9LhAo2sudwGk NxA39C3FugkC3zlI+dbkyuKM20a+1VOuKMk2ximSZc7yFD1cP4223B4TezhYsjyTN8q4 EjK7di8UWMoEB//jdvS5gMr1BXFXkXcWiwPYeJsVqSfgru5qqlGsASp1UXYnr02UtHBH IZIUpBPpWahmcY1zdbfvtGlsZ7nhXqPU+0og4onIAWlqnXKnIBBugEc82QaPfTbANUvS btEg== X-Gm-Message-State: AOAM5307tvVwUYbl3GcXtX+UQnZM9zF54KONGlQcWnUP9xDl0PDnkzG+ wB9dKG/EYLQUazBJ4scmgW2p4Od3WlwARA== X-Received: by 2002:ad4:590d:: with SMTP id ez13mr555335qvb.177.1592427815933; Wed, 17 Jun 2020 14:03:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 14:03:35 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v10 14/73] cpu: define cpu_halted helpers Date: Wed, 17 Jun 2020 17:01:32 -0400 Message-Id: <20200617210231.4393-15-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::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_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, peter.puhov@linaro.org, alex.bennee@linaro.org, Eduardo Habkost 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 9d25fc25a2..92069ebc59 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;