Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3759333pxt; Tue, 10 Aug 2021 10:39:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybUhR5/Lh2I6+PssFp88yzEpt/qL5x18AReRDXnD3kZDAZ5un6vJeh7ayhiVC+NdwVB9sS X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr5595634edd.191.1628617163879; Tue, 10 Aug 2021 10:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617163; cv=none; d=google.com; s=arc-20160816; b=LZ2M9yOlkWCi9jqZYh3/mjpw/RopICWX9DSf9r7nMMfXMgxwT8l0IfYavaVCCJST53 nkVlrjgdXaonOo/wbHJsR0QQ4v9RySjfkjfssO/rPS0+IlGn/97w2SsFfAp4d/6Eq8pR H1l8SmKcy1k+yb4lJkXsoZHEjay4exiE8nByLgrnLC+ceuiuS+o4/VXnl2NUqpTtdqwl igNaXXfAPxaKcjnKup9gYfIB1StQtltcbj22RXAball3TpZ73/f6Z8HbQNzfTCn8ZH4G DgB8OTtusSzz57j7UQSlocBdbnjPUR+Ia/pxkQLVKyL6lCgH/7d9JnwtGkrFdXJOmIG8 /Z2Q== 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=y5u09T/shFt2SGhrvdV3YwM0bAaYj/aYKGhPa5h7MPs=; b=zUaSwRvvoyz8xJ+dRp0ntUeiAbc60yVCDlzXBIKGmzwi2tPTitEiz3Q76z5bdFME5u k4Fgfkwt0M7DQhkCPxzpy+FCyvlJ1PafqmRIVp+41JEynTBu1L9Glmu85pHC5LUspbuQ 5rS5YVAAErpWaS04+FvTsSFJOJcPOyuNiT1rjmLkBLTpYsEjYNtohV1eWa4VmqZNf+8Y 7k3rmksgoCytN8kdVI5fhXZLZaAC10nWWfrd69ZYBZ3hYIyH0nkskavp7zCORGhO6r3F QnHCf/n/xi+pfuRRPHzvhZoOQLyqwWKbLkcKoZH1SSvnWPAoioqjyuDbks4HLnqIhe1s GbCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Asf5BRfO; 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 hr7si20564999ejc.114.2021.08.10.10.39.00; Tue, 10 Aug 2021 10:39:23 -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=Asf5BRfO; 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 S232742AbhHJRe6 (ORCPT + 99 others); Tue, 10 Aug 2021 13:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232498AbhHJRd4 (ORCPT ); Tue, 10 Aug 2021 13:33:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB6C160F94; Tue, 10 Aug 2021 17:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616814; bh=ihAvkDK7uaKrqIGBsVrJT2bcZ8CGQmp7iO0hrwSPxCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Asf5BRfO55dIBxJRSRxqo1SuML9UakDP+d3bzcd29lHofD32nRZf9dUB+yedSPysQ 3P11obWpmbZGXvi3XPbJLwk7DNjyTMhDHnUlO+hn8UphcdRE0Qh13YpYOwQAmk03I2 sxEwrcAwEBGDNrXuW2odQdAf8xaHXD0MVYjUOBH0= 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 4.19 47/54] perf/x86/amd: Dont touch the AMD64_EVENTSEL_HOSTONLY bit inside the guest Date: Tue, 10 Aug 2021 19:30:41 +0200 Message-Id: <20210810172945.744299691@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172944.179901509@linuxfoundation.org> References: <20210810172944.179901509@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 @@ -799,9 +799,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);