From patchwork Tue Feb 27 17:52:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10245901 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 EF3F660362 for ; Tue, 27 Feb 2018 18:01:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0C5628A31 for ; Tue, 27 Feb 2018 18:01:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D522028A46; Tue, 27 Feb 2018 18:01:19 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6150528A31 for ; Tue, 27 Feb 2018 18:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751710AbeB0SBQ (ORCPT ); Tue, 27 Feb 2018 13:01:16 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33838 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbeB0SBO (ORCPT ); Tue, 27 Feb 2018 13:01:14 -0500 Received: by mail-pg0-f67.google.com with SMTP id m19so7816237pgn.1; Tue, 27 Feb 2018 10:01:14 -0800 (PST) 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=O58sc66A5r0YBXNMnZfWv2e7eakMWsy1D3Xe6S8BbvM=; b=dVxwda7KSVRNFylWPBwRgXvzrbmdAAet05XgblJ+10DSPoMsbwwm5aVsH1ZhE3tYkv LqWwcDwkOayDcfkQtYdzFpaIEGYsZeJghTBxxIycr9F/4I8xSt9fglwhZRkQQ1lJX4pP kRDaCMwpriMHxMfUOTGXr0XkiE8UoGzRkmgW+c53zR/fy2gjX1Gu3jZSXeO5433L63Y4 tcIb1wE6esUZWlqrJ72+c7S3oQswTHFGDVfnuNi+YHTsGiLhlepDP6D4xPdc85H9Ltr0 fhJul6pR2lhkOCMk9mKEYlmKGhTnEnjSlSKr5tBK1Em4Kg/wko3uFZlKosPu8zYb60gv UDOQ== 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=O58sc66A5r0YBXNMnZfWv2e7eakMWsy1D3Xe6S8BbvM=; b=bEuLeVKgVyCmaATascKlbm9L3xccJXLyosXq0AxHMug1X9cxFcssGCaSfZ3kdS94bf rG9eJzTLGrdmSlilW64gjUsEd5sJo+8gurVPm3WLCnb77q26kqdVHYHjZWkBk8Odz+h6 fPYRFvC/0lahp6WTC/w6winoAe1xxRvXu1Y3dQBArtvU2I7Jsy5CB2tKUFb5qePaRihx l9BcYylEwVjtdJiXEuueoUQUJ721s8zZsxOj1/UukYQ09Q01ZexD/dJdk9EcBdF+JQpx DNa+kxatezvMt9Kkp07sGzYsIFSqidQmDZsfuH1hL1u9NY9XAyGqXiuwSCqh9FKtE5mF zbbw== X-Gm-Message-State: APf1xPD+aYITl7a5kel3n1JTcZO5ANAuQ30wpwDstP3n09yuZGhtfpB3 8F7QOwYDhZecezbynF6MPUw= X-Google-Smtp-Source: AH8x227DOQI1qH35Xxqw6J3NH31zPwoRn/giW3Ke7UPxP1z7ux18s+ixhKppeKGiuZoxo7FO7csS6g== X-Received: by 10.98.162.26 with SMTP id m26mr14920600pff.217.1519754474101; Tue, 27 Feb 2018 10:01:14 -0800 (PST) Received: from simonLocalRHEL7.x64 ([101.80.181.226]) by smtp.gmail.com with ESMTPSA id m83sm24360910pfk.107.2018.02.27.10.01.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 10:01:13 -0800 (PST) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Cc: Paul Mackerras , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Simon Guo Subject: [PATCH v2 14/30] KVM: PPC: Book3S PR: add kvmppc_save/restore_tm_sprs() APIs Date: Wed, 28 Feb 2018 01:52:22 +0800 Message-Id: <1519753958-11756-4-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1519753958-11756-1-git-send-email-wei.guo.simon@gmail.com> References: <1519753958-11756-1-git-send-email-wei.guo.simon@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 4bf76c9..91d0e59 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" @@ -286,6 +287,27 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, preempt_enable(); } +#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 */