From patchwork Wed May 23 07:01:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10420509 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 97C1F6016C for ; Wed, 23 May 2018 07:48:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A14328EAE for ; Wed, 23 May 2018 07:48:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8810628EC5; Wed, 23 May 2018 07:48:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 6B2AD28F54 for ; Wed, 23 May 2018 07:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932117AbeEWHr7 (ORCPT ); Wed, 23 May 2018 03:47:59 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33363 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbeEWHrt (ORCPT ); Wed, 23 May 2018 03:47:49 -0400 Received: by mail-pl0-f67.google.com with SMTP id n10-v6so12519396plp.0; Wed, 23 May 2018 00:47:49 -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=hiDorcbcmXdJDl8PRb25wHNGkLQuArvNA6EWSnuuilA=; b=uwAJzGVDEC28Zz96ydnGMRZyp955u5Bsd6pymC7LdMnTbrksWY0peo+trb88DATKJ8 RY/UkXgudcOhWKUTL5PLWFyh/CqgEyIOCi2qzeP1J7i9JNUP7EIiYZaltSJ5ZcTVeoj9 0FSgHGj7rZjpHgDtG3xfaaQvk8VE90OiAl+mgIZ5NVaZfsU8Mwh/mopXYC0GS2qOO0v3 fIqhBtUvJtR16jrCaLB+oBi8rKBGiA9fbU/PxlIbEzY9WND7nVu0Ha6p7jnjsYY+psgO j8ka86FnFQioexidfvuj6qVG3CAHsaIto9LHfHlw3dldmDcd+cMO8ju1vk6+dH+mRPFJ /zXA== 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=hiDorcbcmXdJDl8PRb25wHNGkLQuArvNA6EWSnuuilA=; b=r4FG0ehw3K0Qct2imoOLQeU0C/yVoXPbNeyNjPZVnbBgiL+PYdyvaaMt4NGWXvZkTM 0x/DABDo+9fN7DgjgGSdrS069DExOsR/H5KDdi2nE10Z+EmtxatpfYTUuRw5KFepjlpz ZGeoVdduZJosAI0bK+T7mul9iTe4e8Hpe6JK9uMPyL8UTYCirt6LhNSFCVF+bpLQsNQ8 +z1LgU4gA9x9c0lj5Fy6Wvn1FVdH3PPrbtQewPg0CFy1JkME0G/WPU8/XpbDYvAXebBL lyyJkChzbbXlnDLU3bt3Twcg8iWlwFJeAgfaz+FbIaG+sqvTp7D0y2xknLihVL/EX31k 3e8Q== X-Gm-Message-State: ALKqPwe7gB7zxjo23Uz25HBP46VbeAWl6KEpsUr7UAABQM1qnneq7diz 9uzqt+n/MB651XMux+4Ub2Q= X-Google-Smtp-Source: AB8JxZq7eROJ9NwW2s1YvqIw1VHmWuAt6glTxStRgXgZOxSuNq0vwvGR8NYaMmB1EOge8Q2t0VviKA== X-Received: by 2002:a17:902:5952:: with SMTP id e18-v6mr1862662plj.351.1527061669103; Wed, 23 May 2018 00:47:49 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:47:48 -0700 (PDT) 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 v4 13/29] KVM: PPC: Book3S PR: adds new kvmppc_copyto_vcpu_tm/kvmppc_copyfrom_vcpu_tm API for PR KVM. Date: Wed, 23 May 2018 15:01:56 +0800 Message-Id: <1527058932-7434-14-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> 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..f81a921 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.regs.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.regs.ctr; + vcpu->arch.tar_tm = vcpu->arch.tar; + vcpu->arch.lr_tm = vcpu->arch.regs.link; + vcpu->arch.cr_tm = vcpu->arch.cr; + vcpu->arch.xer_tm = vcpu->arch.regs.xer; + vcpu->arch.vrsave_tm = vcpu->arch.vrsave; +} + +static inline void kvmppc_copyfrom_vcpu_tm(struct kvm_vcpu *vcpu) +{ + memcpy(&vcpu->arch.regs.gpr[0], &vcpu->arch.gpr_tm[0], + sizeof(vcpu->arch.regs.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.regs.ctr = vcpu->arch.ctr_tm; + vcpu->arch.tar = vcpu->arch.tar_tm; + vcpu->arch.regs.link = vcpu->arch.lr_tm; + vcpu->arch.cr = vcpu->arch.cr_tm; + vcpu->arch.regs.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) {