~ubuntu-branches/ubuntu/precise/qemu-kvm/precise

« back to all changes in this revision

Viewing changes to hw/ioapic.c

  • Committer: Serge Hallyn
  • Date: 2011-10-19 07:37:43 UTC
  • mfrom: (1.2.7)
  • Revision ID: serge.hallyn@ubuntu.com-20111019073743-7i7n9irsxlm38wic
Tags: 0.15.0+noroms-0ubuntu1
* New upstream release
* Remaining changes from upstream:
  - removed all binary roms and tests/pi_10.com
* Removed Detect-and-use-GCC-atomic-builtins-for-locking.patch - non-NPTL
  implementations were removed with commit
  02615337ef295443daa03233e492194e289a807e
* Drop spice-qxl-locking-fix-for-qemu-kvm.patch - should be unnecessary
  as of commit 196a778428989217b82de042725dc8eb29c8f8d8
* drop patches applied upstream:
  - CVE-2011-1751.diff
  - virtio-guard-against-negative-vq-notifies-CVE-2011-2512.diff
  - CVE-2011-2527.patch
  - fix-pa-configure.patch
* Refreshed the remaining patches:
  - larger_default_ram_size.patch
  - CVE-2011-2212-virtqueue-indirect-overflow.patch
  - qemuifup-fix-paths.patch
  - vpc.patch
* e1000-Dont-set-the-Capabilities-List-bit.patch - switched to the
  cherrypicked upstream patch (as the source file changed quite a bit,
  and the hand-ported patch backported to 0.14.1 does not apply).
* Drop qemu-kvm-spice (all changes from 0.14.1+noroms-0ubuntu7), it will
  need its own source package (LP: #878162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "hw.h"
24
24
#include "pc.h"
25
25
#include "apic.h"
26
 
#include "sysemu.h"
27
 
#include "apic.h"
28
26
#include "ioapic.h"
29
27
#include "qemu-timer.h"
30
28
#include "host-utils.h"
41
39
#define DPRINTF(fmt, ...)
42
40
#endif
43
41
 
44
 
#define IOAPIC_DEFAULT_BASE_ADDRESS  0xfec00000
45
42
#define MAX_IOAPICS                     1
46
43
 
47
44
#define IOAPIC_VERSION                  0x11
93
90
    SysBusDevice busdev;
94
91
    uint8_t id;
95
92
    uint8_t ioregsel;
96
 
    uint64_t base_address;
97
93
    uint32_t irr;
98
94
    uint64_t ioredtbl[IOAPIC_NUM_PINS];
99
95
};
149
145
     * the cleanest way of doing it but it should work. */
150
146
 
151
147
    DPRINTF("%s: %s vec %x\n", __func__, level ? "raise" : "lower", vector);
152
 
    if (vector == 0 && irq0override) {
 
148
    if (vector == 0) {
153
149
        vector = 2;
154
150
    }
155
151
    if (vector >= 0 && vector < IOAPIC_NUM_PINS) {
166
162
                s->irr &= ~mask;
167
163
            }
168
164
        } else {
169
 
            /* edge triggered */
170
 
            if (level) {
 
165
            /* According to the 82093AA manual, we must ignore edge requests
 
166
             * if the input pin is masked. */
 
167
            if (level && !(entry & IOAPIC_LVT_MASKED)) {
171
168
                s->irr |= mask;
172
169
                ioapic_service(s);
173
170
            }
281
278
    int i;
282
279
 
283
280
    chip.chip_id = KVM_IRQCHIP_IOAPIC;
284
 
    kvm_get_irqchip(kvm_context, &chip);
 
281
    kvm_get_irqchip(kvm_state, &chip);
285
282
    kioapic = &chip.chip.ioapic;
286
283
 
287
284
    s->id = kioapic->id;
288
285
    s->ioregsel = kioapic->ioregsel;
289
 
    s->base_address = kioapic->base_address;
290
286
    s->irr = kioapic->irr;
291
287
    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
292
288
        s->ioredtbl[i] = kioapic->redirtbl[i].bits;
306
302
 
307
303
    kioapic->id = s->id;
308
304
    kioapic->ioregsel = s->ioregsel;
309
 
    kioapic->base_address = s->base_address;
 
305
    kioapic->base_address = s->busdev.mmio[0].addr;
310
306
    kioapic->irr = s->irr;
311
307
    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
312
308
        kioapic->redirtbl[i].bits = s->ioredtbl[i];
313
309
    }
314
310
 
315
 
    kvm_set_irqchip(kvm_context, &chip);
 
311
    kvm_set_irqchip(kvm_state, &chip);
316
312
#endif
317
313
}
318
314
 
319
315
static void ioapic_pre_save(void *opaque)
320
316
{
321
317
    IOAPICState *s = (void *)opaque;
322
 
 
 
318
 
323
319
    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
324
320
        kvm_kernel_ioapic_save_to_user(s);
325
321
    }
326
322
}
327
323
 
328
 
static int ioapic_pre_load(void *opaque)
329
 
{
330
 
    IOAPICState *s = opaque;
331
 
 
332
 
    /* in case we are doing version 1, we just set these to sane values */
333
 
    s->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
334
 
    s->irr = 0;
335
 
    return 0;
336
 
}
337
 
 
338
324
static int ioapic_post_load(void *opaque, int version_id)
339
325
{
340
326
    IOAPICState *s = opaque;
354
340
static const VMStateDescription vmstate_ioapic = {
355
341
    .name = "ioapic",
356
342
    .version_id = 3,
357
 
    .post_load = ioapic_post_load,
358
343
    .minimum_version_id = 1,
359
344
    .minimum_version_id_old = 1,
360
 
    .pre_load = ioapic_pre_load,
 
345
    .post_load = ioapic_post_load,
361
346
    .pre_save = ioapic_pre_save,
362
347
    .fields = (VMStateField[]) {
363
348
        VMSTATE_UINT8(id, IOAPICState),
364
349
        VMSTATE_UINT8(ioregsel, IOAPICState),
365
 
        VMSTATE_UINT64_V(base_address, IOAPICState, 2),
 
350
        VMSTATE_UNUSED_V(2, 8), /* to account for qemu-kvm's v2 format */
366
351
        VMSTATE_UINT32_V(irr, IOAPICState, 2),
367
352
        VMSTATE_UINT64_ARRAY(ioredtbl, IOAPICState, IOAPIC_NUM_PINS),
368
353
        VMSTATE_END_OF_LIST()
374
359
    IOAPICState *s = DO_UPCAST(IOAPICState, busdev.qdev, d);
375
360
    int i;
376
361
 
377
 
    s->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
378
362
    s->id = 0;
379
363
    s->ioregsel = 0;
380
364
    s->irr = 0;