qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: qiaonuohan@cn.fujitsu.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH qom-cpu v4 07/18] cpu: Turn cpu_paging_enabled() into a CPUState hook
Date: Tue, 11 Jun 2013 10:52:05 -0400	[thread overview]
Message-ID: <20130611105205.3a8089c6@redhat.com> (raw)
In-Reply-To: <1370794247-28267-8-git-send-email-afaerber@suse.de>

On Sun,  9 Jun 2013 18:10:36 +0200
Andreas Färber <afaerber@suse.de> wrote:

> Relocate assignment of x86 get_arch_id to have all hooks in one place.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> ---
>  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(-)
> 
> 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);
>  
>      const struct VMStateDescription *vmsd;
>      int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
> @@ -138,6 +140,14 @@ struct CPUState {
>  };
>  
>  /**
> + * 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_mapping.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;
>  
>  int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env);
> -bool cpu_paging_enabled(CPUArchState *env);
>  
>  /*
>   * add or merge the memory region [phys_addr, phys_addr + length) into the
> 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(CPUArchState *start_cpu)
>      CPUArchState *env;
>  
>      for (env = start_cpu; env != NULL; env = 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;
>  }
>  
> +bool cpu_paging_enabled(const CPUState *cpu)
> +{
> +    CPUClass *cc = 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 =
>      NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers);
> @@ -176,6 +188,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
>      k->class_by_name = cpu_common_class_by_name;
>      k->reset = cpu_common_reset;
>      k->get_arch_id = cpu_common_get_arch_id;
> +    k->get_paging_enabled = cpu_common_get_paging_enabled;
>      k->write_elf32_qemunote = cpu_common_write_elf32_qemunote;
>      k->write_elf32_note = cpu_common_write_elf32_note;
>      k->write_elf64_qemunote = 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,
>  
>  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, CPUArchState *env)
>      return 0;
>  }
>  
> -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;
>  }
>  
> +static bool x86_cpu_get_paging_enabled(const CPUState *cs)
> +{
> +    X86CPU *cpu = X86_CPU(cs);
> +
> +    return cpu->env.cr[0] & CR0_PG_MASK;
> +}
> +
>  static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>  {
>      X86CPUClass *xcc = X86_CPU_CLASS(oc);
> @@ -2519,6 +2526,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>      cc->reset = x86_cpu_reset;
>  
>      cc->do_interrupt = x86_cpu_do_interrupt;
> +    cc->get_arch_id = x86_cpu_get_arch_id;
> +    cc->get_paging_enabled = x86_cpu_get_paging_enabled;
>  #ifndef CONFIG_USER_ONLY
>      cc->write_elf64_note = x86_cpu_write_elf64_note;
>      cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
> @@ -2526,8 +2535,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
>      cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
>  #endif
>      cpu_class_set_vmsd(cc, &vmstate_x86_cpu);
> -
> -    cc->get_arch_id = x86_cpu_get_arch_id;
>  }
>  
>  static const TypeInfo x86_cpu_type_info = {

  parent reply	other threads:[~2013-06-11 14:55 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09 16:10 [Qemu-devel] [PATCH qom-cpu v4 00/18] dump: Build cleanups, redone Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 01/18] dump: Move stubs into libqemustub.a Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 02/18] pc: Fix crash when attempting to hotplug CPU with negative ID Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 03/18] pc: Create pc-*-1.6 machine-types Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 04/18] target-i386: Update model values on Conroe/Penryn/Nehalem CPU models Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 05/18] target-i386: Set level=4 on Conroe/Penryn/Nehalem Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 06/18] target-i386: cpu: Fix potential buffer overrun in get_register_name_32() Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 07/18] cpu: Turn cpu_paging_enabled() into a CPUState hook Andreas Färber
2013-06-11  8:06   ` Jens Freimann
2013-06-11 14:52   ` Luiz Capitulino [this message]
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 08/18] memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 09/18] cpu: Turn cpu_get_memory_mapping() into a CPUState hook Andreas Färber
2013-06-11  9:20   ` Jens Freimann
2013-06-11 14:56   ` Luiz Capitulino
2013-06-11 16:03     ` Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 10/18] memory_mapping: Drop qemu_get_memory_mapping() stub Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 11/18] dump: Drop qmp_dump_guest_memory() stub and build for all targets Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 12/18] cpu: Change default for CPUClass::get_paging_enabled() Andreas Färber
2013-06-11  9:00   ` Jens Freimann
2013-06-11 15:01   ` Luiz Capitulino
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 13/18] memory_mapping: Cleanup qemu_get_guest_memory_mapping() Andreas Färber
2013-06-11 15:52   ` Luiz Capitulino
2013-06-11 17:47     ` Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 14/18] dump: Abstract dump_init() with cpu_synchronize_all_states() Andreas Färber
2013-06-11 15:55   ` Luiz Capitulino
2013-06-11 17:46     ` Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 15/18] dump: Abstract dump_init() further with qemu_for_each_cpu() Andreas Färber
2013-06-11 15:55   ` Luiz Capitulino
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 16/18] dump: Abstract write_elf{64, 32}_notes() " Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 17/18] memory_mapping: Use hwaddr type for MemoryMapping virt_addr field Andreas Färber
2013-06-09 17:17   ` Peter Maydell
2013-06-09 17:25     ` Andreas Färber
2013-06-09 16:10 ` [Qemu-devel] [PATCH qom-cpu v4 18/18] memory_mapping: Build only once Andreas Färber
2013-06-09 17:29   ` Peter Maydell
2013-06-09 17:36     ` Andreas Färber
2013-06-09 16:19 ` [Qemu-devel] [PATCH qom-cpu v4 00/18] dump: Build cleanups, redone Andreas Färber
2013-06-11 16:54 ` Andreas Färber

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=20130611105205.3a8089c6@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=afaerber@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qiaonuohan@cn.fujitsu.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).