Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3767814pxt; Tue, 10 Aug 2021 10:51:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhgiEbLpIf6W8Gw+fL20ByrL82/4CEqSRC3Iwki03OhCI68v/nRyZxdDOkylFXbauRYrGV X-Received: by 2002:a92:c043:: with SMTP id o3mr150795ilf.189.1628617912448; Tue, 10 Aug 2021 10:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617912; cv=none; d=google.com; s=arc-20160816; b=0Ls/fKlX3pJo9nb3cE0h+ilwQ7zkNxr/FnP22bF/g1n027rpJ0PcgScl4Jmrajxq0s 0WjkZEprehBw3pPaPglhUFiXrJi2n5+N+27IoX9NO2rrMkfgkX5Iy/Wr0kDhX6pEfEef KPbRSKAW6vQsRm6RL2EZ0hIzj9v3zaQDhpyyKYHXOMXM8bsS2FcmBHrykcKfDqCqdcmd nvG51nJBe9gNJT9y5iOalbZo1/aynZPf3QweNAK6RAQpJSmnfPDPsytPamTjAB55bl90 Ahm8ZK2UiYDgJBGEKdlI0ld816ThsR61StfRGi2UcWarXYeTw1Ks2Jp4Nonf86+3SY3J 3hmw== 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=ZsBe+KGTsDGSve+4xgYV8mQPIs5WZs+ihQvo46qtmyo=; b=oQpn90DFiVata5xVCuZ0HnPOINRzLFl0Jq6bBKBTLQt8XvI6K6E8Zbr8WBfiLthaze 1qEXgbtLp1mSSRQ6TxzUtmvXqjXIXIHrhx9Q1qoZmczW8y4Q3KlDGBo3yABVmSDOZ5yS NxBoWWdn8o5T9o4LXOJ/lxfScUzexgHjc1YouZcyHjuiVSWZ0FV+N4RSsQB33uUu4tPo UzO1mmk+w7C8ySQK22MPhWsDtfLVKYOywmL+zXgbIchuz4O2AUiWkHPhsToID1s19ABq sndXvfFRYYBSGjGlQlnGt6zHJGjFDd3KgAXHOZdZaxJHnjg+srLJFUXUEeBy7cTr1Pmd GITw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W0xbUtGP; 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 m25si22868184jah.26.2021.08.10.10.51.40; Tue, 10 Aug 2021 10:51:52 -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=W0xbUtGP; 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 S236002AbhHJRvS (ORCPT + 99 others); Tue, 10 Aug 2021 13:51:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbhHJRs2 (ORCPT ); Tue, 10 Aug 2021 13:48:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06D9E610CB; Tue, 10 Aug 2021 17:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617274; bh=MAHoygpLlLfY3HIeSAJW9XpLd4F/lbg16/4FUEcB4XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0xbUtGPMO+AE3G4X0I2VWfM9cbq4QRP2C1/7aLlg3Pe+R9rg69zLyJ+BZjr2qVvj wNuhkrbNrsw7p+YDsOZ/JsWoNzFGnSStPOz7VHI/oBgHMspPIDL8Cmb07D2KTBkmu0 fRbtqxoUUe2swGayuXqAJ4Ib0fNNiM9MW+VT9g2I= 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.10 123/135] perf/x86/amd: Dont touch the AMD64_EVENTSEL_HOSTONLY bit inside the guest Date: Tue, 10 Aug 2021 19:30:57 +0200 Message-Id: <20210810172959.982346545@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 @@ -1009,9 +1009,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); if (is_counter_pair(hwc)) wrmsrl(x86_pmu_config_addr(hwc->idx + 1), 0);