From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796105000; b=gBRfJaGFs3vwzHBnO/LZhJ//1SYTuz+jKz05hOb+6xRQRzYvFHVLPNGPug6RAgFfB4xX k8XdxEOjt2dgbaGhuZxRlVwg7+L6KpqbQh3M6XPdteWJZnUndcpJ21uQko1dBQnBCV28Q GthtUu99HI01hYZYH+bYtoDKjoFqZz8GfR4mAuhu4RtllM3t/4vcCoX/2Hm3C6cTcl1J6 jaRKgQggNZjQAkplUJEQJGcwsx+xh2ik/Pk2CZuZ9rC4xRWUTIalJYt6Mpv2Krdtp2nb3 z9+gKg9ApTs2o+SFPr5yYD/8XREQqNm0SGM9vYCj+/n1sSP1idjWL72KWnBSJzT9uzQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796105000; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=hgfzxLeGmvmRRR3hfFjF6YQOe+bJVDBo3RzpaDR68BE=; b=umnvGOlxT5qhOTOxHJjfq7D8jM7AjiijB9HSnV9zBapDwMcBJNPYIEDEmOE3glK651r2 ndGbryK5nntuEHw/iYHbcZZGBLE3eRUyTVSd53rBbAVF7j6EB88L16z8a8fHWwLB6Qd1u 7HWO8gAdRn+2pSkofwv6DTUiTGHUYlXY+PxZJXvUeP7ORblCnBng6dpxsx4DuR/DML4Ln YhA44et8JcKdDeVqRor1Uk76P3ILf/iRwsw1E27pn6fnlYPQJ1sqQpglrWRuTdZLN4d9L HCUyzc8DdkxL0ia0bAOVm6hKKmrwLoULkJr17Ixhtq4bVZsK4txx8adp903X+Axok1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J33tmCQ9; arc=none smtp.remote-ip=198.175.65.15 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3F2C606A32E; Tue, 1 Dec 2026 06:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3F2C606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J33tmCQ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796105000; x=1827641000; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=hgfzxLeGmvmRRR3hfFjF6YQOe+bJVDBo3RzpaDR68BE=; b=J33tmCQ9IMdB0zFiiO7jfpFBfMgiv9YAi/zVjhUiqDufhW/poisY8CR+ rp2lflAQi5opVsCSOvZ8/nLa8Dt8ym++zOiXekP6PZBVNfUc4kdBs5V1n xNaczDWpFxuchp9bHXPcU7DnOTp40oUyVTFMK9UoiWQVUlFDwi6uMjzNo SU0ax1FqeR9aea+d8cec1UY5ZkKhZygQnpYJpLkHF0u1+Vw/dhXnUhc/X yd0ElsHbo/1lupOXhiRGPEUy7974JAFeyBHbzPT5jbnqEs44n3J/d8bj0 wJmwqViJC+/5g3wPOAmMHs/YFY1mVlJajkPiRYLjSOz//e9wG2N5brNBt A==; X-CSE-ConnectionGUID: 4AHIY0mIRM+q3mL/2LrSZA== X-CSE-MsgGUID: JoB6zYrJRoqGAjzRymnQyQ== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4952776" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="4952776" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 22:03:20 -0800 X-CSE-ConnectionGUID: vy7phOAhSfC/zyQ4V8efYQ== X-CSE-MsgGUID: MecqoAnQRI6QmZFejv2Ntg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13140158" Received: from unknown (HELO [10.238.2.182]) ([10.238.2.182]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 22:03:17 -0800 Message-ID: <68b2e657-e1f7-40e3-9709-74828c5f8bb6@linux.intel.com> Date: Tue, 1 Dec 2026 14:03:14 +0800 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v10 04/18] perf/x86: Expose perf_capabilities to KVM To: Zide Chen , Sean Christopherson , Paolo Bonzini , Peter Zijlstra Cc: kvm@vger.kernel.org, Jim Mattson , Yosry Ahmed , Andi Kleen , Stephane Eranian , linux-kernel@vger.kernel.org, Mingwei Zhang , Das Sandipan , Shukla Manali , Xudong Hao References: <20261124213901.120572-1-zide.chen@intel.com> <20261124213901.120572-5-zide.chen@intel.com> Content-Language: en-US From: "Mi, Dapeng" In-Reply-To: <20261124213901.120572-5-zide.chen@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Reviewed-by: Dapeng Mi On 11/25/2026 5:38 AM, Zide Chen wrote: > perf already applies model-specific errata (e.g. RPL018 on RPL/MTL) > and sanitizes contradictory values (e.g. clearing pebs_baseline when > the PEBS format is < 4). Reading the MSR directly in KVM bypasses all > of that. > > Add perf_capabilities to struct x86_pmu_capability, next to the > counter counts, bit widths and event masks it already exports, so > that KVM can use the validated value. > > Signed-off-by: Zide Chen > Cc: Peter Zijlstra > --- > v10: New patch. > --- > arch/x86/events/core.c | 1 + > arch/x86/include/asm/perf_event.h | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c > index 8b3ea0adb965..770ca960fa6e 100644 > --- a/arch/x86/events/core.c > +++ b/arch/x86/events/core.c > @@ -3164,6 +3164,7 @@ void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap) > cap->events_mask_len = x86_pmu.events_mask_len; > cap->pebs_ept = x86_pmu.pebs_ept; > cap->mediated = !!(pmu.capabilities & PERF_PMU_CAP_MEDIATED_VPMU); > + cap->perf_capabilities = x86_pmu.intel_cap.capabilities; > } > EXPORT_SYMBOL_FOR_KVM(perf_get_x86_pmu_capability); > > diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h > index ca630bc282fb..a68cb7c79d8b 100644 > --- a/arch/x86/include/asm/perf_event.h > +++ b/arch/x86/include/asm/perf_event.h > @@ -308,6 +308,7 @@ struct x86_pmu_capability { > int events_mask_len; > unsigned int pebs_ept :1; > unsigned int mediated :1; > + u64 perf_capabilities; > }; > > /*