Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1451597pxb; Thu, 4 Mar 2021 11:36:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjhcW8KqRSO23mJm0ika4grq2L74SzKgG9ilDYfyMHaByh8nRaKG52qNTHSZGEKbq1fx5T X-Received: by 2002:a17:906:bfcc:: with SMTP id us12mr6192605ejb.266.1614886593510; Thu, 04 Mar 2021 11:36:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614886593; cv=none; d=google.com; s=arc-20160816; b=LO/h+DkfetDciOtGD0UvqldStqwt3AL497+4xUZuS6MkhE2MyrOqCs0Ce57qjtymUY G3mO82x/UK0XvgilZbI2JcG8Fy+/dgLQFhA2CeLarVLClJV75sQKHo2YPXjwaoM7AHtl rjLjTFDPO3vN80ic/z3dcnElnkc/0rlTPVTlaRH4wVX0L+q6dJk9VSV2KJhycej8e4P4 B2qCpiCMM1u93iMsMC820dRjx39hori0Y6KEMaSRA84jzckPukL4DGCOKi1LFTWENavy Riqg682riwf2ClexM6SbGLuSy2rLmZIyalISvkXSdmYMnUfu+NKyFw1eW6k0iSIcl66N HIKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=XjYQ7qydLcEw2becOT3/DSmJ2WSbUU2yqrSRjSV7Ee4=; b=EMKJo+tfTeBvEksiqyJthKkbtC51M6Dsu04rFhP0SaAZg1+N89Hfre3WVuEd7xx0aS yO/QxIdo65dgVbRqKoiD2+ezh4vlcKUxiJhtWDTQpBHNHwoqghcXmr1lHU8XTQp3aSUq 6Lmw6YS/sujH0v6bwxWElCPBfDgp+0klPYB67ZH7ZVE7uZFcWIDsda8RdeaG5zCMKf2j w0+mAC+rwFnXv8PBDPNymq4TlXvnQBb7oQwZ7VoKRaIx/esLP4OrbbBMoU9a6HvHU+Pr JzsWLIcCaN1l+Xx//+t3qL/G1bsY/WPhIk5FmhU3OB+nfua7m/vo0Np+7xHhnZSF8t6+ SBNQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si53087ejn.713.2021.03.04.11.36.10; Thu, 04 Mar 2021 11:36:33 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231126AbhCDTfQ (ORCPT + 99 others); Thu, 4 Mar 2021 14:35:16 -0500 Received: from mga14.intel.com ([192.55.52.115]:14203 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbhCDTfG (ORCPT ); Thu, 4 Mar 2021 14:35:06 -0500 IronPort-SDR: tnMbW7JWeGCkTOv3+kJUsslwGkD1R22z7JgLuin9PuUzb9alhaTdbu3NAjzK9Z11+WRHc2nAln 7jrXxaFulYzA== X-IronPort-AV: E=McAfee;i="6000,8403,9913"; a="186842212" X-IronPort-AV: E=Sophos;i="5.81,223,1610438400"; d="scan'208";a="186842212" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2021 11:33:20 -0800 IronPort-SDR: JviQkSzYEuA6/b+ZnYdrqMsQXla0p5WcLi7AplNp1NtmclUWiHTNgCzm8dYK8yY3WkMPGXSzBO Z8gvROMo81uA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,223,1610438400"; d="scan'208";a="597026979" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 04 Mar 2021 11:33:20 -0800 Received: from [10.252.141.30] (kliang2-MOBL.ccr.corp.intel.com [10.252.141.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 388105808B1; Thu, 4 Mar 2021 11:33:19 -0800 (PST) Subject: Re: [perf] perf_fuzzer causes unchecked MSR access error To: Vince Weaver Cc: Stephane Eranian , LKML , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim References: <61a56699-aab4-ef6-ed8d-a22b6bf532d@maine.edu> <7170d3b-c17f-1ded-52aa-cc6d9ae999f4@maine.edu> <32888c33-c286-c600-66cb-8b1b03beeb8b@linux.intel.com> <6c1f8e-f81-a781-e594-368e7adef0c0@maine.edu> <9df5f72d-a959-fe46-400a-7dca6c596478@linux.intel.com> From: "Liang, Kan" Message-ID: <473aff30-5e4f-394f-1c75-9bae66e37bbc@linux.intel.com> Date: Thu, 4 Mar 2021 14:33:17 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/2021 3:22 PM, Vince Weaver wrote: > On Wed, 3 Mar 2021, Liang, Kan wrote: > >> We never use bit 58. It should be a new issue. Actually, KVM uses it. They create a fake event called VLBR_EVENT, which uses bit 58. It's introduced from the commit 097e4311cda9 ("perf/x86: Add constraint to create guest LBR event without hw counter"). Since it's a fake event, it doesn't support PEBS. Perf should reject it if it sets the precise_ip. The below patch should fix the MSR access error. diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 5bac48d..1ea3c67 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3659,6 +3659,10 @@ static int intel_pmu_hw_config(struct perf_event *event) return ret; if (event->attr.precise_ip) { + + if ((event->attr.config & INTEL_ARCH_EVENT_MASK) == INTEL_FIXED_VLBR_EVENT) + return -EINVAL; + if (!(event->attr.freq || (event->attr.wakeup_events && !event->attr.watermark))) { event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; if (!(event->attr.sample_type & Thanks, Kan