From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3LVs-0006na-8t for qemu-devel@nongnu.org; Sun, 28 Jul 2013 03:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3LVm-0003nG-2B for qemu-devel@nongnu.org; Sun, 28 Jul 2013 03:35:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3LVl-0003nA-Qe for qemu-devel@nongnu.org; Sun, 28 Jul 2013 03:35:25 -0400 Date: Sun, 28 Jul 2013 10:36:49 +0300 From: "Michael S. Tsirkin" Message-ID: <20130728073649.GH12087@redhat.com> References: <1374681580-17439-1-git-send-email-mst@redhat.com> <1374681580-17439-10-git-send-email-mst@redhat.com> <51F468CF.3020201@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <51F468CF.3020201@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 09/14] i386: define pc guest info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Anthony Liguori , qemu-devel@nongnu.org, Gerd Hoffmann On Sun, Jul 28, 2013 at 02:41:51AM +0200, Andreas F=E4rber wrote: > Am 24.07.2013 18:02, schrieb Michael S. Tsirkin: > > This defines a structure that will be used to fill in guest info tabl= e. > > This structure will be filled in in follow-up patches, using QOM. Fi= ll > > in NUMA node info is not available in QOM so it is filled in directly. > >=20 > > Signed-off-by: Michael S. Tsirkin > > Reviewed-by: Laszlo Ersek > > --- > > hw/i386/pc.c | 33 +++++++++++++++++++++++++++++++++ > > include/hw/i386/pc.h | 31 +++++++++++++++++++++++++++++++ > > include/qemu/typedefs.h | 1 + > > 3 files changed, 65 insertions(+) > >=20 > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > index b0b98a8..b9b8f92 100644 > > --- a/hw/i386/pc.c > > +++ b/hw/i386/pc.c > > @@ -1017,6 +1017,27 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *= guest_info) > > fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof= *info); > > } > > =20 > > +static void pc_set_cpu_guest_info(CPUState *cpu, void *arg) > > +{ > > + PcGuestInfo *guest_info =3D arg; > > + CPUClass *klass =3D CPU_GET_CLASS(cpu); > > + uint64_t apic_id =3D klass->get_arch_id(cpu); >=20 > Please use "cc" to avoid the dreaded "klass". >=20 > > + int j; > > + > > + assert(apic_id <=3D MAX_CPUMASK_BITS); > > + assert(apic_id < guest_info->apic_id_limit); > > + > > + set_bit(apic_id, guest_info->found_cpus); > > + > > + for (j =3D 0; j < guest_info->numa_nodes; j++) { > > + assert(cpu->cpu_index < max_cpus); > > + if (test_bit(cpu->cpu_index, node_cpumask[j])) { > > + guest_info->node_cpu[apic_id] =3D cpu_to_le64(j); > > + break; > > + } > > + } > > +} > > + > > typedef struct PcGuestInfoState { > > PcGuestInfo info; > > Notifier machine_done; > > @@ -1037,6 +1058,18 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t bel= ow_4g_mem_size, > > PcGuestInfoState *guest_info_state =3D g_malloc0(sizeof *guest_i= nfo_state); > > PcGuestInfo *guest_info =3D &guest_info_state->info; > > =20 > > + guest_info->ram_size =3D below_4g_mem_size + above_4g_mem_size; > > + guest_info->apic_id_limit =3D pc_apic_id_limit(max_cpus); > > + guest_info->apic_xrupt_override =3D kvm_allows_irq0_override(); > > + guest_info->numa_nodes =3D nb_numa_nodes; > > + guest_info->node_mem =3D g_memdup(node_mem, guest_info->numa_nod= es * > > + sizeof *guest_info->node_mem); > > + guest_info->node_cpu =3D g_malloc0(guest_info->apic_id_limit * > > + sizeof *guest_info->node_cpu); > > + > > + memset(&guest_info->found_cpus, 0, sizeof guest_info->found_cpus= ); > > + qemu_for_each_cpu(pc_set_cpu_guest_info, guest_info); > > + > > guest_info->pci_info.w32.end =3D IO_APIC_DEFAULT_ADDRESS; > > if (sizeof(hwaddr) =3D=3D 4) { > > guest_info->pci_info.w64.begin =3D 0; > > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h > > index 7fb97b0..7c0bd50 100644 > > --- a/include/hw/i386/pc.h > > +++ b/include/hw/i386/pc.h > > @@ -9,6 +9,9 @@ > > #include "hw/i386/ioapic.h" > > =20 > > #include "qemu/range.h" > > +#include "qemu/bitmap.h" > > +#include "sysemu/sysemu.h" > > +#include "hw/pci/pci.h" > > =20 > > /* PC-style peripherals (also used by other machines). */ > > =20 > > @@ -17,9 +20,37 @@ typedef struct PcPciInfo { > > Range w64; > > } PcPciInfo; > > =20 > > +/* Matches the value hard-coded in BIOS */ > > +#define PC_GUEST_PORT_ACPI_PM_BASE 0xb000 > > + > > +struct AcpiPmInfo { > > + bool s3_disabled; > > + bool s4_disabled; > > + uint8_t s4_val; > > + uint16_t sci_int; > > + uint8_t acpi_enable_cmd; > > + uint8_t acpi_disable_cmd; > > + uint32_t gpe0_blk; > > + uint32_t gpe0_blk_len; > > +}; > > + > > struct PcGuestInfo { > > PcPciInfo pci_info; >=20 > These capitalizations look weird. Can't we use at least PM rather than = Pm? >=20 > Andreas I prefer making a first letter in each work upper case consistently but I don't mind so much. > > bool has_pci_info; > > + hwaddr ram_size; > > + unsigned apic_id_limit; > > + bool apic_xrupt_override; > > + bool has_hpet; > > + uint64_t numa_nodes; > > + uint64_t *node_mem; > > + uint64_t *node_cpu; > > + DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1); > > + DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX); > > + AcpiPmInfo pm; > > + uint64_t mcfg_base; > > + const unsigned char *dsdt_code; > > + unsigned dsdt_size; > > + uint16_t pvpanic_port; > > FWCfgState *fw_cfg; > > }; > > =20 > > diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h > > index ac9f8d4..cb66e19 100644 > > --- a/include/qemu/typedefs.h > > +++ b/include/qemu/typedefs.h > > @@ -65,5 +65,6 @@ typedef struct QEMUSGList QEMUSGList; > > typedef struct SHPCDevice SHPCDevice; > > typedef struct FWCfgState FWCfgState; > > typedef struct PcGuestInfo PcGuestInfo; > > +typedef struct AcpiPmInfo AcpiPmInfo; > > =20 > > #endif /* QEMU_TYPEDEFS_H */ > >=20 >=20 >=20 > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrn= berg