From patchwork Wed May 23 07:01:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 918866 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rQcg6QrMz9s2L for ; Wed, 23 May 2018 18:27:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t3S1XB0F"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40rQcg4YqtzF0kW for ; Wed, 23 May 2018 18:27:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t3S1XB0F"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=wei.guo.simon@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t3S1XB0F"; dkim-atps=neutral Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40rPkd5CQLzDsC1 for ; Wed, 23 May 2018 17:47:53 +1000 (AEST) Received: by mail-pl0-x241.google.com with SMTP id t12-v6so12509502plo.7 for ; Wed, 23 May 2018 00:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0BnlMFirdBjGvIK5bFJxQUrHat5Z/6NyE//oliZxzOY=; b=t3S1XB0Fi6qodL6uyP1ECUmnNjdaLwXE4LqaRqH5Pf59ihNbo1B3sKMlQMRQJkuLNz 6UEDlxelEhleWeGFtRaSFKKzdrRTqFhc1AECf959pj7iA5cM8iXWH3BaNH7Gs8zM1xgT 4G28KnFRI0JTV3W91gWPIF8NpwXIg7eQG7maA8BrnaZnItC/8hpkwIJt+xWS3vNXDhEN jk7d/6YEWvpmhhmoumdvUA0Wuy9725efZVsDUtdJbTXw1xMfHjXRMk8/eyanwCZ3qeZJ HaOdd8gdRqUbaCiHIBP0XUiJjCDe9kpOi5oviWDgQErG+vKwdixuUEcHRnWa15gtHkcP zPhw== 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; bh=0BnlMFirdBjGvIK5bFJxQUrHat5Z/6NyE//oliZxzOY=; b=EU4tiweOdHfHXYdnFaE3SqGCAewvkgB4I+nDMF5S2plo9w3kA5xBE324uktgQfFV6O iUIdaF3ub9pwCl+WPwu/R5G7LapXxE6nkqvPJjiQeYLockkSiZydajDdfH/0R3Wf2R20 cDOCkFdX+BoAXxFDtbpgHZ+u/2pgwKXnq91mX2pAZBR8uaS6/W1i+Cf6Zt7R4ZPt8gac jm0DyQvdHhoH55MOpiopYp76C/2Ek84lweo5n33C2qn+joH+va1M10RefCkarKFhzLTZ deIIlDMOElxT3P3+c8D1r0eu4LeoNkIqhp7ikg5Nwr7OvJFwLPZTsA1t6SQAp0qsYWL/ PQKA== X-Gm-Message-State: ALKqPwca9E9P5wBz3fpxTD7HeFPew2IY3VJjTB7P3+YcrDDsLNicEdBe nFABkmNT9aAuxwZo0RAxH94cNQ== X-Google-Smtp-Source: AB8JxZp/dLf4XPYOP5FltzCp21cc8ByGH4DOCpaGoXYjI981aXka5+hyLIDnJ1DcAAd2jCvCoyiePA== X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr1799934plo.305.1527061671668; Wed, 23 May 2018 00:47:51 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.89]) by smtp.gmail.com with ESMTPSA id a4-v6sm39079171pfj.19.2018.05.23.00.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:47:51 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v4 14/29] KVM: PPC: Book3S PR: add kvmppc_save/restore_tm_sprs() APIs Date: Wed, 23 May 2018 15:01:57 +0800 Message-Id: <1527058932-7434-15-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527058932-7434-1-git-send-email-wei.guo.simon@gmail.com> References: <1527058932-7434-1-git-send-email-wei.guo.simon@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Guo , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Simon Guo This patch adds 2 new APIs kvmppc_save_tm_sprs()/kvmppc_restore_tm_sprs() for the purpose of TEXASR/TFIAR/TFHAR save/restore. Signed-off-by: Simon Guo Reviewed-by: Paul Mackerras --- arch/powerpc/kvm/book3s_pr.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index f2ae5a3..7d4905a 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "book3s.h" @@ -284,6 +285,27 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu) svcpu_put(svcpu); } +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +static inline void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu) +{ + tm_enable(); + vcpu->arch.tfhar = mfspr(SPRN_TFHAR); + vcpu->arch.texasr = mfspr(SPRN_TEXASR); + vcpu->arch.tfiar = mfspr(SPRN_TFIAR); + tm_disable(); +} + +static inline void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu) +{ + tm_enable(); + mtspr(SPRN_TFHAR, vcpu->arch.tfhar); + mtspr(SPRN_TEXASR, vcpu->arch.texasr); + mtspr(SPRN_TFIAR, vcpu->arch.tfiar); + tm_disable(); +} + +#endif + static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu) { int r = 1; /* Indicate we want to get back into the guest */