Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2778846yba; Mon, 22 Apr 2019 12:48:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbS1M1ql5pMk1wlZHTVEw9687qTPtAyvEl8h8WzDrL6fYKjpEUA2RW+e9zrLwK/ZaBUCW/ X-Received: by 2002:aa7:92d1:: with SMTP id k17mr22689256pfa.91.1555962526468; Mon, 22 Apr 2019 12:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555962526; cv=none; d=google.com; s=arc-20160816; b=o+G24xrMamweNH6EcZJR27VjqRwopRUbngjNWwIoBNYXx5o3+1gYhPoseswdKx1Jwm iiufqxwE308QoEC9aQVTAUhVz5UMmg7dCaiy/cFyUIxptmNkgj822BFyY0BLuD+jIYqR IrPL0tRRgUzJdcLKscPPZf4Oq0fgn8gS650O8+6kraZNaEGVUx1qUryz8ndPUwvtIHnk QVLveUEwYZEPH27jRQUX59eP0/7Uneg9+OcsU+ZesQ0ig7OrCngVaDuILjSTTO5EZMNo C4hfHz17VcwbcQKbbtADtIccY7/N1DQ7x+iT4cF0YKBlAjkr0yG9DZjvAHDHdASGE/Wa NZxA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eWtpB+DCe3mKHjyDnhDN3hjNgsndBGePsYllCBDbJ9E=; b=05UKXGK/nomX/Nn2EN+5CNgCs2CkYQIB0LL+4vrCG2o9MAzwGNnbpw07FOLKOeTncG S+fcNuSaX2uNSa5MYm8J4+N2rYQSFs8eu+wu6EiS+cQkUCfpcALw1fFYlI8chZTCOPkh vm72CEAqLil0BHY4/DZzCPM1dreACuzDhcLXG+PK1AqvH3RKO5YyrVIQ5Qg8desosCAx 3aVPP+OHlLkcpmGHGI0TF6ZCMRiA+1etIt74P5RDx9DWrtt77/y6CBNTga9SkiBGk/mE oO3XDBKRBwByMRSP/NJsPrAynwe4Nt+oFtQyAvXsx0Y8c3ywLcAfqlh1Q/dxwDtie54g WPVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CTaPR5Pn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si12683116pgp.30.2019.04.22.12.48.31; Mon, 22 Apr 2019 12:48:46 -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=CTaPR5Pn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729887AbfDVTp5 (ORCPT + 99 others); Mon, 22 Apr 2019 15:45:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729859AbfDVTpu (ORCPT ); Mon, 22 Apr 2019 15:45:50 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04863218D9; Mon, 22 Apr 2019 19:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962349; bh=kr6NEBRC3SUDRwcr/4esG9qxP7e3B4jMzbyLkYa2n+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CTaPR5PndZziuSDTsjJNmKqqCNvGp/YgxbawpkAjYMRZFQFzjn6LUvNLA51i4jNJp SLjHqPiU3rXFqqRr0qUBXtr6g2v24ih1xlL7Fkn3YGTpdUSf6ejbT0JsVP9b4dGRYq 68jkG8iOoEPnl2gaQooT9Wj7Qk2zPdzPwUi85ARA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marc Zyngier , Sasha Levin , kvmarm@lists.cs.columbia.edu Subject: [PATCH AUTOSEL 4.19 18/68] KVM: arm64: Reset the PMU in preemptible context Date: Mon, 22 Apr 2019 15:44:26 -0400 Message-Id: <20190422194516.11634-18-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier [ 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