Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7372528yba; Thu, 2 May 2019 08:46:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbOVNDPDKZYs0VXF7SMTGZ8W77eODyegFT9qYPWX04GzO0fo2PZyHr7Zf9XI96Lk+V1Lfy X-Received: by 2002:a65:5202:: with SMTP id o2mr4709789pgp.402.1556811984251; Thu, 02 May 2019 08:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556811984; cv=none; d=google.com; s=arc-20160816; b=tN9+dU5IAJQGqb3YQiRPyhmp4SYO9WsbOBDCjVkscSW59qyyUzWiqskdPPpGWz8Md5 KbImXf7wpLS0mBnZalknipmGLy9ia0PZRbnHcVqyEnmvfOkDYVbV3U416MDWZIWrvLmR 8694/RtnVimXhtSEev1fzEi24FwserldZRCsKfYvla3HY2vIhc9i8TZWh3rtq7nHiE9m feYS+8uuf5J5LvpbrSs+52v9NIQd2DYWvYpgDEhcu4Bz2vjOP38330fKVVL46pLnQWcm nsVYdGSgRU+8hdD+UjvInaoax/c5sY6NZEGLczCLBsnT7kIWgKk9aMiGSQZwohXAf75V WHBQ== 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=q03GBxHJ2K7NtyF3qCaPWJpNFU+nkjsEvDHk+Wio2J4=; b=lcO44WbL0HA1028fytV+GBDqWQYJNoefPcYmqo10Ovk4oIhFDNNFINlqhfL3bWFr5S Pf32+WQpKkp4WUQo3Tlsj+3YfB6fhJ1tZuevz2o1izptJoiLVuSZ+emtZEgDLFuShabd I4hqCFlCWdTmMyWJxNlTuEp3HvhwQNrzUYjavaZxeZ3kuccnhSoZwZrggwV2i14F6pIm Uox2eOOkIN2x3Aj3qI7pjPJlQkZ4YZGq4fe1UmpSGA0H8iM7yEwLXdZA2fYQy4uwEeF0 VUE5o7HW8vktf03AY1x5WJpGTytyJeR/sQ42+3KIehRbkSBbLH8yOhreryKhHzWAaqW3 ubTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I1EheUvT; 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 4si43718796plh.289.2019.05.02.08.46.08; Thu, 02 May 2019 08:46:24 -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=I1EheUvT; 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 S1727707AbfEBP0R (ORCPT + 99 others); Thu, 2 May 2019 11:26:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727694AbfEBP0O (ORCPT ); Thu, 2 May 2019 11:26:14 -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 E39E721670; Thu, 2 May 2019 15:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810773; bh=g7pQ+qV9qjfPJPHbFyDA5wuEwJSJCE5Zp4tcHpf0DN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1EheUvTVtRFft5XTvvk1JIpRTh+9wj7oSRdo+VkM5nB/K60/0rN/9DObMjkzrVb+ rO5On9Tk5BMtgSHTOOokERY/lwkzw359/y+MCJmIOg+0o0JFpGnAVk7U6lm6AHdvU+ mudnExxABkwgZb5i7Bi2R67fHigs7w0k3bjnmC0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Grall , Marc Zyngier , "Sasha Levin (Microsoft)" Subject: [PATCH 4.19 24/72] KVM: arm64: Reset the PMU in preemptible context Date: Thu, 2 May 2019 17:20:46 +0200 Message-Id: <20190502143335.312482735@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502143333.437607839@linuxfoundation.org> References: <20190502143333.437607839@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 [ Upstream commit ebff0b0e3d3c862c16c487959db5e0d879632559 ] We've become very cautious to now always reset the vcpu when nothing is loaded on the physical CPU. To do so, we now disable preemption and do a kvm_arch_vcpu_put() to make sure we have all the state in memory (and that it won't be loaded behind out back). This now causes issues with resetting the PMU, which calls into perf. Perf itself uses mutexes, which clashes with the lack of preemption. It is worth realizing that the PMU is fully emulated, and that no PMU state is ever loaded on the physical CPU. This means we can perfectly reset the PMU outside of the non-preemptible section. Fixes: e761a927bc9a ("KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded") Reported-by: Julien Grall Tested-by: Julien Grall Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin (Microsoft) --- arch/arm64/kvm/reset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 18b9a522a2b3..0688816f19e2 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -117,6 +117,9 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) int ret = -EINVAL; bool loaded; + /* Reset PMU outside of the non-preemptible section */ + kvm_pmu_vcpu_reset(vcpu); + preempt_disable(); loaded = (vcpu->cpu != -1); if (loaded) @@ -164,9 +167,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) vcpu->arch.reset_state.reset = false; } - /* Reset PMU */ - kvm_pmu_vcpu_reset(vcpu); - /* Default workaround setup is enabled (if supported) */ if (kvm_arm_have_ssbd() == KVM_SSBD_KERNEL) vcpu->arch.workaround_flags |= VCPU_WORKAROUND_2_FLAG; -- 2.19.1