From patchwork Tue Feb 27 17:52:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10245899 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 D421860362 for ; Tue, 27 Feb 2018 18:01:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C465928A31 for ; Tue, 27 Feb 2018 18:01:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B892028A46; Tue, 27 Feb 2018 18:01:18 +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 8474B28A31 for ; Tue, 27 Feb 2018 18:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751663AbeB0SBO (ORCPT ); Tue, 27 Feb 2018 13:01:14 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:42485 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbeB0SBM (ORCPT ); Tue, 27 Feb 2018 13:01:12 -0500 Received: by mail-pg0-f68.google.com with SMTP id y8so7802390pgr.9; Tue, 27 Feb 2018 10:01:12 -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=YhIOI7uScjh+s7oIwMahbpZ6H1IErIxz3eXvv3rkXu4=; b=LsuRDrXFJ7SOzJsZ7VvV77blh5n7r2ngsgfCuKP1gEDXRoiDuBpvTDkFkofRDHTZfr lOdrU0VSx4tvu+f0ntwdb28uDqGGzXM0K5UfGuGM5eq0zSKXB/JRyxL3WEFnM30YgsBX LpmHiMxQkkv3Dhv0xeS6Tbncy7WLM3wwLSSLi6m+eYyaLXuf0HWXChopS+EUY59Tovvf sxrjwQslDpgOrnYPRtvpoQG4N3NAI+xZ/IBhA/M5KZiQ8I7U+z8iIPlt04IUu50xp4xQ QKee+YdYXaSJbeOJH46OQ17F4j2RtaWy6vllH6q6shLjW8NRfujZvOJMrELQboH/dbsl BxMw== 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=YhIOI7uScjh+s7oIwMahbpZ6H1IErIxz3eXvv3rkXu4=; b=ZRqQRbooywznIn42DpIhiU/vX9k20S4cwFf+w1RBW0WDi68myutscUVYYnXWUGKFE+ tHCMvVY3fogjT1AaF2vCX4Z+JcvJgnFLTziyRiKBfHXjdmnEcbckQFzpDh8opT+X5E5p bruQoAaBY+5Ov7D5NGXU/1c8tki7WMrUhXn+cH31Uls5tYNSGLFwstrc71tE9SWh9NnN KQVqLGoEs+Pb3OFz3i2f+zdnWLcOXlrv0Pc2GUteI4RnSEaFYNYk2maHD416J56l6Ery /2Fuhhzi3YY4PJNqHYyjYQI0KxqTbeXcNa0HPaZiz0pyB7OKU5Q58H9Iry6HxrWkGF9M PHxw== X-Gm-Message-State: APf1xPAjckx2kgbX3i35/YpvVdvyDX1lPTjtz6YhwvvnBiJg4eFtIEhN CDH+21srALA/pO7SwwVDEvJVyw== X-Google-Smtp-Source: AG47ELuTH6cRHbbmH3hmkUmd0Gbyflyu7nToVXTbOlp3qylVhefGul9CBvUQ9BJ1IDzTqGSx5J1zMA== X-Received: by 10.98.238.2 with SMTP id e2mr6961024pfi.68.1519754471846; Tue, 27 Feb 2018 10:01:11 -0800 (PST) Received: from simonLocalRHEL7.x64 ([101.80.181.226]) by smtp.gmail.com with ESMTPSA id m83sm24360910pfk.107.2018.02.27.10.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 10:01:11 -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 13/30] KVM: PPC: Book3S PR: adds new kvmppc_copyto_vcpu_tm/kvmppc_copyfrom_vcpu_tm API for PR KVM. Date: Wed, 28 Feb 2018 01:52:21 +0800 Message-Id: <1519753958-11756-3-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_copyto_vcpu_tm() and kvmppc_copyfrom_vcpu_tm(). These 2 APIs will be used to copy from/to TM data between VCPU_TM/VCPU area. PR KVM will use these APIs for treclaim. or trchkpt. emulation. Signed-off-by: Simon Guo --- arch/powerpc/kvm/book3s_emulate.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 2eb457b..63af17f 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -87,6 +87,47 @@ static bool spr_allowed(struct kvm_vcpu *vcpu, enum priv_level level) return true; } +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +static inline void kvmppc_copyto_vcpu_tm(struct kvm_vcpu *vcpu) +{ + memcpy(&vcpu->arch.gpr_tm[0], &vcpu->arch.gpr[0], + sizeof(vcpu->arch.gpr_tm)); + memcpy(&vcpu->arch.fp_tm, &vcpu->arch.fp, + sizeof(struct thread_fp_state)); + memcpy(&vcpu->arch.vr_tm, &vcpu->arch.vr, + sizeof(struct thread_vr_state)); + vcpu->arch.ppr_tm = vcpu->arch.ppr; + vcpu->arch.dscr_tm = vcpu->arch.dscr; + vcpu->arch.amr_tm = vcpu->arch.amr; + vcpu->arch.ctr_tm = vcpu->arch.ctr; + vcpu->arch.tar_tm = vcpu->arch.tar; + vcpu->arch.lr_tm = vcpu->arch.lr; + vcpu->arch.cr_tm = vcpu->arch.cr; + vcpu->arch.xer_tm = vcpu->arch.xer; + vcpu->arch.vrsave_tm = vcpu->arch.vrsave; +} + +static inline void kvmppc_copyfrom_vcpu_tm(struct kvm_vcpu *vcpu) +{ + memcpy(&vcpu->arch.gpr[0], &vcpu->arch.gpr_tm[0], + sizeof(vcpu->arch.gpr)); + memcpy(&vcpu->arch.fp, &vcpu->arch.fp_tm, + sizeof(struct thread_fp_state)); + memcpy(&vcpu->arch.vr, &vcpu->arch.vr_tm, + sizeof(struct thread_vr_state)); + vcpu->arch.ppr = vcpu->arch.ppr_tm; + vcpu->arch.dscr = vcpu->arch.dscr_tm; + vcpu->arch.amr = vcpu->arch.amr_tm; + vcpu->arch.ctr = vcpu->arch.ctr_tm; + vcpu->arch.tar = vcpu->arch.tar_tm; + vcpu->arch.lr = vcpu->arch.lr_tm; + vcpu->arch.cr = vcpu->arch.cr_tm; + vcpu->arch.xer = vcpu->arch.xer_tm; + vcpu->arch.vrsave = vcpu->arch.vrsave_tm; +} + +#endif + int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, unsigned int inst, int *advance) {