From patchwork Wed May 23 07:01:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 918856 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 40rQSw6RK1z9s2S for ; Wed, 23 May 2018 18:21:04 +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="VcnNVB50"; 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 40rQSw4m8QzDrTs for ; Wed, 23 May 2018 18:21:04 +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="VcnNVB50"; 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:c00::241; helo=mail-pf0-x241.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="VcnNVB50"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (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 40rPkY1QjWzDrnr for ; Wed, 23 May 2018 17:47:49 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id e9-v6so10080376pfi.4 for ; 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=qtfidES1XXcEeq7E3Jry9h3skYXwVWKgywLgcFkA6L0=; b=VcnNVB50az3sAhwoatus7MeGzOEBxo/DisiuODPhlyZ1L24buZrhfgATD8y94x92Q2 5CXxFQLjesitp4U5X37b+1hOj+bigSVvFFKjooY89CyoUFOQHZJUjc0qIMjbnrsdXT78 KxTmNMGMPw5R8OnQN6Dgnjw2MkrSKNud9vSttYsxnsr5RBMa4CNELj514E2hlGGcri5d fGDeoLiRGJ+IdcyoRtQ6wzux5e6Nfyt5XScHtXVu79dmJnn3sIKZH6EqVDx9EWZeRaCj 3MERWKDUbWlmxzO7wAjD9BT/oGao9jdLiAT+xml2iVqUS3hCOmwpZhB2+CI4PVoRR4K+ F6Kg== 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=QDRPu0rtu6dmD3rTHvByOdXZpp4WAEk0KctCN/PpjhX89oV7EMxf45rp5vkhcbMHGl POKrBz34Om++lowzhDlVskWg+PDl+keBvup4n2jsNoYu16gfXd7Km56hgNzJ6dfHn2aX jUeB8nhXfGGe30nja64CxN/ItT8LkBRhdi7r0k+bDwnSx6bWvdy7k72bpNeFNGzf7m7G iEIQSBhhgvEUoaLs7W2m3qsub7/e5uctMxWTl2YIfvpexV0fXfD4MsVOah2SukzP9PIQ ILHXN0+oVHHzAAdrRqeAY2XGoXnDOA3VvUzgRDN5GtLJqDwMuEo509/nGLcQf3dbQlMr lWlw== X-Gm-Message-State: ALKqPwfOpsl7ePgO/K2MQaeHKpU1T6362xwQRS1BwW48MN5tzm31sQK3 9SkvjTz2ZZiCwzq1X5WFi4hr7g== X-Google-Smtp-Source: AB8JxZoEH0HuEWgInWRVUOw315hgy5e14lNq1UWRUonn2xd19AF1iQIJ9oyHfHiYMpV0i7yGDYBoaA== X-Received: by 2002:a63:9c3:: with SMTP id 186-v6mr1455320pgj.357.1527061666616; Wed, 23 May 2018 00:47:46 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:47:46 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v4 12/29] KVM: PPC: Book3S PR: prevent TS bits change in kvmppc_interrupt_pr() Date: Wed, 23 May 2018 15:01:55 +0800 Message-Id: <1527058932-7434-13-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 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