Re: [PATCH v2 03/18] i386/cpu: Add default cache model for Intel CPUs with level < 4

2025-07-13 Thread Mi, Dapeng
On 7/11/2025 6:21 PM, Zhao Liu wrote: > Old Intel CPUs with CPUID level < 4, use CPUID 0x2 leaf (if available) > to encode cache information. > > Introduce a cache model "legacy_intel_cpuid2_cache_info" for the CPUs > with CPUID level < 4, based on legacy_l1d_cache, legacy_l1i_cache, > legacy_l2_

Re: [PATCH 8/8] i386/cpu: Enable 0x1f leaf for SapphireRapids by default

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:31 PM, Zhao Liu wrote: > Host SapphireRapids CPU has 0x1f leaf by default, so that enable it for > Guest CPU by default as well. > > Suggested-by: Igor Mammedov > Signed-off-by: Zhao Liu > --- > Changes since RFC: > * Rename the property to "x-force-cpuid-0x1f". (Igor) > --- >

Re: [PATCH 7/8] i386/cpu: Enable 0x1f leaf for GraniteRapids by default

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:31 PM, Zhao Liu wrote: > Host GraniteRapids CPU has 0x1f leaf by default, so that enable it for > Guest CPU by default as well. > > Suggested-by: Igor Mammedov > Signed-off-by: Zhao Liu > --- > Changes since RFC: > * Rename the property to "x-force-cpuid-0x1f". (Igor) > --- > t

Re: [PATCH 6/8] i386/cpu: Enable 0x1f leaf for SierraForest by default

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:31 PM, Zhao Liu wrote: > Host SierraForest CPU has 0x1f leaf by default, so that enable it for > Guest CPU by default as well. > > Suggested-by: Igor Mammedov > Signed-off-by: Zhao Liu > --- > Changes since RFC: > * Rename the property to "x-force-cpuid-0x1f". (Igor) > --- > ta

Re: [PATCH 5/8] i386/cpu: Add a "x-force-cpuid-0x1f" property

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:31 PM, Zhao Liu wrote: > From: Manish Mishra > > Add a "x-force-cpuid-0x1f" property so that CPU models can enable it and > have 0x1f CPUID leaf natually as the Host CPU. > > The advantage is that when the CPU model's cache model is already > consistent with the Host CPU, for exam

Re: [PATCH 3/8] i386/cpu: Introduce cache model for SapphireRapids

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:31 PM, Zhao Liu wrote: > Add the cache model to SapphireRapids (v4) to better emulate its > environment. > > The cache model is based on SapphireRapids-SP (Scalable Performance): > > --- cache 0 --- > cache type = data cache (1) > cache lev

Re: [PATCH 2/8] i386/cpu: Introduce cache model for GraniteRapids

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:30 PM, Zhao Liu wrote: > Add the cache model to GraniteRapids (v3) to better emulate its > environment. > > The cache model is based on GraniteRapids-SP (Scalable Performance): > > --- cache 0 --- > cache type = data cache (1) > cache level

Re: [PATCH 1/8] i386/cpu: Introduce cache model for SierraForest

2025-07-03 Thread Mi, Dapeng
On 6/26/2025 4:30 PM, Zhao Liu wrote: > Add the cache model to SierraForest (v3) to better emulate its > environment. > > The cache model is based on SierraForest-SP (Scalable Performance): > > --- cache 0 --- > cache type = data cache (1) > cache level

Re: [PATCH 16/16] i386/cpu: Use a unified cache_info in X86CPUState

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > At present, all cases using the cache model (CPUID 0x2, 0x4, 0x8005, > 0x8006 and 0x801D leaves) have been verified to be able to > select either cache_info_intel or cache_info_amd based on the vendor. > > Therefore, further merge cache_info_int

Re: [PATCH 13/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x80000005

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > As preparation for merging cache_info_cpuid4 and cache_info_amd in > X86CPUState, set legacy cache model based on vendor in the CPUID > 0x8005 leaf. For AMD CPU, select legacy AMD cache model (in > cache_info_amd) as the default cache model like before,

Re: [PATCH 12/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x4

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > As preparation for merging cache_info_cpuid4 and cache_info_amd in > X86CPUState, set legacy cache model based on vendor in the CPUID 0x4 > leaf. For AMD CPU, select legacy AMD cache model (in cache_info_amd) as > the default cache model, otherwise, select

Re: [PATCH 11/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x2

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > As preparation for merging cache_info_cpuid4 and cache_info_amd in > X86CPUState, set legacy cache model based on vendor in the CPUID 0x2 > leaf. For AMD CPU, select legacy AMD cache model (in cache_info_amd) as > the default cache model, otherwise, select

Re: [PATCH 10/16] i386/cpu: Add legacy_amd_cache_info cache model

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Based on legacy_l1d_cachei_amd, legacy_l1i_cache_amd, legacy_l2_cache_amd > and legacy_l3_cache, build a complete legacy AMD cache model, which can > clarify the purpose of these trivial legacy cache models, simplify the > initialization of cache info in X8

Re: [PATCH 09/16] i386/cpu: Add legacy_intel_cache_info cache model

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Based on legacy_l1d_cache, legacy_l1i_cache, legacy_l2_cache and > legacy_l3_cache, build a complete legacy intel cache model, which can > clarify the purpose of these trivial legacy cache models, simplify the > initialization of cache info in X86CPUState,

Re: [PATCH 08/16] i386/cpu: Fix CPUID[0x80000006] for Intel CPU

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Per SDM, Intel supports CPUID[0x8006]. But only L2 information is > encoded in ECX (note that L2 associativity field encodings rules > consistent with AMD are used), all other fields are reserved. > > Therefore, make the following changes to CPUID[0x800

Re: [PATCH 07/16] i386/cpu: Mark CPUID[0x80000005] as reserved for Intel

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Per SDM, 0x8005 leaf is reserved for Intel CPU, and its current > "assert" check blocks adding new cache model for non-AMD CPUs. > > And please note, although Zhaoxin mostly follows Intel behavior, > this leaf is an exception [1]. > > So, add a compat p

Re: [PATCH 06/16] i386/cpu: Drop CPUID 0x2 specific cache info in X86CPUState

2025-07-03 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > With the pre-defined cache model legacy_intel_cpuid2_cache_info, > for X86CPUState there's no need to cache special cache information > for CPUID 0x2 leaf. > > Drop the cache_info_cpuid2 field of X86CPUState and use the > legacy_intel_cpuid2_cache_info dire

Re: [PATCH 05/16] i386/cpu: Consolidate CPUID 0x4 leaf

2025-07-02 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Modern Intel CPUs use CPUID 0x4 leaf to describe cache information > and leave space in 0x2 for prefetch and TLBs (even TLB has its own leaf > CPUID 0x18). > > And 0x2 leaf provides a descriptor 0xFF to instruct software to check > cache information in 0x4

Re: [PATCH 04/16] i386/cpu: Present same cache model in CPUID 0x2 & 0x4

2025-07-02 Thread Mi, Dapeng
On 7/3/2025 12:14 PM, Mi, Dapeng wrote: > On 6/20/2025 5:27 PM, Zhao Liu wrote: >> For a long time, the default cache models used in CPUID 0x2 and >> 0x4 were inconsistent and had a FIXME note from Eduardo at commit >> 5e891bf8fd50 ("target-i386: Use #defines in

Re: [PATCH 04/16] i386/cpu: Present same cache model in CPUID 0x2 & 0x4

2025-07-02 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > For a long time, the default cache models used in CPUID 0x2 and > 0x4 were inconsistent and had a FIXME note from Eduardo at commit > 5e891bf8fd50 ("target-i386: Use #defines instead of magic numbers for > CPUID cache info"): > > "/*FIXME: CPUID leaf 2 desc

Re: [PATCH 03/16] i386/cpu: Add default cache model for Intel CPUs with level < 4

2025-07-02 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Old Intel CPUs with CPUID level < 4, use CPUID 0x2 leaf (if available) > to encode cache information. > > Introduce a cache model "legacy_intel_cpuid2_cache_info" for the CPUs > with CPUID level < 4, based on legacy_l1d_cache, legacy_l1i_cache, > legacy_l2_

Re: [PATCH 02/16] i386/cpu: Add descriptor 0x49 for CPUID 0x2 encoding

2025-07-02 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > The legacy_l2_cache (2nd-level cache: 4 MByte, 16-way set associative, > 64 byte line size) corresponds to descriptor 0x49, but at present > cpuid2_cache_descriptors doesn't support descriptor 0x49 because it has > multiple meanings. > > The 0x49 is necessa

Re: [PATCH 01/16] i386/cpu: Refine comment of CPUID2CacheDescriptorInfo

2025-07-02 Thread Mi, Dapeng
On 6/20/2025 5:27 PM, Zhao Liu wrote: > Refer to SDM vol.3 table 1-21, add the notes about the missing > descriptor, and fix the typo and comment format. > > Signed-off-by: Zhao Liu > --- > target/i386/cpu.c | 31 ++- > 1 file changed, 22 insertions(+), 9 deletions(-

Re: [PATCH v6 9/9] target/i386/kvm: don't stop Intel PMU counters

2025-07-01 Thread Mi, Dapeng
On 6/24/2025 3:43 PM, Dongli Zhang wrote: > PMU MSRs are set by QEMU only at levels >= KVM_PUT_RESET_STATE, > excluding runtime. Therefore, updating these MSRs without stopping events > should be acceptable. > > In addition, KVM creates kernel perf events with host mode excluded > (exclude_host =

Re: [PATCH v6 7/9] target/i386/kvm: reset AMD PMU registers during VM reset

2025-07-01 Thread Mi, Dapeng
On 6/24/2025 3:43 PM, Dongli Zhang wrote: > + uint32_t sel_base = MSR_K7_EVNTSEL0; > + uint32_t ctr_base = MSR_K7_PERFCTR0; > + /* > + * The address of the next selector or counter register is > + * obtained by incrementing the address of the current selector > + * or counter register by one. > +

Re: [PATCH v6 6/9] target/i386/kvm: query kvm.enable_pmu parameter

2025-07-01 Thread Mi, Dapeng
On 6/24/2025 3:43 PM, Dongli Zhang wrote: > When PMU is enabled in QEMU, there is a chance that PMU virtualization is > completely disabled by the KVM module parameter kvm.enable_pmu=N. > > The kvm.enable_pmu parameter is introduced since Linux v5.17. > Its permission is 0444. It does not change

Re: [PATCH v6 4/9] target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid()

2025-07-01 Thread Mi, Dapeng
On 6/24/2025 3:43 PM, Dongli Zhang wrote: > The initialization of 'has_architectural_pmu_version', > 'num_architectural_pmu_gp_counters', and > 'num_architectural_pmu_fixed_counters' is unrelated to the process of > building the CPUID. > > Extract them out of kvm_x86_build_cpuid(). > > In additio

Re: [PATCH v6 3/9] target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured

2025-07-01 Thread Mi, Dapeng
On 6/24/2025 3:43 PM, Dongli Zhang wrote: > Although AMD PERFCORE and PerfMonV2 are removed when "-pmu" is configured, > there is no way to fully disable KVM AMD PMU virtualization. Neither > "-cpu host,-pmu" nor "-cpu EPYC" achieves this. > > As a result, the following message still appears in t

Re: [PATCH 3/3] target/i386: Support VMX_VM_EXIT_SAVE_IA32_PERF_GLOBAL_CTRL

2025-04-27 Thread Mi, Dapeng
On 4/27/2025 4:54 PM, Zhao Liu wrote: >> @@ -4212,7 +4213,8 @@ static const X86CPUDefinition builtin_x86_defs[] = { >> VMX_VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL | >> VMX_VM_EXIT_ACK_INTR_ON_EXIT | VMX_VM_EXIT_SAVE_IA32_PAT | >> VMX_VM_EXIT_LOAD_IA32_PAT | VMX_V

Re: [PATCH 5/5] i386/kvm: Support fixed counter in KVM PMU filter

2025-04-24 Thread Mi, Dapeng
On 4/9/2025 4:26 PM, Zhao Liu wrote: > KVM_SET_PMU_EVENT_FILTER of x86 KVM allows user to configure x86 fixed > function counters by a bitmap. > > Add the support of x86-fixed-counter in kvm-pmu-filter object and handle > this in i386 kvm codes. > > Signed-off-by: Zhao Liu > Tested-by: Yi Lai >

Re: [PATCH v2 08/10] target/i386/kvm: reset AMD PMU registers during VM reset

2025-04-16 Thread Mi, Dapeng
On 4/7/2025 5:33 PM, Ewan Hai wrote: > > On 4/7/25 4:51 PM, Zhao Liu wrote: > >> On Tue, Apr 01, 2025 at 11:35:49AM +0800, Ewan Hai wrote: >>> Date: Tue, 1 Apr 2025 11:35:49 +0800 >>> From: Ewan Hai >>> Subject: Re: [PATCH v2 08/10] target/i386/kvm: reset AMD PMU registers >>> during VM reset

Re: [PATCH 2/3] target/i386: Call KVM_CAP_PMU_CAPABILITY iotcl to enable/disable PMU

2025-03-26 Thread Mi, Dapeng
On 3/27/2025 10:15 AM, Mingwei Zhang wrote: > On Wed, Mar 26, 2025 at 5:44 PM Mi, Dapeng wrote: >> >> On 3/26/2025 2:46 PM, Dongli Zhang wrote: >>> Hi Dapeng, >>> >>> PATCH 1-4 from the below patchset are already reviewed. (PATCH 5-10 are for &

Re: [PATCH 2/3] target/i386: Call KVM_CAP_PMU_CAPABILITY iotcl to enable/disable PMU

2025-03-26 Thread Mi, Dapeng
On 3/26/2025 2:46 PM, Dongli Zhang wrote: > Hi Dapeng, > > PATCH 1-4 from the below patchset are already reviewed. (PATCH 5-10 are for > PMU > registers reset). > > https://lore.kernel.org/all/20250302220112.17653-1-dongli.zh...@oracle.com/ > > They require only trivial modification. i.e.: > > h

Re: [PATCH v2 10/10] target/i386/kvm: don't stop Intel PMU counters

2025-03-05 Thread Mi, Dapeng
On 3/6/2025 3:00 AM, dongli.zh...@oracle.com wrote: > Hi Dapeng, > > On 3/4/25 11:35 PM, Mi, Dapeng wrote: >> On 3/3/2025 6:00 AM, Dongli Zhang wrote: >>> The kvm_put_msrs() sets the MSRs using KVM_SET_MSRS. The x86 KVM processes >>> these MSRs one by one in a

Re: [PATCH v2 05/10] target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid()

2025-03-05 Thread Mi, Dapeng
On 3/3/2025 6:00 AM, Dongli Zhang wrote: > The initialization of 'has_architectural_pmu_version', > 'num_architectural_pmu_gp_counters', and > 'num_architectural_pmu_fixed_counters' is unrelated to the process of > building the CPUID. > > Extract them out of kvm_x86_build_cpuid(). > > No function

Re: [PATCH v2 10/10] target/i386/kvm: don't stop Intel PMU counters

2025-03-04 Thread Mi, Dapeng
On 3/3/2025 6:00 AM, Dongli Zhang wrote: > The kvm_put_msrs() sets the MSRs using KVM_SET_MSRS. The x86 KVM processes > these MSRs one by one in a loop, only saving the config and triggering the > KVM_REQ_PMU request. This approach does not immediately stop the event > before updating PMC. > > In

Re: [PATCH v2 08/10] target/i386/kvm: reset AMD PMU registers during VM reset

2025-03-04 Thread Mi, Dapeng
On 3/3/2025 6:00 AM, Dongli Zhang wrote: > QEMU uses the kvm_get_msrs() function to save Intel PMU registers from KVM > and kvm_put_msrs() to restore them to KVM. However, there is no support for > AMD PMU registers. Currently, has_pmu_version and num_pmu_gp_counters are > initialized based on cp

Re: [PATCH v2 06/10] target/i386/kvm: rename architectural PMU variables

2025-03-04 Thread Mi, Dapeng
On 3/3/2025 6:00 AM, Dongli Zhang wrote: > AMD does not have what is commonly referred to as an architectural PMU. > Therefore, we need to rename the following variables to be applicable for > both Intel and AMD: > > - has_architectural_pmu_version > - num_architectural_pmu_gp_counters > - num_ar

Re: [PATCH 2/7] target/i386/kvm: introduce 'pmu-cap-disabled' to set KVM_PMU_CAP_DISABLE

2025-02-10 Thread Mi, Dapeng
On 2/10/2025 4:12 AM, dongli.zh...@oracle.com wrote: > Hi Dapeng, > > On 2/7/25 1:52 AM, Mi, Dapeng wrote: >> On 11/21/2024 6:06 PM, Mi, Dapeng wrote: >>> On 11/8/2024 7:44 AM, dongli.zh...@oracle.com wrote: >>>> Hi Zhao, >>>> >>>> >

Re: [PATCH 2/7] target/i386/kvm: introduce 'pmu-cap-disabled' to set KVM_PMU_CAP_DISABLE

2025-02-07 Thread Mi, Dapeng
On 11/21/2024 6:06 PM, Mi, Dapeng wrote: > On 11/8/2024 7:44 AM, dongli.zh...@oracle.com wrote: >> Hi Zhao, >> >> >> On 11/6/24 11:52 PM, Zhao Liu wrote: >>> (+Dapang & Zide) >>> >>> Hi Dongli, >>> >>> On Mon, Nov 04,

Re: [PATCH 2/7] target/i386/kvm: introduce 'pmu-cap-disabled' to set KVM_PMU_CAP_DISABLE

2024-11-21 Thread Mi, Dapeng
On 11/8/2024 7:44 AM, dongli.zh...@oracle.com wrote: > Hi Zhao, > > > On 11/6/24 11:52 PM, Zhao Liu wrote: >> (+Dapang & Zide) >> >> Hi Dongli, >> >> On Mon, Nov 04, 2024 at 01:40:17AM -0800, Dongli Zhang wrote: >>> Date: Mon, 4 Nov 2024 01:40:17 -0800 >>> From: Dongli Zhang >>> Subject: [PATCH

Re: [RFC 3/5] i386/kvm: Support event with select&umask format in KVM PMU filter

2024-07-22 Thread Mi, Dapeng
On 7/19/2024 4:40 PM, Zhao Liu wrote: > Hi Dapeng, > > On Thu, Jul 18, 2024 at 01:28:25PM +0800, Mi, Dapeng wrote: > > [snip] > >>> +case KVM_PMU_EVENT_FMT_X86_DEFAULT: { >>> +uint64_t select, umask; >>> + >>> +

Re: [RFC 3/5] i386/kvm: Support event with select&umask format in KVM PMU filter

2024-07-17 Thread Mi, Dapeng
On 7/10/2024 12:51 PM, Zhao Liu wrote: > The select&umask is the common way for x86 to identify the PMU event, > so support this way as the "x86-default" format in kvm-pmu-filter > object. > > Signed-off-by: Zhao Liu > --- > accel/kvm/kvm-pmu.c | 62

Re: [RFC 0/5] accel/kvm: Support KVM PMU filter

2024-07-17 Thread Mi, Dapeng
On 7/10/2024 12:51 PM, Zhao Liu wrote: > Hi QEMU maintainers, arm and PMU folks, > > I picked up Shaoqing's previous work [1] on the KVM PMU filter for arm, > and now is trying to support this feature for x86 with a JSON-compatible > API. > > While arm and x86 use different KVM ioctls to configur

Re: [PATCH v9 02/21] hw/core/machine: Support modules in -smp

2024-03-11 Thread Mi, Dapeng
On 2/27/2024 6:32 PM, Zhao Liu wrote: From: Zhao Liu Add "modules" parameter parsing support in -smp. Suggested-by: Xiaoyao Li Tested-by: Yongwei Ma Signed-off-by: Zhao Liu --- Changes since v8: * Add module description in qemu_smp_opts. Changes since v7: * New commit to introduce mo