From patchwork Wed Aug 24 22:18:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9298431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4EAFA607F0 for ; Wed, 24 Aug 2016 22:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 239052913F for ; Wed, 24 Aug 2016 22:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16AA529143; Wed, 24 Aug 2016 22:18:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BAD3B2913F for ; Wed, 24 Aug 2016 22:18:58 +0000 (UTC) Received: from localhost ([::1]:53579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgVd-0006fo-UK for patchwork-qemu-devel@patchwork.kernel.org; Wed, 24 Aug 2016 18:18:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgV6-0006ea-0S for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcgV3-0004Ma-Vi for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:22 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:43593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgV2-0004Jm-MI for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:21 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 60F4C20489; Wed, 24 Aug 2016 18:18:05 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Aug 2016 18:18:05 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=WbnFw5OIRBHtJjUyOJXscvJmWzw =; b=R0MVSEpZ72cv7CufGtSygu0rLZgTeMeeyS49gwkHyHVslq6NHJcQLWTDHtm qiOvNQspB6S3dAheHa68Xs8SW77/TtaPymFzbD4yzAB8mngBP+iK7eGEz8Jem0Kk P6FlQZuMpJ/LT3fH2IMlcee4T6G3FeHkfKEvV3THKEOBvQXc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=WbnF w5OIRBHtJjUyOJXscvJmWzw=; b=C4cseCiCBTJ5shpBo98V+U+WJ/JeAvM6rxpW 9tKZZdM99mojyVs9WnHCOVSE4eEvSAUAd3ss4iD2TUa6r8DIPAbF4jwpjhuRxV4f Yxq8mbfO8A04av/jJJYAuRhFHPETeZA8O5kHNhoIw7KF4mgHjT0FoHNv5b4Oi39M 93INODw= X-Sasl-enc: foXvbkgdOhYok4ViGPp81ViZwNDb+o2KuriG/uVflhbH 1472077085 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 1545EF29D0; Wed, 24 Aug 2016 18:18:05 -0400 (EDT) From: "Emilio G. Cota" To: Richard Henderson Date: Wed, 24 Aug 2016 18:18:02 -0400 Message-Id: <1472077083-15022-7-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472077083-15022-1-git-send-email-cota@braap.org> References: <20160824211240.GA26546@flamenco> <1472077083-15022-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.26 Subject: [Qemu-devel] [PATCH 7/8] htm: add powerpc64 intrinsics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@greensocs.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, nikunj@linux.vnet.ibm.com, crosthwaite.peter@gmail.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, serge.fdrv@gmail.com, pbonzini@redhat.com, bobby.prani@gmail.com, alex.bennee@linaro.org, dgilbert@redhat.com, fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Emilio G. Cota --- include/qemu/htm.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/qemu/htm.h b/include/qemu/htm.h index dc84bc1..f367ee4 100644 --- a/include/qemu/htm.h +++ b/include/qemu/htm.h @@ -39,5 +39,44 @@ static inline void htm_abort(void) { _xabort(0); } + +#elif defined(__powerpc64__) +/* compile with -mhtm */ +#include + +static inline int htm_begin(void) +{ + unsigned int status; + + status = __builtin_tbegin(0); + if (likely(status)) { + return HTM_OK; + } + if (_TEXASRU_FAILURE_PERSISTENT(__builtin_get_texasru())) { + return HTM_ABORT_NORETRY; + } + return HTM_ABORT_RETRY; +} + +static inline void htm_end(void) +{ + __builtin_tend(0); +} + +static inline int htm_test(void) +{ + unsigned char state = _HTM_STATE(__builtin_ttest()); + + if (likely(state == _HTM_TRANSACTIONAL)) { + return 1; + } + return 0; +} + +static inline void htm_abort(void) +{ + __builtin_tabort(0); +} + #endif /* ISA */ #endif /* HTM_H */