From patchwork Tue Feb 27 17:52:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10245897 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 4A39860362 for ; Tue, 27 Feb 2018 18:01:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C21B28A46 for ; Tue, 27 Feb 2018 18:01:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30BCC28A4C; Tue, 27 Feb 2018 18:01:13 +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 C2C5828A46 for ; Tue, 27 Feb 2018 18:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751605AbeB0SBL (ORCPT ); Tue, 27 Feb 2018 13:01:11 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:40010 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbeB0SBK (ORCPT ); Tue, 27 Feb 2018 13:01:10 -0500 Received: by mail-pl0-f67.google.com with SMTP id i6so11840730plt.7; Tue, 27 Feb 2018 10:01:09 -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=qtfidES1XXcEeq7E3Jry9h3skYXwVWKgywLgcFkA6L0=; b=I9NdJVev7waQ1eogKyUjYra2cZ5oHW++mFuw1N01NwDBB8+B357Xi5FvEht3sosICv Qr7HeMJBYo1CUceQQC0cnsZ6y1sT6I6IuAGQer76aZuuM5YEzifLn/Zjv8FN2cOKjqEX lWhgrNF5IS3m/y9twIZQ+2X2V1jVLdATcM0Vz01t1Jj28Od5FTDqcQ7e1OwOtKcC+5gr +V+da1eBTsayl6XWci8Bwiu1EtSiYMJaYDu9dW4qFlsIFLDDe8gJbzg/rkLkAY2jMaUT /+gbWlUPj92PBQnpN2VePOXUZkg5pmIKlL9lbb7dnqdbpBjxmwD/9pUrv/0s3FcG7ny9 6ojg== 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=qtfidES1XXcEeq7E3Jry9h3skYXwVWKgywLgcFkA6L0=; b=VXgUdHok1GXjfHCPw2zvfXDm2xO1IHoSYi9knZf81AraHCeLatXEmV8E1HAsGSm91v oPo7uZrMIvo/22wxObXFO9TY0JUAiZqPLKe1/XlZvJaFmmTvnNItaAVazSWfCiCSYykj YS9ejBunZwc07Nx8MBtFq1D0h5t1juUzjgeP/Ae2sUH6qD9QcxmU6FmovTEnaTepWOzW V5qLfiJpVvKHwOqlYEEcThaU59eMSRqczorrZ06TFXXMWsvtI2EHYOZ1v7X5rQUMCWLZ 9puNey76E0UO2uKFlQZvTnrBw/tOivApn0tSrEHVzQwSEKnKPLFqOtBpCOmFUkmd8iKj 7ofA== X-Gm-Message-State: APf1xPCnDHh4oBa3XdkVfaEXYtn2EevqTl1Wc3rgAjVIiTdsiN5C5NDd FPuZ8gBKuYQxGi3t3btIdso= X-Google-Smtp-Source: AH8x226BpgQWzQcj/fuOCfM1+k5JR0kOwbQDQa1+CKuyUHlOKWh98s1qSyqNXTGhlK41g0bv2TqzgQ== X-Received: by 2002:a17:902:bf0a:: with SMTP id bi10-v6mr15073618plb.181.1519754469342; Tue, 27 Feb 2018 10:01:09 -0800 (PST) Received: from simonLocalRHEL7.x64 ([101.80.181.226]) by smtp.gmail.com with ESMTPSA id m83sm24360910pfk.107.2018.02.27.10.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 10:01:07 -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 12/30] KVM: PPC: Book3S PR: prevent TS bits change in kvmppc_interrupt_pr() Date: Wed, 28 Feb 2018 01:52:20 +0800 Message-Id: <1519753958-11756-2-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 PR KVM host usually equipped with enabled TM in its host MSR value, and with non-transactional TS value. When a guest with TM active traps into PR KVM host, the rfid at the tail of kvmppc_interrupt_pr() will try to switch TS bits from S0 (Suspended & TM disabled) to N1 (Non-transactional & TM enabled). That will leads to TM Bad Thing interrupt. This patch manually sets target TS bits unchanged to avoid this exception. Signed-off-by: Simon Guo Reviewed-by: Paul Mackerras --- arch/powerpc/kvm/book3s_segment.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/powerpc/kvm/book3s_segment.S b/arch/powerpc/kvm/book3s_segment.S index 93a180c..98ccc7e 100644 --- a/arch/powerpc/kvm/book3s_segment.S +++ b/arch/powerpc/kvm/book3s_segment.S @@ -383,6 +383,19 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) */ PPC_LL r6, HSTATE_HOST_MSR(r13) +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + /* + * We don't want to change MSR[TS] bits via rfi here. + * The actual TM handling logic will be in host with + * recovered DR/IR bits after HSTATE_VMHANDLER. + * And MSR_TM can be enabled in HOST_MSR so rfid may + * not suppress this change and can lead to exception. + * Manually set MSR to prevent TS state change here. + */ + mfmsr r7 + rldicl r7, r7, 64 - MSR_TS_S_LG, 62 + rldimi r6, r7, MSR_TS_S_LG, 63 - MSR_TS_T_LG +#endif PPC_LL r8, HSTATE_VMHANDLER(r13) #ifdef CONFIG_PPC64