All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Glauber Costa <glommer@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 07/10] provide apic-kvm
Date: Thu, 04 Mar 2010 17:49:31 +0100	[thread overview]
Message-ID: <4B8FE49B.6080202@siemens.com> (raw)
In-Reply-To: <1267215141-13629-8-git-send-email-glommer@redhat.com>

Glauber Costa wrote:
> This patch provides the file apic-kvm.c, which implements a schim over
> the kvm in-kernel APIC.
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> ---
>  Makefile.target   |    2 +-
>  hw/apic-kvm.c     |  157 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/pc.c           |    6 ++-
>  hw/pc.h           |    2 +
>  kvm.h             |    5 ++
>  target-i386/cpu.h |    4 ++
>  target-i386/kvm.c |   25 ++++++++-
>  7 files changed, 197 insertions(+), 4 deletions(-)
>  create mode 100644 hw/apic-kvm.c
> 
> diff --git a/Makefile.target b/Makefile.target
> index bc5263e..f00af07 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -213,7 +213,7 @@ obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
>  obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
>  obj-i386-y += ne2000-isa.o debugcon.o multiboot.o
>  
> -obj-i386-$(CONFIG_KVM) += ioapic-kvm.o i8259-kvm.o
> +obj-i386-$(CONFIG_KVM) += ioapic-kvm.o i8259-kvm.o apic-kvm.o
>  
>  # shared objects
>  obj-ppc-y = ppc.o ide/core.o ide/qdev.o ide/isa.o ide/pci.o ide/macio.o
> diff --git a/hw/apic-kvm.c b/hw/apic-kvm.c
> new file mode 100644
> index 0000000..089fa45
> --- /dev/null
> +++ b/hw/apic-kvm.c
> @@ -0,0 +1,157 @@
> +#include "hw.h"
> +#include "pc.h"
> +#include "pci.h"
> +#include "msix.h"
> +#include "qemu-timer.h"
> +#include "host-utils.h"
> +#include "kvm.h"
> +
> +#define APIC_LVT_NB      6
> +#define APIC_LVT_LINT0   3
> +
> +struct qemu_lapic_state {
> +    uint32_t apicbase;
> +    uint8_t id;
> +    uint8_t arb_id;
> +    uint8_t tpr;
> +    uint32_t spurious_vec;
> +    uint8_t log_dest;
> +    uint8_t dest_mode;
> +    uint32_t isr[8];  /* in service register */
> +    uint32_t tmr[8];  /* trigger mode register */
> +    uint32_t irr[8]; /* interrupt request register */
> +    uint32_t lvt[APIC_LVT_NB];
> +    uint32_t esr; /* error register */
> +    uint32_t icr[2];
> +
> +    uint32_t divide_conf;
> +    int count_shift;
> +    uint32_t initial_count;
> +    int64_t initial_count_load_time, next_time;
> +    uint32_t idx;
> +    int sipi_vector;
> +    int wait_for_sipi;
> +};
> +
> +typedef struct APICState {
> +    CPUState *cpu_env;
> +
> +/* KVM lapic structure is just a big array of regs. But it is what kvm
> + * functions expect. So have both the fields separated, for easy access,
> + * and the kvm stucture, for ioctls communications */
> +    union {
> +        struct qemu_lapic_state dev;
> +        struct kvm_lapic_state kvm_lapic_state;

That looks fishy to me on second sight: Is, e.g., loading the
kvm_lapic_state from the kernel supposed to magically fill the (totally
unaligned) qemu_lapic_state structure? I'm missing the translations of
kvm_kernel_lapic_load_from_user/save_to_user here or some effort to
arrange qemu_lapic_state in a way that it robustly maps on the register
array passed to/from the kernel (if that is possible, haven't checked yet).

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  parent reply	other threads:[~2010-03-04 16:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-26 20:12 [PATCH 00/10] uq/master: irqchip-in-kernel support Glauber Costa
2010-02-26 20:12 ` [PATCH 01/10] introduce VMSTATE_U64 Glauber Costa
2010-02-26 20:12   ` [PATCH 02/10] Provide ioapic-kvm Glauber Costa
2010-02-26 20:12     ` [PATCH 03/10] provide apic_set_irq_delivered Glauber Costa
2010-02-26 20:12       ` [PATCH 04/10] provide i8259-kvm Glauber Costa
2010-02-26 20:12         ` [PATCH 05/10] Don't call apic functions directly from kvm code Glauber Costa
2010-02-26 20:12           ` [PATCH 06/10] export kvm_put_mp_state Glauber Costa
2010-02-26 20:12             ` [PATCH 07/10] provide apic-kvm Glauber Costa
2010-02-26 20:12               ` [PATCH 08/10] Add -kvm option Glauber Costa
2010-02-26 20:12                 ` [PATCH 09/10] Initialize in-kernel irqchip Glauber Costa
2010-02-26 20:12                   ` [PATCH 10/10] Do GSI routing Glauber Costa
2010-03-02  4:31                   ` [PATCH 09/10] Initialize in-kernel irqchip Marcelo Tosatti
2010-03-02 18:25                     ` Glauber Costa
2010-03-09 13:21                       ` Avi Kivity
2010-02-27 10:35                 ` [PATCH 08/10] Add -kvm option Jan Kiszka
2010-03-04 16:20                   ` Jan Kiszka
2010-03-04 19:39                     ` Glauber Costa
2010-03-02  4:31                 ` Marcelo Tosatti
2010-03-02 18:25                   ` Glauber Costa
2010-03-04 19:41                     ` Anthony Liguori
2010-03-04 19:38                 ` Anthony Liguori
2010-03-04 16:49               ` Jan Kiszka [this message]
2010-03-09 13:27           ` [PATCH 05/10] Don't call apic functions directly from kvm code Avi Kivity
2010-03-17 14:00             ` Glauber Costa
2010-03-17 16:29               ` Avi Kivity
2010-03-02  4:28     ` [PATCH 02/10] Provide ioapic-kvm Marcelo Tosatti
2010-03-02 18:26       ` Glauber Costa
2010-02-27 10:28 ` [PATCH 00/10] uq/master: irqchip-in-kernel support Jan Kiszka
2010-03-01 15:19   ` Marcelo Tosatti
2010-03-04 16:33 ` Jan Kiszka
2010-03-08 20:56   ` Marcelo Tosatti

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=4B8FE49B.6080202@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=glommer@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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 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.