Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="al6VQ0gZ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02E44D1 for ; Tue, 28 Nov 2023 07:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701185684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D9lOQjODNv02P43/kZH/wGQ3w31tJS9+8fDtN67uTGI=; b=al6VQ0gZmaO5cUAK8LObkne98U7txuUkzdUJ055/Tk7/NUrbDvgXMLTBHd4n1/GZ8TCCVE 8bxj/xiagKhIXs/1da9nz6dUWczlciN9cpMkwU0FFr5vU2t+m645bmriHaGxfuH+hvSqo4 kMFmXrY5NcLVzL1MVL4Wr+RVKelx3a8= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-Q7OM1teMNMe3L7JDLjL2iA-1; Tue, 28 Nov 2023 10:34:43 -0500 X-MC-Unique: Q7OM1teMNMe3L7JDLjL2iA-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50abbf4ee79so6032815e87.1 for ; Tue, 28 Nov 2023 07:34:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701185682; x=1701790482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D9lOQjODNv02P43/kZH/wGQ3w31tJS9+8fDtN67uTGI=; b=DBH7HK5cxGBYmrFEu0TMo+4Qh76OEmpWm7yLzkSP1kUXJ0ZS2TvmD0ak+Q7prsYXgn PToaqQWSq+MN7bluN9hDot43sVNGVi7z3QFbhkzYcr0u7HwpQNxtAi60OHgJKEWs2byg Kp59UwivDkCUbSKatn4P98eSJqBBEGaG7TBC9e/xFoZKkjnf+S/UE4Wnh1zn50uo9Ret TRy0bCDR/5l26Wrk5BU+jABPEcAn6sgANlvgSaRb96DhjuTzKyOYupnKnL/5ywZvxbxP WreEnv45zC4JuM1RU45gCk6DbdXvm54bsfAbvBFWbcaHtA9++q3S+EHOxwCDmha8rioW EKTA== X-Gm-Message-State: AOJu0YyTNiXbZHPKOMtxCiClZW7gVaGDK2ZM8fZUsMa7eTfqYsk94/lG BFERH6TB/X8TtEOjknM22rZzbPOfZZruHk0GDYQslMVslI/O0CsYuy9mwgf4J7tR/Qt192MVOfZ f769FiMBM/s+6 X-Received: by 2002:ac2:4acb:0:b0:50b:ac31:28e5 with SMTP id m11-20020ac24acb000000b0050bac3128e5mr5758122lfp.65.1701185682044; Tue, 28 Nov 2023 07:34:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVxWl5bdZvuMtpJUQ8Z+EaD52jviZNSCZAMpxb5IUoQ4q6GjfDoZU/DsJDwJO/WcMaVBCVag== X-Received: by 2002:ac2:4acb:0:b0:50b:ac31:28e5 with SMTP id m11-20020ac24acb000000b0050bac3128e5mr5758085lfp.65.1701185681511; Tue, 28 Nov 2023 07:34:41 -0800 (PST) Received: from imammedo.users.ipa.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id d11-20020a056402000b00b0054851cd28d2sm6365832edu.79.2023.11.28.07.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 07:34:41 -0800 (PST) Date: Tue, 28 Nov 2023 16:34:38 +0100 From: Igor Mammedov To: Philippe =?UTF-8?B?TWF0aGlldS1EYXVkw6k=?= Cc: qemu-devel@nongnu.org, Laurent Vivier , Paolo Bonzini , Max Filippov , David Hildenbrand , Peter Xu , Anton Johansson , Peter Maydell , kvm@vger.kernel.org, Marek Vasut , David Gibson , Brian Cain , Yoshinori Sato , "Edgar E . Iglesias" , Claudio Fontana , Daniel Henrique Barboza , Artyom Tarasenko , Marcelo Tosatti , qemu-ppc@nongnu.org, Liu Zhiwei , Aurelien Jarno , Ilya Leoshkevich , Daniel Henrique Barboza , Bastian Koppelmann , =?UTF-8?B?Q8OpZHJpYw==?= Le Goater , Alistair Francis , Alessandro Di Federico , Song Gao , Marcel Apfelbaum , Chris Wulff , "Michael S. Tsirkin" , Alistair Francis , Fabiano Rosas , qemu-s390x@nongnu.org, Yanan Wang , Luc Michel , Weiwei Li , Bin Meng , Stafford Horne , Xiaojuan Yang , "Daniel P . Berrange" , Thomas Huth , qemu-arm@nongnu.org, Jiaxun Yang , Richard Henderson , Aleksandar Rikalo , Bernhard Beschow , Mark Cave-Ayland , qemu-riscv@nongnu.org, Alex =?UTF-8?B?QmVubsOpZQ==?= , Nicholas Piggin , Greg Kurz , Michael Rolnik , Eduardo Habkost , Markus Armbruster , Palmer Dabbelt Subject: Re: [PATCH 02/22] hw/intc/apic: Pass CPU using QOM link property Message-ID: <20231128163438.3d257bdd@imammedo.users.ipa.redhat.com> In-Reply-To: <20230918160257.30127-3-philmd@linaro.org> References: <20230918160257.30127-1-philmd@linaro.org> <20230918160257.30127-3-philmd@linaro.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 18 Sep 2023 18:02:35 +0200 Philippe Mathieu-Daud=C3=A9 wrote: > QOM objects shouldn't access each other internals fields > except using the QOM API. >=20 > Declare the 'cpu' and 'base-addr' properties, set them > using object_property_set_link() and qdev_prop_set_uint32() > respectively. >=20 > Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Igor Mammedov > --- > hw/intc/apic_common.c | 2 ++ > target/i386/cpu-sysemu.c | 11 ++++++----- > 2 files changed, 8 insertions(+), 5 deletions(-) >=20 > diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c > index 68ad30e2f5..e28f7402ab 100644 > --- a/hw/intc/apic_common.c > +++ b/hw/intc/apic_common.c > @@ -394,6 +394,8 @@ static Property apic_properties_common[] =3D { > true), > DEFINE_PROP_BOOL("legacy-instance-id", APICCommonState, legacy_insta= nce_id, > false), > + DEFINE_PROP_LINK("cpu", APICCommonState, cpu, TYPE_X86_CPU, X86CPU *= ), > + DEFINE_PROP_UINT32("base-addr", APICCommonState, apicbase, 0), > DEFINE_PROP_END_OF_LIST(), > }; > =20 > diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c > index 6a164d3769..6edfb7e2af 100644 > --- a/target/i386/cpu-sysemu.c > +++ b/target/i386/cpu-sysemu.c > @@ -269,7 +269,6 @@ APICCommonClass *apic_get_class(Error **errp) > =20 > void x86_cpu_apic_create(X86CPU *cpu, Error **errp) > { > - APICCommonState *apic; > APICCommonClass *apic_class =3D apic_get_class(errp); > =20 > assert(apic_class); > @@ -279,11 +278,13 @@ void x86_cpu_apic_create(X86CPU *cpu, Error **errp) > OBJECT(cpu->apic_state)); > object_unref(OBJECT(cpu->apic_state)); > =20 > + if (!object_property_set_link(OBJECT(cpu->apic_state), "cpu", > + OBJECT(cpu), errp)) { > + return; > + } > qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id); > - /* TODO: convert to link<> */ > - apic =3D APIC_COMMON(cpu->apic_state); > - apic->cpu =3D cpu; > - apic->apicbase =3D APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; > + qdev_prop_set_uint32(cpu->apic_state, "base-addr", > + APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE= ); > } > =20 > void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)