From: Greg Kurz <groug@kaod.org>
To: Igor Mammedov <imammedo@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
Bharata B Rao <bharata@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: move registration of "host" CPU core type to machine code
Date: Fri, 29 Sep 2017 09:25:52 +0200 [thread overview]
Message-ID: <20170929092552.44e4401c@bahia.lan> (raw)
In-Reply-To: <20170929084111.09780a0b@nial.brq.redhat.com>
On Fri, 29 Sep 2017 08:41:11 +0200
Igor Mammedov <imammedo@redhat.com> wrote:
[...]
> > > I don't see from this commit a reason why it can't be done in cpu-models.c
> > > dependencies here are
> > > mfpvr() - which probably should work without KVM
> >
> > Correct.
> >
> > > ppc_cpu_class_by_pvr() - should work fine if 'host' type is being
> > > registered as the last among the other CPU types
> >
> > We have:
> >
> > ppc_cpu_class_by_pvr()
> > object_class_get_list()
> > object_class_foreach()
> > object_class_foreach_tramp()
> > type_initialize()
> > type_get_parent()
> >
> > type_initialize() recursively initializes all parent types, and
> > type_get_parent() aborts if the parent type isn't registered yet,
> > which may happen as long as all type_init() functions haven't been
> > called => ppc_cpu_class_by_pvr() cannot be safely called from a
> > type_init() function.
> I don't get what you are trying to say,
> could you be more specific about what parent type might be not
> registered?
With the patch below applied, TYPE_CPU isn't registered at the
time we call ppc_cpu_class_by_pvr().
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index cb5777afa0b4..4445a292d578 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -123,8 +123,6 @@ static bool kvmppc_is_pr(KVMState *ks)
return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
}
-static int kvm_ppc_register_host_cpu_type(void);
-
int kvm_arch_init(MachineState *ms, KVMState *s)
{
cap_interrupt_unset = kvm_check_extension(s, KVM_CAP_PPC_UNSET_IRQ);
@@ -163,8 +161,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
"VM to stall at times!\n");
}
- kvm_ppc_register_host_cpu_type();
-
return 0;
}
@@ -2487,7 +2483,7 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
return pvr_pcc;
}
-static int kvm_ppc_register_host_cpu_type(void)
+int kvm_ppc_register_host_cpu_type(void)
{
TypeInfo type_info = {
.name = TYPE_HOST_POWERPC_CPU,
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index d6be38ecafbd..a46c5a36402a 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -71,6 +71,7 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu);
bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path);
+int kvm_ppc_register_host_cpu_type(void);
#else
static inline uint32_t kvmppc_get_tbfreq(void)
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index c6399a3a0d0d..b6e02c583836 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -10766,6 +10766,9 @@ static void ppc_cpu_register_types(void)
{
type_register_static(&ppc_cpu_type_info);
type_register_static(&ppc_vhyp_type_info);
+#ifdef CONFIG_KVM
+ kvm_ppc_register_host_cpu_type();
+#endif
}
type_init(ppc_cpu_register_types)
next prev parent reply other threads:[~2017-09-29 7:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-25 9:47 [Qemu-devel] [PATCH] spapr: move registration of "host" CPU core type to machine code Greg Kurz
2017-09-25 13:41 ` Igor Mammedov
2017-09-25 15:48 ` Greg Kurz
2017-09-25 21:47 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-09-27 12:19 ` Igor Mammedov
2017-09-27 15:32 ` Greg Kurz
2017-09-29 6:41 ` Igor Mammedov
2017-09-29 7:25 ` Greg Kurz [this message]
2017-09-26 2:57 ` [Qemu-devel] " David Gibson
2017-09-26 7:19 ` Greg Kurz
2017-09-26 8:29 ` Igor Mammedov
2017-09-27 6:39 ` David Gibson
2017-09-27 12:11 ` Igor Mammedov
2017-09-28 4:01 ` David Gibson
2017-09-27 6:21 ` David Gibson
2017-09-27 8:13 ` Igor Mammedov
2017-09-27 11:49 ` [Qemu-devel] [RFC] ppc: define spapr core types statically Igor Mammedov
2017-09-27 16:18 ` Greg Kurz
2017-09-28 4:22 ` David Gibson
2017-09-29 6:44 ` Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170929092552.44e4401c@bahia.lan \
--to=groug@kaod.org \
--cc=bharata@linux.vnet.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.