Received: by 2002:a17:504:1e0a:b0:1be9:327d:8ee3 with SMTP id i10csp485583njk; Thu, 23 Jan 2025 15:45:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWnIOkSRpz/i6Gf4xo0V1SiL+QaeD7+n/NA1Q8zWGOwkproOLp4chpABj+wlnFKKyzgVmt5AwkhDnEb2g==@linaro.org X-Received: by 2002:a05:600c:3d96:b0:434:a26c:8291 with SMTP id 5b1f17b1804b1-4389143b5dbmr244298985e9.24.1737675954156; Thu, 23 Jan 2025 15:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737675954; cv=none; d=google.com; s=arc-20240605; b=B0ESvCHq3G9XAB6lCJMs7nvcNxwz2elqkiSXuAexteRD0Up9l1OIzx0O+g+rtnNj6I DIYykRupW7kughCprdSU9hwaXrpLaw5uBwVjLidP/CQwekNU3Oew3Ke/TK8mYr3z2uG5 GwaoOwAyLMDjIPChIs/N0QNI7HYv2hZOcgD2uKRAssLIeS1AgR8Tb1A/nQ0nylIT4+aQ y8z1Zhfwv1NR/wZ7VVR34PbLX8EZYmH/35UcMjiv9dAdQZpDNOXk1zp3MGPPMlJzE5ME IT+i/a6zqhMp5zoA1fSqUMEQDFeH6Lf1OkT6EllfiiZ71ey9rzQbJw+U7o2A+r2sQEIn rJcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MvtCakZyrGCXwv1NUluQigNUDDDoRJgD07DKcxozaAI=; fh=5AYAIza0q4RCZkpwsMlseM1vOKroPpJphyZbyhDuBsQ=; b=T+32+bl7N9AL3F2uu4EtCc3KAhlYxoNLdDKsW+FDE1IZNZJIK258CGk4M+Ewigxhjd WmXCVWSDo67PaJPzFygZOu37obtKo/3XvAuZ92+EwzP1tWNV+qxeYvFOcm5wm+hntjx4 1vB/uk9Pq5ABiUkv2Iv+JM9MFw/HLuM0nt1V8aHS/f3tJmvBeSxv7AVGkM6zVtEWp0dq URPVGzjUQ+OGfBinONODXIyUym2EUIDvykRH+7BmnqGh0726YOKfukYjJmJ9g3dmZmiN hZzd/9OS1GNYx/ZCcpIfymEP43GYoAEtfBNjMOV5GkI3rxkmqC3thD0szPwAWG0lhrob IbQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FfZuVMtp; spf=pass (google.com: domain of philmd@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=philmd@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-438bd4a485esor2044945e9.3.2025.01.23.15.45.53 for (Google Transport Security); Thu, 23 Jan 2025 15:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of philmd@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FfZuVMtp; spf=pass (google.com: domain of philmd@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=philmd@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737675953; x=1738280753; darn=linaro.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=MvtCakZyrGCXwv1NUluQigNUDDDoRJgD07DKcxozaAI=; b=FfZuVMtpkaaNKbPdhAoVBpQoixO9iPgoblGPnYL+iMI6QLkMOaWobn+GBzmgxRCB9+ YxLmMCBkcxDM3hMr4zQ7YVMgknaTTZb96/A30YLg2+B8z6YICc6m1QezxK8dJHBXYFR0 ozktOpZmXN1sKJ/X6FWYFvW/CKXANrW+3In3DbWxO4alXSNPuViPPpqKKUwMGIqgNOeb QGzfvLMhIj2nNUwYhDCIb1lY8kmo5E4w7MM+pSLCZOXsQxk91rEcYWnrSR2Yy/XgQETf vh6gL1RhofwWAjLjrfVNv/gaNkYd0R6JIbBft4+zyr7vZrIHmdYOWIBBYGqYY6fV7Yhl YjSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737675953; x=1738280753; 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=MvtCakZyrGCXwv1NUluQigNUDDDoRJgD07DKcxozaAI=; b=XmcLpZFI59f6IdR7itrtncu5fyIegITM+MhncS7wtgBTPf/2REpf772TrCJY7D1LIx kTIiXVO3gziLja7e8qHciFq3J5B93M+NzTuOucBWMHcdwGQCOj+8wTFN1EacRIY41+J/ FlnNQhvBfUm/Ojaz4BIVFXaTet+bNbSuu2GASPQBrxUtKI91YwGhKUTMi/oPct8C4vbY RaUkVrJm6+rTceoM9VLwrTZJgpqlGRPXtCERSbqiHbrkaIsLcs/tTIdFGalr1y1jOM9M cDPx9G5GOrdiohMYN8PYolUqd9rkuk7as1ukVC3BCM0E1NnesBTZN8GjmgZRg9ADeYUV QF0w== X-Forwarded-Encrypted: i=1; AJvYcCWpoekIS40dJc5qYHn5x/AgvzXniJjc9yJLQNEYygSOPnbNR9OyNeaqUfuxkjZjcFTxg5YTBYCpnw+M8w==@linaro.org X-Gm-Message-State: AOJu0Yw2jwqGJtD7LQWhBmzgETEeq1kDxiS9igOHohW/90nri+DdoFHk NhgLhBMVcFuAKCEdI90TmqH7aJud9790wUJEV4VhfM19PzIC3BOr36HbMXRWeBNmVA== X-Gm-Gg: ASbGncuYq3j9gt5mGN+5XleQvvZZUfLUEDXGxkCAID845/t4vqBiy4qgpvpKZy96Veh LbdXvnmH3iSivVDNeH58WefklDQopm0LCh2SRNmYXwfbF7NCYj96nPmpLwV+MgRXmn6edQY+Hhd UzAM7J6ZTYzCiHiy5i2K+8v/SVh2BJ3tI3eMsUVOLh54imUlvGnLRDkWXXoqOoO00F7IYjy3+7Z PJdwHA+SaDp0XrumTtoOiGCyg4huxWFM1rhnL4HNIiEnw4VY7Xu9hac5ZcNxkotEvGYqfaIGWTi EgRpos68bbg8J7ABi1kzYL8ZCb+kqY+/qVxU+wagVFso5gGffD6CD5c= X-Google-Smtp-Source: AGHT+IESHbhLNhi6WI+MIsv7kwcNIGaQJ9dXLlWxoyCR3XibduHPGVHiP0CzOiY9OItw0/7PMnFvyA== X-Received: by 2002:a05:600c:1987:b0:434:f753:6012 with SMTP id 5b1f17b1804b1-438913f2f4emr282730315e9.17.1737675953608; Thu, 23 Jan 2025 15:45:53 -0800 (PST) Return-Path: Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd43cdbbsm7488805e9.0.2025.01.23.15.45.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Jan 2025 15:45:52 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, David Hildenbrand , qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org, Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 17/20] cpus: Have cpu_class_init_props() per user / system emulation Date: Fri, 24 Jan 2025 00:44:11 +0100 Message-ID: <20250123234415.59850-18-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250123234415.59850-1-philmd@linaro.org> References: <20250123234415.59850-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TUID: eaTN3tpmZyTx Rather than maintaining a mix of system / user code for CPU class properties, move system properties to cpu-system.c and user ones to the new cpu-user.c unit. Signed-off-by: Philippe Mathieu-Daudé --- cpu-target.c | 58 -------------------------------------------- hw/core/cpu-system.c | 40 ++++++++++++++++++++++++++++++ hw/core/cpu-user.c | 27 +++++++++++++++++++++ hw/core/meson.build | 5 +++- 4 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 hw/core/cpu-user.c diff --git a/cpu-target.c b/cpu-target.c index c05ef1ff096..dff8c0747f9 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -19,15 +19,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "hw/qdev-core.h" -#include "hw/qdev-properties.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "migration/vmstate.h" #ifndef CONFIG_USER_ONLY #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" -#include "exec/memory.h" #endif #include "system/accel-ops.h" #include "system/cpus.h" @@ -179,61 +176,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) accel_cpu_common_unrealize(cpu); } -/* - * This can't go in hw/core/cpu.c because that file is compiled only - * once for both user-mode and system builds. - */ -static const Property cpu_common_props[] = { -#ifdef CONFIG_USER_ONLY - /* - * Create a property for the user-only object, so users can - * adjust prctl(PR_SET_UNALIGN) from the command-line. - * Has no effect if the target does not support the feature. - */ - DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, - prctl_unalign_sigbus, false), -#else - /* - * Create a memory property for system CPU object, so users can - * wire up its memory. The default if no link is set up is to use - * the system address space. - */ - DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, - MemoryRegion *), -#endif -}; - -#ifndef CONFIG_USER_ONLY -static bool cpu_get_start_powered_off(Object *obj, Error **errp) -{ - CPUState *cpu = CPU(obj); - return cpu->start_powered_off; -} - -static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp) -{ - CPUState *cpu = CPU(obj); - cpu->start_powered_off = value; -} -#endif - -void cpu_class_init_props(DeviceClass *dc) -{ -#ifndef CONFIG_USER_ONLY - ObjectClass *oc = OBJECT_CLASS(dc); - - /* - * We can't use DEFINE_PROP_BOOL in the Property array for this - * property, because we want this to be settable after realize. - */ - object_class_property_add_bool(oc, "start-powered-off", - cpu_get_start_powered_off, - cpu_set_start_powered_off); -#endif - - device_class_set_props(dc, cpu_common_props); -} - void cpu_exec_initfn(CPUState *cpu) { #ifndef CONFIG_USER_ONLY diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 6aae28a349a..c63c984a803 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -20,7 +20,10 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "exec/memory.h" #include "exec/tswap.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" #include "hw/core/sysemu-cpu-ops.h" bool cpu_paging_enabled(const CPUState *cpu) @@ -142,3 +145,40 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) } return res; } + +static const Property cpu_system_props[] = { + /* + * Create a memory property for system CPU object, so users can + * wire up its memory. The default if no link is set up is to use + * the system address space. + */ + DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, + MemoryRegion *), +}; + +static bool cpu_get_start_powered_off(Object *obj, Error **errp) +{ + CPUState *cpu = CPU(obj); + return cpu->start_powered_off; +} + +static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp) +{ + CPUState *cpu = CPU(obj); + cpu->start_powered_off = value; +} + +void cpu_class_init_props(DeviceClass *dc) +{ + ObjectClass *oc = OBJECT_CLASS(dc); + + /* + * We can't use DEFINE_PROP_BOOL in the Property array for this + * property, because we want this to be settable after realize. + */ + object_class_property_add_bool(oc, "start-powered-off", + cpu_get_start_powered_off, + cpu_set_start_powered_off); + + device_class_set_props(dc, cpu_system_props); +} diff --git a/hw/core/cpu-user.c b/hw/core/cpu-user.c new file mode 100644 index 00000000000..e5ccf6bf13a --- /dev/null +++ b/hw/core/cpu-user.c @@ -0,0 +1,27 @@ +/* + * QEMU CPU model (user specific) + * + * Copyright (c) Linaro, Ltd. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" +#include "hw/core/cpu.h" + +static const Property cpu_user_props[] = { + /* + * Create a property for the user-only object, so users can + * adjust prctl(PR_SET_UNALIGN) from the command-line. + * Has no effect if the target does not support the feature. + */ + DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, + prctl_unalign_sigbus, false), +}; + +void cpu_class_init_props(DeviceClass *dc) +{ + device_class_set_props(dc, cpu_user_props); +} diff --git a/hw/core/meson.build b/hw/core/meson.build index 65a1698ed1f..b5a545a0edd 100644 --- a/hw/core/meson.build +++ b/hw/core/meson.build @@ -46,4 +46,7 @@ system_ss.add(files( 'vm-change-state-handler.c', 'clock-vmstate.c', )) -user_ss.add(files('qdev-user.c')) +user_ss.add(files( + 'cpu-user.c', + 'qdev-user.c', +)) -- 2.47.1