All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, pkrempa@redhat.com, ehabkost@redhat.com,
	mst@redhat.com, eduardo.otubo@profitbricks.com,
	Bandan Das <bdas@redhat.com>,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 08/16] apic: move MAX_APICS check to 'apic' class
Date: Mon, 18 Jul 2016 18:35:20 +0200	[thread overview]
Message-ID: <20160718163519.GA23807@potion> (raw)
In-Reply-To: <1468515285-173356-9-git-send-email-imammedo@redhat.com>

2016-07-14 18:54+0200, Igor Mammedov:
> MAX_APICS is only used by child 'apic' class and not
> by its parent TYPE_APIC_COMMON or any other derived
> class.
> Move check into end user 'apic' class so it won't
> get in the way of other APIC implementations
> if they support more then MAX_APICS.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---

The other two APIC implementations, for KVM a Xen, don't seem to need
this extra check.

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>

> CC: Radim Krčmář <rkrcmar@redhat.com>
> CC: pbonzini@redhat.com
> ---
>  include/hw/i386/apic_internal.h |  4 +---
>  hw/intc/apic.c                  | 10 ++++++++++
>  hw/intc/apic_common.c           |  8 --------
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
> index 73ce716..67348e9 100644
> --- a/include/hw/i386/apic_internal.h
> +++ b/include/hw/i386/apic_internal.h
> @@ -121,8 +121,6 @@
>  #define VAPIC_ENABLE_BIT                0
>  #define VAPIC_ENABLE_MASK               (1 << VAPIC_ENABLE_BIT)
>  
> -#define MAX_APICS 255
> -
>  typedef struct APICCommonState APICCommonState;
>  
>  #define TYPE_APIC_COMMON "apic-common"
> @@ -176,7 +174,7 @@ struct APICCommonState {
>      uint32_t initial_count;
>      int64_t initial_count_load_time;
>      int64_t next_time;
> -    int idx;
> +    int idx; /* not actually common, used only by 'apic' derived class */
>      QEMUTimer *timer;
>      int64_t timer_expiry;
>      int sipi_vector;
> diff --git a/hw/intc/apic.c b/hw/intc/apic.c
> index e1ab935..b0d237b 100644
> --- a/hw/intc/apic.c
> +++ b/hw/intc/apic.c
> @@ -28,7 +28,9 @@
>  #include "trace.h"
>  #include "hw/i386/pc.h"
>  #include "hw/i386/apic-msidef.h"
> +#include "qapi/error.h"
>  
> +#define MAX_APICS 255
>  #define MAX_APIC_WORDS 8
>  
>  #define SYNC_FROM_VAPIC                 0x1
> @@ -869,6 +871,14 @@ static const MemoryRegionOps apic_io_ops = {
>  static void apic_realize(DeviceState *dev, Error **errp)
>  {
>      APICCommonState *s = APIC_COMMON(dev);
> +    static int apic_no;
> +
> +    if (apic_no >= MAX_APICS) {
> +        error_setg(errp, "%s initialization failed.",
> +                   object_get_typename(OBJECT(dev)));
> +        return;
> +    }
> +    s->idx = apic_no++;
>  
>      memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic-msi",
>                            APIC_SPACE_SIZE);
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index e6eb694..fd425d1 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -299,14 +299,6 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
>      APICCommonState *s = APIC_COMMON(dev);
>      APICCommonClass *info;
>      static DeviceState *vapic;
> -    static int apic_no;
> -
> -    if (apic_no >= MAX_APICS) {
> -        error_setg(errp, "%s initialization failed.",
> -                   object_get_typename(OBJECT(dev)));
> -        return;
> -    }
> -    s->idx = apic_no++;
>  
>      info = APIC_COMMON_GET_CLASS(s);
>      info->realize(dev, errp);
> -- 
> 2.7.4
> 

  reply	other threads:[~2016-07-18 16:35 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 16:54 [Qemu-devel] [PATCH v4 00/16] pc: add CPU hot-add/hot-remove with device_add/device_del Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 01/16] pc: set APIC ID based on socket/core/thread ids if it's not been set yet Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 02/16] pc: delay setting number of boot CPUs to machine_done time Igor Mammedov
2016-07-14 17:37   ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 03/16] pc: register created initial and hotpluged CPUs in one place pc_cpu_plug() Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 04/16] pc: forbid BSP removal Igor Mammedov
2016-07-14 17:49   ` Bandan Das
2016-07-14 17:54   ` Eduardo Habkost
2016-07-14 18:16     ` Bandan Das
2016-07-14 20:55       ` Eduardo Habkost
2016-07-14 21:02         ` Bandan Das
2016-07-15  9:25     ` Igor Mammedov
2016-07-18  8:31   ` [Qemu-devel] [PATCH v5 " Igor Mammedov
2016-07-19 12:55     ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 05/16] pc: enforce adding CPUs contiguously and removing them in opposit order Igor Mammedov
2016-07-14 18:10   ` Bandan Das
2016-07-15  9:33     ` Igor Mammedov
2016-07-15 15:57       ` Bandan Das
2016-07-18  8:32   ` [Qemu-devel] [PATCH v5 " Igor Mammedov
2016-07-18 21:05   ` [Qemu-devel] [PATCH v4 " Eric Blake
2016-07-19 12:25     ` Igor Mammedov
2016-07-19 12:30       ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 06/16] pc: cpu: allow device_add to be used with x86 cpu Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 07/16] pc: implement query-hotpluggable-cpus callback Igor Mammedov
2016-07-18 20:46   ` Michael S. Tsirkin
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 08/16] apic: move MAX_APICS check to 'apic' class Igor Mammedov
2016-07-18 16:35   ` Radim Krčmář [this message]
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 09/16] apic: drop APICCommonState.idx and use APIC ID as index in local_apics[] Igor Mammedov
2016-07-18 16:58   ` Radim Krčmář
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 10/16] apic: kvm-apic: fix crash due to access to freed memory region Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 11/16] (kvm)apic: add unrealize callbacks Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 12/16] apic: use apic_id as apic's migration instance_id Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 13/16] target-i386: cpu: do not ignore error and fix apic parent Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 14/16] target-i386: fix apic object leak when CPU is deleted Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 15/16] target-i386: add x86_cpu_unrealizefn() Igor Mammedov
2016-07-19 17:05   ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 16/16] pc: make device_del CPU work for x86 CPUs Igor Mammedov
2016-07-18 21:59 ` [Qemu-devel] [PATCH v4 00/16] pc: add CPU hot-add/hot-remove with device_add/device_del Michael S. Tsirkin
2016-08-10 13:56   ` Eduardo Otubo
2016-08-10 14:07     ` 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=20160718163519.GA23807@potion \
    --to=rkrcmar@redhat.com \
    --cc=bdas@redhat.com \
    --cc=eduardo.otubo@profitbricks.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@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.