From patchwork Tue Oct 10 09:28:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 731437 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1641467wrw; Tue, 10 Oct 2023 02:32:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAAlp3Ki/N/Gva2w04VtjsjXxZHhX0FlbSLCxVy9lSD56Tw35TUwfz0tDdhWaaXDQTEsaj X-Received: by 2002:a05:6214:3bc4:b0:65c:fd5b:d74e with SMTP id ng4-20020a0562143bc400b0065cfd5bd74emr17714064qvb.26.1696930373035; Tue, 10 Oct 2023 02:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696930373; cv=none; d=google.com; s=arc-20160816; b=k3kqXBg0ffJq35/vDBruMUt4fekxDk/SCDRp/lqggV8KwrFlOeYw5PQm2/9nKAwKvc wRNWx+X5l2Bcd+c3NjlWpIn97EZDBzHhVL1PwQsnAS+C5AA2XI+8yqejHxKYO8a9ToRt AK2wgcFdmqDuOWMvSDLDZzGTv74csKM3aybIR05Ovuxt1wXWdhMtLFagMwL5Jtbajj75 0oIYlyMhuS0KfdIIHBq7qeHJBY0bAMyVJA1LtS5uQ/KdZkUwacUGRDt3kSRXgsnf12iP z6Ajlc8XZRYshTr57DD2y1oeptSFReEdHBhZENT6ox15Xft4cg6ZAduM9JneKvRunlqr byWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=igxlAzxucraozvyYxr1AoU5+SPegRZLZXUAG6vlLMuM=; fh=iupQBrmerAoZOw8v6swRnyYBx+6KhbF7AbBF1Jawaz4=; b=sUHADf1NS31/RA2sEc3+tOgh508bBe2+Zvry8LM8EsIWe7YsZFIw1UWAKwiDGBhZ9m V70qrMpeMUOt7xof2vwj5KHHf2p6oyLNF8ihBoMbjRddI5XmjW+j2LJ0ONJG283uL718 HEL0vKtJ6eMYNg3iUnloNG2MlVBtdcGsp9obL5hjBT7ZzCMYGSZG3Nf7XsrrgocBvLa8 SgsCj8up4ZzGWw5Eo3q4nJTeuS7lB4StksHH4qW/knEYKb6O1AS9O7/lKNRF4O8BJCNB BT34LAXD7jmmh7pV8a4uQlN83IpK28bXdtalENz+Tm2C9lVzmzTgrV5EPjuuHF0L2rWF bMxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ugshjq8+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t5-20020a0c8d85000000b0065b174c561fsi7185226qvb.112.2023.10.10.02.32.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2023 02:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ugshjq8+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qq95b-0003jn-Bj; Tue, 10 Oct 2023 05:31:44 -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 1qq95G-0002Lu-5y for qemu-devel@nongnu.org; Tue, 10 Oct 2023 05:31:22 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qq95D-0008QK-4d for qemu-devel@nongnu.org; Tue, 10 Oct 2023 05:31:21 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-53d8320f0easo519206a12.3 for ; Tue, 10 Oct 2023 02:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696930277; x=1697535077; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=igxlAzxucraozvyYxr1AoU5+SPegRZLZXUAG6vlLMuM=; b=ugshjq8+VseuTYN3ir7Uttxe/UnSs1Hu0LkjAKReFPyRZYaTSZHIVlIsoohCSI8xom e+7tkqYcX/I/QRzVpKrIkfJzwLrYv9OtCfQJ4wlx8IkSUV77+UCSiJjqXuzX8pYBFUao ckNbjoalDcllWzYR4WtVg276N1FiXLOm0l+yoWwkOPSFBQ+h/OdOa68BKPnDCZv5qseQ DxUoNOCQsu2jHHTEAt2EdShTkz7/ZEKs1Mzse7rC7XDPXOPRl+c6dj5OKZPioXT+ajIO BwccaWB6+x8bqLGBGPLSCB/1CSs4MbH9kZjK4e4yKOgqlCY2OjVIokpP/03euOUgdTuq DvOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696930277; x=1697535077; 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=igxlAzxucraozvyYxr1AoU5+SPegRZLZXUAG6vlLMuM=; b=TRJNOndRYB6unamsdceUJS0PspViqpsOHSdjF3xmJtFNqhu8zfStrSXn+6nl3WGFtN mxAu5biYnGJUgm/DoPyuxZmTrg/rCOwatjpcE1VTyz5YRRmIdMkx08rllg3B1WmHKU6K gqPy5v3Tf0De23gUz5c5dMEGnyulLKYvDkTMAf2jp7XyWbkg4HvWZAOtzkQzBNVt4U7d jklBZ9B3FqymP3cWs6+sS3dkXZJHzRTgoa4eYXtR9juY3nSQBYyvGaeLqkF4YOsAU8Lq or6RJFKbEyugYml6NeK1IDBJA2o72TTTGk5E8k7tLzfuuLn5oDJZZk2dFJhEyGp4W3ay W+MQ== X-Gm-Message-State: AOJu0Yy+3b/NHVlreDZNrzc3fylJOpa7kO0kVduzlti37CFKjUUERyxq OGl1VCGvxtplo8lEEiRuLcLS1/j+knywdb5IsptI6g== X-Received: by 2002:a05:6402:785:b0:523:ae0a:a446 with SMTP id d5-20020a056402078500b00523ae0aa446mr18233078edy.24.1696930277343; Tue, 10 Oct 2023 02:31:17 -0700 (PDT) Received: from m1x-phil.lan (aif79-h01-176-172-113-148.dsl.sta.abo.bbox.fr. [176.172.113.148]) by smtp.gmail.com with ESMTPSA id ev5-20020a056402540500b0053b67aba57bsm4579372edb.17.2023.10.10.02.31.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Oct 2023 02:31:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , "Michael S. Tsirkin" , Song Gao , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier , Bastian Koppelmann , qemu-arm@nongnu.org, Jiaxun Yang , Ilya Leoshkevich , Yoshinori Sato , Paolo Bonzini , Weiwei Li , Nicholas Piggin , qemu-riscv@nongnu.org, "Edgar E. Iglesias" , Bin Meng , Yanan Wang , Palmer Dabbelt , Alistair Francis , Aleksandar Rikalo , Daniel Henrique Barboza , Marek Vasut , Peter Maydell , qemu-ppc@nongnu.org, Michael Rolnik , Max Filippov , Mark Cave-Ayland , Laurent Vivier , Stafford Horne , Thomas Huth , Chris Wulff , Sergio Lopez , Xiaojuan Yang , Richard Henderson , Liu Zhiwei , Artyom Tarasenko , Daniel Henrique Barboza , Eduardo Habkost , Brian Cain , Marcel Apfelbaum , Aurelien Jarno , qemu-s390x@nongnu.org Subject: [PATCH 16/18] target/i386: Make X86_CPU common to new I386_CPU / X86_64_CPU types Date: Tue, 10 Oct 2023 11:28:58 +0200 Message-ID: <20231010092901.99189-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231010092901.99189-1-philmd@linaro.org> References: <20231010092901.99189-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=philmd@linaro.org; helo=mail-ed1-x52a.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "target/foo/cpu-qom.h" can not use any target specific definitions. Currently "target/i386/cpu-qom.h" defines TYPE_X86_CPU depending on the i386/x86_64 build type. This doesn't scale in a heterogeneous context where we need to access both types concurrently. In order to do that, introduce the new I386_CPU / X86_64_CPU types, both inheriting a common TYPE_X86_CPU base type. Keep the current "base" and "max" CPU types as 32 or 64-bit, depending on the binary built. Adapt the cpu-plug-test, since the 'base' architecture is now common to both 32/64-bit x86 targets. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Richard Henderson --- target/i386/cpu-qom.h | 16 +++++++++------- target/i386/cpu.h | 3 +++ target/i386/cpu.c | 20 ++++++++++++++++++-- tests/qtest/cpu-plug-test.c | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/target/i386/cpu-qom.h b/target/i386/cpu-qom.h index 78207c0a7c..81f40bf91e 100644 --- a/target/i386/cpu-qom.h +++ b/target/i386/cpu-qom.h @@ -1,5 +1,5 @@ /* - * QEMU x86 CPU + * QEMU x86 CPU QOM header (target agnostic) * * Copyright (c) 2012 SUSE LINUX Products GmbH * @@ -24,13 +24,15 @@ #include "qemu/notify.h" #include "qom/object.h" -#ifdef TARGET_X86_64 -#define TYPE_X86_CPU "x86_64-cpu" -#else -#define TYPE_X86_CPU "i386-cpu" -#endif +#define TYPE_X86_CPU "x86-cpu" +#define TYPE_I386_CPU "i386-cpu" +#define TYPE_X86_64_CPU "x86_64-cpu" -OBJECT_DECLARE_CPU_TYPE(X86CPU, X86CPUClass, X86_CPU) +OBJECT_DECLARE_CPU_TYPE(I386CPU, X86CPUClass, I386_CPU) +OBJECT_DECLARE_CPU_TYPE(X86_64CPU, X86CPUClass, X86_64_CPU) + +#define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU +#define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX) #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7c976971c7..5deb39a380 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -28,6 +28,9 @@ #include "qemu/cpu-float.h" #include "qemu/timer.h" +/* Abstract QOM X86 CPU, not exposed to other targets */ +OBJECT_DECLARE_CPU_TYPE(X86CPU, X86CPUClass, X86_CPU) + #define XEN_NR_VIRQS 24 /* The x86 has a strong memory model with some store-after-load re-ordering */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8f1fd5f304..1b1dae92c6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8033,12 +8033,28 @@ static const TypeInfo x86_cpu_types[] = { .class_size = sizeof(X86CPUClass), .class_init = x86_cpu_common_class_init, }, { - .name = X86_CPU_TYPE_NAME("base"), + .name = TYPE_I386_CPU, .parent = TYPE_X86_CPU, + .abstract = true, + }, { + .name = TYPE_X86_64_CPU, + .parent = TYPE_X86_CPU, + .abstract = true, + }, { + .name = X86_CPU_TYPE_NAME("base"), +#ifdef TARGET_X86_64 + .parent = TYPE_X86_64_CPU, +#else + .parent = TYPE_I386_CPU, +#endif .class_init = x86_cpu_base_class_init, }, { .name = X86_CPU_TYPE_NAME("max"), - .parent = TYPE_X86_CPU, +#ifdef TARGET_X86_64 + .parent = TYPE_X86_64_CPU, +#else + .parent = TYPE_I386_CPU, +#endif .instance_init = max_x86_cpu_initfn, .class_init = max_x86_cpu_class_init, } diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c index 7f5dd5f85a..97316d131f 100644 --- a/tests/qtest/cpu-plug-test.c +++ b/tests/qtest/cpu-plug-test.c @@ -90,7 +90,7 @@ static void add_pc_test_case(const char *mname) data->machine = g_strdup(mname); data->cpu_model = "Haswell"; /* 1.3+ theoretically */ data->device_model = g_strdup_printf("%s-%s-cpu", data->cpu_model, - qtest_get_arch()); + qtest_get_base_arch()); data->sockets = 1; data->cores = 3; data->threads = 2;