Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.1…
Browse files Browse the repository at this point in the history
…-pull-request' into staging

linux-user pull request 20200605-v2

Implement F_OFD_ fcntl() command, /proc/cpuinfo for hppa
Fix socket(), prnctl() error codes, underflow in target_mremap,
    epoll_create() strace, oldumount for alpha
User-mode build dependencies improvement

# gpg: Signature made Sat 06 Jun 2020 14:15:36 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-5.1-pull-request:
  stubs: Restrict ui/win32-kbd-hook to system-mode
  hw/core: Restrict CpuClass::get_crash_info() to system-mode
  target/s390x: Restrict CpuClass::get_crash_info() to system-mode
  target/i386: Restrict CpuClass::get_crash_info() to system-mode
  arch_init: Remove unused 'qapi-commands-misc.h' include
  exec: Assert CPU migration is not used on user-only build
  target/riscv/cpu: Restrict CPU migration to system-mode
  stubs/Makefile: Reduce the user-mode object list
  util/Makefile: Reduce the user-mode object list
  tests/Makefile: Restrict some softmmu-only tests
  tests/Makefile: Only display TCG-related tests when TCG is available
  configure: Avoid building TCG when not needed
  Makefile: Only build virtiofsd if system-mode is enabled
  linux-user: implement OFD locks
  linux-user/mmap.c: fix integer underflow in target_mremap
  linux-user/strace.list: fix epoll_create{,1} -strace output
  linux-user: Add support for /proc/cpuinfo on hppa platform
  linux-user: return target error codes for socket() and prctl()
  linux-user, alpha: fix oldumount syscall

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 8, 2020
2 parents 5a92241 + 95722b2 commit 49ee115
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ HELPERS-y += vhost-user-gpu$(EXESUF)
vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
endif

ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
ifeq ($(CONFIG_SOFTMMU)$(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyyy)
HELPERS-y += virtiofsd$(EXESUF)
vhost-user-json-y += tools/virtiofsd/50-qemu-virtiofsd.json
endif
Expand Down
1 change: 0 additions & 1 deletion arch_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "sysemu/arch_init.h"
#include "hw/pci/pci.h"
#include "hw/audio/soundhw.h"
#include "qapi/qapi-commands-misc.h"
#include "qapi/error.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
Expand Down
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,10 @@ if [ "$ARCH" = "unknown" ]; then
linux_user="no"
fi

if [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
tcg="no"
fi

default_target_list=""

mak_wilds=""
Expand Down
4 changes: 3 additions & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,9 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)

qemu_plugin_vcpu_init_hook(cpu);

#ifndef CONFIG_USER_ONLY
#ifdef CONFIG_USER_ONLY
assert(cc->vmsd == NULL);
#else /* !CONFIG_USER_ONLY */
if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu);
}
Expand Down
2 changes: 2 additions & 0 deletions hw/core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ static bool cpu_common_exec_interrupt(CPUState *cpu, int int_req)
return false;
}

#if !defined(CONFIG_USER_ONLY)
GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
Expand All @@ -219,6 +220,7 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
}
return res;
}
#endif

void cpu_dump_state(CPUState *cpu, FILE *f, int flags)
{
Expand Down
7 changes: 6 additions & 1 deletion include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ bool cpu_paging_enabled(const CPUState *cpu);
void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
Error **errp);

#if !defined(CONFIG_USER_ONLY)

/**
* cpu_write_elf64_note:
* @f: pointer to a function that writes memory to a file
Expand Down Expand Up @@ -539,6 +541,8 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
*/
GuestPanicInformation *cpu_get_crash_info(CPUState *cpu);

#endif /* !CONFIG_USER_ONLY */

/**
* CPUDumpFlags:
* @CPU_DUMP_CODE:
Expand Down Expand Up @@ -632,7 +636,8 @@ static inline int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs)
}
return ret;
}
#endif

#endif /* CONFIG_USER_ONLY */

/**
* cpu_list_add:
Expand Down
4 changes: 4 additions & 0 deletions linux-user/generic/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
#define TARGET_F_SETLKW64 14
#endif

#define TARGET_F_OFD_GETLK 36
#define TARGET_F_OFD_SETLK 37
#define TARGET_F_OFD_SETLKW 38

#ifndef TARGET_F_SETOWN_EX
#define TARGET_F_SETOWN_EX 15
#define TARGET_F_GETOWN_EX 16
Expand Down
2 changes: 1 addition & 1 deletion linux-user/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
if (prot == 0) {
host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) {
mmap_reserve(old_addr + old_size, new_size - old_size);
mmap_reserve(old_addr + old_size, old_size - new_size);
}
} else {
errno = ENOMEM;
Expand Down
4 changes: 2 additions & 2 deletions linux-user/strace.list
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
{ TARGET_NR_dup3, "dup3" , "%s(%d,%d,%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_epoll_create
{ TARGET_NR_epoll_create, "%s(%d)", NULL, NULL, NULL },
{ TARGET_NR_epoll_create, "epoll_create", "%s(%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_epoll_create1
{ TARGET_NR_epoll_create1, "%s(%d)", NULL, NULL, NULL },
{ TARGET_NR_epoll_create1, "epoll_create1", "%s(%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_epoll_ctl
{ TARGET_NR_epoll_ctl, "epoll_ctl" , NULL, NULL, NULL },
Expand Down
33 changes: 28 additions & 5 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ static abi_long do_socket(int domain, int type, int protocol)
#endif
protocol == NETLINK_KOBJECT_UEVENT ||
protocol == NETLINK_AUDIT)) {
return -EPFNOSUPPORT;
return -TARGET_EPFNOSUPPORT;
}

if (domain == AF_PACKET ||
Expand Down Expand Up @@ -5856,7 +5856,7 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)

abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
{
return -ENOSYS;
return -TARGET_ENOSYS;
}
#else
abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
Expand Down Expand Up @@ -6098,6 +6098,9 @@ static int target_to_host_fcntl_cmd(int cmd)
case TARGET_F_SETFD:
case TARGET_F_GETFL:
case TARGET_F_SETFL:
case TARGET_F_OFD_GETLK:
case TARGET_F_OFD_SETLK:
case TARGET_F_OFD_SETLKW:
ret = cmd;
break;
case TARGET_F_GETLK:
Expand Down Expand Up @@ -6383,6 +6386,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
break;

case TARGET_F_GETLK64:
case TARGET_F_OFD_GETLK:
ret = copy_from_user_flock64(&fl64, arg);
if (ret) {
return ret;
Expand All @@ -6394,6 +6398,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
case TARGET_F_OFD_SETLK:
case TARGET_F_OFD_SETLKW:
ret = copy_from_user_flock64(&fl64, arg);
if (ret) {
return ret;
Expand Down Expand Up @@ -7378,7 +7384,7 @@ static int is_proc_myself(const char *filename, const char *entry)
}

#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) || \
defined(TARGET_SPARC) || defined(TARGET_M68K)
defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA)
static int is_proc(const char *filename, const char *entry)
{
return strcmp(filename, entry) == 0;
Expand Down Expand Up @@ -7438,6 +7444,18 @@ static int open_cpuinfo(void *cpu_env, int fd)
}
#endif

#if defined(TARGET_HPPA)
static int open_cpuinfo(void *cpu_env, int fd)
{
dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
dprintf(fd, "capabilities\t: os32\n");
dprintf(fd, "model\t\t: 9000/778/B160L\n");
dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
return 0;
}
#endif

#if defined(TARGET_M68K)
static int open_hardware(void *cpu_env, int fd)
{
Expand All @@ -7462,7 +7480,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags,
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
{ "/proc/net/route", open_net_route, is_proc },
#endif
#if defined(TARGET_SPARC)
#if defined(TARGET_SPARC) || defined(TARGET_HPPA)
{ "/proc/cpuinfo", open_cpuinfo, is_proc },
#endif
#if defined(TARGET_M68K)
Expand Down Expand Up @@ -8031,8 +8049,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
}
}
return ret;
#ifdef TARGET_NR_umount
#if defined(TARGET_NR_umount) || defined(TARGET_NR_oldumount)
#if defined(TARGET_NR_umount)
case TARGET_NR_umount:
#endif
#if defined(TARGET_NR_oldumount)
case TARGET_NR_oldumount:
#endif
if (!(p = lock_user_string(arg1)))
return -TARGET_EFAULT;
ret = get_errno(umount(p));
Expand Down
52 changes: 30 additions & 22 deletions stubs/Makefile.objs
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
stub-obj-y += arch_type.o
stub-obj-y += bdrv-next-monitor-owned.o
stub-obj-y += blk-commit-all.o
stub-obj-y += blockdev-close-all-bdrv-states.o
stub-obj-y += clock-warp.o
stub-obj-y += cpu-get-clock.o
stub-obj-y += cpu-get-icount.o
stub-obj-y += dump.o
stub-obj-y += error-printf.o
stub-obj-y += fdset.o
stub-obj-y += gdbstub.o
stub-obj-y += get-vm-name.o
stub-obj-y += iothread.o
stub-obj-y += iothread-lock.o
stub-obj-y += is-daemonized.o
stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
stub-obj-y += machine-init-done.o
stub-obj-y += migr-blocker.o
stub-obj-y += change-state-handler.o
stub-obj-y += monitor.o
stub-obj-y += monitor-core.o
stub-obj-y += notify-event.o
stub-obj-y += qmp_memory_device.o
stub-obj-y += qtest.o
stub-obj-y += ramfb.o
stub-obj-y += replay.o
stub-obj-y += replay-user.o
stub-obj-y += runstate-check.o
stub-obj-$(CONFIG_SOFTMMU) += semihost.o
stub-obj-y += set-fd-handler.o
stub-obj-y += vmgenid.o
stub-obj-y += sysbus.o
stub-obj-y += tpm.o
stub-obj-y += trace-control.o
stub-obj-y += uuid.o
stub-obj-y += vm-stop.o
stub-obj-y += vmstate.o
stub-obj-y += win32-kbd-hook.o
stub-obj-$(CONFIG_SOFTMMU) += win32-kbd-hook.o

#######################################################################
# code used by both qemu system emulation and qemu-img

ifeq ($(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS)),y)

stub-obj-y += arch_type.o
stub-obj-y += bdrv-next-monitor-owned.o
stub-obj-y += blockdev-close-all-bdrv-states.o
stub-obj-y += change-state-handler.o
stub-obj-y += clock-warp.o
stub-obj-y += fd-register.o
stub-obj-y += qmp_memory_device.o
stub-obj-y += target-monitor-defs.o
stub-obj-y += fw_cfg.o
stub-obj-y += get-vm-name.o
stub-obj-y += iothread.o
stub-obj-y += machine-init-done.o
stub-obj-y += migr-blocker.o
stub-obj-y += monitor.o
stub-obj-y += pci-host-piix.o
stub-obj-y += ram-block.o
stub-obj-y += replay-user.o
stub-obj-y += target-get-monitor-def.o
stub-obj-y += vmgenid.o
stub-obj-y += target-monitor-defs.o
stub-obj-y += uuid.o
stub-obj-y += vm-stop.o
stub-obj-y += xen-common.o
stub-obj-y += xen-hvm.o
stub-obj-y += pci-host-piix.o
stub-obj-y += ram-block.o
stub-obj-y += ramfb.o
stub-obj-y += fw_cfg.o
stub-obj-$(CONFIG_SOFTMMU) += semihost.o

endif # CONFIG_SOFTMMU || CONFIG_TOOLS
6 changes: 5 additions & 1 deletion target/i386/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6850,6 +6850,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
x86_cpu_register_bit_prop(cpu, name, w, bitnr);
}

#if !defined(CONFIG_USER_ONLY)
static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
Expand Down Expand Up @@ -6893,6 +6894,7 @@ static void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v,
errp);
qapi_free_GuestPanicInformation(panic_info);
}
#endif /* !CONFIG_USER_ONLY */

static void x86_cpu_initfn(Object *obj)
{
Expand Down Expand Up @@ -6939,8 +6941,10 @@ static void x86_cpu_initfn(Object *obj)
x86_cpu_get_unavailable_features,
NULL, NULL, NULL);

#if !defined(CONFIG_USER_ONLY)
object_property_add(obj, "crash-information", "GuestPanicInformation",
x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
#endif

for (w = 0; w < FEATURE_WORDS; w++) {
int bitnr;
Expand Down Expand Up @@ -7252,7 +7256,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
cc->cpu_exec_interrupt = x86_cpu_exec_interrupt;
#endif
cc->dump_state = x86_cpu_dump_state;
cc->get_crash_info = x86_cpu_get_crash_info;
cc->set_pc = x86_cpu_set_pc;
cc->synchronize_from_tb = x86_cpu_synchronize_from_tb;
cc->gdb_read_register = x86_cpu_gdb_read_register;
Expand All @@ -7263,6 +7266,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
cc->asidx_from_attrs = x86_asidx_from_attrs;
cc->get_memory_mapping = x86_cpu_get_memory_mapping;
cc->get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug;
cc->get_crash_info = x86_cpu_get_crash_info;
cc->write_elf64_note = x86_cpu_write_elf64_note;
cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote;
cc->write_elf32_note = x86_cpu_write_elf32_note;
Expand Down
6 changes: 4 additions & 2 deletions target/riscv/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,12 @@ static void riscv_cpu_init(Object *obj)
cpu_set_cpustate_pointers(cpu);
}

#ifndef CONFIG_USER_ONLY
static const VMStateDescription vmstate_riscv_cpu = {
.name = "cpu",
.unmigratable = 1,
};
#endif

static Property riscv_cpu_properties[] = {
DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true),
Expand Down Expand Up @@ -528,13 +530,13 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
cc->do_transaction_failed = riscv_cpu_do_transaction_failed;
cc->do_unaligned_access = riscv_cpu_do_unaligned_access;
cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug;
/* For now, mark unmigratable: */
cc->vmsd = &vmstate_riscv_cpu;
#endif
#ifdef CONFIG_TCG
cc->tcg_initialize = riscv_translate_init;
cc->tlb_fill = riscv_cpu_tlb_fill;
#endif
/* For now, mark unmigratable: */
cc->vmsd = &vmstate_riscv_cpu;
device_class_set_props(dc, riscv_cpu_properties);
}

Expand Down
Loading

0 comments on commit 49ee115

Please sign in to comment.