Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3803404ybi; Mon, 29 Jul 2019 12:57:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWVsdV63f9qN0Qd5poqu08G5ITSuDso/t5e8XaJh7Vuwp7GDRGcPWrzEulodRhZooPu66y X-Received: by 2002:a17:902:684f:: with SMTP id f15mr112020362pln.332.1564430250416; Mon, 29 Jul 2019 12:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430250; cv=none; d=google.com; s=arc-20160816; b=B1UB2NYbLuKvzYHnquHMW3T4I7zhdQB33nc9rdqlIDP9hRcANdURxSBzPwI4PxbiVv JewtI383RinbbWlzicLiDVnA89PMHqFQ93p4zHFQXHDs7P/JjdTSAF5wsGqYdWlQj0mW UJKCcZ51oOhiA8sf2L48mB9EjbzSzgNDA0nQTnGt1aypfdNu3I0CH27fgbdI6X4AK1mn yQnOkVtfd86aZ4K3vYT9ZEOY376sqGDzssNwHFgrPGkyM3Ug9MhbVjpbAmqw4/Opo91V y+9o1bz/L2poR/9OzvjHe7F4xfN8mobMsLUULsNYhGeEnpGz7VBBbd47NO8G9cPylL0m XjEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nfvd1l5NzdX88Gy0KtMaA/ge7hhfaZe0PeBP/dbwDuk=; b=uacX+48cGd9xv0c0R3MtEas1KF5NlVZghduTtXfV8bgqCnsIYmKoGtFwVT3UB9yPJI vEUYC9tZxoPI/kNf/LaWL0MhvQdGsOrONshDDhrU38Jf+qgYoYhtdfRaaxB3bQH0gR3s 8l3YAvXUBJo7MDc6mYi17g+m8UYV8QHZTc9FaLIDx4TmnNdkxar76u/uMItn/z2gSduJ 5YXI9Qqwp32IyWNUizW6/lqaiaoRCDCjOyC/UAWk9UW6FL0jpfzrwxYjwX+M9pqHVVoi PiZJ09JfHmD26bPcMxwwc5cdPRpztdYLZHdpaWMf/ObeK2tOhf2wMBlWj/8OKRuaJtui pv9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UnAYMdLl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si52623722plq.331.2019.07.29.12.57.15; Mon, 29 Jul 2019 12:57:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UnAYMdLl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403911AbfG2T4G (ORCPT + 99 others); Mon, 29 Jul 2019 15:56:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:48958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404265AbfG2T4E (ORCPT ); Mon, 29 Jul 2019 15:56:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 474AA204EC; Mon, 29 Jul 2019 19:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430163; bh=XRSDJcvmHaQSZCMe638gYg9xJlsKDcJ71p0J4mZtS3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnAYMdLlE9pP54xvOkYBvCbAaDCqYAQENZl+ywKI1fzUtD1cnUdEz/pbWgp3PZzwP RMSESNEuTXtXyqiRe39F0BvdnkiqsmucvtV3wCR1CU96P+Eeu1cKF/yTti9f3mZHKb Pqf6RaNB0L/gEH+6Y5WAMrF/uTguJHklKyYyzX3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suraj Jitindar Singh , Michael Ellerman Subject: [PATCH 5.2 200/215] powerpc/pmu: Set pmcregs_in_use in paca when running as LPAR Date: Mon, 29 Jul 2019 21:23:16 +0200 Message-Id: <20190729190814.579910296@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suraj Jitindar Singh commit 28d2a6e6684d9851905f379816d8a4d03587ed94 upstream. The ability to run nested guests under KVM means that a guest can also act as a hypervisor for it's own nested guest. Currently ppc_set_pmu_inuse() assumes that either FW_FEATURE_LPAR is set, indicating a guest environment, and so sets the pmcregs_in_use flag in the lppaca, or that it isn't set, indicating a hypervisor environment, and so sets the pmcregs_in_use flag in the paca. The pmcregs_in_use flag in the lppaca is used to communicate this information to a hypervisor and so must be set in a guest environment. The pmcregs_in_use flag in the paca is used by KVM code to determine whether the host state of the performance monitoring unit (PMU) must be saved and restored when running a guest. Thus when a guest also acts as a hypervisor it must set this bit in both places since it needs to ensure both that the real hypervisor saves it's PMU registers when it runs (requires pmcregs_in_use flag in lppaca), and that it saves it's own PMU registers when running a nested guest (requires pmcregs_in_use flag in paca). Modify ppc_set_pmu_inuse() so that the pmcregs_in_use bit is set in both the lppaca and the paca when a guest (LPAR) is running with the capability of running it's own guests (CONFIG_KVM_BOOK3S_HV_POSSIBLE). Fixes: 95a6432ce903 ("KVM: PPC: Book3S HV: Streamlined guest entry/exit path on P9 for radix guests") Cc: stable@vger.kernel.org # v4.20+ Signed-off-by: Suraj Jitindar Singh Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190703012022.15644-2-sjitindarsingh@gmail.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/pmc.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/powerpc/include/asm/pmc.h +++ b/arch/powerpc/include/asm/pmc.h @@ -27,11 +27,10 @@ static inline void ppc_set_pmu_inuse(int #ifdef CONFIG_PPC_PSERIES get_lppaca()->pmcregs_in_use = inuse; #endif - } else { + } #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE - get_paca()->pmcregs_in_use = inuse; + get_paca()->pmcregs_in_use = inuse; #endif - } #endif }