From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 B89C91CD1F for ; Thu, 3 Jul 2025 07:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751527126; cv=none; b=KSB5oTUdi1bIioslLIliqHg0x2QwoWAYEg8S0gcr1pUkU3yoWhUYmSWc+op5r8yAUaLpkAgmAWwt1FXSWPkotuMC1Z8qZm6BqoXAXNz2AqJVGhxY2HxpWx/UcNh7Be7ARD1VDFrob9s1Zu0FokBh22L+CpILkuwimzMh1HjXvGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751527126; c=relaxed/simple; bh=y/Iecl85y+ckLurPf5zWK8lSIDvcS82wO6Az/OPu2bw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TPTQUxiksMGVDk54nxOb2j2CDqJiRfQckIYfoHpmxv61FtvBv4xTdoKPI0bj0LJCWvsRIHhTjmYswKaH+zESsL41uislzCdM1U618KAz3TfefvO6gLppzhhxze4Q2DSBn123UAAUuiNxFpyWwxMcZozj+10ASGbHMVpqeMDXmF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ITuIzenR; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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.b="ITuIzenR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751527125; x=1783063125; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=y/Iecl85y+ckLurPf5zWK8lSIDvcS82wO6Az/OPu2bw=; b=ITuIzenRMz6WIdy1oSCJhtsVtlgKqFQioL9j3k3aNCM4tNJ5u/SfqwoF o0RXp9DvBhwgB3fVpuJJIIj0nIS6nKUOwDke9FgBvv2+13gRPin57WVK6 y0Nd+frKlGTaB1zgL9tINDg6c6dNfYUXslhmwr0finbBXsURMT905bMSZ m/QjHCi67WYvDRIHUi1CcHU5myvSCaSqa+NYxUt0D5Lots6GdlCDDmEaF d50Ungmc7OghVAKbAYj1g2eE5n/UtmDg03Dakf8/JgrVlANen98Dwz5YQ CBNnUXlI0TqeELGqCDw40wXsfFcZb73c44ngrcrSnGQn9nW8Cpdt4W6yO g==; X-CSE-ConnectionGUID: Uckw80tLQaSQJ7yIbcGeqQ== X-CSE-MsgGUID: Udkk/lnBTFKkbpapaflynQ== X-IronPort-AV: E=McAfee;i="6800,10657,11482"; a="53711116" X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="53711116" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 00:18:44 -0700 X-CSE-ConnectionGUID: drtH/3P+TfyL2GOQOs2hOA== X-CSE-MsgGUID: UFlvVw7oScOo3wAK/iF1Cg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,283,1744095600"; d="scan'208";a="159798915" Received: from dapengmi-mobl1.ccr.corp.intel.com (HELO [10.124.240.80]) ([10.124.240.80]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 00:18:39 -0700 Message-ID: <8d2b621f-3a3d-4657-8013-2f181b05d17a@linux.intel.com> Date: Thu, 3 Jul 2025 15:18:37 +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 10/16] i386/cpu: Add legacy_amd_cache_info cache model To: Zhao Liu , Paolo Bonzini , Marcelo Tosatti , "Michael S . Tsirkin" , =?UTF-8?Q?Daniel_P_=2E_Berrang=C3=A9?= , Igor Mammedov , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost Cc: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Babu Moger , Ewan Hai , Pu Wen , Tao Su , Yi Lai , Dapeng Mi , qemu-devel@nongnu.org, kvm@vger.kernel.org References: <20250620092734.1576677-1-zhao1.liu@intel.com> <20250620092734.1576677-11-zhao1.liu@intel.com> Content-Language: en-US From: "Mi, Dapeng" In-Reply-To: <20250620092734.1576677-11-zhao1.liu@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 X86CPUState, and make it easier to > handle compatibility later. > > Signed-off-by: Zhao Liu > --- > target/i386/cpu.c | 112 ++++++++++++++++++++++------------------------ > 1 file changed, 53 insertions(+), 59 deletions(-) > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index ec229830c532..bf8d7a19c88d 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -643,60 +643,58 @@ static void encode_topo_cpuid8000001e(X86CPU *cpu, X86CPUTopoInfo *topo_info, > * These are legacy cache values. If there is a need to change any > * of these values please use builtin_x86_defs > */ > -static CPUCacheInfo legacy_l1d_cache_amd = { > - .type = DATA_CACHE, > - .level = 1, > - .size = 64 * KiB, > - .self_init = 1, > - .line_size = 64, > - .associativity = 2, > - .sets = 512, > - .partitions = 1, > - .lines_per_tag = 1, > - .no_invd_sharing = true, > - .share_level = CPU_TOPOLOGY_LEVEL_CORE, > -}; > - > -static CPUCacheInfo legacy_l1i_cache_amd = { > - .type = INSTRUCTION_CACHE, > - .level = 1, > - .size = 64 * KiB, > - .self_init = 1, > - .line_size = 64, > - .associativity = 2, > - .sets = 512, > - .partitions = 1, > - .lines_per_tag = 1, > - .no_invd_sharing = true, > - .share_level = CPU_TOPOLOGY_LEVEL_CORE, > -}; > - > -static CPUCacheInfo legacy_l2_cache_amd = { > - .type = UNIFIED_CACHE, > - .level = 2, > - .size = 512 * KiB, > - .line_size = 64, > - .lines_per_tag = 1, > - .associativity = 16, > - .sets = 512, > - .partitions = 1, > - .share_level = CPU_TOPOLOGY_LEVEL_CORE, > -}; > - > -/* Level 3 unified cache: */ > -static CPUCacheInfo legacy_l3_cache = { > - .type = UNIFIED_CACHE, > - .level = 3, > - .size = 16 * MiB, > - .line_size = 64, > - .associativity = 16, > - .sets = 16384, > - .partitions = 1, > - .lines_per_tag = 1, > - .self_init = true, > - .inclusive = true, > - .complex_indexing = true, > - .share_level = CPU_TOPOLOGY_LEVEL_DIE, > +static const CPUCaches legacy_amd_cache_info = { > + .l1d_cache = &(CPUCacheInfo) { > + .type = DATA_CACHE, > + .level = 1, > + .size = 64 * KiB, > + .self_init = 1, > + .line_size = 64, > + .associativity = 2, > + .sets = 512, > + .partitions = 1, > + .lines_per_tag = 1, > + .no_invd_sharing = true, > + .share_level = CPU_TOPOLOGY_LEVEL_CORE, > + }, > + .l1i_cache = &(CPUCacheInfo) { > + .type = INSTRUCTION_CACHE, > + .level = 1, > + .size = 64 * KiB, > + .self_init = 1, > + .line_size = 64, > + .associativity = 2, > + .sets = 512, > + .partitions = 1, > + .lines_per_tag = 1, > + .no_invd_sharing = true, > + .share_level = CPU_TOPOLOGY_LEVEL_CORE, > + }, > + .l2_cache = &(CPUCacheInfo) { > + .type = UNIFIED_CACHE, > + .level = 2, > + .size = 512 * KiB, > + .line_size = 64, > + .lines_per_tag = 1, > + .associativity = 16, > + .sets = 512, > + .partitions = 1, > + .share_level = CPU_TOPOLOGY_LEVEL_CORE, > + }, > + .l3_cache = &(CPUCacheInfo) { > + .type = UNIFIED_CACHE, > + .level = 3, > + .size = 16 * MiB, > + .line_size = 64, > + .associativity = 16, > + .sets = 16384, > + .partitions = 1, > + .lines_per_tag = 1, > + .self_init = true, > + .inclusive = true, > + .complex_indexing = true, > + .share_level = CPU_TOPOLOGY_LEVEL_DIE, > + }, > }; > > /* > @@ -8982,11 +8980,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > } > > env->cache_info_cpuid4 = legacy_intel_cache_info; > - > - env->cache_info_amd.l1d_cache = &legacy_l1d_cache_amd; > - env->cache_info_amd.l1i_cache = &legacy_l1i_cache_amd; > - env->cache_info_amd.l2_cache = &legacy_l2_cache_amd; > - env->cache_info_amd.l3_cache = &legacy_l3_cache; > + env->cache_info_amd = legacy_amd_cache_info; > } > > #ifndef CONFIG_USER_ONLY Reviewed-by: Dapeng Mi