Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D070130F924 for ; Wed, 11 Feb 2026 06:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770790494; cv=none; b=BiXRgrqyhMjtkCyuIFpt2EZC8rv5bdvTgSdGFOmUuO6Iev5YP9uiPd789alm9l2QF7YF/7UNYvmEjlzE5hNCrg4zrOvIE2kHmpKXsNamJnukfE8md8+rkFEhUMIKQLwrVn6FppJTqVuM6vBVl7r4A1cGqQnfnRsD1oRbLjMvrWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770790494; c=relaxed/simple; bh=rP5llVY+IJ2BiSdns8crbNzy366rp4QhMGd+dzV2WHQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rGCtSod4CbTZCmJljzrbfTCLVvdExZgoLfNv3zwwEX6uQOW+hLnhvP4kzFwkuZyvUq4D6UawAKDKUESxPX6fLaaaQAmi0JBrIEcoP1/ueUDaGHEo/aoaLz66tNvYPZtYhxu4iI1aiMUB1t/oP0yr4/rF65PVHBVaB+NSHUI4xm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=a3HC6cMA; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="a3HC6cMA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770790493; x=1802326493; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=rP5llVY+IJ2BiSdns8crbNzy366rp4QhMGd+dzV2WHQ=; b=a3HC6cMAabnYqWT53fG+zGd5ugbfZ2TkCsJr1ovOln9rZ3qT0fl25DOS ZF1K2ZyjI9pb7ZEZG+5+vKOTzNDjTx1pztDgDurdmOrQx3u0SnwJmR9cF RxK/PxGqjxXYJN7xXi7QXpPTtonS+GABKU2aUsp8ze6rR9CgYe+LdrcYa zRzSJw8i6gNTggbLVnXhvCyX4F/wsoWtZooXmRb2qnsLB8vBD63nHjRIZ QWU74kpPfoFm0PmgeBobpAINcLwy2yNMwPdJ5TlYgnFuZGHaaOMbY/cf9 ZeUFEI3qghqtcCq3S9Zfba0tYr/zjpNO++syB8m8SEARVnquYUYhg0pPT Q==; X-CSE-ConnectionGUID: MLiHCcs4RYq+ZT/WHpma1A== X-CSE-MsgGUID: /WZDJ1vqQAqP97uYYppBhg== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="97387989" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="97387989" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 22:14:52 -0800 X-CSE-ConnectionGUID: 4GJdpKNRRdS4hQ6jszuq4g== X-CSE-MsgGUID: hN7ZDFQGQtuhhY1HequhuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="249784774" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.240.173]) ([10.124.240.173]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 22:14:50 -0800 Message-ID: <7803017e-aefa-421a-92a1-3b5820beba53@intel.com> Date: Wed, 11 Feb 2026 14:14:46 +0800 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2 01/11] target/i386: Disable unsupported BTS for guest To: Zide Chen , qemu-devel@nongnu.org, kvm@vger.kernel.org, Paolo Bonzini , Zhao Liu , Peter Xu , Fabiano Rosas Cc: Dongli Zhang , Dapeng Mi References: <20260128231003.268981-1-zide.chen@intel.com> <20260128231003.268981-2-zide.chen@intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <20260128231003.268981-2-zide.chen@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/29/2026 7:09 AM, Zide Chen wrote: > BTS (Branch Trace Store), enumerated by IA32_MISC_ENABLE.BTS_UNAVAILABLE > (bit 11), is deprecated and has been superseded by LBR and Intel PT. > > KVM yields control of the above mentioned bit to userspace since KVM > commit 9fc222967a39 ("KVM: x86: Give host userspace full control of > MSR_IA32_MISC_ENABLES"). > > However, QEMU does not set this bit, which allows guests to write the > BTS and BTINT bits in IA32_DEBUGCTL. Since KVM doesn't support BTS, > this may lead to unexpected MSR access errors. > > Signed-off-by: Zide Chen Since the patch is handling BTS, Reviewed-by: Xiaoyao Li Besides, I'm curious about the (legacy) PEBS enable. Before KVM commit 9fc222967a39, BTS_UNAVAIL and PEBS_UNAVAIL in MISC_ENABLES are maintained by KVM and userspace cannot change them. KVM keeps MISC_ENABLES.PEBS_UNAVAIL set when !(vcpu->arch.perf_capabilities & PERF_CAP_PEBS_FORMAT) After KVM commit 9fc222967a39, it's userspace's responsibility to set correct value for MSR_IA32_MISC_EANBLES. So, if PEBS is not exposed to guest, QEMU should set MISC_ENABLE_PEBS_UNAVAIL. But I don't see such logic in QEMU. (Maybe the later patch in this series will handle it, let me keep reading.) > --- > V2: > - Address Dapeng's comments. > - Remove mention of VMState version_id from the commit message. > > target/i386/cpu.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > index 2bbc977d9088..f02812bfd19f 100644 > --- a/target/i386/cpu.h > +++ b/target/i386/cpu.h > @@ -474,8 +474,11 @@ typedef enum X86Seg { > > #define MSR_IA32_MISC_ENABLE 0x1a0 > /* Indicates good rep/movs microcode on some processors: */ > -#define MSR_IA32_MISC_ENABLE_DEFAULT 1 > +#define MSR_IA32_MISC_ENABLE_FASTSTRING (1ULL << 0) > +#define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL (1ULL << 11) > #define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << 18) > +#define MSR_IA32_MISC_ENABLE_DEFAULT (MSR_IA32_MISC_ENABLE_FASTSTRING |\ Nit, we usually add a space before "\" > + MSR_IA32_MISC_ENABLE_BTS_UNAVAIL) > > #define MSR_MTRRphysBase(reg) (0x200 + 2 * (reg)) > #define MSR_MTRRphysMask(reg) (0x200 + 2 * (reg) + 1)