import kvm-unittest in QEMU source tree
PATCH 1/1 import kvm-unittest in QEMU source tree
This simply imports kvm-unittest git into qemu source tree.
We can next work on making make check run it
automatically.
Squashed 'kvm-unittest/' content from commit 2bc0e29
git-subtree-dir: kvm-unittest
git-subtree-split: 2bc0e29ee4447bebcd3b90053881f59265306adc
---
Gleb, Paolo, any objections to this? I really want a small guest for running ACPI tests during make check, and kvm-unittest seems to fit the bill.
Ability to test e.g. PCI with this in-tree would be very benefitial.
kvm-unittest/iotable.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Kernel-based Virtual Machine test driver +* +* This test driver provides a simple way of testing kvm, without a full +* device model. +* +* Copyright (C) 2006 Qumranet +* +* Authors: +* +* Avi Kivity <[email protected]> +* Yaniv Kamay <[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +*/ + +#include <stdint.h> + +#define MAX_IO_TABLE 50 + +typedef int (io_table_handler_t )(void *,int ,int ,uint64_t ,uint64_t *); + +struct io_table_entry +{ +uint64_t start; +uint64_t end; +io_table_handler_t *handler; +void *opaque; +}; + +struct io_table +{ +int nr_entries; +struct io_table_entry entries[MAX_IO_TABLE ]; +}; + +struct io_table_entry *io_table_lookup (struct io_table *io_table, +uint64_t addr); +int io_table_register (struct io_table *io_table,uint64_t start,uint64_t size, +io_table_handler_t *handler,void *opaque);
kvm-unittest/lib/libcflat.h new file +61 -0
61 lines not on this page · raw message
kvm-unittest/lib/powerpc/44x/timebase.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Copyright IBM Corp. 2008 +* +* Authors: Hollis Blanchard <[email protected]> +*/ + +#ifndef __TIMEBASE_H__ +#define __TIMEBASE_H__ + +unsigned long long mftb (void ); + +#endif /* __TIMEBASE_H__ */
kvm-unittest/lib/x86/apic-defs.h new file +133 -0
133 lines not on this page · raw message
kvm-unittest/lib/x86/apic.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef CFLAT_APIC_H +#define CFLAT_APIC_H + +#include <stdint.h> +#include "apic-defs.h" + +typedef struct { +uint8_t vector; +uint8_t delivery_mode:3 ; +uint8_t dest_mode:1 ; +uint8_t delivery_status:1 ; +uint8_t polarity:1 ; +uint8_t remote_irr:1 ; +uint8_t trig_mode:1 ; +uint8_t mask:1 ; +uint8_t reserve:7 ; +uint8_t reserved[4 ]; +uint8_t dest_id; +}ioapic_redir_entry_t ; + +void mask_pic_interrupts (void ); + +void ioapic_write_redir (unsigned line,ioapic_redir_entry_t e); +void ioapic_write_reg (unsigned reg,uint32_t value); + +void enable_apic (void ); +uint32_t apic_read (unsigned reg); +void apic_write (unsigned reg,uint32_t val); +void apic_icr_write (uint32_t val,uint32_t dest); +uint32_t apic_id (void ); + +int enable_x2apic (void ); + +#endif
kvm-unittest/lib/x86/atomic.h new file +164 -0
164 lines not on this page · raw message
kvm-unittest/lib/x86/desc.h new file +87 -0
87 lines not on this page · raw message
kvm-unittest/lib/x86/fake-apic.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef SILLY_APIC_H +#define SILLY_APIC_H + +#define APIC_BASE 0x1000 +#define APIC_SIZE 0x100 + +#define APIC_REG_NCPU 0x00 +#define APIC_REG_ID 0x04 +#define APIC_REG_SIPI_ADDR 0x08 +#define APIC_REG_SEND_SIPI 0x0c +#define APIC_REG_IPI_VECTOR 0x10 +#define APIC_REG_SEND_IPI 0x14 + +#endif
kvm-unittest/lib/x86/fwcfg.h new file +44 -0
44 lines not on this page · raw message
kvm-unittest/lib/x86/io.h new file +40 -0
@@ -0,0 +1,40 @@ +#ifndef IO_H +#define IO_H + +static inline unsigned char inb (unsigned short port) +{ +unsigned char value; + asmvolatile ("inb %w1, %0" :"=a" (value) :"Nd" (port)); +return value; +} + +static inline unsigned short inw (unsigned short port) +{ +unsigned short value; + asmvolatile ("inw %w1, %0" :"=a" (value) :"Nd" (port)); +return value; +} + +static inline unsigned int inl (unsigned short port) +{ +unsigned int value; + asmvolatile ("inl %w1, %0" :"=a" (value) :"Nd" (port)); +return value; +} + +static inline void outb (unsigned char value,unsigned short port) +{ + asmvolatile ("outb %b0, %w1" : :"a" (value),"Nd" (port)); +} + +static inline void outw (unsigned short value,unsigned short port) +{ + asmvolatile ("outw %w0, %w1" : :"a" (value),"Nd" (port)); +} + +static inline void outl (unsigned int value,unsigned short port) +{ + asmvolatile ("outl %0, %w1" : :"a" (value),"Nd" (port)); +} + +#endif
kvm-unittest/lib/x86/isr.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ISR_TEST__ +#define __ISR_TEST__ + +typedef struct { +ulong regs[sizeof (ulong)*2 ]; +ulong func; +ulong rip; +ulong cs; +ulong rflags; +}isr_regs_t ; + +void handle_irq (unsigned vec,void (*func)(isr_regs_t *regs)); + +#endif
kvm-unittest/lib/x86/msr.h new file +411 -0
411 lines not on this page · raw message
kvm-unittest/lib/x86/pci.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef PCI_H +#define PCI_H + +#include <inttypes.h> +#include "libcflat.h" + +typedef uint16_t pcidevaddr_t ; +enum { +PCIDEVADDR_INVALID =0x0 +}; +pcidevaddr_t pci_find_dev (uint16_t vendor_id,uint16_t device_id); +unsigned long pci_bar_addr (pcidevaddr_t dev,int bar_num); +bool pci_bar_is_memory (pcidevaddr_t dev,int bar_num); +bool pci_bar_is_valid (pcidevaddr_t dev,int bar_num); + +#endif
kvm-unittest/lib/x86/processor.h new file +325 -0
325 lines not on this page · raw message
kvm-unittest/lib/x86/smp.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef __SMP_H +#define __SMP_H + +#define mb () asm volatile("mfence":::"memory") +#define rmb () asm volatile("lfence":::"memory") +#define wmb () asm volatile("sfence" ::: "memory") + +struct spinlock { +int v; +}; + +void smp_init (void ); + +int cpu_count (void ); +int smp_id (void ); +void on_cpu (int cpu,void (*function)(void *data),void *data); +void on_cpu_async (int cpu,void (*function)(void *data),void *data); +void spin_lock (struct spinlock *lock); +void spin_unlock (struct spinlock *lock); + +#endif
kvm-unittest/lib/x86/vm.h new file +71 -0
71 lines not on this page · raw message
kvm-unittest/x86/ioram.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __IO_RAM_H +#define __IO_RAM_H + +#define IORAM_BASE_PHYS 0xff000000UL +#define IORAM_LEN 0x10000UL + +#endif
kvm-unittest/x86/kvmclock.h new file +60 -0
60 lines not on this page · raw message
kvm-unittest/x86/print.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef PRINT_H +#define PRINT_H + +.macro PRINT text + +.data + +333: .asciz "\text\n" + +.previous + + push %rdi + lea 333b, %rdi + call print + pop %rdi + +.endm + +#endif
kvm-unittest/x86/svm.h new file +328 -0
328 lines not on this page · raw message
kvm-unittest/x86/types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __TYPES_H +#define __TYPES_H + +#define DE_VECTOR 0 +#define DB_VECTOR 1 +#define BP_VECTOR 3 +#define OF_VECTOR 4 +#define BR_VECTOR 5 +#define UD_VECTOR 6 +#define NM_VECTOR 7 +#define DF_VECTOR 8 +#define TS_VECTOR 10 +#define NP_VECTOR 11 +#define SS_VECTOR 12 +#define GP_VECTOR 13 +#define PF_VECTOR 14 +#define MF_VECTOR 16 +#define MC_VECTOR 18 + +#endif
kvm-unittest/x86/vmx.h new file +479 -0
479 lines not on this page · raw message
kvm-unittest/iotable.c new file +53 -0
53 lines not on this page · raw message
kvm-unittest/kvmtrace.c new file +706 -0
534 lines not on this page · raw message
kvm-unittest/lib/fwcfg.c new file +58 -0
58 lines not on this page · raw message
kvm-unittest/lib/powerpc/44x/map.c new file +51 -0
51 lines not on this page · raw message
kvm-unittest/lib/powerpc/io.c new file +35 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/lib/printf.c new file +182 -0
182 lines not on this page · raw message
kvm-unittest/lib/string.c new file +86 -0
86 lines not on this page · raw message
kvm-unittest/lib/x86/apic.c new file +143 -0
143 lines not on this page · raw message
kvm-unittest/lib/x86/atomic.c new file +37 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/lib/x86/desc.c new file +355 -0
355 lines not on this page · raw message
kvm-unittest/lib/x86/fwcfg.c new file +45 -0
45 lines not on this page · raw message
kvm-unittest/lib/x86/io.c new file +83 -0
83 lines not on this page · raw message
kvm-unittest/lib/x86/isr.c new file +98 -0
98 lines not on this page · raw message
kvm-unittest/lib/x86/pci.c new file +55 -0
55 lines not on this page · raw message
kvm-unittest/lib/x86/smp.c new file +124 -0
124 lines not on this page · raw message
kvm-unittest/lib/x86/vm.c new file +256 -0
256 lines not on this page · raw message
kvm-unittest/main-ppc.c new file +383 -0
383 lines not on this page · raw message
kvm-unittest/powerpc/helloworld.c new file +27 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/x86/access.c new file +860 -0
860 lines not on this page · raw message
kvm-unittest/x86/apic.c new file +344 -0
344 lines not on this page · raw message
kvm-unittest/x86/asyncpf.c new file +113 -0
113 lines not on this page · raw message
kvm-unittest/x86/emulator.c new file +1024 -0
1,024 lines not on this page · raw message
kvm-unittest/x86/eventinj.c new file +422 -0
422 lines not on this page · raw message
kvm-unittest/x86/idt_test.c new file +49 -0
49 lines not on this page · raw message
kvm-unittest/x86/init.c new file +129 -0
129 lines not on this page · raw message
kvm-unittest/x86/kvmclock.c new file +279 -0
279 lines not on this page · raw message
kvm-unittest/x86/kvmclock_test.c new file +167 -0
167 lines not on this page · raw message
kvm-unittest/x86/msr.c new file +149 -0
149 lines not on this page · raw message
kvm-unittest/x86/pcid.c new file +186 -0
186 lines not on this page · raw message
kvm-unittest/x86/pmu.c new file +414 -0
414 lines not on this page · raw message
kvm-unittest/x86/realmode.c new file +1627 -0
1,627 lines not on this page · raw message
kvm-unittest/x86/rmap_chain.c new file +54 -0
54 lines not on this page · raw message
kvm-unittest/x86/s3.c new file +203 -0
203 lines not on this page · raw message
kvm-unittest/x86/sieve.c new file +51 -0
51 lines not on this page · raw message
kvm-unittest/x86/svm.c new file +812 -0
812 lines not on this page · raw message
kvm-unittest/x86/taskswitch.c new file +164 -0
164 lines not on this page · raw message
kvm-unittest/x86/taskswitch2.c new file +279 -0
279 lines not on this page · raw message
kvm-unittest/x86/tsc_adjust.c new file +60 -0
60 lines not on this page · raw message
kvm-unittest/x86/vmexit.c new file +448 -0
448 lines not on this page · raw message
kvm-unittest/x86/vmx.c new file +600 -0
600 lines not on this page · raw message
kvm-unittest/x86/vmx_tests.c new file +87 -0
87 lines not on this page · raw message
kvm-unittest/x86/xsave.c new file +262 -0
262 lines not on this page · raw message
kvm-unittest/Makefile new file +60 -0
60 lines not on this page · raw message
kvm-unittest/api/api-sample.cc new file +30 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/api/dirty-log-perf.cc new file +144 -0
144 lines not on this page · raw message
kvm-unittest/api/dirty-log.cc new file +78 -0
78 lines not on this page · raw message
kvm-unittest/api/exception.cc new file +33 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/api/exception.hh new file +19 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/api/identity.cc new file +95 -0
95 lines not on this page · raw message
kvm-unittest/api/identity.hh new file +43 -0
43 lines not on this page · raw message
kvm-unittest/api/kvmxx.cc new file +194 -0
194 lines not on this page · raw message
kvm-unittest/api/kvmxx.hh new file +85 -0
85 lines not on this page · raw message
kvm-unittest/api/memmap.cc new file +76 -0
76 lines not on this page · raw message
kvm-unittest/api/memmap.hh new file +43 -0
43 lines not on this page · raw message
kvm-unittest/config-powerpc-440.mak new file +15 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/config-powerpc.mak new file +39 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/config-x86-common.mak new file +122 -0
122 lines not on this page · raw message
kvm-unittest/config-x86_64.mak new file +14 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/configure new file +92 -0
92 lines not on this page · raw message
kvm-unittest/kvmtrace_format new file +532 -0
532 lines not on this page · raw message
kvm-unittest/lib/powerpc/44x/timebase.S new file +28 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/lib/powerpc/44x/tlbwe.S new file +29 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/powerpc/44x/tlbsx.S new file +33 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/powerpc/44x/tlbwe.S new file +27 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/powerpc/44x/tlbwe_16KB.S new file +35 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/powerpc/44x/tlbwe_hole.S new file +27 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/powerpc/cstart.S new file +38 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/run_tests.sh new file +123 -0
123 lines not on this page · raw message
kvm-unittest/x86-run new file +41 -0
41 lines not on this page · raw message
kvm-unittest/x86/cstart.S new file +192 -0
192 lines not on this page · raw message
kvm-unittest/x86/cstart64.S new file +245 -0
245 lines not on this page · raw message
kvm-unittest/x86/realmode.lds new file +12 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/x86/run-kvm-unit-tests new file +6 -0
Lines of this file are not shown. View the raw message.
kvm-unittest/x86/unittests.cfg new file +157 -0
157 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 12 lines · Michael S. Tsirkin
This simply imports kvm-unittest git into qemu source tree.
We can next work on making make check run it
automatically.Squashed 'kvm-unittest/' content from commit 2bc0e29
git-subtree-dir: kvm-unittest
git-subtree-split:2bc0e29ee4447bebcd3b90053881f59265306adcSigned-off-by Michael S. Tsirkin <[email protected]>
Quoted 8 lines
---
Gleb, Paolo, any objections to this? I really want a small guest for running ACPI tests during make check, and kvm-unittest seems to fit the bill.
Ability to test e.g. PCI with this in-tree would be very benefitial.
Sorry for slow reply, I just noticed this mail now.
So far qemu is a dependency for kvm-unit-tests (both x86 and arm use it), but at some point that could change (if another arch doesn't want to use qemu). So if that happens, then it won't make much sense for the tests to live in qemu. Thus I'm not 100% in favor of moving them. However, if the consensus is to move them, then I have two comments on this patch.
1) There are a couple pendings patches on the kvm list that tidy up the kvm-unit-tests repo - removing lots of the files. That should be committed first to avoid importing a bunch of files right before deleting them.
2) The name shouldn't change from kvm-unit-tests to kvm-unittest.
drew
Quoted 22 lines · Andrew Jones
Quoted 12 lines · Michael S. Tsirkin
This simply imports kvm-unittest git into qemu source tree.
We can next work on making make check run it
automatically.Squashed 'kvm-unittest/' content from commit 2bc0e29
git-subtree-dir: kvm-unittest
git-subtree-split:2bc0e29ee4447bebcd3b90053881f59265306adcSigned-off-by Michael S. Tsirkin <[email protected]>Quoted 8 lines
---
Gleb, Paolo, any objections to this? I really want a small guest for running ACPI tests during make check, and kvm-unittest seems to fit the bill.
Ability to test e.g. PCI with this in-tree would be very benefitial.
Quoted 8 lines
Sorry for slow reply, I just noticed this mail now.
So far qemu is a dependency for kvm-unit-tests (both x86 and arm use it), but at some point that could change (if another arch doesn't want to use qemu). So if that happens, then it won't make much sense for the tests to live in qemu. Thus I'm not 100% in favor of moving them. However, if the consensus is to move them, then I have two comments on this patch.
Do not worry, we are far from such consensus :)
Quoted 8 lines
1) There are a couple pendings patches on the kvm list that tidy up the kvm-unit-tests repo - removing lots of the files. That should be committed first to avoid importing a bunch of files right before deleting them.
2) The name shouldn't change from kvm-unit-tests to kvm-unittest.
drew
--
Gleb.
Quoted 25 lines · Gleb Natapov
Quoted 24 lines · Andrew Jones
Quoted 12 lines · Michael S. Tsirkin
This simply imports kvm-unittest git into qemu source tree.
We can next work on making make check run it
automatically.Squashed 'kvm-unittest/' content from commit 2bc0e29
git-subtree-dir: kvm-unittest
git-subtree-split:2bc0e29ee4447bebcd3b90053881f59265306adcSigned-off-by Michael S. Tsirkin <[email protected]>Quoted 8 lines
---
Gleb, Paolo, any objections to this? I really want a small guest for running ACPI tests during make check, and kvm-unittest seems to fit the bill.
Ability to test e.g. PCI with this in-tree would be very benefitial.
Sorry for slow reply, I just noticed this mail now.
Quoted 7 lines
Quoted 6 lines
So far qemu is a dependency for kvm-unit-tests (both x86 and arm use it), but at some point that could change (if another arch doesn't want to use qemu). So if that happens, then it won't make much sense for the tests to live in qemu. Thus I'm not 100% in favor of moving them. However, if the consensus is to move them, then I have two comments on this patch.
Do not worry, we are far from such consensus :)
I don't think kvm-unit-tests belong in QEMU either. They are tied to the kernel side of things, not QEMU and many of the tests don't make sense for TCG.
If you want to execute guest code within QEMU's make check, we can copy the basic infrastructure in kvm-unit-tests. It's so simple that a "fork" isn't really much of a concern to me.
Regards,
Anthony Liguori
Quoted 11 lines
Quoted 8 lines
1) There are a couple pendings patches on the kvm list that tidy up the kvm-unit-tests repo - removing lots of the files. That should be committed first to avoid importing a bunch of files right before deleting them.
2) The name shouldn't change from kvm-unit-tests to kvm-unittest.
drew
--
Gleb.
Quoted 38 lines · Anthony Liguori
Quoted 25 lines · Gleb Natapov
Quoted 24 lines · Andrew Jones
Quoted 12 lines · Michael S. Tsirkin
This simply imports kvm-unittest git into qemu source tree.
We can next work on making make check run it
automatically.Squashed 'kvm-unittest/' content from commit 2bc0e29
git-subtree-dir: kvm-unittest
git-subtree-split:2bc0e29ee4447bebcd3b90053881f59265306adcSigned-off-by Michael S. Tsirkin <[email protected]>Quoted 8 lines
---
Gleb, Paolo, any objections to this? I really want a small guest for running ACPI tests during make check, and kvm-unittest seems to fit the bill.
Ability to test e.g. PCI with this in-tree would be very benefitial.
Sorry for slow reply, I just noticed this mail now.
Quoted 7 lines
Quoted 6 lines
So far qemu is a dependency for kvm-unit-tests (both x86 and arm use it), but at some point that could change (if another arch doesn't want to use qemu). So if that happens, then it won't make much sense for the tests to live in qemu. Thus I'm not 100% in favor of moving them. However, if the consensus is to move them, then I have two comments on this patch.
Do not worry, we are far from such consensus :)
I don't think kvm-unit-tests belong in QEMU either. They are tied to the kernel side of things, not QEMU and many of the tests don't make sense for TCG.
Quoted 7 lines
If you want to execute guest code within QEMU's make check, we can copy the basic infrastructure in kvm-unit-tests. It's so simple that a "fork" isn't really much of a concern to me.
Regards,
Anthony Liguori
For now I'm only testing the bios so it's even simpler, I just put 16 bit code in the boot sector.
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
1) There are a couple pendings patches on the kvm list that tidy up the kvm-unit-tests repo - removing lots of the files. That should be committed first to avoid importing a bunch of files right before deleting them.
2) The name shouldn't change from kvm-unit-tests to kvm-unittest.
drew
--
Gleb.