From nobody Sat Nov 15 12:46:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1752492332; cv=none; d=zohomail.com; s=zohoarc; b=d8XXVmUUvy7egbd7ue282Oxd+1bJB2iZLtY9nzYv9G4nmgEmWU2YxGCfORLnlR1ZQueTC/arNxkzLaXmJwK2FQsWC35kOU+RU26vPV+ZzkgQVWR58D2EU+Hbn3rBWgdsYaunN8WaUyC3MGKVldyN+5zT+p19GAH79EYCPPcUBGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752492332; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=thCWbzpn9tuIPYHaAUoFp+onJN6KsKkVNOqqjaM55Rk=; b=VHYso0vaB9KW64KgQa1eGetwj33ptSBavG5drZTe4xWVl/fM9zlGYnSnom3wQJEYp7wYueYXVuwxLaY1GmlV+ddeT5yth7FgzoRaS9zX8UNum2az4ANx7D68UsbaFrrMu9mAsk1OfmI6oXZfOV/7530Th1eNMxZfAJoS9HdDuO8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1752492332641356.1365137803275; Mon, 14 Jul 2025 04:25:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubHDr-0006ZL-09; Mon, 14 Jul 2025 07:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubH0q-0001fm-Va for qemu-devel@nongnu.org; Mon, 14 Jul 2025 07:06:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubH0o-000263-QZ for qemu-devel@nongnu.org; Mon, 14 Jul 2025 07:06:24 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-diUf87Y5MS-InqGVf24TBg-1; Mon, 14 Jul 2025 07:06:20 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-451d2037f1eso27401095e9.0 for ; Mon, 14 Jul 2025 04:06:20 -0700 (PDT) Received: from [192.168.10.48] ([151.49.73.155]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4560f844c2dsm57366755e9.0.2025.07.14.04.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 04:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752491182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=thCWbzpn9tuIPYHaAUoFp+onJN6KsKkVNOqqjaM55Rk=; b=gSn28D1CC84Nqfb3bZ+jMxCrYpSNbDMKs2coTrGbGBqeSKXADOEv11BYD/mlQrCsx5lygw hF7CP6w3vXU2RkGfrcM+QOSDnm6NWyyll7dtMHUau3kOji8VOLnSkFJXAOjETxFB0g750B 2X06xpbhzmHrm4YzyZsTWmfTBtr7Tw8= X-MC-Unique: diUf87Y5MS-InqGVf24TBg-1 X-Mimecast-MFC-AGG-ID: diUf87Y5MS-InqGVf24TBg_1752491180 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752491178; x=1753095978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=thCWbzpn9tuIPYHaAUoFp+onJN6KsKkVNOqqjaM55Rk=; b=HSim5prEJuSalNjAtoiqmrRpKfqhhgsDruwLPpinuYRumkdBE8ZXn4gjiA5EqW09je bYQCNxBbD/31nFKas7FHM7LwKYTCcg1RTxWrATyTchZwvVXdwrjOykc2YgegKUSf5LZn nNkB0kkJJZR2q98JK9D1iYUoyKY3ohYLZpQUqhd/uFp31iN7HeWbwwq8EFuByqEYEVzM ja31rOJV8vzEdC6GZBD2qZ9rg5vQZ28x+iHjVkBko7rpC6L3du+vYtuMoJAATUwRAFwF 0a+zGhuEpQMMTZqgDQ18SBp3awy85wM0FoLDMbNXZRw5A9M7BDU8icgRbG8s+0w8pEhD 8t5Q== X-Gm-Message-State: AOJu0YwXsHQEqE9PrEWG7ILBzpd1VHyX6bFvAnV+A6KIUoj6bBZEXOh0 WVydHMtTKcrk4EyXu7DhL+ZfQNyenDZaalX4zAJWi2sKf9XWPFYwakhCRBYgJsRZ4hl22YdHk7q b/+Im6c1TquiNFU5GhuNI8ifes3xxoSvTURhehibQXAIkceQw/oJ3zDo1Obj+RNLWbn3JpWpJ+x GI0VzEGrTL9n+F8cF67ji5KmR4AZnAyh7YjWZ3tif8 X-Gm-Gg: ASbGncs0bDOMTgzjtwqSnSeutQdqFx1bD6PaZWJ0C67XLQNB8e+r/Vs9/pO09lj/CcQ cfxAaMBaLdFHyswsO6YWNNYqwasm4+Jlfq+UMzjFhwUrfLhvY7E3bps0ueLiXludKfpdwqVt7gL nAGWZ7doiiTVNPxnI2NDj7cJsDzBKWYMdK6vNqBXXvo6ZOQG+A1lxtcdZwBRorGsMMCek8Si1tu 8uzlFy+E5CVk7ioAd7vqugahMcHlL6BBoiatg8U9rxIgZERCiFW5ZQvezStdC3U1Li0MbTRDS7Z 5cANS8hwQQnFsn42cP2Euuu0vuscsItuZjiYNNKt2eo= X-Received: by 2002:a05:6000:2884:b0:3a5:2c18:b181 with SMTP id ffacd0b85a97d-3b5f2e3a02bmr8888230f8f.53.1752491178469; Mon, 14 Jul 2025 04:06:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNVX7zC3TllamP4vaK0OHrsMzqq6pSljcEdTSRvt/3fSxaZFDlk3q5MtCBqZ0+yf43Igl0Yw== X-Received: by 2002:a05:6000:2884:b0:3a5:2c18:b181 with SMTP id ffacd0b85a97d-3b5f2e3a02bmr8888197f8f.53.1752491177915; Mon, 14 Jul 2025 04:06:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu , Dapeng Mi , Yi Lai Subject: [PULL 50/77] i386/cpu: Add legacy_intel_cache_info cache model Date: Mon, 14 Jul 2025 13:03:39 +0200 Message-ID: <20250714110406.117772-51-pbonzini@redhat.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250714110406.117772-1-pbonzini@redhat.com> References: <20250714110406.117772-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1752492334352116600 Content-Type: text/plain; charset="utf-8" From: Zhao Liu 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, and make it easier to handle compatibility later. Reviewed-by: Dapeng Mi Tested-by: Yi Lai Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20250711102143.1622339-12-zhao1.liu@intel.c= om Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 101 +++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6a0e8592bbe..d265dc81563 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -640,21 +640,6 @@ static void encode_topo_cpuid8000001e(X86CPU *cpu, X86= CPUTopoInfo *topo_info, * These are legacy cache values. If there is a need to change any * of these values please use builtin_x86_defs */ - -/* L1 data cache: */ -static CPUCacheInfo legacy_l1d_cache =3D { - .type =3D DATA_CACHE, - .level =3D 1, - .size =3D 32 * KiB, - .self_init =3D 1, - .line_size =3D 64, - .associativity =3D 8, - .sets =3D 64, - .partitions =3D 1, - .no_invd_sharing =3D true, - .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, -}; - static CPUCacheInfo legacy_l1d_cache_amd =3D { .type =3D DATA_CACHE, .level =3D 1, @@ -669,20 +654,6 @@ static CPUCacheInfo legacy_l1d_cache_amd =3D { .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, }; =20 -/* L1 instruction cache: */ -static CPUCacheInfo legacy_l1i_cache =3D { - .type =3D INSTRUCTION_CACHE, - .level =3D 1, - .size =3D 32 * KiB, - .self_init =3D 1, - .line_size =3D 64, - .associativity =3D 8, - .sets =3D 64, - .partitions =3D 1, - .no_invd_sharing =3D true, - .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, -}; - static CPUCacheInfo legacy_l1i_cache_amd =3D { .type =3D INSTRUCTION_CACHE, .level =3D 1, @@ -697,20 +668,6 @@ static CPUCacheInfo legacy_l1i_cache_amd =3D { .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, }; =20 -/* Level 2 unified cache: */ -static CPUCacheInfo legacy_l2_cache =3D { - .type =3D UNIFIED_CACHE, - .level =3D 2, - .size =3D 4 * MiB, - .self_init =3D 1, - .line_size =3D 64, - .associativity =3D 16, - .sets =3D 4096, - .partitions =3D 1, - .no_invd_sharing =3D true, - .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, -}; - static CPUCacheInfo legacy_l2_cache_amd =3D { .type =3D UNIFIED_CACHE, .level =3D 2, @@ -800,6 +757,59 @@ static const CPUCaches legacy_intel_cpuid2_cache_info = =3D { }, }; =20 +static const CPUCaches legacy_intel_cache_info =3D { + .l1d_cache =3D &(CPUCacheInfo) { + .type =3D DATA_CACHE, + .level =3D 1, + .size =3D 32 * KiB, + .self_init =3D 1, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 64, + .partitions =3D 1, + .no_invd_sharing =3D true, + .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, + }, + .l1i_cache =3D &(CPUCacheInfo) { + .type =3D INSTRUCTION_CACHE, + .level =3D 1, + .size =3D 32 * KiB, + .self_init =3D 1, + .line_size =3D 64, + .associativity =3D 8, + .sets =3D 64, + .partitions =3D 1, + .no_invd_sharing =3D true, + .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, + }, + .l2_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 2, + .size =3D 4 * MiB, + .self_init =3D 1, + .line_size =3D 64, + .associativity =3D 16, + .sets =3D 4096, + .partitions =3D 1, + .no_invd_sharing =3D true, + .share_level =3D CPU_TOPOLOGY_LEVEL_CORE, + }, + .l3_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 3, + .size =3D 16 * MiB, + .line_size =3D 64, + .associativity =3D 16, + .sets =3D 16384, + .partitions =3D 1, + .lines_per_tag =3D 1, + .self_init =3D true, + .inclusive =3D true, + .complex_indexing =3D true, + .share_level =3D CPU_TOPOLOGY_LEVEL_DIE, + }, +}; + /* TLB definitions: */ =20 #define L1_DTLB_2M_ASSOC 1 @@ -8980,10 +8990,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) env->enable_legacy_cpuid2_cache =3D true; } =20 - env->cache_info_cpuid4.l1d_cache =3D &legacy_l1d_cache; - env->cache_info_cpuid4.l1i_cache =3D &legacy_l1i_cache; - env->cache_info_cpuid4.l2_cache =3D &legacy_l2_cache; - env->cache_info_cpuid4.l3_cache =3D &legacy_l3_cache; + env->cache_info_cpuid4 =3D legacy_intel_cache_info; =20 env->cache_info_amd.l1d_cache =3D &legacy_l1d_cache_amd; env->cache_info_amd.l1i_cache =3D &legacy_l1i_cache_amd; --=20 2.50.0