From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmPz0-0006hZ-R6 for qemu-devel@nongnu.org; Tue, 11 Jun 2013 10:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmPyy-0008TY-6S for qemu-devel@nongnu.org; Tue, 11 Jun 2013 10:55:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmPyx-0008TM-Tj for qemu-devel@nongnu.org; Tue, 11 Jun 2013 10:55:36 -0400 Date: Tue, 11 Jun 2013 10:52:05 -0400 From: Luiz Capitulino Message-ID: <20130611105205.3a8089c6@redhat.com> In-Reply-To: <1370794247-28267-8-git-send-email-afaerber@suse.de> References: <1370794247-28267-1-git-send-email-afaerber@suse.de> <1370794247-28267-8-git-send-email-afaerber@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qom-cpu v4 07/18] cpu: Turn cpu_paging_enabled() into a CPUState hook List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?UTF-8?B?RsOkcmJlcg==?= Cc: qiaonuohan@cn.fujitsu.com, qemu-devel@nongnu.org On Sun, 9 Jun 2013 18:10:36 +0200 Andreas F=C3=A4rber wrote: > Relocate assignment of x86 get_arch_id to have all hooks in one place. >=20 > Signed-off-by: Andreas F=C3=A4rber Reviewed-by: Luiz Capitulino > --- > include/qom/cpu.h | 10 ++++++++++ > include/sysemu/memory_mapping.h | 1 - > memory_mapping-stub.c | 6 ------ > memory_mapping.c | 2 +- > qom/cpu.c | 13 +++++++++++++ > target-i386/arch_memory_mapping.c | 6 +----- > target-i386/cpu.c | 11 +++++++++-- > 7 files changed, 34 insertions(+), 15 deletions(-) >=20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 7cd9442..1f70240 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -48,6 +48,7 @@ typedef struct CPUState CPUState; > * @reset: Callback to reset the #CPUState to its initial state. > * @do_interrupt: Callback for interrupt handling. > * @get_arch_id: Callback for getting architecture-dependent CPU ID. > + * @get_paging_enabled: Callback for inquiring whether paging is enabled. > * @vmsd: State description for migration. > * > * Represents a CPU family or model. > @@ -62,6 +63,7 @@ typedef struct CPUClass { > void (*reset)(CPUState *cpu); > void (*do_interrupt)(CPUState *cpu); > int64_t (*get_arch_id)(CPUState *cpu); > + bool (*get_paging_enabled)(const CPUState *cpu); > =20 > const struct VMStateDescription *vmsd; > int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, > @@ -138,6 +140,14 @@ struct CPUState { > }; > =20 > /** > + * cpu_paging_enabled: > + * @cpu: The CPU whose state is to be inspected. > + * > + * Returns: %true if paging is enabled, %false otherwise. > + */ > +bool cpu_paging_enabled(const CPUState *cpu); > + > +/** > * cpu_write_elf64_note: > * @f: pointer to a function that writes memory to a file > * @cpu: The CPU whose memory is to be dumped > diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapp= ing.h > index 1256125..6f01524 100644 > --- a/include/sysemu/memory_mapping.h > +++ b/include/sysemu/memory_mapping.h > @@ -31,7 +31,6 @@ typedef struct MemoryMappingList { > } MemoryMappingList; > =20 > int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); > -bool cpu_paging_enabled(CPUArchState *env); > =20 > /* > * add or merge the memory region [phys_addr, phys_addr + length) into t= he > diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c > index 24d5d67..6c0dfeb 100644 > --- a/memory_mapping-stub.c > +++ b/memory_mapping-stub.c > @@ -25,9 +25,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list, > { > return -1; > } > - > -bool cpu_paging_enabled(CPUArchState *env) > -{ > - return true; > -} > - > diff --git a/memory_mapping.c b/memory_mapping.c > index ff45b3a..0790aac 100644 > --- a/memory_mapping.c > +++ b/memory_mapping.c > @@ -170,7 +170,7 @@ static CPUArchState *find_paging_enabled_cpu(CPUArchS= tate *start_cpu) > CPUArchState *env; > =20 > for (env =3D start_cpu; env !=3D NULL; env =3D env->next_cpu) { > - if (cpu_paging_enabled(env)) { > + if (cpu_paging_enabled(ENV_GET_CPU(env))) { > return env; > } > } > diff --git a/qom/cpu.c b/qom/cpu.c > index 04aefbb..9f6da0f 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -50,6 +50,18 @@ bool cpu_exists(int64_t id) > return data.found; > } > =20 > +bool cpu_paging_enabled(const CPUState *cpu) > +{ > + CPUClass *cc =3D CPU_GET_CLASS(cpu); > + > + return cc->get_paging_enabled(cpu); > +} > + > +static bool cpu_common_get_paging_enabled(const CPUState *cpu) > +{ > + return true; > +} > + > /* CPU hot-plug notifiers */ > static NotifierList cpu_added_notifiers =3D > NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers); > @@ -176,6 +188,7 @@ static void cpu_class_init(ObjectClass *klass, void *= data) > k->class_by_name =3D cpu_common_class_by_name; > k->reset =3D cpu_common_reset; > k->get_arch_id =3D cpu_common_get_arch_id; > + k->get_paging_enabled =3D cpu_common_get_paging_enabled; > k->write_elf32_qemunote =3D cpu_common_write_elf32_qemunote; > k->write_elf32_note =3D cpu_common_write_elf32_note; > k->write_elf64_qemunote =3D cpu_common_write_elf64_qemunote; > diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_= mapping.c > index 5096fbd..c5a10ec 100644 > --- a/target-i386/arch_memory_mapping.c > +++ b/target-i386/arch_memory_mapping.c > @@ -241,7 +241,7 @@ static void walk_pml4e(MemoryMappingList *list, > =20 > int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env) > { > - if (!cpu_paging_enabled(env)) { > + if (!cpu_paging_enabled(ENV_GET_CPU(env))) { > /* paging is disabled */ > return 0; > } > @@ -273,7 +273,3 @@ int cpu_get_memory_mapping(MemoryMappingList *list, C= PUArchState *env) > return 0; > } > =20 > -bool cpu_paging_enabled(CPUArchState *env) > -{ > - return env->cr[0] & CR0_PG_MASK; > -} > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 4b2da0d..f6fa7fa 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -2505,6 +2505,13 @@ static int64_t x86_cpu_get_arch_id(CPUState *cs) > return env->cpuid_apic_id; > } > =20 > +static bool x86_cpu_get_paging_enabled(const CPUState *cs) > +{ > + X86CPU *cpu =3D X86_CPU(cs); > + > + return cpu->env.cr[0] & CR0_PG_MASK; > +} > + > static void x86_cpu_common_class_init(ObjectClass *oc, void *data) > { > X86CPUClass *xcc =3D X86_CPU_CLASS(oc); > @@ -2519,6 +2526,8 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) > cc->reset =3D x86_cpu_reset; > =20 > cc->do_interrupt =3D x86_cpu_do_interrupt; > + cc->get_arch_id =3D x86_cpu_get_arch_id; > + cc->get_paging_enabled =3D x86_cpu_get_paging_enabled; > #ifndef CONFIG_USER_ONLY > cc->write_elf64_note =3D x86_cpu_write_elf64_note; > cc->write_elf64_qemunote =3D x86_cpu_write_elf64_qemunote; > @@ -2526,8 +2535,6 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) > cc->write_elf32_qemunote =3D x86_cpu_write_elf32_qemunote; > #endif > cpu_class_set_vmsd(cc, &vmstate_x86_cpu); > - > - cc->get_arch_id =3D x86_cpu_get_arch_id; > } > =20 > static const TypeInfo x86_cpu_type_info =3D {