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 Guo X-Patchwork-Id: 878758 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zrRlm3KGSz9s1s for ; Wed, 28 Feb 2018 05:18:44 +1100 (AEDT) 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="I9NdJVev"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zrRlm1d0HzDrD4 for ; Wed, 28 Feb 2018 05:18:44 +1100 (AEDT) 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="I9NdJVev"; 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:c01::244; helo=mail-pl0-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="I9NdJVev"; dkim-atps=neutral Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::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 3zrRMW2WcrzF1Cm for ; Wed, 28 Feb 2018 05:01:11 +1100 (AEDT) Received: by mail-pl0-x244.google.com with SMTP id u13so11849796plq.1 for ; Tue, 27 Feb 2018 10:01:11 -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=LXiuQsLoQLebFR/uHDUl2wf3RmTj7Y1+Nk7NFDeQ4E5I7gwx2DxdiN3lfZ84R5n5YU XV5ob+ECRhCs9YAZneOVNZ+TVdhIGx9m5SSVbfsuLBvaY55xTrasaYmu3AnnZBwKPSlZ CHwjI07QZRb5hgvA27B+BB2RZR0vak55Vsx5Vb5G+jkQt0rAIy11ajpHAKGmMWBgN294 R6cUOnXPAmwPY+nxav8vcEsMUeRr0JH+QByPuzgOPBc8yADJWdHeXEk9//Pngt+w2C4b IcJADXuCnEpgTis6Hz1E1TJoNP4RUAyZm0NR41QPmFEeFeISEM+I+BP317V3dL61Unss kc8A== X-Gm-Message-State: APf1xPB72NLmkFimAW/r4E5R/O07jtRNDhY6DEuiXXkd5kkiuvUydYYf cd+bL9vK8n6FLDPB5LAaEabQaA== 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 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> 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 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