Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3761724pxt; Tue, 10 Aug 2021 10:42:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAdP2BevBgDVop/PPiCdE4E1ODE7xkUOodlz092A8JYH3VDrFTTZq1dEN2+LwAuamsaZ5E X-Received: by 2002:a05:6402:2709:: with SMTP id y9mr2959497edd.149.1628617376002; Tue, 10 Aug 2021 10:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617375; cv=none; d=google.com; s=arc-20160816; b=CvQMrySsHToLqGJtP7c9sozLnga10BUWwodbtcJxVzfDT+iTNCf0XB0IpFRK9Fx7Gt rzNg0UOO4bzPYzclultxXGEXbtvx5lYlcBFF3crWwQphYSOgEahLGVTpZ0id8Zou3r2s dLqJouoJKOvClrtGyUa58ZxH4ozFUbR7xzDKJhUbvyN4r6Y4UOspNpbWz+KVgjZyH0gP aCoOp5tdocuqb9gcU4YtbqTOBL0DNyT7RLqCF90OHy1o3qCeL44Yd6p5Z8CMUr4HfrQA TuxyPgDBnTBJTbffvZc7OS8AiYA27BR2tQpB43+iaXsPn4UpzS9PxX62RMNmQ0y/Q0Ts BCjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PBFKH22tfa9dQVjknziyyjxfHLr+AD3ZDDpCLzNCO0g=; b=re7POb8swm1yH6vCDW01IuZYIfLmGZOU/PbmJ/5Ji+GEcxHycn/nKl4DiSwYx38jXO uOdRAmPyKfDhLlPX3xG/6CBTXkwze1LZmGrYNMIUDA/YBzpeCZnnHEaj/0jE+C53vnNR C1YyJSsbgShrlnYGoYpYzOAxG5Sc7DMoZVxzngjdZ+aeFKB/q83jPPZjzO5oaknCPDyd NS14qOnvWmsssTsVm4X2/+I027ghr8z8hbma0jI+5c78Hc11WX3AErlfwhskgL9Z+NaB oGc7SAOWE7bRpRFOSZUOplzZZ0jQz+yE8RoTv7MtfZ60+VVm8k2xWrKod6I5ZfcoR7Jp RZtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LF0RcYCy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b2si10215867edy.436.2021.08.10.10.42.31; Tue, 10 Aug 2021 10:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LF0RcYCy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232452AbhHJRl3 (ORCPT + 99 others); Tue, 10 Aug 2021 13:41:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:43990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234778AbhHJRiQ (ORCPT ); Tue, 10 Aug 2021 13:38:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88B646101E; Tue, 10 Aug 2021 17:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616980; bh=Fz3osT4DG4eGCCCkjBdddW7LB3h7cyjEm7iXc2Pi3d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LF0RcYCytwW5aPnwvnrR54J0bELSDmicvUGM9uzRhaqQJK0HO1Z+0j4SIFHeLkZAm R25v22/yGIpl8JdvogXKXRn+E4pf+g96XihyMEs+TsWmxh+e2G2RY0ApC1jH6VOO0W +TC7sj19j2Zk3LWHkaOIjMFdSNawciakvFE45Mzo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Like Xu , "Peter Zijlstra (Intel)" , Liam Merwick , Kim Phillips Subject: [PATCH 5.4 77/85] perf/x86/amd: Dont touch the AMD64_EVENTSEL_HOSTONLY bit inside the guest Date: Tue, 10 Aug 2021 19:30:50 +0200 Message-Id: <20210810172950.834994078@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172948.192298392@linuxfoundation.org> References: <20210810172948.192298392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Like Xu commit df51fe7ea1c1c2c3bfdb81279712fdd2e4ea6c27 upstream. If we use "perf record" in an AMD Milan guest, dmesg reports a #GP warning from an unchecked MSR access error on MSR_F15H_PERF_CTLx: [] unchecked MSR access error: WRMSR to 0xc0010200 (tried to write 0x0000020000110076) at rIP: 0xffffffff8106ddb4 (native_write_msr+0x4/0x20) [] Call Trace: [] amd_pmu_disable_event+0x22/0x90 [] x86_pmu_stop+0x4c/0xa0 [] x86_pmu_del+0x3a/0x140 The AMD64_EVENTSEL_HOSTONLY bit is defined and used on the host, while the guest perf driver should avoid such use. Fixes: 1018faa6cf23 ("perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled") Signed-off-by: Like Xu Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Liam Merwick Tested-by: Kim Phillips Tested-by: Liam Merwick Link: https://lkml.kernel.org/r/20210802070850.35295-1-likexu@tencent.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/perf_event.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -852,9 +852,10 @@ void x86_pmu_stop(struct perf_event *eve static inline void x86_pmu_disable_event(struct perf_event *event) { + u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask); struct hw_perf_event *hwc = &event->hw; - wrmsrl(hwc->config_base, hwc->config); + wrmsrl(hwc->config_base, hwc->config & ~disable_mask); } void x86_pmu_enable_event(struct perf_event *event);