Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into…
Browse files Browse the repository at this point in the history
… staging

* cpu-exec fixes (Emilio, Laurent)
* TCG bugfix in queue.h (Paolo)
* high address load for linuxboot (Zhijian)
* PVH support (Liam, Stefano)
* misc i386 changes (Paolo, Robert, Doug)
* configure tweak for openpty (Thomas)
* elf2dmp port to Windows (Viktor)
* initial improvements to Makefile infrastructure (Yang + GSoC 2013)

# gpg: Signature made Tue 05 Feb 2019 17:34:42 GMT
# gpg:                using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream: (76 commits)
  queue: fix QTAILQ_FOREACH_REVERSE_SAFE
  scsi-generic: Convert from DPRINTF() macro to trace events
  scsi-disk: Convert from DPRINTF() macro to trace events
  pc: Use hotplug_handler_(plug|unplug|unplug_request)
  i386: hvf: Fix smp boot hangs
  hw/vfio/Makefile.objs: Create new CONFIG_* variables for VFIO core and PCI
  hw/i2c/Makefile.objs: Create new CONFIG_* variables for EEPROM and ACPI controller
  hw/tricore/Makefile.objs: Create CONFIG_* for tricore
  hw/openrisc/Makefile.objs: Create CONFIG_* for openrisc
  hw/moxie/Makefile.objs: Conditionally build moxie
  hw/hppa/Makefile.objs: Create CONFIG_* for hppa
  hw/cris/Makefile.objs: Create CONFIG_* for cris
  hw/alpha/Makefile.objs: Create CONFIG_* for alpha
  hw/sparc64/Makefile.objs: Create CONFIG_* for sparc64
  hw/riscv/Makefile.objs: Create CONFIG_* for riscv boards
  hw/nios2/Makefile.objs: Conditionally build nios2
  hw/xtensa/Makefile.objs: Build xtensa_sim and xtensa_fpga conditionally
  hw/lm32/Makefile.objs: Conditionally build lm32 and milkmyst
  hw/sparc/Makefile.objs: CONFIG_* for sun4m and leon3 created
  hw/s390/Makefile.objs: Create new CONFIG_* variables for s390x boards and devices
  ...

Signed-off-by: Peter Maydell <[email protected]>

# Conflicts:
#	qemu-deprecated.texi
  • Loading branch information
pm215 committed Feb 5, 2019
2 parents 47994e1 + 5ed76a4 commit 3e29da9
Show file tree
Hide file tree
Showing 155 changed files with 3,103 additions and 1,777 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
/pc-bios/optionrom/linuxboot_dma.bin
/pc-bios/optionrom/linuxboot_dma.raw
/pc-bios/optionrom/linuxboot_dma.img
/pc-bios/optionrom/pvh.asm
/pc-bios/optionrom/pvh.bin
/pc-bios/optionrom/pvh.raw
/pc-bios/optionrom/pvh.img
/pc-bios/optionrom/multiboot.asm
/pc-bios/optionrom/multiboot.bin
/pc-bios/optionrom/multiboot.raw
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ ifneq ($(EXESUF),)
qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
endif

elf2dmp: LIBS = $(CURL_LIBS)
elf2dmp: $(elf2dmp-obj-y)
elf2dmp$(EXESUF): LIBS += $(CURL_LIBS)
elf2dmp$(EXESUF): $(elf2dmp-obj-y)
$(call LINK, $^)

ifdef CONFIG_IVSHMEM
Expand Down Expand Up @@ -673,7 +673,7 @@ efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
efi-e1000e.rom efi-vmxnet3.rom \
bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin \
multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
s390-ccw.img s390-netboot.img \
spapr-rtas.bin slof.bin skiboot.lid \
palcode-clipper \
Expand Down
4 changes: 4 additions & 0 deletions accel/tcg/cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ void cpu_exec_step_atomic(CPUState *cpu)
#ifndef CONFIG_SOFTMMU
tcg_debug_assert(!have_mmap_lock());
#endif
if (qemu_mutex_iothread_locked()) {
qemu_mutex_unlock_iothread();
}
assert_no_pages_locked();
}

Expand Down Expand Up @@ -702,6 +705,7 @@ int cpu_exec(CPUState *cpu)
if (qemu_mutex_iothread_locked()) {
qemu_mutex_unlock_iothread();
}
assert_no_pages_locked();
}

/* if an exception is pending, we execute it here */
Expand Down
20 changes: 14 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4612,9 +4612,17 @@ elif compile_prog "" "$pthread_lib -lrt" ; then
libs_qga="$libs_qga -lrt"
fi

if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
"$haiku" != "yes" ; then
# Check whether we need to link libutil for openpty()
cat > $TMPC << EOF
extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
int main(void) { return openpty(0, 0, 0, 0, 0); }
EOF

if ! compile_prog "" "" ; then
if compile_prog "" "-lutil" ; then
libs_softmmu="-lutil $libs_softmmu"
libs_tools="-lutil $libs_tools"
fi
fi

##########################################
Expand Down Expand Up @@ -5782,8 +5790,8 @@ if test "$want_tools" = "yes" ; then
if [ "$ivshmem" = "yes" ]; then
tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
fi
if [ "$posix" = "yes" ] && [ "$curl" = "yes" ]; then
tools="elf2dmp $tools"
if [ "$curl" = "yes" ]; then
tools="elf2dmp\$(EXESUF) $tools"
fi
fi
if test "$softmmu" = yes ; then
Expand Down Expand Up @@ -7129,14 +7137,14 @@ TARGET_ABI_DIR=""
case "$target_name" in
i386)
mttcg="yes"
gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
gdb_xml_files="i386-32bit.xml"
target_compiler=$cross_cc_i386
target_compiler_cflags=$cross_cc_ccflags_i386
;;
x86_64)
TARGET_BASE_ARCH=i386
mttcg="yes"
gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
gdb_xml_files="i386-64bit.xml"
target_compiler=$cross_cc_x86_64
;;
alpha)
Expand Down
12 changes: 8 additions & 4 deletions contrib/elf2dmp/kdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ typedef struct DBGKD_GET_VERSION64 {
uint64_t DebuggerDataList;
} DBGKD_GET_VERSION64;

#ifndef _WIN32
typedef struct LIST_ENTRY64 {
struct LIST_ENTRY64 *Flink;
struct LIST_ENTRY64 *Blink;
} LIST_ENTRY64;
#endif

typedef struct DBGKD_DEBUG_DATA_HEADER64 {
struct LIST_ENTRY64 {
struct LIST_ENTRY64 *Flink;
struct LIST_ENTRY64 *Blink;
} List;
LIST_ENTRY64 List;
uint32_t OwnerTag;
uint32_t Size;
} DBGKD_DEBUG_DATA_HEADER64;
Expand Down
27 changes: 15 additions & 12 deletions contrib/elf2dmp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*
*/

#include <inttypes.h>

#include "qemu/osdep.h"
#include "err.h"
#include "addrspace.h"
Expand Down Expand Up @@ -41,7 +43,8 @@ static const uint64_t SharedUserData = 0xfffff78000000000;
#define KUSD_OFFSET_PRODUCT_TYPE 0x264

#define SYM_RESOLVE(base, r, s) ((s = pdb_resolve(base, r, #s)),\
s ? printf(#s" = 0x%016lx\n", s) : eprintf("Failed to resolve "#s"\n"), s)
s ? printf(#s" = 0x%016"PRIx64"\n", s) :\
eprintf("Failed to resolve "#s"\n"), s)

static uint64_t rol(uint64_t x, uint64_t y)
{
Expand Down Expand Up @@ -98,8 +101,8 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
return NULL;
}

printf("[KiWaitNever] = 0x%016lx\n", kwn);
printf("[KiWaitAlways] = 0x%016lx\n", kwa);
printf("[KiWaitNever] = 0x%016"PRIx64"\n", kwn);
printf("[KiWaitAlways] = 0x%016"PRIx64"\n", kwa);

/*
* If KDBG header can be decoded, KDBG size is available
Expand Down Expand Up @@ -202,7 +205,7 @@ static int fix_dtb(struct va_space *vs, QEMU_Elf *qe)

if (is_system(s)) {
va_space_set_dtb(vs, s->cr[3]);
printf("DTB 0x%016lx has been found from CPU #%zu"
printf("DTB 0x%016"PRIx64" has been found from CPU #%zu"
" as system task CR3\n", vs->dtb, i);
return !(va_space_resolve(vs, SharedUserData));
}
Expand All @@ -222,7 +225,7 @@ static int fix_dtb(struct va_space *vs, QEMU_Elf *qe)
}

va_space_set_dtb(vs, *cr3);
printf("DirectoryTableBase = 0x%016lx has been found from CPU #0"
printf("DirectoryTableBase = 0x%016"PRIx64" has been found from CPU #0"
" as interrupt handling CR3\n", vs->dtb);
return !(va_space_resolve(vs, SharedUserData));
}
Expand Down Expand Up @@ -393,8 +396,8 @@ static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr,
return 1;
}

printf("Debug Directory RVA = 0x%016x\n",
data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress);
printf("Debug Directory RVA = 0x%08"PRIx32"\n",
(uint32_t)data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress);

if (va_space_rw(vs,
base + data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress,
Expand Down Expand Up @@ -488,7 +491,7 @@ int main(int argc, char *argv[])
}

state = qemu_elf.state[0];
printf("CPU #0 CR3 is 0x%016lx\n", state->cr[3]);
printf("CPU #0 CR3 is 0x%016"PRIx64"\n", state->cr[3]);

va_space_create(&vs, &ps, state->cr[3]);
if (fix_dtb(&vs, &qemu_elf)) {
Expand All @@ -497,18 +500,18 @@ int main(int argc, char *argv[])
goto out_elf;
}

printf("CPU #0 IDT is at 0x%016lx\n", state->idt.base);
printf("CPU #0 IDT is at 0x%016"PRIx64"\n", state->idt.base);

if (va_space_rw(&vs, state->idt.base,
&first_idt_desc, sizeof(first_idt_desc), 0)) {
eprintf("Failed to get CPU #0 IDT[0]\n");
err = 1;
goto out_ps;
}
printf("CPU #0 IDT[0] -> 0x%016lx\n", idt_desc_addr(first_idt_desc));
printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc));

KernBase = idt_desc_addr(first_idt_desc) & ~(PAGE_SIZE - 1);
printf("Searching kernel downwards from 0x%16lx...\n", KernBase);
printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase);

for (; KernBase >= 0xfffff78000000000; KernBase -= PAGE_SIZE) {
nt_start_addr = va_space_resolve(&vs, KernBase);
Expand All @@ -521,7 +524,7 @@ int main(int argc, char *argv[])
}
}

printf("KernBase = 0x%16lx, signature is \'%.2s\'\n", KernBase,
printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
(char *)nt_start_addr);

if (pe_get_pdb_symstore_hash(KernBase, nt_start_addr, pdb_hash, &vs)) {
Expand Down
33 changes: 11 additions & 22 deletions contrib/elf2dmp/pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#include <inttypes.h>

#include "qemu/osdep.h"
#include "pdb.h"
#include "err.h"
Expand Down Expand Up @@ -66,7 +68,7 @@ uint64_t pdb_find_public_v3_symbol(struct pdb_reader *r, const char *name)
uint32_t sect_rva = segment->dword[1];
uint64_t rva = sect_rva + sym->public_v3.offset;

printf("%s: 0x%016x(%d:\'%.8s\') + 0x%08x = 0x%09lx\n", name,
printf("%s: 0x%016x(%d:\'%.8s\') + 0x%08x = 0x%09"PRIx64"\n", name,
sect_rva, sym->public_v3.segment,
((char *)segment - 8), sym->public_v3.offset, rva);
return rva;
Expand Down Expand Up @@ -277,28 +279,18 @@ static void pdb_reader_exit(struct pdb_reader *r)

int pdb_init_from_file(const char *name, struct pdb_reader *reader)
{
GError *gerr = NULL;
int err = 0;
int fd;
void *map;
struct stat st;

fd = open(name, O_RDONLY, 0);
if (fd == -1) {
eprintf("Failed to open PDB file \'%s\'\n", name);
reader->gmf = g_mapped_file_new(name, TRUE, &gerr);
if (gerr) {
eprintf("Failed to map PDB file \'%s\'\n", name);
return 1;
}
reader->fd = fd;

fstat(fd, &st);
reader->file_size = st.st_size;

map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) {
eprintf("Failed to map PDB file\n");
err = 1;
goto out_fd;
}

reader->file_size = g_mapped_file_get_length(reader->gmf);
map = g_mapped_file_get_contents(reader->gmf);
if (pdb_reader_init(reader, map)) {
err = 1;
goto out_unmap;
Expand All @@ -307,16 +299,13 @@ int pdb_init_from_file(const char *name, struct pdb_reader *reader)
return 0;

out_unmap:
munmap(map, st.st_size);
out_fd:
close(fd);
g_mapped_file_unref(reader->gmf);

return err;
}

void pdb_exit(struct pdb_reader *reader)
{
munmap(reader->ds.header, reader->file_size);
close(reader->fd);
g_mapped_file_unref(reader->gmf);
pdb_reader_exit(reader);
}
4 changes: 3 additions & 1 deletion contrib/elf2dmp/pdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#define PDB_H


#ifndef _WIN32
typedef struct GUID {
unsigned int Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
#endif

struct PDB_FILE {
uint32_t size;
Expand Down Expand Up @@ -216,7 +218,7 @@ typedef struct pdb_seg {
#define IMAGE_FILE_MACHINE_AMD64 0x8664

struct pdb_reader {
int fd;
GMappedFile *gmf;
size_t file_size;
struct {
PDB_DS_HEADER *header;
Expand Down
6 changes: 4 additions & 2 deletions contrib/elf2dmp/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define PE_H


#ifndef _WIN32
typedef struct IMAGE_DOS_HEADER {
uint16_t e_magic; /* 0x00: MZ Header signature */
uint16_t e_cblp; /* 0x02: Bytes on last page of file */
Expand Down Expand Up @@ -87,8 +88,6 @@ typedef struct IMAGE_NT_HEADERS64 {
IMAGE_OPTIONAL_HEADER64 OptionalHeader;
} __attribute__ ((packed)) IMAGE_NT_HEADERS64;

#define IMAGE_FILE_DEBUG_DIRECTORY 6

typedef struct IMAGE_DEBUG_DIRECTORY {
uint32_t Characteristics;
uint32_t TimeDateStamp;
Expand All @@ -101,6 +100,9 @@ typedef struct IMAGE_DEBUG_DIRECTORY {
} __attribute__ ((packed)) IMAGE_DEBUG_DIRECTORY;

#define IMAGE_DEBUG_TYPE_CODEVIEW 2
#endif

#define IMAGE_FILE_DEBUG_DIRECTORY 6

typedef struct guid_t {
uint32_t a;
Expand Down
27 changes: 8 additions & 19 deletions contrib/elf2dmp/qemu_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,17 @@ static void exit_states(QEMU_Elf *qe)

int QEMU_Elf_init(QEMU_Elf *qe, const char *filename)
{
GError *gerr = NULL;
int err = 0;
struct stat st;

qe->fd = open(filename, O_RDONLY, 0);
if (qe->fd == -1) {
eprintf("Failed to open ELF dump file \'%s\'\n", filename);
qe->gmf = g_mapped_file_new(filename, TRUE, &gerr);
if (gerr) {
eprintf("Failed to map ELF dump file \'%s\'\n", filename);
return 1;
}

fstat(qe->fd, &st);
qe->size = st.st_size;

qe->map = mmap(NULL, qe->size, PROT_READ | PROT_WRITE,
MAP_PRIVATE, qe->fd, 0);
if (qe->map == MAP_FAILED) {
eprintf("Failed to map ELF file\n");
err = 1;
goto out_fd;
}
qe->map = g_mapped_file_get_contents(qe->gmf);
qe->size = g_mapped_file_get_length(qe->gmf);

if (init_states(qe)) {
eprintf("Failed to extract QEMU CPU states\n");
Expand All @@ -149,16 +141,13 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename)
return 0;

out_unmap:
munmap(qe->map, qe->size);
out_fd:
close(qe->fd);
g_mapped_file_unref(qe->gmf);

return err;
}

void QEMU_Elf_exit(QEMU_Elf *qe)
{
exit_states(qe);
munmap(qe->map, qe->size);
close(qe->fd);
g_mapped_file_unref(qe->gmf);
}
Loading

0 comments on commit 3e29da9

Please sign in to comment.