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 Guo X-Patchwork-Id: 918850 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rQQF3srBz9s1b for ; Wed, 23 May 2018 18:18:45 +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="VN8fi6pI"; 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 40rQQF2MRjzDqG0 for ; Wed, 23 May 2018 18:18:45 +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="VN8fi6pI"; 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:c05::244; helo=mail-pg0-x244.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="VN8fi6pI"; dkim-atps=neutral Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (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 40rPkT726MzDrnr for ; Wed, 23 May 2018 17:47:45 +1000 (AEST) Received: by mail-pg0-x244.google.com with SMTP id w3-v6so9027621pgv.12 for ; Wed, 23 May 2018 00:47:45 -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=g+bhyRW5MvRzDFOWb5d5o6U0EY7SI0dAsuZXfzE0YKGD88MHr4miPY6IGoIb2Vex/9 HTKany2cE9ZKEWBatjkGlaNYl4h7bkAIvP4iB3kVZvvKXyFWZuwdgInnqPHbmljUUrFJ fVtcSPZesLkXZFRIqtE3yAdLTNiuYJMfuaiKaCcaPTg7F4YNTSwyBQB1fT9IKDQicVUE U4r+jgbDV3DB8mvV0p7reXnrQ/n84b/CXLewenCX3sPsSEst5oREUJbQMi35E4yGgU1n QgHcitIYsQl822Gsw0aWlHPwqeo29NtUuWo/7UgIBUtZoPD3IejF/mQ88PUG9+F8WrB3 /M5Q== X-Gm-Message-State: ALKqPweeTP2F3f6EskVmR85dQKeTMexl3YKXmQcfoIdL/ofBXjF6HLLW uM+XisDR6c2CUVr77BzPYL+CDg== 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 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> 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 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;