From patchwork Wed May 23 07:01:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10420505 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 8E41F60327 for ; Wed, 23 May 2018 07:47:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81CE228ED5 for ; Wed, 23 May 2018 07:47:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 802D428EE3; Wed, 23 May 2018 07:47:56 +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 22E3A28F2B for ; Wed, 23 May 2018 07:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754369AbeEWHrx (ORCPT ); Wed, 23 May 2018 03:47:53 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38813 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754275AbeEWHro (ORCPT ); Wed, 23 May 2018 03:47:44 -0400 Received: by mail-pg0-f68.google.com with SMTP id n9-v6so9039056pgq.5; Wed, 23 May 2018 00:47:44 -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=Fd7zRPuC8QHUggE7nig11elvhE6bWqgSLOfzfP6sqbc=; b=VN8fi6pI3S1YvMjwydIj8sQG8XxjorS9qGVWoIStYkXxCEJh3QS8hsgtVum6KCbtoC HEEVkW2fGaYjohzv9ZtPpVpTw+ecGBizyVPFszue01zDf/eLF5fcM6avio+o7EbSH44K adrwz6kTjUHVZqhMYtss7f3fU8AFKb7ZgQcHf+nWQSAO3qWNDJ5FBsyudoZqkI84l9HT cpvKk7qmL/qR7cI5wb7a1RjKk59/9ThH2nNyNasHhog2IFm/P7HXCk61qznHKbX84L7f mG1b4c8uQjEl8IM+lqGKhagPsXN1t7o/+BQkGqYmoSyLldcAmVSHV0VUVSO7KY7MK9Bc oBzw== 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=Fd7zRPuC8QHUggE7nig11elvhE6bWqgSLOfzfP6sqbc=; b=ka/Xw8gGz/IS9g4SkBRsLSBhNRoXo7ldyXSOd1RtSextWbcVaLb0rCQsnCyFqWTk2c PY6nKIr4cEWpRScuBeECWKqkcmZmvsg+yJYTpHYQ33fz55V92dOiaoa3sL88xHZU8BmH wbm3j6cydUOKVgXgDibw5X+V3M7U4i3PQBypNLH59Ph1uk3YLz4fXw4+CF2pj893egPk wTEHnNZhEaHWklQj48Cmzh9RGnsl+U3a8nadSFSqEXH9bv5fPsrIbOx0ZV6JL0xfPARc 2MzKRsqs92ynXzsc5wZwfUtyhr+OmpthG8gtvdEPLQYCa+oAR7oYyKTwJjnRcVGdb4Xw mNyw== X-Gm-Message-State: ALKqPwdXpfa7nD6qXvrDl6TGOdmCxGbrIkWAigb/7Vup1CfukzOh7iUq M/eodMEV4Kdf+U8cu5lFcblsbg== X-Google-Smtp-Source: AB8JxZrakWuLSOTpEspDxk8Su75l9okGC7bLfdhvXuBFmZPSEqEHRUMUnzpQaAHEYbyoDOuP6WB9tA== X-Received: by 2002:a63:7a5a:: with SMTP id j26-v6mr1455408pgn.421.1527061664095; Wed, 23 May 2018 00:47:44 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:47:42 -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 11/29] KVM: PPC: Book3S PR: implement RFID TM behavior to suppress change from S0 to N0 Date: Wed, 23 May 2018 15:01:54 +0800 Message-Id: <1527058932-7434-12-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 Accordingly to ISA specification for RFID, in MSR TM disabled and TS suspended state(S0), if the target MSR is TM disabled and TS state is inactive(N0), rfid should suppress this update. This patch make RFID emulation of PR KVM to be consistent with this. Signed-off-by: Simon Guo Reviewed-by: Paul Mackerras --- arch/powerpc/kvm/book3s_emulate.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 68d6898..2eb457b 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c @@ -117,11 +117,28 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, case 19: switch (get_xop(inst)) { case OP_19_XOP_RFID: - case OP_19_XOP_RFI: + case OP_19_XOP_RFI: { + unsigned long srr1 = kvmppc_get_srr1(vcpu); +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + unsigned long cur_msr = kvmppc_get_msr(vcpu); + + /* + * add rules to fit in ISA specification regarding TM + * state transistion in TM disable/Suspended state, + * and target TM state is TM inactive(00) state. (the + * change should be suppressed). + */ + if (((cur_msr & MSR_TM) == 0) && + ((srr1 & MSR_TM) == 0) && + MSR_TM_SUSPENDED(cur_msr) && + !MSR_TM_ACTIVE(srr1)) + srr1 |= MSR_TS_S; +#endif kvmppc_set_pc(vcpu, kvmppc_get_srr0(vcpu)); - kvmppc_set_msr(vcpu, kvmppc_get_srr1(vcpu)); + kvmppc_set_msr(vcpu, srr1); *advance = 0; break; + } default: emulated = EMULATE_FAIL;